aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf32-ppc.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2017-08-23 08:58:08 +0930
committerAlan Modra <amodra@gmail.com>2017-08-23 08:58:08 +0930
commit46434633f9cee98afac1cf945ad00c9d4fdf5a4d (patch)
treed1a7aff7763c817abd2f2d9561759cf35441cd2f /bfd/elf32-ppc.c
parentbb4b64b0dbe015a4b3fb3993273f8b9b0f8cb421 (diff)
downloadfsf-binutils-gdb-46434633f9cee98afac1cf945ad00c9d4fdf5a4d.zip
fsf-binutils-gdb-46434633f9cee98afac1cf945ad00c9d4fdf5a4d.tar.gz
fsf-binutils-gdb-46434633f9cee98afac1cf945ad00c9d4fdf5a4d.tar.bz2
Make undefined symbols in allocate_dynrelocs dynamic
..if they have dynamic relocs. An undefined symbol in a PIC object that finds no definition ought to become dynamic in order to support --allow-shlib-undefined, but there is nothing in the generic ELF linker code to do this if the reference isn't via the GOT or PLT. (An initialized function pointer is an example.) So it falls to backend code to ensure the symbol is made dynamic. PR 21988 * elf64-ppc.c (ensure_undef_dynamic): Rename from ensure_undefweak_dynamic. Handle undefined too. * elf32-ppc.c (ensure_undef_dynamic): Likewise. * elf32-hppa.c (ensure_undef_dynamic): Likewise. (allocate_dynrelocs): Discard undefined non-default visibility relocs first. Make undefined syms dynamic. Tidy goto.
Diffstat (limited to 'bfd/elf32-ppc.c')
-rw-r--r--bfd/elf32-ppc.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index f32ba9b..ac3b12bb 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -5942,17 +5942,18 @@ allocate_got (struct ppc_elf_link_hash_table *htab, unsigned int need)
return where;
}
-/* If H is undefined weak, make it dynamic if that makes sense. */
+/* If H is undefined, make it dynamic if that makes sense. */
static bfd_boolean
-ensure_undefweak_dynamic (struct bfd_link_info *info,
- struct elf_link_hash_entry *h)
+ensure_undef_dynamic (struct bfd_link_info *info,
+ struct elf_link_hash_entry *h)
{
struct elf_link_hash_table *htab = elf_hash_table (info);
if (htab->dynamic_sections_created
- && info->dynamic_undefined_weak != 0
- && h->root.type == bfd_link_hash_undefweak
+ && ((info->dynamic_undefined_weak != 0
+ && h->root.type == bfd_link_hash_undefweak)
+ || h->root.type == bfd_link_hash_undefined)
&& h->dynindx == -1
&& !h->forced_local
&& ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
@@ -5986,9 +5987,8 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
{
unsigned int need;
- /* Make sure this symbol is output as a dynamic symbol.
- Undefined weak syms won't yet be marked as dynamic. */
- if (!ensure_undefweak_dynamic (info, &eh->elf))
+ /* Make sure this symbol is output as a dynamic symbol. */
+ if (!ensure_undef_dynamic (info, &eh->elf))
return FALSE;
need = 0;
@@ -6102,9 +6102,8 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
if (eh->dyn_relocs != NULL)
{
- /* Make sure undefined weak symbols are output as a dynamic
- symbol in PIEs. */
- if (!ensure_undefweak_dynamic (info, h))
+ /* Make sure this symbol is output as a dynamic symbol. */
+ if (!ensure_undef_dynamic (info, h))
return FALSE;
}
}
@@ -6120,9 +6119,8 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
&& eh->has_addr16_lo
&& htab->params->pic_fixup > 0))
{
- /* Make sure this symbol is output as a dynamic symbol.
- Undefined weak syms won't yet be marked as dynamic. */
- if (!ensure_undefweak_dynamic (info, h))
+ /* Make sure this symbol is output as a dynamic symbol. */
+ if (!ensure_undef_dynamic (info, h))
return FALSE;
if (h->dynindx == -1)