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] HPPA64 linker segmentation faults


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

commit 586338b839d3f65d22eb3baef41f7395974f1f11
Author: Alan Modra <amodra@gmail.com>
Date:   Tue May 28 08:41:56 2019 +0930

    HPPA64 linker segmentation faults
    
    One of the ld tests produces:
    failed with: <Segmentation fault>, no expected output
    FAIL: Discarded dynamic relocation section
    
    This patch cures the segv.  (The test still fails with ld producing
    a really messed up output, DT_RELA at address 0!)
    
    	PR 24596
    	* elf64-hppa.c (elf64_hppa_finalize_dynreloc): Get the output bfd
    	from bfd_link_info, not an output section owner.
    	(elf64_hppa_finish_dynamic_symbol, elf64_hppa_finalize_opd): Likewise.
    	(elf_hppa_final_link_relocate): Likewise.

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

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 254ebcb..72da0df 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,6 +1,14 @@
 2019-05-28  Alan Modra  <amodra@gmail.com>
 
 	PR 24596
+	* elf64-hppa.c (elf64_hppa_finalize_dynreloc): Get the output bfd
+	from bfd_link_info, not an output section owner.
+	(elf64_hppa_finish_dynamic_symbol, elf64_hppa_finalize_opd): Likewise.
+	(elf_hppa_final_link_relocate): Likewise.
+
+2019-05-28  Alan Modra  <amodra@gmail.com>
+
+	PR 24596
 	* aout-tic30.c (MY_bfd_final_link): Don't segfault on missing
 	create_object_symbols_section, obj_textsec, obj_datasec or
 	obj_bsssec.  Fix other errors in placement.
diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c
index 6dc083f..9f6a513 100644
--- a/bfd/elf64-hppa.c
+++ b/bfd/elf64-hppa.c
@@ -2011,7 +2011,7 @@ elf64_hppa_finish_dynamic_symbol (bfd *output_bfd,
 	 in the output_offset of the PLT section.  */
 
       bfd_put_64 (splt->owner, value, splt->contents + hh->plt_offset);
-      value = _bfd_get_gp_value (splt->output_section->owner);
+      value = _bfd_get_gp_value (info->output_bfd);
       bfd_put_64 (splt->owner, value, splt->contents + hh->plt_offset + 0x8);
 
       /* Create a dynamic IPLT relocation for this entry.
@@ -2027,7 +2027,7 @@ elf64_hppa_finish_dynamic_symbol (bfd *output_bfd,
 
       loc = spltrel->contents;
       loc += spltrel->reloc_count++ * sizeof (Elf64_External_Rela);
-      bfd_elf64_swap_reloca_out (splt->output_section->owner, &rel, loc);
+      bfd_elf64_swap_reloca_out (info->output_bfd, &rel, loc);
     }
 
   /* Initialize an external call stub entry if requested.  */
@@ -2143,7 +2143,7 @@ elf64_hppa_finalize_opd (struct elf_link_hash_entry *eh, void *data)
       bfd_put_64 (sopd->owner, value, sopd->contents + hh->opd_offset + 16);
 
       /* The last word is our local __gp value.  */
-      value = _bfd_get_gp_value (sopd->output_section->owner);
+      value = _bfd_get_gp_value (info->output_bfd);
       bfd_put_64 (sopd->owner, value, sopd->contents + hh->opd_offset + 24);
     }
 
@@ -2220,7 +2220,7 @@ elf64_hppa_finalize_opd (struct elf_link_hash_entry *eh, void *data)
 
       loc = sopdrel->contents;
       loc += sopdrel->reloc_count++ * sizeof (Elf64_External_Rela);
-      bfd_elf64_swap_reloca_out (sopd->output_section->owner, &rel, loc);
+      bfd_elf64_swap_reloca_out (info->output_bfd, &rel, loc);
     }
   return TRUE;
 }
@@ -2315,7 +2315,7 @@ elf64_hppa_finalize_dlt (struct elf_link_hash_entry *eh, void *data)
 
       loc = sdltrel->contents;
       loc += sdltrel->reloc_count++ * sizeof (Elf64_External_Rela);
-      bfd_elf64_swap_reloca_out (sdlt->output_section->owner, &rel, loc);
+      bfd_elf64_swap_reloca_out (info->output_bfd, &rel, loc);
     }
   return TRUE;
 }
@@ -2431,8 +2431,7 @@ elf64_hppa_finalize_dynreloc (struct elf_link_hash_entry *eh,
 	  loc = hppa_info->other_rel_sec->contents;
 	  loc += (hppa_info->other_rel_sec->reloc_count++
 		  * sizeof (Elf64_External_Rela));
-	  bfd_elf64_swap_reloca_out (hppa_info->other_rel_sec->output_section->owner,
-				     &rel, loc);
+	  bfd_elf64_swap_reloca_out (info->output_bfd, &rel, loc);
 	}
     }
 
@@ -3381,8 +3380,7 @@ elf_hppa_final_link_relocate (Elf_Internal_Rela *rel,
 				(hppa_info->opd_sec->contents + off + 16));
 
 		    /* The last word is our local __gp value.  */
-		    value = _bfd_get_gp_value
-			      (hppa_info->opd_sec->output_section->owner);
+		    value = _bfd_get_gp_value (info->output_bfd);
 		    bfd_put_64 (hppa_info->opd_sec->owner, value,
 				(hppa_info->opd_sec->contents + off + 24));
 		  }
@@ -3591,8 +3589,7 @@ elf_hppa_final_link_relocate (Elf_Internal_Rela *rel,
 			 + hh->opd_offset + 16));
 
 	    /* The last word is our local __gp value.  */
-	    value = _bfd_get_gp_value
-		      (hppa_info->opd_sec->output_section->owner);
+	    value = _bfd_get_gp_value (info->output_bfd);
 	    bfd_put_64 (hppa_info->opd_sec->owner, value,
 			hppa_info->opd_sec->contents + hh->opd_offset + 24);
 
@@ -3718,8 +3715,7 @@ elf_hppa_final_link_relocate (Elf_Internal_Rela *rel,
 			    (hppa_info->opd_sec->contents + off + 16));
 
 		/* The last word is our local __gp value.  */
-		value = _bfd_get_gp_value
-			  (hppa_info->opd_sec->output_section->owner);
+		value = _bfd_get_gp_value (info->output_bfd);
 		bfd_put_64 (hppa_info->opd_sec->owner, value,
 			    hppa_info->opd_sec->contents + off + 24);
 	      }


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