Since commit "Always descend into output section statements in lang_do_assignments" (https://github.com/bminor/binutils-gdb/commit/f02cb058822459ea29a9fdaa928c2623df435908), symbols defined with --dynamic-list don't appear as dynamic symbols anymore in the linked ELF binary. Stripped down test case: test.ld (the .dtors section is the relevant part, the rest is copied from the ld manual): PHDRS { headers PT_PHDR PHDRS ; interp PT_INTERP ; text PT_LOAD FILEHDR PHDRS ; data PT_LOAD ; dynamic PT_DYNAMIC ; } SECTIONS { . = SIZEOF_HEADERS; .interp : { *(.interp) } :text :interp .text : { *(.text) } :text .rodata : { *(.rodata) } /* defaults to :text */ . = . + 0x1000; /* move to a new page in memory */ .data : { *(.data) } :data .dynamic : { *(.dynamic) } :data :dynamic .dtors : { _dtors_start = .; _dtors_end = .; } } ---------- test.dl (dynamic list): { _dtors_start; _dtors_end; }; ---------- test commands: $ as /dev/null -o test.o $ ld -T test.ld --dynamic-list test.dl -o test test.o $ objdump -T test output before the mentioned commit: test: file format elf64-x86-64 DYNAMIC SYMBOL TABLE: 00000000000012a8 g D .dynamic 0000000000000000 _dtors_end 00000000000012a8 g D .dynamic 0000000000000000 _dtors_start output with the current master branch: test: file format elf64-x86-64 DYNAMIC SYMBOL TABLE: no symbols
The master branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=73ec947d59c511411377ad51ef792a5fcdd3f0cc commit 73ec947d59c511411377ad51ef792a5fcdd3f0cc Author: Alan Modra <amodra@gmail.com> Date: Tue May 2 21:56:43 2017 +0930 PR 21384, --dynamic-list regression with f02cb058 The commit to "Always descend into output section statements in lang_do_assignments" meant that linker script symbols were not bfd_link_hash_new when ld called bfd_elf_record_link_assignment. This patch corrects that problem by testing h->non_elf instead. PR 21384 * elflink.c (bfd_elf_link_mark_dynamic_symbol): Test h->non_elf rather than h->root.type == bfd_link_hash_new. (bfd_elf_record_link_assignment): Similarly, call bfd_elf_link_mark_dynamic_symbol when h->non_elf.
The master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=640226f048b67d79da85742728e40114c9ee5da0 commit 640226f048b67d79da85742728e40114c9ee5da0 Author: H.J. Lu <hjl.tools@gmail.com> Date: Tue May 2 13:54:22 2017 -0700 Add a test for PR ld/21384 PR ld/21384 * testsuite/ld-elf/pr21384.d: New file. * testsuite/ld-elf/pr21384.dl: Likewise. * testsuite/ld-elf/pr21384.ld: Likewise. * testsuite/ld-elf/pr21384.s: Likewise.
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=5d84490bf6ac806c15781a833f0e1e7a191f334f commit 5d84490bf6ac806c15781a833f0e1e7a191f334f Author: H.J. Lu <hjl.tools@gmail.com> Date: Sat Oct 14 11:23:45 2017 -0700 cris: Don't hide symbol which was forced to be dynamic h->root.dynamic is set on symbols which were forced to be dynamic due to a version script file. Don't remove such symbols from dynamic symbol table. This fixes: FAIL: ld-elf/pr21384 PR ld/21384 * elf32-cris.c (elf_cris_discard_excess_program_dynamics): Don't hide symbol which was forced to be dynamic.