public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* 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

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).