aboutsummaryrefslogtreecommitdiff
path: root/bfd/elflink.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2021-04-12 17:16:58 +0930
committerAlan Modra <amodra@gmail.com>2021-04-12 21:19:02 +0930
commitb585e899960202fbe3c137cbf765f75b088592fe (patch)
treefe63d180fe988f6a6cd54eea6706eac2ae792328 /bfd/elflink.c
parentf5b10973531cdda7e1aba7496f70476b5146fcf8 (diff)
downloadbinutils-b585e899960202fbe3c137cbf765f75b088592fe.zip
binutils-b585e899960202fbe3c137cbf765f75b088592fe.tar.gz
binutils-b585e899960202fbe3c137cbf765f75b088592fe.tar.bz2
elf_backend_archive_symbol_lookup
elf_backend_archive_symbol_lookup might be called when the linker hash table has entries of type generic_link_hash_entry. This happens for instance when running the mmix target linker testsuite where the output is mmo but input is elf64-mmix. * elf-bfd.h (struct elf_backend_data): Return bfd_link_hash_entry* from elf_backend_archive_symbol_lookup. (_bfd_elf_archive_symbol_lookup): Return bfd_link_hash_entry*. * elf64-ppc.c (ppc64_elf_archive_symbol_lookup): Likewise. Check we have a ppc_hash_table before accessing ppc_link_hash_entry fields. * elflink.c (_bfd_elf_archive_symbol_lookup): Return bfd_link_hash_entry*. (elf_link_add_archive_symbols): Adjust to suit.
Diffstat (limited to 'bfd/elflink.c')
-rw-r--r--bfd/elflink.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c
index e8f3a9e..3acf795 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -5742,16 +5742,16 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
/* Return the linker hash table entry of a symbol that might be
satisfied by an archive symbol. Return -1 on error. */
-struct elf_link_hash_entry *
+struct bfd_link_hash_entry *
_bfd_elf_archive_symbol_lookup (bfd *abfd,
struct bfd_link_info *info,
const char *name)
{
- struct elf_link_hash_entry *h;
+ struct bfd_link_hash_entry *h;
char *p, *copy;
size_t len, first;
- h = elf_link_hash_lookup (elf_hash_table (info), name, false, false, true);
+ h = bfd_link_hash_lookup (info->hash, name, false, false, true);
if (h != NULL)
return h;
@@ -5768,20 +5768,19 @@ _bfd_elf_archive_symbol_lookup (bfd *abfd,
len = strlen (name);
copy = (char *) bfd_alloc (abfd, len);
if (copy == NULL)
- return (struct elf_link_hash_entry *) -1;
+ return (struct bfd_link_hash_entry *) -1;
first = p - name + 1;
memcpy (copy, name, first);
memcpy (copy + first, name + first + 1, len - first);
- h = elf_link_hash_lookup (elf_hash_table (info), copy, false, false, true);
+ h = bfd_link_hash_lookup (info->hash, copy, false, false, true);
if (h == NULL)
{
/* We also need to check references to the symbol without the
version. */
copy[first - 1] = '\0';
- h = elf_link_hash_lookup (elf_hash_table (info), copy,
- false, false, true);
+ h = bfd_link_hash_lookup (info->hash, copy, false, false, true);
}
bfd_release (abfd, copy);
@@ -5810,7 +5809,7 @@ elf_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info)
bool loop;
size_t amt;
const struct elf_backend_data *bed;
- struct elf_link_hash_entry * (*archive_symbol_lookup)
+ struct bfd_link_hash_entry * (*archive_symbol_lookup)
(bfd *, struct bfd_link_info *, const char *);
if (! bfd_has_map (abfd))
@@ -5851,7 +5850,7 @@ elf_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info)
symdefend = symdef + c;
for (i = 0; symdef < symdefend; symdef++, i++)
{
- struct elf_link_hash_entry *h;
+ struct bfd_link_hash_entry *h;
bfd *element;
struct bfd_link_hash_entry *undefs_tail;
symindex mark;
@@ -5865,21 +5864,22 @@ elf_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info)
}
h = archive_symbol_lookup (abfd, info, symdef->name);
- if (h == (struct elf_link_hash_entry *) -1)
+ if (h == (struct bfd_link_hash_entry *) -1)
goto error_return;
if (h == NULL)
continue;
- if (h->root.type == bfd_link_hash_undefined)
+ if (h->type == bfd_link_hash_undefined)
{
/* If the archive element has already been loaded then one
of the symbols defined by that element might have been
made undefined due to being in a discarded section. */
- if (h->indx == -3)
+ if (is_elf_hash_table (info->hash)
+ && ((struct elf_link_hash_entry *) h)->indx == -3)
continue;
}
- else if (h->root.type == bfd_link_hash_common)
+ else if (h->type == bfd_link_hash_common)
{
/* We currently have a common symbol. The archive map contains
a reference to this symbol, so we may want to include it. We
@@ -5898,7 +5898,7 @@ elf_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info)
}
else
{
- if (h->root.type != bfd_link_hash_undefweak)
+ if (h->type != bfd_link_hash_undefweak)
/* Symbol must be defined. Don't check it again. */
included[i] = true;
continue;