From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by sourceware.org (Postfix) with ESMTPS id D2C9E3857C53 for ; Mon, 24 Aug 2020 17:18:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D2C9E3857C53 Received: by mail-pg1-x544.google.com with SMTP id p37so4874985pgl.3 for ; Mon, 24 Aug 2020 10:18:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=cnqV6OXQ1PF+5G2nsNOr81lkXf+CUyrXD3jwpcOud8A=; b=aZwDhb4T3SI8QLlkaPlexMAxxFPrq8svb0tS8hv98gnRjWMoL3fKIzVV3TBH0ADi4i MpWcsXuRlG7C2Ao9QHilk0tfPrisvTk0YqAmAviqUm/jwa/YMKdnLzr2rrvfY6dt97FW mr/K2isP74FafOBO1gRX+2G66I3lglmMOVDSJvRwTbNp5dVlBBV5y7AqYuhDNJwhTvnj RqdiboC3yJpvIdJE8Zt153riHWEjq0VOUH20ecomANuAqs7jv35/BQwvTX2tBcHYxORL z9K9h40x0gmWo7yNt8wHUaPrI2tRS9FM6DHdrRWqRebyoZqo+eAT7MT7aXYp4kpRDbA0 rMMg== X-Gm-Message-State: AOAM531T6jX48R6iKURbh3jfSs2NxcdJhMPtaE4XBMjsWotUketdRoWw 9B2nkefvRAjujA4hhltMavz9ZhZSUi5RYw== X-Google-Smtp-Source: ABdhPJyDrUtD+JutYIiiXVv0pcK6j3n09nL6RYEVHS8p5G+R3BE80ohuqhhgDPyAByAbhuEt5z3PDQ== X-Received: by 2002:a62:8c97:: with SMTP id m145mr4781837pfd.104.1598289492130; Mon, 24 Aug 2020 10:18:12 -0700 (PDT) Received: from bubble.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id u123sm6669099pfb.209.2020.08.24.10.18.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Aug 2020 10:18:11 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 9B8CE87F1B; Tue, 25 Aug 2020 02:48:05 +0930 (ACST) Date: Tue, 25 Aug 2020 02:48:05 +0930 From: Alan Modra To: binutils@sourceware.org Subject: Re: PR26483, ASAN: ppc_elf_link_params elf32-ppc.c:2314 Message-ID: <20200824171805.GO15695@bubble.grove.modra.org> References: <20200824163757.GL15695@bubble.grove.modra.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200824163757.GL15695@bubble.grove.modra.org> User-Agent: Mutt/1.9.4 (2018-02-28) X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Aug 2020 17:18:20 -0000 On Tue, Aug 25, 2020 at 02:07:57AM +0930, Alan Modra wrote: > PR 26483 > * elf32-ppc.c (ppc_elf_hash_table): Test is_elf_hash_table before > accessing elf_hash_table_id. And some more. * 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. diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c index 1c436a78d5..ae8cac84e6 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 4d9d6b9992..7d282f39ac 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 283a614030..66930c0c7d 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 d4ad18c825..9adf627975 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 f6ecc380d8..ab928530db 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 4360b5418c..6e5a2d87d6 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 2998aad205..7806ec7417 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 ad0779b52c..9908c0112a 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 56284eaf00..b9b1dad1ae 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 2be3b92644..1751b66bae 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 5857c943ae..533d662ee8 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 720c270a59..f88f276772 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 120816f918..b9b8bec6aa 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 f1122fd71e..e3203b264f 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 10aa022bee..1b5c2efcd6 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 83547b2cff..57da1a206a 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 ef78187dce..38406eda3d 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 530a10d3be..158f909d05 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 481bed4c4f..04949463eb 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 dcdee26082..13cff2c5e0 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 e062dc0386..3511466739 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 8928b11fbc..65c6ceb379 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 cb89dfb03f..1976450fa4 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 dd52b35118..bf8207e3a7 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 fd001607a3..5ce8775459 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 c8c691e4b1..0522850a5d 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 e347332aa2..cadf645df9 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 fb78c24177..5af1b1c3ff 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 a0439041c0..fda653e1af 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 f09b073259..6fbf237e67 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 2631a0d350..abe344c0c8 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 -- Alan Modra Australia Development Lab, IBM