diff options
author | Alan Modra <amodra@gmail.com> | 2017-08-23 08:58:08 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2017-08-23 08:58:08 +0930 |
commit | 46434633f9cee98afac1cf945ad00c9d4fdf5a4d (patch) | |
tree | d1a7aff7763c817abd2f2d9561759cf35441cd2f /bfd/elf64-ppc.c | |
parent | bb4b64b0dbe015a4b3fb3993273f8b9b0f8cb421 (diff) | |
download | gdb-46434633f9cee98afac1cf945ad00c9d4fdf5a4d.zip gdb-46434633f9cee98afac1cf945ad00c9d4fdf5a4d.tar.gz 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/elf64-ppc.c')
-rw-r--r-- | bfd/elf64-ppc.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index 7f4f7b6..f0fde1d 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -9743,17 +9743,18 @@ merge_got_entries (struct got_entry **pent) } } -/* 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) @@ -9832,9 +9833,8 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) for (gent = h->got.glist; gent != NULL; gent = gent->next) if (!gent->is_indirect) { - /* 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 (!is_ppc64_elf (gent->owner)) @@ -9888,9 +9888,8 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) if (eh->dyn_relocs != NULL) { - /* 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; } } @@ -9925,9 +9924,8 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) if (!h->non_got_ref && !h->def_regular) { - /* 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) |