+2020-08-25 Alan Modra <amodra@gmail.com>
+
+ * elf-m10300.c (elf32_mn10300_hash_table): Test is_elf_hash_table
+ before accessing elf_hash_table_id.
+ * elf32-arc.c (elf_arc_hash_table): Likewise.
+ * elf32-arm.c (elf32_arm_hash_table): Likewise.
+ * elf32-avr.c (avr_link_hash_table): Likewise.
+ * elf32-bfin.c (bfinfdpic_hash_table): Likewise.
+ * elf32-cris.c (elf_cris_hash_table): Likewise.
+ * elf32-csky.c (csky_elf_hash_table): Likewise.
+ * elf32-frv.c (frvfdpic_hash_table): Likewise.
+ * elf32-hppa.c (hppa_link_hash_table): Likewise.
+ * elf32-lm32.c (lm32_elf_hash_table): Likewise.
+ * elf32-m32r.c (m32r_elf_hash_table): Likewise.
+ * elf32-m68hc1x.h (m68hc11_elf_hash_table): Likewise.
+ * elf32-m68k.c (elf_m68k_hash_table): Likewise.
+ * elf32-metag.c (metag_link_hash_table): Likewise.
+ * elf32-microblaze.c (elf32_mb_hash_table): Likewise.
+ * elf32-nds32.h (nds32_elf_hash_table): Likewise.
+ * elf32-or1k.c (or1k_elf_hash_table): Likewise.
+ * elf32-s390.c (elf_s390_hash_table): Likewise.
+ * elf32-sh.c (sh_elf_hash_table): Likewise.
+ * elf32-spu.c (spu_hash_table): Likewise.
+ * elf32-tilepro.c (tilepro_elf_hash_table): Likewise.
+ * elf32-xtensa.c (elf_xtensa_hash_table): Likewise.
+ * elf64-alpha.c (alpha_elf_hash_table): Likewise.
+ * elf64-hppa.c (hppa_link_hash_table): Likewise.
+ * elf64-ia64-vms.c (elf64_ia64_hash_table): Likewise.
+ * elf64-s390.c (elf_s390_hash_table): Likewise.
+ * elfnn-ia64.c (elfNN_ia64_hash_table): Likewise.
+ * elfnn-riscv.c (riscv_elf_hash_table): Likewise.
+ * elfxx-mips.c (mips_elf_hash_table): Likewise.
+ * elfxx-sparc.h (_bfd_sparc_elf_hash_table): Likewise.
+ * elfxx-tilegx.c (tilegx_elf_hash_table): Likewise.
+
2020-08-21 Jon Turney <jon.turney@dronecode.org.uk>
* elf.c (elfcore_grok_win32pstatus): Change name_size to unsigned
/* Get the MN10300 ELF linker hash table from a link_info structure. */
#define elf32_mn10300_hash_table(p) \
- (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
- == MN10300_ELF_DATA ? ((struct elf32_mn10300_link_hash_table *) ((p)->hash)) : NULL)
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == MN10300_ELF_DATA) \
+ ? (struct elf32_mn10300_link_hash_table *) (p)->hash : NULL)
#define elf32_mn10300_link_hash_traverse(table, func, info) \
(elf_link_hash_traverse \
}
#define elf_arc_hash_table(p) \
- (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
- == ARC_ELF_DATA ? ((struct elf_arc_link_hash_table *) ((p)->hash)) : NULL)
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == ARC_ELF_DATA) \
+ ? (struct elf_arc_link_hash_table *) (p)->hash : NULL)
static bfd_boolean
elf_arc_check_relocs (bfd * abfd,
(info)))
/* Get the ARM elf linker hash table from a link_info structure. */
-#define elf32_arm_hash_table(info) \
- (elf_hash_table_id ((struct elf_link_hash_table *) ((info)->hash)) \
- == ARM_ELF_DATA ? ((struct elf32_arm_link_hash_table *) ((info)->hash)) : NULL)
+#define elf32_arm_hash_table(p) \
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == ARM_ELF_DATA) \
+ ? (struct elf32_arm_link_hash_table *) (p)->hash : NULL)
#define arm_stub_hash_lookup(table, string, create, copy) \
((struct elf32_arm_stub_hash_entry *) \
/* Various hash macros and functions. */
#define avr_link_hash_table(p) \
- /* PR 3874: Check that we have an AVR style hash table before using it. */\
- (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
- == AVR_ELF_DATA ? ((struct elf32_avr_link_hash_table *) ((p)->hash)) : NULL)
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == AVR_ELF_DATA) \
+ ? (struct elf32_avr_link_hash_table *) (p)->hash : NULL)
#define avr_stub_hash_entry(ent) \
((struct elf32_avr_stub_hash_entry *)(ent))
/* Get the Blackfin ELF linker hash table from a link_info structure. */
-#define bfinfdpic_hash_table(info) \
- (elf_hash_table_id ((struct elf_link_hash_table *) ((info)->hash)) \
- == BFIN_ELF_DATA ? ((struct bfinfdpic_elf_link_hash_table *) ((info)->hash)) : NULL)
+#define bfinfdpic_hash_table(p) \
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == BFIN_ELF_DATA) \
+ ? (struct bfinfdpic_elf_link_hash_table *) (p)->hash : NULL)
#define bfinfdpic_got_section(info) \
(bfinfdpic_hash_table (info)->elf.sgot)
/* Get the CRIS ELF linker hash table from a link_info structure. */
#define elf_cris_hash_table(p) \
- (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
- == CRIS_ELF_DATA ? ((struct elf_cris_link_hash_table *) ((p)->hash)) : NULL)
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == CRIS_ELF_DATA) \
+ ? (struct elf_cris_link_hash_table *) (p)->hash : NULL)
/* Get the CRIS ELF linker hash entry from a regular hash entry (the
"parent class"). The .root reference is just a simple type
(info)))
/* Get the C-SKY ELF linker hash table from a link_info structure. */
-#define csky_elf_hash_table(info) \
- ((elf_hash_table_id ((struct elf_link_hash_table *) ((info)->hash)) \
- == CSKY_ELF_DATA) \
- ? ((struct csky_elf_link_hash_table *) ((info)->hash)) \
- : NULL)
+#define csky_elf_hash_table(p) \
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == CSKY_ELF_DATA) \
+ ? (struct csky_elf_link_hash_table *) (p)->hash : NULL)
#define csky_elf_hash_entry(ent) ((struct csky_elf_link_hash_entry*)(ent))
/* Get the FRV ELF linker hash table from a link_info structure. */
#define frvfdpic_hash_table(p) \
- (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
- == FRV_ELF_DATA ? ((struct frvfdpic_elf_link_hash_table *) ((p)->hash)) : NULL)
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == FRV_ELF_DATA) \
+ ? (struct frvfdpic_elf_link_hash_table *) (p)->hash : NULL)
#define frvfdpic_got_section(info) \
(frvfdpic_hash_table (info)->elf.sgot)
/* Various hash macros and functions. */
#define hppa_link_hash_table(p) \
- (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
- == HPPA32_ELF_DATA ? ((struct elf32_hppa_link_hash_table *) ((p)->hash)) : NULL)
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == HPPA32_ELF_DATA) \
+ ? (struct elf32_hppa_link_hash_table *) (p)->hash : NULL)
#define hppa_elf_hash_entry(ent) \
((struct elf32_hppa_link_hash_entry *)(ent))
/* Get the lm32 ELF linker hash table from a link_info structure. */
#define lm32_elf_hash_table(p) \
- (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
- == LM32_ELF_DATA ? ((struct elf_lm32_link_hash_table *) ((p)->hash)) : NULL)
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == LM32_ELF_DATA) \
+ ? (struct elf_lm32_link_hash_table *) (p)->hash : NULL)
#define lm32fdpic_got_section(info) \
(lm32_elf_hash_table (info)->root.sgot)
/* Get the m32r ELF linker hash table from a link_info structure. */
#define m32r_elf_hash_table(p) \
- (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
- == M32R_ELF_DATA ? ((struct elf_link_hash_table *) ((p)->hash)) : NULL)
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == M32R_ELF_DATA) \
+ ? (struct elf_link_hash_table *) (p)->hash : NULL)
/* Create an m32r ELF linker hash table. */
/* Get the Sparc64 ELF linker hash table from a link_info structure. */
#define m68hc11_elf_hash_table(p) \
- (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
- == M68HC11_ELF_DATA ? ((struct m68hc11_elf_link_hash_table *) ((p)->hash)) : NULL)
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == M68HC11_ELF_DATA) \
+ ? (struct m68hc11_elf_link_hash_table *) (p)->hash : NULL)
/* Create a 68HC11/68HC12 ELF linker hash table. */
/* Get the m68k ELF linker hash table from a link_info structure. */
#define elf_m68k_hash_table(p) \
- (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
- == M68K_ELF_DATA ? ((struct elf_m68k_link_hash_table *) ((p)->hash)) : NULL)
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == M68K_ELF_DATA) \
+ ? (struct elf_m68k_link_hash_table *) (p)->hash : NULL)
/* Shortcut to multi-GOT data. */
#define elf_m68k_multi_got(INFO) (&elf_m68k_hash_table (INFO)->multi_got_)
/* Various hash macros and functions. */
#define metag_link_hash_table(p) \
- (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
- == METAG_ELF_DATA ? ((struct elf_metag_link_hash_table *) ((p)->hash)) : NULL)
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == METAG_ELF_DATA) \
+ ? (struct elf_metag_link_hash_table *) (p)->hash : NULL)
#define metag_elf_hash_entry(ent) \
((struct elf_metag_link_hash_entry *)(ent))
/* Get the ELF linker hash table from a link_info structure. */
-#define elf32_mb_hash_table(p) \
- (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
- == MICROBLAZE_ELF_DATA ? ((struct elf32_mb_link_hash_table *) ((p)->hash)) : NULL)
+#define elf32_mb_hash_table(p) \
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == MICROBLAZE_ELF_DATA) \
+ ? (struct elf32_mb_link_hash_table *) (p)->hash : NULL)
/* Create an entry in a microblaze ELF linker hash table. */
int, int, FILE *,
int, int, int);
-#define nds32_elf_hash_table(info) \
- (elf_hash_table_id ((struct elf_link_hash_table *) ((info)->hash)) \
- == NDS32_ELF_DATA ? \
- ((struct elf_nds32_link_hash_table *) ((info)->hash)) : NULL)
+#define nds32_elf_hash_table(p) \
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == NDS32_ELF_DATA) \
+ ? (struct elf_nds32_link_hash_table *) (p)->hash : NULL)
#define elf32_nds32_compute_jump_table_size(htab) \
((htab)->next_tls_desc_index * 4)
/* Get the ELF linker hash table from a link_info structure. */
#define or1k_elf_hash_table(p) \
- (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
- == OR1K_ELF_DATA ? ((struct elf_or1k_link_hash_table *) ((p)->hash)) : NULL)
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == OR1K_ELF_DATA) \
+ ? (struct elf_or1k_link_hash_table *) (p)->hash : NULL)
static bfd_boolean
elf_or1k_mkobject (bfd *abfd)
/* Get the s390 ELF linker hash table from a link_info structure. */
#define elf_s390_hash_table(p) \
- (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
- == S390_ELF_DATA ? ((struct elf_s390_link_hash_table *) ((p)->hash)) : NULL)
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == S390_ELF_DATA) \
+ ? (struct elf_s390_link_hash_table *) (p)->hash : NULL)
#undef ELF64
#include "elf-s390-common.c"
/* Get the sh ELF linker hash table from a link_info structure. */
#define sh_elf_hash_table(p) \
- (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
- == SH_ELF_DATA ? ((struct elf_sh_link_hash_table *) ((p)->hash)) : NULL)
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == SH_ELF_DATA) \
+ ? (struct elf_sh_link_hash_table *) (p)->hash : NULL)
/* Create an entry in an sh ELF linker hash table. */
};
#define spu_hash_table(p) \
- (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
- == SPU_ELF_DATA ? ((struct spu_link_hash_table *) ((p)->hash)) : NULL)
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == SPU_ELF_DATA) \
+ ? (struct spu_link_hash_table *) (p)->hash : NULL)
struct call_info
{
/* Get the Tilepro ELF linker hash table from a link_info structure. */
#define tilepro_elf_hash_table(p) \
- (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
- == TILEPRO_ELF_DATA \
- ? ((struct elf_link_hash_table *) ((p)->hash)) : NULL)
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == TILEPRO_ELF_DATA) \
+ ? (struct elf_link_hash_table *) (p)->hash : NULL)
static reloc_howto_type *
tilepro_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
/* Get the Xtensa ELF linker hash table from a link_info structure. */
#define elf_xtensa_hash_table(p) \
- (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
- == XTENSA_ELF_DATA ? ((struct elf_xtensa_link_hash_table *) ((p)->hash)) : NULL)
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == XTENSA_ELF_DATA) \
+ ? (struct elf_xtensa_link_hash_table *) (p)->hash : NULL)
/* Create an entry in an Xtensa ELF linker hash table. */
/* Get the Alpha ELF linker hash table from a link_info structure. */
#define alpha_elf_hash_table(p) \
- (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
- == ALPHA_ELF_DATA ? ((struct alpha_elf_link_hash_table *) ((p)->hash)) : NULL)
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == ALPHA_ELF_DATA) \
+ ? (struct alpha_elf_link_hash_table *) (p)->hash : NULL)
/* Get the object's symbols as our own entry type. */
};
#define hppa_link_hash_table(p) \
- (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
- == HPPA64_ELF_DATA ? ((struct elf64_hppa_link_hash_table *) ((p)->hash)) : NULL)
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == HPPA64_ELF_DATA) \
+ ? (struct elf64_hppa_link_hash_table *) (p)->hash : NULL)
#define hppa_elf_hash_entry(ent) \
((struct elf64_hppa_link_hash_entry *)(ent))
};
#define elf64_ia64_hash_table(p) \
- (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
- == IA64_ELF_DATA ? ((struct elf64_ia64_link_hash_table *) ((p)->hash)) : NULL)
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == IA64_ELF_DATA) \
+ ? (struct elf64_ia64_link_hash_table *) (p)->hash : NULL)
struct elf64_ia64_vms_obj_tdata
{
/* Get the s390 ELF linker hash table from a link_info structure. */
#define elf_s390_hash_table(p) \
- (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
- == S390_ELF_DATA ? ((struct elf_s390_link_hash_table *) ((p)->hash)) : NULL)
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == S390_ELF_DATA) \
+ ? (struct elf_s390_link_hash_table *) (p)->hash : NULL)
#define ELF64 1
#include "elf-s390-common.c"
};
#define elfNN_ia64_hash_table(p) \
- (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
- == IA64_ELF_DATA ? ((struct elfNN_ia64_link_hash_table *) ((p)->hash)) : NULL)
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == IA64_ELF_DATA) \
+ ? (struct elfNN_ia64_link_hash_table *) (p)->hash : NULL)
static struct elfNN_ia64_dyn_sym_info * get_dyn_sym_info
(struct elfNN_ia64_link_hash_table *ia64_info,
/* Get the RISC-V ELF linker hash table from a link_info structure. */
#define riscv_elf_hash_table(p) \
- (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
- == RISCV_ELF_DATA ? ((struct riscv_elf_link_hash_table *) ((p)->hash)) : NULL)
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == RISCV_ELF_DATA) \
+ ? (struct riscv_elf_link_hash_table *) (p)->hash : NULL)
static bfd_boolean
riscv_info_to_howto_rela (bfd *abfd,
/* Get the MIPS ELF linker hash table from a link_info structure. */
#define mips_elf_hash_table(p) \
- (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
- == MIPS_ELF_DATA ? ((struct mips_elf_link_hash_table *) ((p)->hash)) : NULL)
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == MIPS_ELF_DATA) \
+ ? (struct mips_elf_link_hash_table *) (p)->hash : NULL)
/* A structure used to communicate with htab_traverse callbacks. */
struct mips_htab_traverse_info
/* Get the SPARC ELF linker hash table from a link_info structure. */
#define _bfd_sparc_elf_hash_table(p) \
- (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
- == SPARC_ELF_DATA ? ((struct _bfd_sparc_elf_link_hash_table *) ((p)->hash)) : NULL)
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == SPARC_ELF_DATA) \
+ ? (struct _bfd_sparc_elf_link_hash_table *) (p)->hash : NULL)
extern reloc_howto_type *_bfd_sparc_elf_reloc_type_lookup
(bfd *, bfd_reloc_code_real_type);
/* Get the Tile ELF linker hash table from a link_info structure. */
#define tilegx_elf_hash_table(p) \
- (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
- == TILEGX_ELF_DATA ? ((struct tilegx_elf_link_hash_table *) ((p)->hash)) : NULL)
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == TILEGX_ELF_DATA) \
+ ? (struct tilegx_elf_link_hash_table *) (p)->hash : NULL)
#ifdef BFD64
static bfd_vma