This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] weakdef list handling


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e3e53eed9c2f1ab82ae4a7683f474b4f6eb162c7

commit e3e53eed9c2f1ab82ae4a7683f474b4f6eb162c7
Author: Alan Modra <amodra@gmail.com>
Date:   Sun Nov 12 14:12:41 2017 +1030

    weakdef list handling
    
    The existing code allowed common and indirect symbols to pass an
    assert, but then read root.u.def which is not valid for anything
    besides defined and weakdef symbols.  The garbage root.u.def.section
    pointer read can't possibly match pointers stored at the same location
    for indirect and common symbols, so we would always have left
    u.weakdef NULL.
    
    	* elflink.c (elf_link_add_object_symbols): Ignore anything but
    	defined and defweak symbols when setting up weakdefs.

Diff:
---
 bfd/ChangeLog | 5 +++++
 bfd/elflink.c | 8 ++++----
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 735136d..989149a 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,10 @@
 2017-11-12  Alan Modra  <amodra@gmail.com>
 
+	* elflink.c (elf_link_add_object_symbols): Ignore anything but
+	defined and defweak symbols when setting up weakdefs.
+
+2017-11-12  Alan Modra  <amodra@gmail.com>
+
 	* elf32-hppa.c (elf32_hppa_adjust_dynamic_symbol): Set non_got_ref
 	to keep dyn_relocs, clear to discard.  Comment.
 	(allocate_dynrelocs): Always clear non_got_ref when clearing
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 122549c..72886d5 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -5145,10 +5145,10 @@ error_free_dyn:
 	  weaks = hlook->u.weakdef;
 	  hlook->u.weakdef = NULL;
 
-	  BFD_ASSERT (hlook->root.type == bfd_link_hash_defined
-		      || hlook->root.type == bfd_link_hash_defweak
-		      || hlook->root.type == bfd_link_hash_common
-		      || hlook->root.type == bfd_link_hash_indirect);
+	  if (hlook->root.type != bfd_link_hash_defined
+	      && hlook->root.type != bfd_link_hash_defweak)
+	    continue;
+
 	  slook = hlook->root.u.def.section;
 	  vlook = hlook->root.u.def.value;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]