From 4916030821bb0b052091bd1e29f1851e1512a056 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Mon, 3 May 2021 12:28:46 +0930 Subject: PPC: undefweak dynamic relocs This makes the default for ppc to keep dynamic relocs on undefweak symbols when the code won't cause DT_TEXTREL (for instance when -fPIE or -fPIC). If ld is given -z dynamic-undefined-weak then dynamic relocations will be created for non-PIC at the expense of possibly causing DT_TEXTREL to be set on ppc32. Note that DT_TEXTREL and GNU indirect functions are incompatible. * elf32-ppc.c (allocate_dynrelocs): Keep dyn_relocs for undefweak symbols when -z dynamic-undefined-weak or when there are no dynamic relocs in read-only sections and -z nodynamic-undefined-weak is not given. * elf64-ppc.c (allocate_dynrelocs): Likewise. --- bfd/elf64-ppc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'bfd/elf64-ppc.c') diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index bc960bf..a4a0530 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -9808,7 +9808,11 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) relocs against symbols which are not dynamic. */ else if (h->type != STT_GNU_IFUNC) { - if (h->dynamic_adjusted + if ((h->dynamic_adjusted + || (h->ref_regular + && h->root.type == bfd_link_hash_undefweak + && (info->dynamic_undefined_weak > 0 + || !_bfd_elf_readonly_dynrelocs (h)))) && !h->def_regular && !ELF_COMMON_DEF_P (h)) { -- cgit v1.1