[binutils-gdb] PR23207, hppa ld SIGSEGVs on invalid object files

Alan Modra amodra@sourceware.org
Tue May 22 05:57:00 GMT 2018


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

commit 7455c018e45766ab7193cbd45f98f781e0dc7d84
Author: Alan Modra <amodra@gmail.com>
Date:   Mon May 21 21:29:25 2018 +0930

    PR23207, hppa ld SIGSEGVs on invalid object files
    
    We don't create PLT call stubs for anything in non-alloc sections,
    so it doesn't pay to go looking for them.  The problem is that
    non-alloc sections aren't processed by group_sections and thus don't
    get a link_sec set up for them.
    
    	PR 23207
    	* elf32-hppa.c (final_link_relocate): Don't look for plt call
    	stubs in non-alloc sections.

Diff:
---
 bfd/ChangeLog    |  6 ++++++
 bfd/elf32-hppa.c | 23 ++++++++++++-----------
 2 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 0af7a24..b4caff9 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2018-05-22  Alan Modra  <amodra@gmail.com>
+
+	PR 23207
+	* elf32-hppa.c (final_link_relocate): Don't look for plt call
+	stubs in non-alloc sections.
+
 2018-05-21  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR ld/23201
diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c
index 722452b..5ad49ab 100644
--- a/bfd/elf32-hppa.c
+++ b/bfd/elf32-hppa.c
@@ -3267,18 +3267,19 @@ final_link_relocate (asection *input_section,
     case R_PARISC_PCREL22F:
       /* If this call should go via the plt, find the import stub in
 	 the stub hash.  */
-      if (sym_sec == NULL
-	  || sym_sec->output_section == NULL
-	  || (hh != NULL
-	      && hh->eh.plt.offset != (bfd_vma) -1
-	      && hh->eh.dynindx != -1
-	      && !hh->plabel
-	      && (bfd_link_pic (info)
-		  || !hh->eh.def_regular
-		  || hh->eh.root.type == bfd_link_hash_defweak)))
+      if ((input_section->flags & SEC_ALLOC) != 0
+	  && (sym_sec == NULL
+	      || sym_sec->output_section == NULL
+	      || (hh != NULL
+		  && hh->eh.plt.offset != (bfd_vma) -1
+		  && hh->eh.dynindx != -1
+		  && !hh->plabel
+		  && (bfd_link_pic (info)
+		      || !hh->eh.def_regular
+		      || hh->eh.root.type == bfd_link_hash_defweak))))
 	{
 	  hsh = hppa_get_stub_entry (input_section, sym_sec,
-					    hh, rela, htab);
+				     hh, rela, htab);
 	  if (hsh != NULL)
 	    {
 	      value = (hsh->stub_offset
@@ -3478,7 +3479,7 @@ final_link_relocate (asection *input_section,
       if (value + addend + max_branch_offset >= 2*max_branch_offset)
 	{
 	  hsh = hppa_get_stub_entry (input_section, sym_sec,
-					    hh, rela, htab);
+				     hh, rela, htab);
 	  if (hsh == NULL)
 	    return bfd_reloc_undefined;



More information about the Binutils-cvs mailing list