[binutils-gdb] PowerPC64 segfault in ppc64_elf_edit_toc

Alan Modra amodra@sourceware.org
Sat Aug 24 00:38:00 GMT 2019


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

commit 6d5554a605a8ce908ba04b00fd960d02ca9fc613
Author: Alan Modra <amodra@gmail.com>
Date:   Sat Aug 24 09:59:03 2019 +0930

    PowerPC64 segfault in ppc64_elf_edit_toc
    
    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.

Diff:
---
 bfd/ChangeLog   | 5 +++++
 bfd/elf64-ppc.c | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 981e0cd..9f7a8cf 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -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
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index 60918d9..4eba829 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -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;



More information about the Binutils-cvs mailing list