PowerPC64 segfault in ppc64_elf_edit_toc
authorAlan Modra <amodra@gmail.com>
Sat, 24 Aug 2019 00:29:03 +0000 (09:59 +0930)
committerAlan Modra <amodra@gmail.com>
Sat, 24 Aug 2019 00:35:40 +0000 (10:05 +0930)
Found on a GOT reference to __ehdr_start, which is tweaked to be
undefined weak at some stages of linking.  SYMBOL_REFERENCES_LOCAL
isn't a sufficient test.

* elf64-ppc.c (ppc64_elf_edit_toc): Exclude undefined weak
symbols from GOT optimisation.

bfd/ChangeLog
bfd/elf64-ppc.c

index 981e0cd4e9228d1c6254e66a249b8617022b7058..9f7a8cfc6afc96bd3348d8ffbc44c079cfb6514c 100644 (file)
@@ -1,3 +1,8 @@
+2019-08-24  Alan Modra  <amodra@gmail.com>
+
+       * elf64-ppc.c (ppc64_elf_edit_toc): Exclude undefined weak
+       symbols from GOT optimisation.
+
 2019-08-23  Stafford Horne  <shorne@gmail.com>
 
        * elf32-or1k.c (or1k_elf_finish_dynamic_symbol): Use correct value for
index 60918d91a173dded0cac234866b303566a1825cd..4eba829450845b0cfa3328aebb93328ca08e3e87 100644 (file)
@@ -9112,6 +9112,11 @@ ppc64_elf_edit_toc (struct bfd_link_info *info)
                              r_symndx, ibfd))
                goto got_error_ret;
 
+             if (sym_sec == NULL
+                 || sym_sec->output_section == NULL
+                 || discarded_section (sym_sec))
+               continue;
+
              if (!SYMBOL_REFERENCES_LOCAL (info, h))
                continue;