aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2021-04-12 17:16:03 +0930
committerAlan Modra <amodra@gmail.com>2021-04-12 21:19:02 +0930
commit2cc15b10e5ce606e8348b7cf9b89ec06541231c5 (patch)
tree583cb501aed91a00ff9d41c3ce46a3eef8e3e843 /bfd
parentb585e899960202fbe3c137cbf765f75b088592fe (diff)
downloadgdb-2cc15b10e5ce606e8348b7cf9b89ec06541231c5.zip
gdb-2cc15b10e5ce606e8348b7cf9b89ec06541231c5.tar.gz
gdb-2cc15b10e5ce606e8348b7cf9b89ec06541231c5.tar.bz2
convert elf_link_hash macros to inline functions
Involves a bit of editing as we now need to be more precise in pointer types. bfd/ * elf-bfd.h (is_elf_hash_table): Convert macro to inline function. (elf_link_hash_lookup, elf_link_hash_traverse): Likewise. (elf_hash_table, elf_hash_table_id): Likewise. * elf32-arm.c (elf32_arm_setup_section_lists): Delete redundant is_elf_hash_table check. * elf32-csky.c (elf32_csky_setup_section_lists): Likewise. * elf32-hppa.c (clobber_millicode_symbols): Correct param types. * elf64-alpha.c (elf64_alpha_output_extsym): Likewise. * elfnn-ia64.c (elfNN_ia64_global_dyn_info_free: Likewise. (elfNN_ia64_global_dyn_sym_thunk: Likewise. * elf64-ia64-vms.c (elf64_ia64_global_dyn_info_free): Likewise. (elf64_ia64_global_dyn_sym_thunk): Likewise. (elf64_vms_link_add_object_symbols): Pass base type of hash table to is_elf_hash_table. * elflink.c (_bfd_elf_dynamic_symbol_p): Likewise. (_bfd_elf_symbol_refs_local_p, _bfd_elf_add_dynamic_entry): Likewise. (_bfd_elf_strip_zero_sized_dynamic_sections): Likewise. (_bfd_elf_link_check_relocs, elf_link_add_object_symbols): Likewise. (bfd_elf_final_link): Likewise. * elfnn-aarch64.c (elfNN_aarch64_setup_section_lists): Likewise. * elf64-ppc.c (ppc64_elf_set_toc): Likewise. Use bfd_link_hash_lookup. ld/ * emultempl/mipself.em (mips_create_output_section_statements): Pass base type of hash table to is_elf_hash_table. * ldelf.c (ldelf_after_open): Likewise.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog24
-rw-r--r--bfd/elf-bfd.h49
-rw-r--r--bfd/elf32-arm.c2
-rw-r--r--bfd/elf32-csky.c2
-rw-r--r--bfd/elf32-hppa.c6
-rw-r--r--bfd/elf64-alpha.c3
-rw-r--r--bfd/elf64-ia64-vms.c16
-rw-r--r--bfd/elf64-ppc.c9
-rw-r--r--bfd/elflink.c28
-rw-r--r--bfd/elfnn-aarch64.c2
-rw-r--r--bfd/elfnn-ia64.c6
11 files changed, 93 insertions, 54 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 68224f8..84f16fc 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,29 @@
2021-04-12 Alan Modra <amodra@gmail.com>
+ * elf-bfd.h (is_elf_hash_table): Convert macro to inline function.
+ (elf_link_hash_lookup, elf_link_hash_traverse): Likewise.
+ (elf_hash_table, elf_hash_table_id): Likewise.
+ * elf32-arm.c (elf32_arm_setup_section_lists): Delete redundant
+ is_elf_hash_table check.
+ * elf32-csky.c (elf32_csky_setup_section_lists): Likewise.
+ * elf32-hppa.c (clobber_millicode_symbols): Correct param types.
+ * elf64-alpha.c (elf64_alpha_output_extsym): Likewise.
+ * elfnn-ia64.c (elfNN_ia64_global_dyn_info_free: Likewise.
+ (elfNN_ia64_global_dyn_sym_thunk: Likewise.
+ * elf64-ia64-vms.c (elf64_ia64_global_dyn_info_free): Likewise.
+ (elf64_ia64_global_dyn_sym_thunk): Likewise.
+ (elf64_vms_link_add_object_symbols): Pass base type of hash table
+ to is_elf_hash_table.
+ * elflink.c (_bfd_elf_dynamic_symbol_p): Likewise.
+ (_bfd_elf_symbol_refs_local_p, _bfd_elf_add_dynamic_entry): Likewise.
+ (_bfd_elf_strip_zero_sized_dynamic_sections): Likewise.
+ (_bfd_elf_link_check_relocs, elf_link_add_object_symbols): Likewise.
+ (bfd_elf_final_link): Likewise.
+ * elfnn-aarch64.c (elfNN_aarch64_setup_section_lists): Likewise.
+ * elf64-ppc.c (ppc64_elf_set_toc): Likewise. Use bfd_link_hash_lookup.
+
+2021-04-12 Alan Modra <amodra@gmail.com>
+
* 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*.
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 6f9d737..e0b7e57 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -707,30 +707,49 @@ struct elf_link_hash_table
asection *dynsym;
};
+/* Returns TRUE if the hash table is a struct elf_link_hash_table. */
+
+static inline bool
+is_elf_hash_table (const struct bfd_link_hash_table *htab)
+{
+ return htab->type == bfd_link_elf_hash_table;
+}
+
/* Look up an entry in an ELF linker hash table. */
-#define elf_link_hash_lookup(table, string, create, copy, follow) \
- ((struct elf_link_hash_entry *) \
- bfd_link_hash_lookup (&(table)->root, (string), (create), \
- (copy), (follow)))
+static inline struct elf_link_hash_entry *
+elf_link_hash_lookup (struct elf_link_hash_table *table, const char *string,
+ bool create, bool copy, bool follow)
+{
+ return (struct elf_link_hash_entry *)
+ bfd_link_hash_lookup (&table->root, string, create, copy, follow);
+}
/* Traverse an ELF linker hash table. */
-#define elf_link_hash_traverse(table, func, info) \
- (bfd_link_hash_traverse \
- (&(table)->root, \
- (bool (*) (struct bfd_link_hash_entry *, void *)) (func), \
- (info)))
+static inline void
+elf_link_hash_traverse (struct elf_link_hash_table *table,
+ bool (*f) (struct elf_link_hash_entry *, void *),
+ void *info)
+{
+ bfd_link_hash_traverse (&table->root,
+ (bool (*) (struct bfd_link_hash_entry *, void *)) f,
+ info);
+}
/* Get the ELF linker hash table from a link_info structure. */
-#define elf_hash_table(p) ((struct elf_link_hash_table *) ((p)->hash))
-
-#define elf_hash_table_id(table) ((table) -> hash_table_id)
+static inline struct elf_link_hash_table *
+elf_hash_table (const struct bfd_link_info *info)
+{
+ return (struct elf_link_hash_table *) info->hash;
+}
-/* Returns TRUE if the hash table is a struct elf_link_hash_table. */
-#define is_elf_hash_table(htab) \
- (((struct bfd_link_hash_table *) (htab))->type == bfd_link_elf_hash_table)
+static inline enum elf_target_id
+elf_hash_table_id (const struct elf_link_hash_table *table)
+{
+ return table->hash_table_id;
+}
/* Constant information held for an ELF backend. */
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 51a65d8..29656a7 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -5262,8 +5262,6 @@ elf32_arm_setup_section_lists (bfd *output_bfd,
if (htab == NULL)
return 0;
- if (! is_elf_hash_table (htab))
- return 0;
/* Count the number of input BFDs and find the top input section id. */
for (input_bfd = info->input_bfds, bfd_count = 0, top_id = 0;
diff --git a/bfd/elf32-csky.c b/bfd/elf32-csky.c
index 1dee29a..f8209a4 100644
--- a/bfd/elf32-csky.c
+++ b/bfd/elf32-csky.c
@@ -3865,8 +3865,6 @@ elf32_csky_setup_section_lists (bfd *output_bfd,
if (!htab)
return 0;
- if (! is_elf_hash_table (htab))
- return 0;
/* Count the number of input BFDs and find the top input section id. */
for (input_bfd = info->input_bfds, bfd_count = 0, top_id = 0;
diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c
index 22a4625..77170dd 100644
--- a/bfd/elf32-hppa.c
+++ b/bfd/elf32-hppa.c
@@ -2031,13 +2031,11 @@ allocate_dynrelocs (struct elf_link_hash_entry *eh, void *inf)
static bool
clobber_millicode_symbols (struct elf_link_hash_entry *eh,
- struct bfd_link_info *info)
+ void *info)
{
if (eh->type == STT_PARISC_MILLI
&& !eh->forced_local)
- {
- elf32_hppa_hide_symbol (info, eh, true);
- }
+ elf32_hppa_hide_symbol ((struct bfd_link_info *) info, eh, true);
return true;
}
diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c
index 1f68f82..6f5eead 100644
--- a/bfd/elf64-alpha.c
+++ b/bfd/elf64-alpha.c
@@ -1558,8 +1558,9 @@ struct extsym_info
};
static bool
-elf64_alpha_output_extsym (struct alpha_elf_link_hash_entry *h, void * data)
+elf64_alpha_output_extsym (struct elf_link_hash_entry *x, void * data)
{
+ struct alpha_elf_link_hash_entry *h = (struct alpha_elf_link_hash_entry *) x;
struct extsym_info *einfo = (struct extsym_info *) data;
bool strip;
asection *sec, *output_section;
diff --git a/bfd/elf64-ia64-vms.c b/bfd/elf64-ia64-vms.c
index 3353f51..c72015b 100644
--- a/bfd/elf64-ia64-vms.c
+++ b/bfd/elf64-ia64-vms.c
@@ -990,7 +990,7 @@ elf64_ia64_local_htab_eq (const void *ptr1, const void *ptr2)
/* Free the global elf64_ia64_dyn_sym_info array. */
static bool
-elf64_ia64_global_dyn_info_free (void **xentry,
+elf64_ia64_global_dyn_info_free (struct elf_link_hash_entry *xentry,
void * unused ATTRIBUTE_UNUSED)
{
struct elf64_ia64_link_hash_entry *entry
@@ -1090,7 +1090,7 @@ struct elf64_ia64_dyn_sym_traverse_data
};
static bool
-elf64_ia64_global_dyn_sym_thunk (struct bfd_hash_entry *xentry,
+elf64_ia64_global_dyn_sym_thunk (struct elf_link_hash_entry *xentry,
void * xdata)
{
struct elf64_ia64_link_hash_entry *entry
@@ -4767,7 +4767,7 @@ elf64_vms_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
hope of using a dynamic object which does not exactly match
the format of the output file. */
if (bfd_link_relocatable (info)
- || !is_elf_hash_table (htab)
+ || !is_elf_hash_table (&htab->root)
|| info->output_bfd->xvec != abfd->xvec)
{
if (bfd_link_relocatable (info))
@@ -4786,7 +4786,7 @@ elf64_vms_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
format. FIXME: If there are no input BFD's of the same
format as the output, we can't make a shared library. */
if (bfd_link_pic (info)
- && is_elf_hash_table (htab)
+ && is_elf_hash_table (&htab->root)
&& info->output_bfd->xvec == abfd->xvec
&& !htab->dynamic_sections_created)
{
@@ -4794,7 +4794,7 @@ elf64_vms_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
goto error_return;
}
}
- else if (!is_elf_hash_table (htab))
+ else if (!is_elf_hash_table (&htab->root))
goto error_return;
else
{
@@ -5034,7 +5034,7 @@ elf64_vms_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
*sym_hash = h;
- if (is_elf_hash_table (htab))
+ if (is_elf_hash_table (&htab->root))
{
while (h->root.type == bfd_link_hash_indirect
|| h->root.type == bfd_link_hash_warning)
@@ -5103,7 +5103,7 @@ elf64_vms_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
h->root.u.c.p->alignment_power = old_alignment;
}
- if (is_elf_hash_table (htab))
+ if (is_elf_hash_table (&htab->root))
{
/* Check the alignment when a common symbol is involved. This
can change when a common symbol is overridden by a normal
@@ -5257,7 +5257,7 @@ elf64_vms_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
I have no idea how to handle linking PIC code into a file of a
different format. It probably can't be done. */
if (! dynamic
- && is_elf_hash_table (htab)
+ && is_elf_hash_table (&htab->root)
&& bed->check_relocs != NULL
&& (*bed->relocs_compatible) (abfd->xvec, info->output_bfd->xvec))
{
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index 7873f97..08227f0 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -13955,19 +13955,20 @@ ppc64_elf_set_toc (struct bfd_link_info *info, bfd *obfd)
struct elf_link_hash_entry *h;
struct elf_link_hash_table *htab = elf_hash_table (info);
- if (is_elf_hash_table (htab)
+ if (is_elf_hash_table (&htab->root)
&& htab->hgot != NULL)
h = htab->hgot;
else
{
- h = elf_link_hash_lookup (htab, ".TOC.", false, false, true);
- if (is_elf_hash_table (htab))
+ h = (struct elf_link_hash_entry *)
+ bfd_link_hash_lookup (&htab->root, ".TOC.", false, false, true);
+ if (is_elf_hash_table (&htab->root))
htab->hgot = h;
}
if (h != NULL
&& h->root.type == bfd_link_hash_defined
&& !h->root.linker_def
- && (!is_elf_hash_table (htab)
+ && (!is_elf_hash_table (&htab->root)
|| h->def_regular))
{
TOCstart = defined_sym_val (h) - TOC_BASE_OFF;
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 3acf795..cb38a02 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -3244,7 +3244,7 @@ _bfd_elf_dynamic_symbol_p (struct elf_link_hash_entry *h,
case STV_PROTECTED:
hash_table = elf_hash_table (info);
- if (!is_elf_hash_table (hash_table))
+ if (!is_elf_hash_table (&hash_table->root))
return false;
bed = get_elf_backend_data (hash_table->dynobj);
@@ -3328,7 +3328,7 @@ _bfd_elf_symbol_refs_local_p (struct elf_link_hash_entry *h,
return false;
hash_table = elf_hash_table (info);
- if (!is_elf_hash_table (hash_table))
+ if (!is_elf_hash_table (&hash_table->root))
return true;
bed = get_elf_backend_data (hash_table->dynobj);
@@ -3522,7 +3522,7 @@ _bfd_elf_add_dynamic_entry (struct bfd_link_info *info,
Elf_Internal_Dyn dyn;
hash_table = elf_hash_table (info);
- if (! is_elf_hash_table (hash_table))
+ if (! is_elf_hash_table (&hash_table->root))
return false;
if (tag == DT_RELA || tag == DT_REL)
@@ -3566,7 +3566,7 @@ _bfd_elf_strip_zero_sized_dynamic_sections (struct bfd_link_info *info)
return true;
hash_table = elf_hash_table (info);
- if (!is_elf_hash_table (hash_table))
+ if (!is_elf_hash_table (&hash_table->root))
return false;
if (!hash_table->dynobj)
@@ -3997,7 +3997,7 @@ _bfd_elf_link_check_relocs (bfd *abfd, struct bfd_link_info *info)
I have no idea how to handle linking PIC code into a file of a
different format. It probably can't be done. */
if ((abfd->flags & DYNAMIC) == 0
- && is_elf_hash_table (htab)
+ && is_elf_hash_table (&htab->root)
&& bed->check_relocs != NULL
&& elf_object_id (abfd) == elf_hash_table_id (htab)
&& (*bed->relocs_compatible) (abfd->xvec, info->output_bfd->xvec))
@@ -4094,7 +4094,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
hope of using a dynamic object which does not exactly match
the format of the output file. */
if (bfd_link_relocatable (info)
- || !is_elf_hash_table (htab)
+ || !is_elf_hash_table (&htab->root)
|| info->output_bfd->xvec != abfd->xvec)
{
if (bfd_link_relocatable (info))
@@ -4202,7 +4202,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
|| (!bfd_link_relocatable (info)
&& info->nointerp
&& (info->export_dynamic || info->dynamic)))
- && is_elf_hash_table (htab)
+ && is_elf_hash_table (&htab->root)
&& info->output_bfd->xvec == abfd->xvec
&& !htab->dynamic_sections_created)
{
@@ -4210,7 +4210,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
goto error_return;
}
}
- else if (!is_elf_hash_table (htab))
+ else if (!is_elf_hash_table (&htab->root))
goto error_return;
else
{
@@ -4794,7 +4794,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
old_bfd = NULL;
new_sec = sec;
- if (is_elf_hash_table (htab))
+ if (is_elf_hash_table (&htab->root))
{
Elf_Internal_Versym iver;
unsigned int vernum = 0;
@@ -4970,7 +4970,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
/* Setting the index to -3 tells elf_link_output_extsym that
this symbol is defined in a discarded section. */
- if (discarded && is_elf_hash_table (htab))
+ if (discarded && is_elf_hash_table (&htab->root))
h->indx = -3;
new_weak = (flags & BSF_WEAK) != 0;
@@ -4978,7 +4978,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
&& definition
&& new_weak
&& !bed->is_function_type (ELF_ST_TYPE (isym->st_info))
- && is_elf_hash_table (htab)
+ && is_elf_hash_table (&htab->root)
&& h->u.alias == NULL)
{
/* Keep a list of all weak defined non function symbols from
@@ -5017,7 +5017,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
h->root.u.c.p->alignment_power = old_alignment;
}
- if (is_elf_hash_table (htab))
+ if (is_elf_hash_table (&htab->root))
{
/* Set a flag in the hash table entry indicating the type of
reference or definition we just found. A dynamic symbol
@@ -5679,7 +5679,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
of the .stab/.stabstr sections. */
if (! dynamic
&& ! info->traditional_format
- && is_elf_hash_table (htab)
+ && is_elf_hash_table (&htab->root)
&& (info->strip != strip_all && info->strip != strip_debugger))
{
asection *stabstr;
@@ -12074,7 +12074,7 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
bool sections_removed;
bool ret;
- if (!is_elf_hash_table (htab))
+ if (!is_elf_hash_table (&htab->root))
return false;
if (bfd_link_pic (info))
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index e2b1de7..0a1d7a6 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -3423,7 +3423,7 @@ elfNN_aarch64_setup_section_lists (bfd *output_bfd,
struct elf_aarch64_link_hash_table *htab =
elf_aarch64_hash_table (info);
- if (!is_elf_hash_table (htab))
+ if (!is_elf_hash_table (&htab->root.root))
return 0;
/* Count the number of input BFDs and find the top input section id. */
diff --git a/bfd/elfnn-ia64.c b/bfd/elfnn-ia64.c
index ceebe55..d469925 100644
--- a/bfd/elfnn-ia64.c
+++ b/bfd/elfnn-ia64.c
@@ -1391,8 +1391,8 @@ elfNN_ia64_local_htab_eq (const void *ptr1, const void *ptr2)
/* Free the global elfNN_ia64_dyn_sym_info array. */
static bool
-elfNN_ia64_global_dyn_info_free (void **xentry,
- void * unused ATTRIBUTE_UNUSED)
+elfNN_ia64_global_dyn_info_free (struct elf_link_hash_entry *xentry,
+ void *unused ATTRIBUTE_UNUSED)
{
struct elfNN_ia64_link_hash_entry *entry
= (struct elfNN_ia64_link_hash_entry *) xentry;
@@ -1489,7 +1489,7 @@ struct elfNN_ia64_dyn_sym_traverse_data
};
static bool
-elfNN_ia64_global_dyn_sym_thunk (struct bfd_hash_entry *xentry,
+elfNN_ia64_global_dyn_sym_thunk (struct elf_link_hash_entry *xentry,
void * xdata)
{
struct elfNN_ia64_link_hash_entry *entry