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] Fix powerpc64 segfault caused by zero r_symndx relocs.


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

commit c27b8c2aeb369972f4f9f98f390607694c56a127
Author: Alan Modra <amodra@gmail.com>
Date:   Wed Dec 2 18:49:53 2015 +1030

    Fix powerpc64 segfault caused by zero r_symndx relocs.
    
    Fixes a segfault in ppc64_elf_tls_optimize found when testing
    R_PPC64_ENTRY, and potential for trouble in other places found by
    code inspection.
    
    	* elf64-ppc.c (ppc64_elf_tls_optimize): Don't segfault on NULL
    	symbol section or output section.
    	(ppc64_elf_edit_toc): Similarly for ld -R objects.
    	(ppc64_elf_size_stubs): Likewise.

Diff:
---
 bfd/ChangeLog   | 7 +++++++
 bfd/elf64-ppc.c | 8 ++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 544ed88..fbbea1d 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,10 @@
+2015-12-02  Alan Modra  <amodra@gmail.com>
+
+	* elf64-ppc.c (ppc64_elf_tls_optimize): Don't segfault on NULL
+	symbol section or output section.
+	(ppc64_elf_edit_toc): Similarly for ld -R objects.
+	(ppc64_elf_size_stubs): Likewise.
+
 2015-12-01  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR ld/19319
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index 42356d8..9b5ebcd 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -8391,7 +8391,8 @@ ppc64_elf_tls_optimize (struct bfd_link_info *info)
 		      if (h != NULL
 			  && h->root.type == bfd_link_hash_undefweak)
 			ok_tprel = TRUE;
-		      else
+		      else if (sym_sec != NULL
+			       && sym_sec->output_section != NULL)
 			{
 			  value += sym_sec->output_offset;
 			  value += sym_sec->output_section->vma;
@@ -8952,6 +8953,7 @@ ppc64_elf_edit_toc (struct bfd_link_info *info)
 		goto error_ret;
 
 	      if (sym_sec == NULL
+		  || sym_sec->output_section == NULL
 		  || discarded_section (sym_sec))
 		continue;
 
@@ -12275,7 +12277,9 @@ ppc64_elf_size_stubs (struct bfd_link_info *info)
 		  if (hash == NULL)
 		    {
 		      sym_value = sym->st_value;
-		      ok_dest = TRUE;
+		      if (sym_sec != NULL
+			  && sym_sec->output_section != NULL)
+			ok_dest = TRUE;
 		    }
 		  else if (hash->elf.root.type == bfd_link_hash_defined
 			   || hash->elf.root.type == bfd_link_hash_defweak)


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