HPPA64 linker segmentation fault

Message ID 20190528013000.GP6820@bubble.grove.modra.org
State New
Headers show
Series
  • HPPA64 linker segmentation fault
Related show

Commit Message

Alan Modra May 28, 2019, 1:30 a.m.
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.


-- 
Alan Modra
Australia Development Lab, IBM

Patch

diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c
index 6dc083f202..9f6a51334f 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);
 	      }