From 4a7e52349807017f9bc09ea25f07924f2ec971b3 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Fri, 1 Dec 2017 07:53:16 +1030 Subject: PR22533, dynamic relocs generated for weak aliases This cleans up yet more craziness with non_got_ref. PR 22533 * elf32-hppa.c (elf32_hppa_copy_indirect_symbol): Don't do anything special with non_got_ref for weak aliases. (elf32_hppa_check_relocs): Tweak setting of non_got_ref. (elf32_hppa_adjust_dynamic_symbol): When initialising weak aliases, don't uselessly copy non_got_ref. Clear dyn_relocs instead if strong symbol is allocated in dynbss. Tidy comments. (elf32_hppa_relocate_section): Comment fix. * elf32-ppc.c (ppc_elf_copy_indirect_symbol): Don't do anything special with non_got_ref for weak aliases. (ppc_elf_adjust_dynamic_symbol): When initialising weak aliases, don't uselessly copy non_got_ref. Clear dyn_relocs instead if strong symbol is allocated in dynbss. Tidy comments. * elf64-ppc.c (ppc64_elf_copy_indirect_symbol): Don't do anything special with non_got_ref for weak aliases. (ppc64_elf_adjust_dynamic_symbol): When initialising weak aliases, don't uselessly copy non_got_ref. Clear dyn_relocs instead if strong symbol is allocated in dynbss. Tidy comments. --- bfd/elf64-ppc.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'bfd/elf64-ppc.c') diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index 2486390babf..b7f4029bf56 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -4761,18 +4761,11 @@ ppc64_elf_copy_indirect_symbol (struct bfd_link_info *info, if (eind->oh != NULL) edir->oh = ppc_follow_link (eind->oh); - /* If called to transfer flags for a weakdef during processing - of elf_adjust_dynamic_symbol, don't copy NON_GOT_REF. - We clear it ourselves for ELIMINATE_COPY_RELOCS. */ - if (!(ELIMINATE_COPY_RELOCS - && eind->elf.root.type != bfd_link_hash_indirect - && edir->elf.dynamic_adjusted)) - edir->elf.non_got_ref |= eind->elf.non_got_ref; - if (edir->elf.versioned != versioned_hidden) edir->elf.ref_dynamic |= eind->elf.ref_dynamic; edir->elf.ref_regular |= eind->elf.ref_regular; edir->elf.ref_regular_nonweak |= eind->elf.ref_regular_nonweak; + edir->elf.non_got_ref |= eind->elf.non_got_ref; edir->elf.needs_plt |= eind->elf.needs_plt; edir->elf.pointer_equality_needed |= eind->elf.pointer_equality_needed; @@ -7216,8 +7209,9 @@ ppc64_elf_adjust_dynamic_symbol (struct bfd_link_info *info, BFD_ASSERT (def->root.type == bfd_link_hash_defined); h->root.u.def.section = def->root.u.def.section; h->root.u.def.value = def->root.u.def.value; - if (ELIMINATE_COPY_RELOCS) - h->non_got_ref = def->non_got_ref; + if (def->root.u.def.section == htab->elf.sdynbss + || def->root.u.def.section == htab->elf.sdynrelro) + ((struct ppc_link_hash_entry *) h)->dyn_relocs = NULL; return TRUE; } @@ -7275,11 +7269,6 @@ ppc64_elf_adjust_dynamic_symbol (struct bfd_link_info *info, determine the address it must put in the global offset table, so both the dynamic object and the regular object will refer to the same memory location for the variable. */ - - /* We must generate a R_PPC64_COPY reloc to tell the dynamic linker - to copy the initial value out of the dynamic object and into the - runtime process image. We need to remember the offset into the - .rela.bss section we are going to use. */ if ((h->root.u.def.section->flags & SEC_READONLY) != 0) { s = htab->elf.sdynrelro; @@ -7292,6 +7281,9 @@ ppc64_elf_adjust_dynamic_symbol (struct bfd_link_info *info, } if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0) { + /* We must generate a R_PPC64_COPY reloc to tell the dynamic + linker to copy the initial value out of the dynamic object + and into the runtime process image. */ srel->size += sizeof (Elf64_External_Rela); h->needs_copy = 1; } -- cgit v1.2.1