From 6528b6eba85f044667876a2ad77d4612a9e5fc65 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Wed, 22 Feb 2017 08:10:58 +1030 Subject: PowerPC ld segfault on script discarding dynamic sections bfd/ * elf64-ppc.c (ppc64_elf_finish_dynamic_sections): Don't segfault on .got or .plt output section being discarded by script. * elf32-ppc.c (ppc_elf_finish_dynamic_sections): Likewise. Move vxworks splt temp. gold/ * powerpc.cc (Target_powerpc::make_iplt_section): Check that output_section exists before attempting add_output_section_data. (Target_powerpc::make_brlt_section): Likewise. --- bfd/elf32-ppc.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'bfd/elf32-ppc.c') diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index 30998b1ade..d82193560e 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -10418,7 +10418,6 @@ ppc_elf_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) { asection *sdyn; - asection *splt; struct ppc_elf_link_hash_table *htab; bfd_vma got; bfd *dynobj; @@ -10431,10 +10430,6 @@ ppc_elf_finish_dynamic_sections (bfd *output_bfd, htab = ppc_elf_hash_table (info); dynobj = htab->elf.dynobj; sdyn = bfd_get_linker_section (dynobj, ".dynamic"); - if (htab->is_vxworks) - splt = htab->elf.splt; - else - splt = NULL; got = 0; if (htab->elf.hgot != NULL) @@ -10489,7 +10484,8 @@ ppc_elf_finish_dynamic_sections (bfd *output_bfd, } } - if (htab->elf.sgot != NULL) + if (htab->elf.sgot != NULL + && htab->elf.sgot->output_section != bfd_abs_section_ptr) { if (htab->elf.hgot->root.u.def.section == htab->elf.sgot || htab->elf.hgot->root.u.def.section == htab->elf.sgotplt) @@ -10531,8 +10527,12 @@ ppc_elf_finish_dynamic_sections (bfd *output_bfd, } /* Fill in the first entry in the VxWorks procedure linkage table. */ - if (splt && splt->size > 0) + if (htab->is_vxworks + && htab->elf.splt != NULL + && htab->elf.splt->size != 0 + && htab->elf.splt->output_section != bfd_abs_section_ptr) { + asection *splt = htab->elf.splt; /* Use the right PLT. */ const bfd_vma *plt_entry = (bfd_link_pic (info) ? ppc_elf_vxworks_pic_plt0_entry -- cgit v1.2.3