aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf32-hppa.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-hppa.c
parentbb4b64b0dbe015a4b3fb3993273f8b9b0f8cb421 (diff)
downloadgdb-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/elf32-hppa.c')
-rw-r--r--bfd/elf32-hppa.c51
1 files changed, 25 insertions, 26 deletions
diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c
index f63ff3f..3adac6d 100644
--- a/bfd/elf32-hppa.c
+++ b/bfd/elf32-hppa.c
@@ -1919,16 +1919,20 @@ elf32_hppa_adjust_dynamic_symbol (struct bfd_link_info *info,
return _bfd_elf_adjust_dynamic_copy (info, eh, sec);
}
-/* Make an undefined weak symbol dynamic. */
+/* If EH is undefined, make it dynamic if that makes sense. */
static bfd_boolean
-ensure_undef_weak_dynamic (struct bfd_link_info *info,
- struct elf_link_hash_entry *eh)
+ensure_undef_dynamic (struct bfd_link_info *info,
+ struct elf_link_hash_entry *eh)
{
- if (eh->dynindx == -1
+ struct elf_link_hash_table *htab = elf_hash_table (info);
+
+ if (htab->dynamic_sections_created
+ && (eh->root.type == bfd_link_hash_undefweak
+ || eh->root.type == bfd_link_hash_undefined)
+ && eh->dynindx == -1
&& !eh->forced_local
&& eh->type != STT_PARISC_MILLI
- && eh->root.type == bfd_link_hash_undefweak
&& ELF_ST_VISIBILITY (eh->other) == STV_DEFAULT)
return bfd_elf_link_record_dynamic_symbol (info, eh);
return TRUE;
@@ -1957,7 +1961,7 @@ allocate_plt_static (struct elf_link_hash_entry *eh, void *inf)
if (htab->etab.dynamic_sections_created
&& eh->plt.refcount > 0)
{
- if (!ensure_undef_weak_dynamic (info, eh))
+ if (!ensure_undef_dynamic (info, eh))
return FALSE;
if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, bfd_link_pic (info), eh))
@@ -2034,7 +2038,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *eh, void *inf)
if (eh->got.refcount > 0)
{
- if (!ensure_undef_weak_dynamic (info, eh))
+ if (!ensure_undef_dynamic (info, eh))
return FALSE;
sec = htab->etab.sgot;
@@ -2070,8 +2074,14 @@ allocate_dynrelocs (struct elf_link_hash_entry *eh, void *inf)
changes. */
if (bfd_link_pic (info))
{
+ /* Discard relocs on undefined syms with non-default visibility. */
+ if ((eh->root.type == bfd_link_hash_undefined
+ || eh->root.type == bfd_link_hash_undefweak)
+ && ELF_ST_VISIBILITY (eh->other) != STV_DEFAULT)
+ hh->dyn_relocs = NULL;
+
#if RELATIVE_DYNRELOCS
- if (SYMBOL_CALLS_LOCAL (info, eh))
+ else if (SYMBOL_CALLS_LOCAL (info, eh))
{
struct elf32_hppa_dyn_reloc_entry **hdh_pp;
@@ -2087,15 +2097,9 @@ allocate_dynrelocs (struct elf_link_hash_entry *eh, void *inf)
}
#endif
- /* Also discard relocs on undefined weak syms with non-default
- visibility. */
- if (hh->dyn_relocs != NULL
- && eh->root.type == bfd_link_hash_undefweak)
+ if (hh->dyn_relocs != NULL)
{
- if (ELF_ST_VISIBILITY (eh->other) != STV_DEFAULT)
- hh->dyn_relocs = NULL;
-
- else if (!ensure_undef_weak_dynamic (info, eh))
+ if (!ensure_undef_dynamic (info, eh))
return FALSE;
}
}
@@ -2113,19 +2117,14 @@ allocate_dynrelocs (struct elf_link_hash_entry *eh, void *inf)
&& (eh->root.type == bfd_link_hash_undefweak
|| eh->root.type == bfd_link_hash_undefined))))
{
- if (!ensure_undef_weak_dynamic (info, eh))
+ if (!ensure_undef_dynamic (info, eh))
return FALSE;
- /* If that succeeded, we know we'll be keeping all the
- relocs. */
- if (eh->dynindx != -1)
- goto keep;
+ if (eh->dynindx == -1)
+ hh->dyn_relocs = NULL;
}
-
- hh->dyn_relocs = NULL;
- return TRUE;
-
- keep: ;
+ else
+ hh->dyn_relocs = NULL;
}
/* Finally, allocate space. */