Sourceware Bugzilla – Bug 6019
[avr] avr-ld --relax requires --gc-sections
Last modified: 2008-06-04 09:59:03 UTC
avr-ld fails with --relax, unless --gc-sections is also used, even if
-ffunction-sections is not used with avr-gcc.
Please can you provide a test case for this ?
Created attachment 2756 [details]
This zip file contains the source code of a project that exhibits the bug, and
it contains a short build script. This source code comes from WinAVR
(SourceForge) bug #1819125:
Unfortunately this is all I have in the way of test case. I know that it is too
large, but I haven't had time to investigate into a smaller test case.
Note that in the build script, using -Wl,--relax causes ld to fail. Using
-Wl,--relax,--gc-sections causes the link to be successful. This is with a
host=mingw toolchain. I have not verified the bug on a host=linux toolchain.
Created attachment 2766 [details]
reduced test case
avr-gcc -c -o onewire.o -Os onewire.i
avr-gcc -Wl,--relax -o onewire.elf onewire.o
-Os is necessary and the linker doesn't crash with --gc-sections
I've attached a reduced test case made with multidelta. It got minimized to 11
meaningful lines. It was run through the preprocessor before minimization so the
actual code is hard to read but I doubt that really matters.
Created attachment 2768 [details]
Add test for no local symbols
Hi Eric, Hi Jevin,
Please could you try out the uploaded patch and let me know if it works for
you ? (I am especially interested to know if it works on the real programs
where you encountered this bug, not just the reduced testcase).
Patch fixes bug on real-world application.
Great - I have applied the patch along with the changelog entry below.
* elf32-avr.c (elf32_avr_relax_section): Handle the case where
there are no local symbols.