Hello, it seems that ld has some issue when run with --relax on AVR targets resulting in a segmentation fault. See details at http://comments.gmane.org/gmane.comp.gnu.binutils/55903 Simple test case: //avr-gcc main.c -mrelax -ffunction-sections -mmcu=atmega128 // using binutils-2.22 void func2(int a) { } void func1(void) { func2(10); } int main(void) { func1(); }
More details: [fabio@gamma ldbug]$ avr-gcc main.c -mrelax -ffunction-sections -mmcu=atmega128 -save-temps -v Using built-in specs. COLLECT_GCC=avr-gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/avr/4.6.2/lto-wrapper Target: avr Configured with: ../configure --disable-libssp --disable-nls --enable-languages=c,c++ --infodir=/usr/share/info --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --prefix=/usr --target=avr --with-gnu-as --with-gnu-ld --with-as=/usr/bin/avr-as --with-ld=/usr/bin/avr-ld Thread model: single gcc version 4.6.2 (GCC) COLLECT_GCC_OPTIONS='-mrelax' '-ffunction-sections' '-mmcu=atmega128' '-save-temps' '-v' /usr/lib/gcc/avr/4.6.2/cc1 -E -quiet -v -imultilib avr51 main.c -mrelax -mmcu=atmega128 -ffunction-sections -fpch-preprocess -o main.i ignoring nonexistent directory "/usr/lib/gcc/avr/4.6.2/../../../../avr/sys-include" #include "..." search starts here: #include <...> search starts here: /usr/lib/gcc/avr/4.6.2/include /usr/lib/gcc/avr/4.6.2/include-fixed /usr/lib/gcc/avr/4.6.2/../../../../avr/include End of search list. COLLECT_GCC_OPTIONS='-mrelax' '-ffunction-sections' '-mmcu=atmega128' '-save-temps' '-v' /usr/lib/gcc/avr/4.6.2/cc1 -fpreprocessed main.i -quiet -dumpbase main.c -mrelax -mmcu=atmega128 -auxbase main -version -ffunction-sections -o main.s GNU C (GCC) version 4.6.2 (avr) compiled by GNU C version 4.6.2 20111223 (prerelease), GMP version 5.0.2, MPFR version 3.1.0-p3, MPC version 0.9 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 GNU C (GCC) version 4.6.2 (avr) compiled by GNU C version 4.6.2 20111223 (prerelease), GMP version 5.0.2, MPFR version 3.1.0-p3, MPC version 0.9 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 7f65a69733ae527e3ce90dec3bf8f000 COLLECT_GCC_OPTIONS='-mrelax' '-ffunction-sections' '-mmcu=atmega128' '-save-temps' '-v' /usr/bin/avr-as -v -mmcu=atmega128 -o main.o main.s GNU assembler version 2.22.51 (avr) using BFD version (GNU Binutils) 2.22.51.20120117 COMPILER_PATH=/usr/lib/gcc/avr/4.6.2/:/usr/lib/gcc/avr/4.6.2/:/usr/lib/gcc/avr/:/usr/lib/gcc/avr/4.6.2/:/usr/lib/gcc/avr/ LIBRARY_PATH=/usr/lib/gcc/avr/4.6.2/avr51/:/usr/lib/gcc/avr/4.6.2/../../../../avr/lib/avr51/:/usr/lib/gcc/avr/4.6.2/:/usr/lib/gcc/avr/4.6.2/../../../../avr/lib/ COLLECT_GCC_OPTIONS='-mrelax' '-ffunction-sections' '-mmcu=atmega128' '-save-temps' '-v' /usr/lib/gcc/avr/4.6.2/collect2 --relax -m avr51 -Tdata 0x800100 /usr/lib/gcc/avr/4.6.2/../../../../avr/lib/avr51/crtm128.o -L/usr/lib/gcc/avr/4.6.2/avr51 -L/usr/lib/gcc/avr/4.6.2/../../../../avr/lib/avr51 -L/usr/lib/gcc/avr/4.6.2 -L/usr/lib/gcc/avr/4.6.2/../../../../avr/lib main.o -lgcc -lc -lgcc
Created attachment 6170 [details] Test case
Created attachment 6171 [details] .i .s .o
Upgraded to current binutils weekly snapshot. I'm no more able to replicate the issue.
*** This bug has been marked as a duplicate of bug 12161 ***