weakdef list handling
authorAlan Modra <amodra@gmail.com>
Sun, 12 Nov 2017 03:42:41 +0000 (14:12 +1030)
committerAlan Modra <amodra@gmail.com>
Sun, 12 Nov 2017 07:15:24 +0000 (17:45 +1030)
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.

bfd/ChangeLog
bfd/elflink.c

index 735136d7f85d48bcc71923470a6e5d08fbb2ea7c..989149a497387b8cb7e9f935a9f17609edbba87e 100644 (file)
@@ -1,3 +1,8 @@
+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
index 122549c594b1034553383200abe225f1146cf95d..72886d57e50d2bdad83c3930c364fe01063e79f6 100644 (file)
@@ -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;