* PR 21384, --dynamic-list regression with f02cb058 @ 2017-05-02 15:22 Alan Modra 2017-05-02 20:57 ` H.J. Lu 0 siblings, 1 reply; 8+ messages in thread From: Alan Modra @ 2017-05-02 15:22 UTC (permalink / raw) To: binutils 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. diff --git a/bfd/ChangeLog b/bfd/ChangeLog index dff6a59..c62cf13 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,11 @@ +2017-05-02 Alan Modra <amodra@gmail.com> + + 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. + 2017-04-29 Alan Modra <amodra@gmail.com> PR 21432 diff --git a/bfd/elflink.c b/bfd/elflink.c index 4af4b1c..9acc069 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -580,7 +580,7 @@ bfd_elf_link_mark_dynamic_symbol (struct bfd_link_info *info, && (ELF_ST_TYPE (sym->st_info) == STT_OBJECT || ELF_ST_TYPE (sym->st_info) == STT_COMMON)))) || (d != NULL - && h->root.type == bfd_link_hash_new + && h->non_elf && (*d->match) (&d->head, NULL, h->root.root.string))) h->dynamic = 1; } @@ -623,6 +623,14 @@ bfd_elf_record_link_assignment (bfd *output_bfd, } } + /* Symbols defined in a linker script but not referenced anywhere + else will have non_elf set. */ + if (h->non_elf) + { + bfd_elf_link_mark_dynamic_symbol (info, h, NULL); + h->non_elf = 0; + } + switch (h->root.type) { case bfd_link_hash_defined: @@ -639,8 +647,6 @@ bfd_elf_record_link_assignment (bfd *output_bfd, bfd_link_repair_undef_list (&htab->root); break; case bfd_link_hash_new: - bfd_elf_link_mark_dynamic_symbol (info, h, NULL); - h->non_elf = 0; break; case bfd_link_hash_indirect: /* We had a versioned symbol in a dynamic library. We make the -- Alan Modra Australia Development Lab, IBM ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: PR 21384, --dynamic-list regression with f02cb058 2017-05-02 15:22 PR 21384, --dynamic-list regression with f02cb058 Alan Modra @ 2017-05-02 20:57 ` H.J. Lu 2017-05-02 22:28 ` Alan Modra 2017-05-03 13:44 ` Maciej W. Rozycki 0 siblings, 2 replies; 8+ messages in thread From: H.J. Lu @ 2017-05-02 20:57 UTC (permalink / raw) To: Alan Modra; +Cc: Binutils [-- Attachment #1: Type: text/plain, Size: 2494 bytes --] On Tue, May 2, 2017 at 8:22 AM, Alan Modra <amodra@gmail.com> wrote: > 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. > > diff --git a/bfd/ChangeLog b/bfd/ChangeLog > index dff6a59..c62cf13 100644 > --- a/bfd/ChangeLog > +++ b/bfd/ChangeLog > @@ -1,3 +1,11 @@ > +2017-05-02 Alan Modra <amodra@gmail.com> > + > + 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. > + > 2017-04-29 Alan Modra <amodra@gmail.com> > > PR 21432 > diff --git a/bfd/elflink.c b/bfd/elflink.c > index 4af4b1c..9acc069 100644 > --- a/bfd/elflink.c > +++ b/bfd/elflink.c > @@ -580,7 +580,7 @@ bfd_elf_link_mark_dynamic_symbol (struct bfd_link_info *info, > && (ELF_ST_TYPE (sym->st_info) == STT_OBJECT > || ELF_ST_TYPE (sym->st_info) == STT_COMMON)))) > || (d != NULL > - && h->root.type == bfd_link_hash_new > + && h->non_elf > && (*d->match) (&d->head, NULL, h->root.root.string))) > h->dynamic = 1; > } > @@ -623,6 +623,14 @@ bfd_elf_record_link_assignment (bfd *output_bfd, > } > } > > + /* Symbols defined in a linker script but not referenced anywhere > + else will have non_elf set. */ > + if (h->non_elf) > + { > + bfd_elf_link_mark_dynamic_symbol (info, h, NULL); > + h->non_elf = 0; > + } > + > switch (h->root.type) > { > case bfd_link_hash_defined: > @@ -639,8 +647,6 @@ bfd_elf_record_link_assignment (bfd *output_bfd, > bfd_link_repair_undef_list (&htab->root); > break; > case bfd_link_hash_new: > - bfd_elf_link_mark_dynamic_symbol (info, h, NULL); > - h->non_elf = 0; > break; > case bfd_link_hash_indirect: > /* We had a versioned symbol in a dynamic library. We make the > I checked in a test for this. -- H.J. [-- Attachment #2: 0001-Add-a-test-for-PR-ld-21384.patch --] [-- Type: text/x-patch, Size: 3022 bytes --] From 640226f048b67d79da85742728e40114c9ee5da0 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" <hjl.tools@gmail.com> Date: Tue, 2 May 2017 13:54:22 -0700 Subject: [PATCH] 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. --- ld/ChangeLog | 8 ++++++++ ld/testsuite/ld-elf/pr21384.d | 11 +++++++++++ ld/testsuite/ld-elf/pr21384.dl | 4 ++++ ld/testsuite/ld-elf/pr21384.ld | 22 ++++++++++++++++++++++ ld/testsuite/ld-elf/pr21384.s | 2 ++ 5 files changed, 47 insertions(+) create mode 100644 ld/testsuite/ld-elf/pr21384.d create mode 100644 ld/testsuite/ld-elf/pr21384.dl create mode 100644 ld/testsuite/ld-elf/pr21384.ld create mode 100644 ld/testsuite/ld-elf/pr21384.s diff --git a/ld/ChangeLog b/ld/ChangeLog index 238404d..4fc4e1d 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,11 @@ +2017-05-02 H.J. Lu <hongjiu.lu@intel.com> + + 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. + 2017-05-01 H.J. Lu <hongjiu.lu@intel.com> * testsuite/ld-i386/tls.exp: Run GNU2 TLS tests only if there diff --git a/ld/testsuite/ld-elf/pr21384.d b/ld/testsuite/ld-elf/pr21384.d new file mode 100644 index 0000000..5a3aedc --- /dev/null +++ b/ld/testsuite/ld-elf/pr21384.d @@ -0,0 +1,11 @@ +#ld: -T pr21384.ld --dynamic-list $srcdir/$subdir/pr21384.dl --no-dynamic-linker +#readelf : --dyn-syms --wide +#target: *-*-linux* *-*-gnu* *-*-solaris* + +Symbol table '\.dynsym' contains [0-9]+ entries: + +Num: +Value +Size Type +Bind +Vis +Ndx Name + +0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND + +#... + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +edata + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +fdata +#pass diff --git a/ld/testsuite/ld-elf/pr21384.dl b/ld/testsuite/ld-elf/pr21384.dl new file mode 100644 index 0000000..b164dc0 --- /dev/null +++ b/ld/testsuite/ld-elf/pr21384.dl @@ -0,0 +1,4 @@ +{ + fdata; + edata; +}; diff --git a/ld/testsuite/ld-elf/pr21384.ld b/ld/testsuite/ld-elf/pr21384.ld new file mode 100644 index 0000000..034887d --- /dev/null +++ b/ld/testsuite/ld-elf/pr21384.ld @@ -0,0 +1,22 @@ +SECTIONS +{ + .data : + { + fdata = .; + *(.data) + edata = .; + } + .dynamic : { *(.dynamic) } + .hash : { *(.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .gnu.version : { *(.gnu.version) } + .gnu.version_d : { *(.gnu.version_d) } + .shstrtab : { *(.shstrtab) } + .symtab : { *(.symtab) } + .strtab : { *(.strtab) } + .plt : { *(.plt) } + .got.plt : { *(.got.plt) } + .got : { *(.got) } + /DISCARD/ : { *(*) } +} diff --git a/ld/testsuite/ld-elf/pr21384.s b/ld/testsuite/ld-elf/pr21384.s new file mode 100644 index 0000000..ece49d5 --- /dev/null +++ b/ld/testsuite/ld-elf/pr21384.s @@ -0,0 +1,2 @@ + .data + .byte 0 -- 2.9.3 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: PR 21384, --dynamic-list regression with f02cb058 2017-05-02 20:57 ` H.J. Lu @ 2017-05-02 22:28 ` Alan Modra 2017-05-02 23:03 ` H.J. Lu 2017-05-03 13:44 ` Maciej W. Rozycki 1 sibling, 1 reply; 8+ messages in thread From: Alan Modra @ 2017-05-02 22:28 UTC (permalink / raw) To: H.J. Lu; +Cc: Binutils On Tue, May 02, 2017 at 01:57:49PM -0700, H.J. Lu wrote: > I checked in a test for this. Thanks. Incidentally, on my x86_64-linux box I've been seeing Executing on host: sh -c {gcc -B/home/alan/build/gas/all/ld/tmpdir/ld/ -L/usr/local/x86_64-linux/lib64 -L/usr/local/lib64 -L/lib64 -L/usr/lib64 -L/usr/local/x86_64-linux/lib -L/usr/local/lib -L/lib -L/usr/lib -o tmpdir/tls-1en -L/home/alan/src/binutils-gdb/ld/testsuite/ld-x86-64 -Wl,-z,now tmpdir/tls-main1.o tmpdir/libtls-1a.so tmpdir/libtls-1bn.so -Wl,-R,tmpdir tmpdir/dummy.o 2>&1} /dev/null ld.tmp (timeout = 300) spawn [open ...] tmpdir/libtls-1bn.so: undefined reference to `gd' collect2: error: ld returned 1 exit status tmpdir/libtls-1bn.so: undefined reference to `gd' collect2: error: ld returned 1 exit status FAIL: TLS without PLT (3) gcc (Ubuntu 4.9.4-2ubuntu1~16.04) 4.9.4 -- Alan Modra Australia Development Lab, IBM ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: PR 21384, --dynamic-list regression with f02cb058 2017-05-02 22:28 ` Alan Modra @ 2017-05-02 23:03 ` H.J. Lu 2017-05-03 7:45 ` Alan Modra 0 siblings, 1 reply; 8+ messages in thread From: H.J. Lu @ 2017-05-02 23:03 UTC (permalink / raw) To: Alan Modra; +Cc: Binutils [-- Attachment #1: Type: text/plain, Size: 1035 bytes --] On Tue, May 2, 2017 at 3:28 PM, Alan Modra <amodra@gmail.com> wrote: > On Tue, May 02, 2017 at 01:57:49PM -0700, H.J. Lu wrote: >> I checked in a test for this. > > Thanks. Incidentally, on my x86_64-linux box I've been seeing > > Executing on host: sh -c {gcc -B/home/alan/build/gas/all/ld/tmpdir/ld/ -L/usr/local/x86_64-linux/lib64 -L/usr/local/lib64 -L/lib64 -L/usr/lib64 -L/usr/local/x86_64-linux/lib -L/usr/local/lib -L/lib -L/usr/lib -o tmpdir/tls-1en -L/home/alan/src/binutils-gdb/ld/testsuite/ld-x86-64 -Wl,-z,now tmpdir/tls-main1.o tmpdir/libtls-1a.so tmpdir/libtls-1bn.so -Wl,-R,tmpdir tmpdir/dummy.o 2>&1} /dev/null ld.tmp (timeout = 300) > spawn [open ...] > tmpdir/libtls-1bn.so: undefined reference to `gd' > collect2: error: ld returned 1 exit status > tmpdir/libtls-1bn.so: undefined reference to `gd' > collect2: error: ld returned 1 exit status > FAIL: TLS without PLT (3) > > gcc (Ubuntu 4.9.4-2ubuntu1~16.04) 4.9.4 > I checked in this patch. Please give it a try. Thanks. -- H.J. [-- Attachment #2: 0001-x86-Add-Wl-no-as-needed-to-some-TLS-tests.patch --] [-- Type: text/x-patch, Size: 2255 bytes --] From 3d8505928a06e00b05bb162c1ad0dd612c1c16af Mon Sep 17 00:00:00 2001 From: "H.J. Lu" <hjl.tools@gmail.com> Date: Tue, 2 May 2017 16:00:49 -0700 Subject: [PATCH] x86: Add -Wl,--no-as-needed to some TLS tests * testsuite/ld-i386/tls.exp: Add -Wl,--no-as-needed to "TLS without PLT (1)" and "TLS without PLT (3)". * testsuite/ld-x86-64/tls.exp: Add -Wl,--no-as-needed to to "TLS without PLT (3)". --- ld/ChangeLog | 7 +++++++ ld/testsuite/ld-i386/tls.exp | 4 ++-- ld/testsuite/ld-x86-64/tls.exp | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ld/ChangeLog b/ld/ChangeLog index 4fc4e1d..ff52608 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,5 +1,12 @@ 2017-05-02 H.J. Lu <hongjiu.lu@intel.com> + * testsuite/ld-i386/tls.exp: Add -Wl,--no-as-needed to + "TLS without PLT (1)" and "TLS without PLT (3)". + * testsuite/ld-x86-64/tls.exp: Add -Wl,--no-as-needed to + to "TLS without PLT (3)". + +2017-05-02 H.J. Lu <hongjiu.lu@intel.com> + PR ld/21384 * testsuite/ld-elf/pr21384.d: New file. * testsuite/ld-elf/pr21384.dl: Likewise. diff --git a/ld/testsuite/ld-i386/tls.exp b/ld/testsuite/ld-i386/tls.exp index 7a99e46..5fd42bc 100644 --- a/ld/testsuite/ld-i386/tls.exp +++ b/ld/testsuite/ld-i386/tls.exp @@ -141,7 +141,7 @@ run_ld_link_exec_tests [list \ ] \ [list \ "TLS without PLT (1)" \ - "tmpdir/tls-main1.o \ + "-Wl,--no-as-needed tmpdir/tls-main1.o \ tmpdir/libtls-1a.so tmpdir/libtls-1b.so -Wl,-R,tmpdir" \ "" \ { dummy.s } \ @@ -159,7 +159,7 @@ run_ld_link_exec_tests [list \ ] \ [list \ "TLS without PLT (3)" \ - "-Wl,-z,now tmpdir/tls-main1.o \ + "-Wl,--no-as-needed -Wl,-z,now tmpdir/tls-main1.o \ tmpdir/libtls-1a.so tmpdir/libtls-1bn.so -Wl,-R,tmpdir" \ "" \ { dummy.s } \ diff --git a/ld/testsuite/ld-x86-64/tls.exp b/ld/testsuite/ld-x86-64/tls.exp index 5282146..4263d95 100644 --- a/ld/testsuite/ld-x86-64/tls.exp +++ b/ld/testsuite/ld-x86-64/tls.exp @@ -159,7 +159,7 @@ run_ld_link_exec_tests [list \ ] \ [list \ "TLS without PLT (3)" \ - "-Wl,-z,now tmpdir/tls-main1.o \ + "-Wl,--no-as-needed -Wl,-z,now tmpdir/tls-main1.o \ tmpdir/libtls-1a.so tmpdir/libtls-1bn.so -Wl,-R,tmpdir" \ "" \ { dummy.s } \ -- 2.9.3 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: PR 21384, --dynamic-list regression with f02cb058 2017-05-02 23:03 ` H.J. Lu @ 2017-05-03 7:45 ` Alan Modra 0 siblings, 0 replies; 8+ messages in thread From: Alan Modra @ 2017-05-03 7:45 UTC (permalink / raw) To: H.J. Lu; +Cc: Binutils On Tue, May 02, 2017 at 04:03:01PM -0700, H.J. Lu wrote: > On Tue, May 2, 2017 at 3:28 PM, Alan Modra <amodra@gmail.com> wrote: > > FAIL: TLS without PLT (3) > > > > gcc (Ubuntu 4.9.4-2ubuntu1~16.04) 4.9.4 > > I checked in this patch. Please give it a try. Thanks, that fixed it. -- Alan Modra Australia Development Lab, IBM ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: PR 21384, --dynamic-list regression with f02cb058 2017-05-02 20:57 ` H.J. Lu 2017-05-02 22:28 ` Alan Modra @ 2017-05-03 13:44 ` Maciej W. Rozycki 2017-05-03 14:46 ` H.J. Lu 1 sibling, 1 reply; 8+ messages in thread From: Maciej W. Rozycki @ 2017-05-03 13:44 UTC (permalink / raw) To: H.J. Lu; +Cc: Alan Modra, Binutils On Tue, 2 May 2017, H.J. Lu wrote: > I checked in a test for this. Which fails for MIPS targets -- did you regression-test it properly before committing? Maciej ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: PR 21384, --dynamic-list regression with f02cb058 2017-05-03 13:44 ` Maciej W. Rozycki @ 2017-05-03 14:46 ` H.J. Lu 2017-05-03 21:22 ` Maciej W. Rozycki 0 siblings, 1 reply; 8+ messages in thread From: H.J. Lu @ 2017-05-03 14:46 UTC (permalink / raw) To: Maciej W. Rozycki; +Cc: Alan Modra, Binutils [-- Attachment #1: Type: text/plain, Size: 355 bytes --] On Wed, May 3, 2017 at 6:44 AM, Maciej W. Rozycki <macro@imgtec.com> wrote: > On Tue, 2 May 2017, H.J. Lu wrote: > >> I checked in a test for this. > > Which fails for MIPS targets -- did you regression-test it properly > before committing? > Sorry for the noise. I checked in this to accommodate additional dynamic symbols on some targets. -- H.J. [-- Attachment #2: 0001-Adjust-testsuite-ld-elf-pr21384.d.patch --] [-- Type: text/x-patch, Size: 1347 bytes --] From b22908217d8593185af3f76fab6f0f01457b0600 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" <hjl.tools@gmail.com> Date: Wed, 3 May 2017 07:40:51 -0700 Subject: [PATCH] Adjust testsuite/ld-elf/pr21384.d Adjust testsuite/ld-elf/pr21384.d to accommodate additional dynamic symbols on some targets. * testsuite/ld-elf/pr21384.d: Adjusted to accommodate additional dynamic symbols on some targets. --- ld/ChangeLog | 5 +++++ ld/testsuite/ld-elf/pr21384.d | 1 + 2 files changed, 6 insertions(+) diff --git a/ld/ChangeLog b/ld/ChangeLog index 92af8b9..16133b8 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,8 @@ +2017-05-03 H.J. Lu <hongjiu.lu@intel.com> + + * testsuite/ld-elf/pr21384.d: Adjusted to accommodate + additional dynamic symbols on some targets. + 2017-05-02 Maciej W. Rozycki <macro@imgtec.com> * testsuite/ld-mips-elf/mips16-branch-absolute-1.d: New test. diff --git a/ld/testsuite/ld-elf/pr21384.d b/ld/testsuite/ld-elf/pr21384.d index 5a3aedc..5f17aaf 100644 --- a/ld/testsuite/ld-elf/pr21384.d +++ b/ld/testsuite/ld-elf/pr21384.d @@ -7,5 +7,6 @@ Symbol table '\.dynsym' contains [0-9]+ entries: +0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND + #... +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +edata +#... +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +fdata #pass -- 2.9.3 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: PR 21384, --dynamic-list regression with f02cb058 2017-05-03 14:46 ` H.J. Lu @ 2017-05-03 21:22 ` Maciej W. Rozycki 0 siblings, 0 replies; 8+ messages in thread From: Maciej W. Rozycki @ 2017-05-03 21:22 UTC (permalink / raw) To: H.J. Lu; +Cc: Alan Modra, Binutils On Wed, 3 May 2017, H.J. Lu wrote: > > Which fails for MIPS targets -- did you regression-test it properly > > before committing? > > Sorry for the noise. I checked in this to accommodate additional > dynamic symbols on some targets. Thanks! Maciej ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2017-05-03 21:22 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-05-02 15:22 PR 21384, --dynamic-list regression with f02cb058 Alan Modra 2017-05-02 20:57 ` H.J. Lu 2017-05-02 22:28 ` Alan Modra 2017-05-02 23:03 ` H.J. Lu 2017-05-03 7:45 ` Alan Modra 2017-05-03 13:44 ` Maciej W. Rozycki 2017-05-03 14:46 ` H.J. Lu 2017-05-03 21:22 ` Maciej W. Rozycki
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).