aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bfd/ChangeLog35
-rw-r--r--bfd/elf-m10300.c5
-rw-r--r--bfd/elf32-arc.c5
-rw-r--r--bfd/elf32-arm.c7
-rw-r--r--bfd/elf32-avr.c6
-rw-r--r--bfd/elf32-bfin.c7
-rw-r--r--bfd/elf32-cris.c5
-rw-r--r--bfd/elf32-csky.c9
-rw-r--r--bfd/elf32-frv.c5
-rw-r--r--bfd/elf32-hppa.c5
-rw-r--r--bfd/elf32-lm32.c5
-rw-r--r--bfd/elf32-m32r.c5
-rw-r--r--bfd/elf32-m68hc1x.h5
-rw-r--r--bfd/elf32-m68k.c5
-rw-r--r--bfd/elf32-metag.c5
-rw-r--r--bfd/elf32-microblaze.c7
-rw-r--r--bfd/elf32-nds32.h8
-rw-r--r--bfd/elf32-or1k.c5
-rw-r--r--bfd/elf32-s390.c5
-rw-r--r--bfd/elf32-sh.c5
-rw-r--r--bfd/elf32-spu.c5
-rw-r--r--bfd/elf32-tilepro.c6
-rw-r--r--bfd/elf32-xtensa.c5
-rw-r--r--bfd/elf64-alpha.c5
-rw-r--r--bfd/elf64-hppa.c5
-rw-r--r--bfd/elf64-ia64-vms.c5
-rw-r--r--bfd/elf64-s390.c5
-rw-r--r--bfd/elfnn-ia64.c5
-rw-r--r--bfd/elfnn-riscv.c5
-rw-r--r--bfd/elfxx-mips.c5
-rw-r--r--bfd/elfxx-sparc.h5
-rw-r--r--bfd/elfxx-tilegx.c5
32 files changed, 133 insertions, 72 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index f2d1812..0c63859 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,38 @@
+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
diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c
index 1c436a7..ae8cac8 100644
--- a/bfd/elf-m10300.c
+++ b/bfd/elf-m10300.c
@@ -128,8 +128,9 @@ struct elf_mn10300_obj_tdata
/* 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 \
diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c
index 4d9d6b9..7d282f3 100644
--- a/bfd/elf32-arc.c
+++ b/bfd/elf32-arc.c
@@ -1939,8 +1939,9 @@ elf_arc_relocate_section (bfd * output_bfd,
}
#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,
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 283a614..66930c0 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -3255,9 +3255,10 @@ struct elf32_arm_link_hash_entry
(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 *) \
diff --git a/bfd/elf32-avr.c b/bfd/elf32-avr.c
index d4ad18c..9adf627 100644
--- a/bfd/elf32-avr.c
+++ b/bfd/elf32-avr.c
@@ -106,9 +106,9 @@ struct elf32_avr_link_hash_table
/* 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))
diff --git a/bfd/elf32-bfin.c b/bfd/elf32-bfin.c
index f6ecc38..ab92853 100644
--- a/bfd/elf32-bfin.c
+++ b/bfd/elf32-bfin.c
@@ -1668,9 +1668,10 @@ struct bfinfdpic_elf_link_hash_table
/* 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)
diff --git a/bfd/elf32-cris.c b/bfd/elf32-cris.c
index 4360b54..6e5a2d8 100644
--- a/bfd/elf32-cris.c
+++ b/bfd/elf32-cris.c
@@ -837,8 +837,9 @@ struct elf_cris_link_hash_table
/* 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
diff --git a/bfd/elf32-csky.c b/bfd/elf32-csky.c
index 2998aad..7806ec7 100644
--- a/bfd/elf32-csky.c
+++ b/bfd/elf32-csky.c
@@ -1184,11 +1184,10 @@ struct csky_elf_link_hash_entry
(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))
diff --git a/bfd/elf32-frv.c b/bfd/elf32-frv.c
index ad0779b..9908c01 100644
--- a/bfd/elf32-frv.c
+++ b/bfd/elf32-frv.c
@@ -826,8 +826,9 @@ struct frvfdpic_elf_link_hash_table
/* 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)
diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c
index 56284ea..b9b1dad 100644
--- a/bfd/elf32-hppa.c
+++ b/bfd/elf32-hppa.c
@@ -296,8 +296,9 @@ struct elf32_hppa_link_hash_table
/* 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))
diff --git a/bfd/elf32-lm32.c b/bfd/elf32-lm32.c
index 2be3b92..1751b66 100644
--- a/bfd/elf32-lm32.c
+++ b/bfd/elf32-lm32.c
@@ -67,8 +67,9 @@ struct elf_lm32_link_hash_table
/* 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)
diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c
index 5857c94..533d662 100644
--- a/bfd/elf32-m32r.c
+++ b/bfd/elf32-m32r.c
@@ -1509,8 +1509,9 @@ struct elf_m32r_pcrel_relocs_copied
/* 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. */
diff --git a/bfd/elf32-m68hc1x.h b/bfd/elf32-m68hc1x.h
index 720c270..f88f276 100644
--- a/bfd/elf32-m68hc1x.h
+++ b/bfd/elf32-m68hc1x.h
@@ -127,8 +127,9 @@ struct m68hc11_elf_link_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. */
diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c
index 120816f..b9b8bec 100644
--- a/bfd/elf32-m68k.c
+++ b/bfd/elf32-m68k.c
@@ -910,8 +910,9 @@ struct elf_m68k_link_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_)
diff --git a/bfd/elf32-metag.c b/bfd/elf32-metag.c
index f1122fd..e3203b2 100644
--- a/bfd/elf32-metag.c
+++ b/bfd/elf32-metag.c
@@ -906,8 +906,9 @@ metag_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
/* 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))
diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
index 10aa022..1b5c2ef 100644
--- a/bfd/elf32-microblaze.c
+++ b/bfd/elf32-microblaze.c
@@ -756,9 +756,10 @@ struct elf32_mb_link_hash_table
/* 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. */
diff --git a/bfd/elf32-nds32.h b/bfd/elf32-nds32.h
index 83547b2..57da1a2 100644
--- a/bfd/elf32-nds32.h
+++ b/bfd/elf32-nds32.h
@@ -104,10 +104,10 @@ extern void bfd_elf32_nds32_set_target_option (struct bfd_link_info *,
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)
diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
index ef78187..38406ed 100644
--- a/bfd/elf32-or1k.c
+++ b/bfd/elf32-or1k.c
@@ -921,8 +921,9 @@ struct elf_or1k_link_hash_table
/* 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)
diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c
index 530a10d..158f909 100644
--- a/bfd/elf32-s390.c
+++ b/bfd/elf32-s390.c
@@ -751,8 +751,9 @@ struct elf_s390_link_hash_table
/* 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"
diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c
index 481bed4..0494946 100644
--- a/bfd/elf32-sh.c
+++ b/bfd/elf32-sh.c
@@ -2192,8 +2192,9 @@ struct elf_sh_link_hash_table
/* 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. */
diff --git a/bfd/elf32-spu.c b/bfd/elf32-spu.c
index dcdee26..13cff2c 100644
--- a/bfd/elf32-spu.c
+++ b/bfd/elf32-spu.c
@@ -371,8 +371,9 @@ struct got_entry
};
#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
{
diff --git a/bfd/elf32-tilepro.c b/bfd/elf32-tilepro.c
index e062dc0..3511466 100644
--- a/bfd/elf32-tilepro.c
+++ b/bfd/elf32-tilepro.c
@@ -729,9 +729,9 @@ tilepro_elf_mkobject (bfd *abfd)
/* 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,
diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
index 8928b11..65c6ceb 100644
--- a/bfd/elf32-xtensa.c
+++ b/bfd/elf32-xtensa.c
@@ -705,8 +705,9 @@ struct elf_xtensa_link_hash_table
/* 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. */
diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c
index cb89dfb..1976450 100644
--- a/bfd/elf64-alpha.c
+++ b/bfd/elf64-alpha.c
@@ -216,8 +216,9 @@ struct alpha_elf_link_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. */
diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c
index dd52b35..bf8207e 100644
--- a/bfd/elf64-hppa.c
+++ b/bfd/elf64-hppa.c
@@ -145,8 +145,9 @@ struct elf64_hppa_link_hash_table
};
#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))
diff --git a/bfd/elf64-ia64-vms.c b/bfd/elf64-ia64-vms.c
index fd00160..5ce8775 100644
--- a/bfd/elf64-ia64-vms.c
+++ b/bfd/elf64-ia64-vms.c
@@ -170,8 +170,9 @@ struct elf64_ia64_allocate_data
};
#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
{
diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c
index c8c691e..0522850 100644
--- a/bfd/elf64-s390.c
+++ b/bfd/elf64-s390.c
@@ -670,8 +670,9 @@ struct elf_s390_link_hash_table
/* 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"
diff --git a/bfd/elfnn-ia64.c b/bfd/elfnn-ia64.c
index e347332..cadf645 100644
--- a/bfd/elfnn-ia64.c
+++ b/bfd/elfnn-ia64.c
@@ -166,8 +166,9 @@ struct elfNN_ia64_allocate_data
};
#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,
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index fb78c24..5af1b1c 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -120,8 +120,9 @@ struct riscv_elf_link_hash_table
/* 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,
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index a043904..fda653e 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -534,8 +534,9 @@ struct mips_elf_link_hash_table
/* 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
diff --git a/bfd/elfxx-sparc.h b/bfd/elfxx-sparc.h
index f09b073..6fbf237 100644
--- a/bfd/elfxx-sparc.h
+++ b/bfd/elfxx-sparc.h
@@ -84,8 +84,9 @@ struct _bfd_sparc_elf_link_hash_table
/* 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);
diff --git a/bfd/elfxx-tilegx.c b/bfd/elfxx-tilegx.c
index 2631a0d..abe344c 100644
--- a/bfd/elfxx-tilegx.c
+++ b/bfd/elfxx-tilegx.c
@@ -840,8 +840,9 @@ struct tilegx_elf_link_hash_table
/* 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