FS#34902 - [avr-gcc] addition of --enable-linker-build-id in 4.8.0-1 makes broken executables

Attached to Project: Community Packages
Opened by Justin Gottula (jgottula) - Tuesday, 23 April 2013, 06:51 GMT
Last edited by Jakob Gruber (schuay) - Tuesday, 23 April 2013, 14:57 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Jakob Gruber (schuay)
Jakob Wadsager (fleet)
Architecture All
Severity High
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


The avr-gcc PKGBUILD was changed in 4.8.0-1 to add --enable-linker-build-id to the gcc configuration command line. Presumably this was copy-and-pasted from the PKGBUILD for normal (non-cross-compiling) gcc, where it doesn't affect anything. But when compiling for avr, the '.note.gnu.build-id' section gets dumped at address zero in compiled executables, meaning that the interrupt vector table is wrong. Which is bad. Very bad.

I filed a bug upstream (http://sourceware.org/bugzilla/show_bug.cgi?id=15389), requesting that the linker scripts in avr-binutils be updated to prevent this from happening, but strictly speaking, the 'right' solution is not to configure with --enable-linker-build-id; in fact, it's probably even better to explicitly use --disable-linker-build-id since enabling by default has been discussed (http://gcc.gnu.org/ml/gcc-patches/2010-10/msg00253.html) in the past, although it hasn't happened up to this point.

Additional info:
avr-gcc 4.7.2-1: works
avr-gcc 4.8.0-1: broken
avr-binutils 2.23.2-1: not directly implicated

Steps to reproduce:
1. install avr-gcc 4.8.0-1
2. compile any program for any target avr:
echo 'int main(void) {}' >broken.c
avr-gcc -mmcu=atmega324p -c broken.c
avr-gcc -mmcu=atmega324p -o broken.elf broken.o
3. run 'avr-objdump -h' and 'avr-objdump -D' on the executable
4. observe that .text begins at 0x24 (!)

5. roll back to 4.7.2-1, compile again, and note that the bad section is gone
6. with 4.7.2-1, explicitly use -Wl,--build-id when linking and it's back

7. compare the output of avr-gcc with the '-v' option at the linker step between the two versions, which clearly shows that the --build-id option is passed to the linker when using the 4.8.0-1 package, but not the 4.7.2-1 package
This task depends upon

Closed by  Jakob Gruber (schuay)
Tuesday, 23 April 2013, 14:57 GMT
Reason for closing:  Fixed
Additional comments about closing:  avr-gcc 4.8.0-2, thanks for the helpful report.
Comment by Justin Gottula (jgottula) - Tuesday, 23 April 2013, 07:11 GMT
I should have mentioned: removing the --enable-linker-build-id line from the 4.8.0-1 PKGBUILD does, in fact, resolve the problem.
Comment by Jakob Gruber (schuay) - Tuesday, 23 April 2013, 08:48 GMT
Thanks, I'll push a fixed package sometime tonight.