From 586338b839d3f65d22eb3baef41f7395974f1f11 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Tue, 28 May 2019 08:41:56 +0930 Subject: [PATCH] HPPA64 linker segmentation faults One of the ld tests produces: failed with: , 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. --- bfd/ChangeLog | 8 ++++++++ bfd/elf64-hppa.c | 22 +++++++++------------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 254ebcb2cd5..72da0df2644 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,11 @@ +2019-05-28 Alan Modra + + 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 PR 24596 diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c index 6dc083f2027..9f6a51334f4 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); } -- 2.30.2