+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*
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;
+}
\f
/* Constant information held for an ELF backend. */
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;
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;
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;
}
};
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;
/* 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
};
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
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))
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)
{
goto error_return;
}
}
- else if (!is_elf_hash_table (htab))
+ else if (!is_elf_hash_table (&htab->root))
goto error_return;
else
{
*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)
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
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))
{
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;
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);
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);
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)
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)
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))
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))
|| (!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)
{
goto error_return;
}
}
- else if (!is_elf_hash_table (htab))
+ else if (!is_elf_hash_table (&htab->root))
goto error_return;
else
{
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;
/* 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;
&& 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
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
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;
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))
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. */
/* 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;
};
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
+2021-04-12 Alan Modra <amodra@gmail.com>
+
+ * 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.
+
2021-04-12 Alan Modra <amodra@gmail.com>
PR 27719
struct elf_link_hash_table *htab;
htab = elf_hash_table (&link_info);
- if (is_elf_hash_table (htab) && is_mips_elf (link_info.output_bfd))
+ if (is_elf_hash_table (&htab->root) && is_mips_elf (link_info.output_bfd))
_bfd_mips_elf_linker_flags (&link_info, insn32, ignore_branch_isa,
${gnu_target});
after_open_default ();
htab = elf_hash_table (&link_info);
- if (!is_elf_hash_table (htab))
+ if (!is_elf_hash_table (&htab->root))
return;
if (command_line.out_implib_filename)