Created attachment 10070 [details] small example Hi. I have received an internal error when linking an elf to a flat binary, that contains a globally unique symbol (marked as "u" by nm). It only happens if I try to produce a flat binary, and works normally when the result is an elf file. The symbol is a static variable in a template class (I think it would be the same if the template is a function, but I haven't tried it...) I have attached a simple example source file that demonstrates the bug. You can compile it with the following commands: g++ -c main.cpp -o main.o ld main.o --oformat binary -o main.bin -e main The last command results in: 'ld: BFD (GNU Binutils for Ubuntu) 2.28 internal error, aborting at ../../bfd/linker.c:2162 in _bfd_generic_link_output_symbols ld: Please report this bug.' The problem is related to the symbol _ZN3fooILi4EE3barE (foo<4>::bar).
The master branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=af54f0eb968ba8cb3862fd3cad097a3f3363467b commit af54f0eb968ba8cb3862fd3cad097a3f3363467b Author: Alan Modra <amodra@gmail.com> Date: Mon Jun 5 11:02:42 2017 +0930 PR21529, internal error in linker.c PR 21529 * linker.c (_bfd_generic_link_output_symbols): Handle BSF_GNU_UNIQUE.
The binutils-2_28-branch branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=dfa8a3425800c868052808d4237a2c6f80e5b204 commit dfa8a3425800c868052808d4237a2c6f80e5b204 Author: Alan Modra <amodra@gmail.com> Date: Mon Jun 5 11:02:42 2017 +0930 PR21529, internal error in linker.c PR 21529 * linker.c (_bfd_generic_link_output_symbols): Handle BSF_GNU_UNIQUE.
Fixed.
The master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d9409498813c75c1a9e9287ac6e5100ed3130390 commit d9409498813c75c1a9e9287ac6e5100ed3130390 Author: H.J. Lu <hjl.tools@gmail.com> Date: Mon Jun 5 14:54:12 2017 -0700 Add a testcase for PR ld/21529 PR ld/21529 * testsuite/ld-unique/pr21529.d: New file. * testsuite/ld-unique/pr21529.s: Likewise. * testsuite/ld-unique/unique.exp: Run *.d.
The master branch has been updated by Maciej W. Rozycki <macro@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=211b0bed95b3f6b177a541ec52302b8febd6b49c commit 211b0bed95b3f6b177a541ec52302b8febd6b49c Author: Maciej W. Rozycki <macro@imgtec.com> Date: Fri Jul 14 11:53:08 2017 +0100 PR ld/21529: Use a linker script to limit output with the test case Complement commit d9409498813c ("Add a testcase for PR ld/21529") and use a linker script to prevent an inter-segment gap arranged by the default linker script associated with some targets such as `rx-elf': $ ld -e main -o tmpdir/dump-elf tmpdir/pr21529.o $ readelf -l tmpdir/dump-elf Elf file type is EXEC (Executable file) Entry point 0x10000004 There are 2 program headers, starting at offset 52 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x001000 0x10000000 0x10000000 0x00008 0x00008 R E 0x1000 LOAD 0x001ffc 0xbffffffc 0xbffffffc 0x00004 0x00004 RW 0x1000 Section to Segment mapping: Segment Sections... 00 .text 01 .stack $ and converted to padding with the use of the binary BFD for output from producing unreasonably large files. ld/ * testsuite/ld-unique/pr21529.ld: New test linker script. * testsuite/ld-unique/pr21529.d: Use it.
The binutils-2_29-branch branch has been updated by Maciej W. Rozycki <macro@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=991a4012c56f09d9ea7f0b44e47231693a774e94 commit 991a4012c56f09d9ea7f0b44e47231693a774e94 Author: Maciej W. Rozycki <macro@imgtec.com> Date: Fri Jul 14 11:53:08 2017 +0100 PR ld/21529: Use a linker script to limit output with the test case Complement commit d9409498813c ("Add a testcase for PR ld/21529") and use a linker script to prevent an inter-segment gap arranged by the default linker script associated with some targets such as `rx-elf': $ ld -e main -o tmpdir/dump-elf tmpdir/pr21529.o $ readelf -l tmpdir/dump-elf Elf file type is EXEC (Executable file) Entry point 0x10000004 There are 2 program headers, starting at offset 52 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x001000 0x10000000 0x10000000 0x00008 0x00008 R E 0x1000 LOAD 0x001ffc 0xbffffffc 0xbffffffc 0x00004 0x00004 RW 0x1000 Section to Segment mapping: Segment Sections... 00 .text 01 .stack $ and converted to padding with the use of the binary BFD for output from producing unreasonably large files. ld/ * testsuite/ld-unique/pr21529.ld: New test linker script. * testsuite/ld-unique/pr21529.d: Use it. (cherry picked from commit 211b0bed95b3f6b177a541ec52302b8febd6b49c)