In an own project which worked for years, the linker suddenly aborts with the libbfd-error /usr/bin/ld: BFD 2.14.90.0.7 20031029 Debian GNU/Linux internal error, aborting at ../../bfd/elf32-i386.c line 2247 in elf_i386_relocate_section I broke my app down to a small testcase which I will try to append to this bugreport. My system is Debian/sid.
Created attachment 119 [details] Small test app which is the minimal version to reproduce the bug on my system. Rreproduces the bug on my system.
I could not reproduce this problem with current mainline binutils and gcc-3.3.3-hammer. There have been quite a few changes to elf32-i386.c since binutils-2.14.90.0.7 and it's likely that one of them has fixed the bug. Please try your testcase with a newer binutils. If current mainline binutils fails for you, then we need the set of object files involved in the link rather than C/C++ source files. Compiler differences may make it impossible to reproduce.
Created attachment 121 [details] Object files that reproduce the bug with binutils 2.15 I updated binutils to the current mainline (2.15), but the ld-error remains. I attached an archive with the modules which make the following line crash. g++ -g -O2 -o test main.o modules/.libs/libmodules.a /usr/bin/ld: BFD 2.15 internal error, aborting at ../../bfd/elf32-i386.c line 2262 in elf_i386_relocate_section
This is a relocation against a local symbol in a removed linkonce section. Various hacks have been tried to handle such symbols and each one fails in some cases, so I'm inclined to say this is really a problem with your c++ compiler. HJ was the last person to touch the relevant linker code. He might have a better idea than I whether anything can be done with this particular testcase.
I can reproduce it with gcc 3.3.5 20040627 and gcc 3.4.1 20040627.
It is a nasty problem, which can only be properly solved with comdat group.
Here is the linker patch http://sources.redhat.com/ml/binutils/2004-06/msg00567.html
http://sources.redhat.com/ml/binutils-cvs/2004-10/msg00084.html