Using any simple test program, do this on a 32bit host (64bit hosts tend not to crash reliably here) $ avr-gcc -mmcu=attiny2313 avr_test.c -c $ avr-ld -m avr2 -o avr_test.hex /opt/cross/avr/lib/crttn2313.o --oformat ihex avr_test.o BFD 2.17.50.0.8 20061201 internal error, aborting at ../../bfd/linker.c line 2397 in set_symbol_from_hash I tracked that back to one specific patch added in August 2006: cvs -d :pserver:anoncvs@sourceware.org:/cvs/src co -D '2006-10-17 15:41' binutils - is good cvs -d :pserver:anoncvs@sourceware.org:/cvs/src co -D '2006-10-17 15:42' binutils - crashes. The Changelog of the patch has this: diff -u -r1.3635 -r1.3636 --- bfd/ChangeLog 16 Oct 2006 17:21:44 -0000 1.3635 +++ bfd/ChangeLog 17 Oct 2006 13:41:46 -0000 1.3636 @@ -1,3 +1,55 @@ +2006-10-17 Alan Modra <amodra@bigpond.net.au> + + * elf-bfd.h (struct elf_link_hash_table): Reorder. Add + text_index_section and data_index_section. + (struct elf_backend_data): Add elf_backend_init_index_section. + (_bfd_elf_init_1_index_section): Declare. + (_bfd_elf_init_2_index_sections): Declare. + * elfxx-target.h (elf_backend_init_index_section): Define. + (elfNN_bed): Init new field. + * elflink.c (_bfd_elf_link_omit_section_dynsym): Keep first tls + section and text_index_section plus data_index_section. + (_bfd_elf_link_renumber_dynsyms): Clear dynindx on omitted sections. + (_bfd_elf_init_1_index_section): New function. + (_bfd_elf_init_2_index_sections): New function. + (bfd_elf_size_dynsym_hash_dynstr): Call elf_backend_init_index_section. + (elf_link_input_bfd): When emitting relocs, use text_index_section + and data_index_section for removed sections. + * elf-m10300.c (elf_backend_omit_section_dynsym): Define. + * elf32-i386.c: Likewise. + * elf32-m32r.c: Likewise. + * elf32-sh.c: Likewise. ... elf32-avr.c is not in the list. Can someone please help extending this patch to cover also avr targets? Thanks, Jw.
Created attachment 1501 [details] avr_test.o main object to test
Created attachment 1509 [details] Add definition of elf_backend_omit_section_dynsym to elf32-avr.c
Hi Juergen, I do not have access to the /opt/cross/avr/lib/crttn2313.o object file, so I am not able to reproduce this bug. But adding the necessary line to elf32-avr.c looks fairly straightforward, so please could you try out the attached patch and let me know if it works for you ? Cheers Nick
Sorry for the crttn2313.o, it is not necessary to reproduce. Using the attached avr_test.o, $ avr-ld -m avr2 -o avr_test.hex --oformat ihex avr_test.o also crashes the linker. Nick, I am sorry to say this, but your patch (definition of elf_backend_omit_section_dynsym) does not cure the crash. (anyway, thanks for providing the definition.)
Created attachment 1520 [details] Check for avr formated hash tables before using them in avr code.
Hi Juergen, OK, I found a 32-bit host and reproduced the problem. It turns out to be memory corruption in the AVR code due to the use of the linker's --oformat command line option. This selects a non-AVR aware output format, which internally means that a different kind of hash table is used. The AVR code was always assuming that its special, extended hash tables were being used, and so it was corruptong memory. Please could you try out the uploaded patch which should fix this problem. Cheers Nick
Works! And I am really happy, this turned out to be only avr-related. Thanks you!