From patchwork Sat Nov 16 06:32:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam James X-Patchwork-Id: 101269 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5D1483857BBA for ; Sat, 16 Nov 2024 06:33:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5D1483857BBA X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) by sourceware.org (Postfix) with ESMTP id 6775B3857C7A for ; Sat, 16 Nov 2024 06:32:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6775B3857C7A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6775B3857C7A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:470:ea4a:1:5054:ff:fec7:86e4 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1731738765; cv=none; b=gNCC6d1cX67AhFYvkWjs6Kg4mnKzRbO++9ZjaCZ6inArhzIjqZZ0XeTSTxErtqeScGL4qETpzI69CLQ5VePNMlS3MjooBB698k8F2xg8aTD43yaiqSA0caKbmPN1/2mMdGO3oo2Lb7ewxMt7yoH6uB6eCFOWC97gUpB8JoSSnSU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1731738765; c=relaxed/simple; bh=ulPv6Go0X+mJbzehrlExyQ5IYAKkytP4iG7aJMe0jn4=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=RTu6iZiJsC43GSV9fh9nEODL7mB1g42krQlFDPyBqkH2r2Dl9BPE48L/myuWno6zPN9gvgvcSbOY9L4E6tuvSehpp+enwk7JuO/q9iwpCNf0p+M+G2NbRiePMg0ndILKU7YygLnhJqcuyUK52sB9qd/uW4KidrtRjZ4algiBXvo= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6775B3857C7A From: Sam James To: binutils@sourceware.org Cc: amodra@gmail.com, Sam James Subject: [PATCH 1/3] bfd: fix -std=gnu23 compatibility wrt _Bool Date: Sat, 16 Nov 2024 06:32:22 +0000 Message-ID: <3cdcfa87e2dde1bb6bb6b79143cd3f8dffa8761f.1731738744.git.sam@gentoo.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org GCC trunk now defaults to -std=gnu23. We return false in a few places which can't work when true/false are a proper type (_Bool). Return NULL where appropriate instead of false. All callers handle this appropriately. ChangeLog: PR ld/32372 * bfd/elf32-ppc.c (ppc_elf_tls_setup): Return NULL. * bfd/elf32-xtensa.c (translate_reloc_bfd_fix): Ditto. (translate_reloc): Ditto. * bfd/elf64-ppc.c (update_local_sym_info): Ditto. * bfd/mach-o.c (bfd_mach_o_lookup_uuid_command): Ditto. * bfd/xsym.c (bfd_sym_read_name_table): Ditto. --- bfd/elf32-ppc.c | 2 +- bfd/elf32-xtensa.c | 4 ++-- bfd/elf64-ppc.c | 2 +- bfd/mach-o.c | 2 +- bfd/xsym.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index a5370a0624e..8c89ae1611f 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -4352,7 +4352,7 @@ ppc_elf_tls_setup (bfd *obfd, struct bfd_link_info *info) _bfd_elf_strtab_delref (elf_hash_table (info)->dynstr, opt->dynstr_index); if (!bfd_elf_link_record_dynamic_symbol (info, opt)) - return false; + return NULL; } htab->tls_get_addr = opt; } diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c index eb7fef9331e..58f79e55529 100644 --- a/bfd/elf32-xtensa.c +++ b/bfd/elf32-xtensa.c @@ -10070,7 +10070,7 @@ translate_reloc_bfd_fix (reloc_bfd_fix *fix) location. Otherwise, the relocation should move within the section. */ - removed = false; + removed = NULL; if (is_operand_relocation (fix->src_type)) { /* Check if the original relocation is against a literal being @@ -10141,7 +10141,7 @@ translate_reloc (const r_reloc *orig_rel, r_reloc *new_rel, asection *sec) target_offset = orig_rel->target_offset; - removed = false; + removed = NULL; if (is_operand_relocation (ELF32_R_TYPE (orig_rel->rela.r_info))) { /* Check if the original relocation is against a literal being diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index cd3aaacaeb3..9674fcdd6be 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -4664,7 +4664,7 @@ update_local_sym_info (bfd *abfd, Elf_Internal_Shdr *symtab_hdr, size_t amt = sizeof (*ent); ent = bfd_alloc (abfd, amt); if (ent == NULL) - return false; + return NULL; ent->next = local_got_ents[r_symndx]; ent->addend = r_addend; ent->owner = abfd; diff --git a/bfd/mach-o.c b/bfd/mach-o.c index 93224aaed00..974747caadd 100644 --- a/bfd/mach-o.c +++ b/bfd/mach-o.c @@ -6037,7 +6037,7 @@ bfd_mach_o_lookup_uuid_command (bfd *abfd) bfd_mach_o_load_command *uuid_cmd = NULL; int ncmd = bfd_mach_o_lookup_command (abfd, BFD_MACH_O_LC_UUID, &uuid_cmd); if (ncmd != 1 || uuid_cmd == NULL) - return false; + return NULL; return &uuid_cmd->command.uuid; } diff --git a/bfd/xsym.c b/bfd/xsym.c index 070ba4a2318..fe14acc121f 100644 --- a/bfd/xsym.c +++ b/bfd/xsym.c @@ -130,7 +130,7 @@ bfd_sym_read_name_table (bfd *abfd, bfd_sym_header_block *dshb) size_t table_offset = dshb->dshb_nte.dti_first_page * dshb->dshb_page_size; if (bfd_seek (abfd, table_offset, SEEK_SET) != 0) - return false; + return NULL; return _bfd_alloc_and_read (abfd, table_size, table_size); } From patchwork Sat Nov 16 06:32:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam James X-Patchwork-Id: 101268 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 264C53857830 for ; Sat, 16 Nov 2024 06:33:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 264C53857830 X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) by sourceware.org (Postfix) with ESMTP id 6153F3857C6D for ; Sat, 16 Nov 2024 06:32:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6153F3857C6D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6153F3857C6D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:470:ea4a:1:5054:ff:fec7:86e4 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1731738765; cv=none; b=C1M06ucB4ok865pa912MTQJO/u7cY/Rd7ddJR0ieUvfomQYl+J7xYWhyq4nqsyvaMKwSvR87IubWmk5oNCUAJ0qOShykx4pYCVcaVL5DhgFjbKbXWutR70M7i/AwJMEuh/faEmnZDZNk8sQAL16VZ45iIBOzIOhVbyVQf61G3RQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1731738765; c=relaxed/simple; bh=2TrNuP2v7KqLP7jD0a9KnQCr0ICIqhHM14RtBIOmS88=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=WDX39CrS0pXdqOb1b4DlAwoRmwLLFGL3mXE82YiiPdsAbMVTld5Wjw1kzIPCbNgBQTur4tELIpw1RGVUSwDj1B6r5K5t85c2Wsm09SGwEML6VsFFhxnlym2Nwo92L7MCAI3U3U4nNP1kdO45799nb/HUl/nMmLvEYbxgxv3f/AA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6153F3857C6D From: Sam James To: binutils@sourceware.org Cc: amodra@gmail.com, Sam James Subject: [PATCH 2/3] opcodes: fix -std=gnu23 compatibility wrt static_assert Date: Sat, 16 Nov 2024 06:32:23 +0000 Message-ID: <0bc9bfda425cb174ea8cd3822aa206dfba3b1ff0.1731738744.git.sam@gentoo.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org static_assert is declared in C23 so we can't reuse that identifier: * Define our own static_assert conditionally; * Rename "static assert" hacks to _N as we do already in some places to avoid a conflict. ChangeLog: PR ld/32372 * opcodes/i386-gen.c (static_assert): Define conditionally. * opcodes/mips-formats.h (MAPPED_INT): Rename identifier. (MAPPED_REG): Rename identifier. (OPTIONAL_MAPPED_REG): Rename identifier. * opcodes/s390-opc.c (static_assert): Define conditionally. --- opcodes/i386-gen.c | 2 ++ opcodes/mips-formats.h | 6 +++--- opcodes/s390-opc.c | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/opcodes/i386-gen.c b/opcodes/i386-gen.c index 053b66675c5..7ee8a30310c 100644 --- a/opcodes/i386-gen.c +++ b/opcodes/i386-gen.c @@ -30,7 +30,9 @@ /* Build-time checks are preferrable over runtime ones. Use this construct in preference where possible. */ +#ifndef static_assert #define static_assert(e) ((void)sizeof (struct { int _:1 - 2 * !(e); })) +#endif static const char *program_name = NULL; static int debug = 0; diff --git a/opcodes/mips-formats.h b/opcodes/mips-formats.h index 90df7100803..c4dec6352bf 100644 --- a/opcodes/mips-formats.h +++ b/opcodes/mips-formats.h @@ -49,7 +49,7 @@ #define MAPPED_INT(SIZE, LSB, MAP, PRINT_HEX) \ { \ typedef char ATTRIBUTE_UNUSED \ - static_assert[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \ + static_assert_3[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \ static const struct mips_mapped_int_operand op = { \ { OP_MAPPED_INT, SIZE, LSB }, MAP, PRINT_HEX \ }; \ @@ -83,7 +83,7 @@ #define MAPPED_REG(SIZE, LSB, BANK, MAP) \ { \ typedef char ATTRIBUTE_UNUSED \ - static_assert[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \ + static_assert_4[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \ static const struct mips_reg_operand op = { \ { OP_REG, SIZE, LSB }, OP_REG_##BANK, MAP \ }; \ @@ -93,7 +93,7 @@ #define OPTIONAL_MAPPED_REG(SIZE, LSB, BANK, MAP) \ { \ typedef char ATTRIBUTE_UNUSED \ - static_assert[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \ + static_assert_5[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \ static const struct mips_reg_operand op = { \ { OP_OPTIONAL_REG, SIZE, LSB }, OP_REG_##BANK, MAP \ }; \ diff --git a/opcodes/s390-opc.c b/opcodes/s390-opc.c index 9d9f0973e55..49efd714157 100644 --- a/opcodes/s390-opc.c +++ b/opcodes/s390-opc.c @@ -36,7 +36,9 @@ /* Build-time checks are preferrable over runtime ones. Use this construct in preference where possible. */ +#ifndef static_assert #define static_assert(e) ((void)sizeof (struct { int _:1 - 2 * !(e); })) +#endif #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) From patchwork Sat Nov 16 06:32:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam James X-Patchwork-Id: 101270 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A9CD73857B98 for ; Sat, 16 Nov 2024 06:35:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A9CD73857B98 X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) by sourceware.org (Postfix) with ESMTP id 7E7A83857B8C for ; Sat, 16 Nov 2024 06:32:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7E7A83857B8C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7E7A83857B8C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:470:ea4a:1:5054:ff:fec7:86e4 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1731738766; cv=none; b=PPVzrfPp2/PCf7HKsibzI35Jjc4I3OSqi8Ajc3/4fRa/UgqRZhSmIc4rW9N6dTCFkFOp+IqPK141Ybf3xgrLnSO6LoB+JJuX+xf0Fq3YvIB79Sy92rYWAq5DcIMHdseyrp6eu0sww3t+U+It+5V9VEBRx8voHpyUF0/opN0Egek= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1731738766; c=relaxed/simple; bh=+mRGJGY7h67uWrSn1rmWjGABR5mouBH1KOoAMv7QleY=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=mUVBU2Qu5FRcy1edCO2gZsUijerXpNq5g/pGMCE8puLsrilXktqQN3wWE1wWK0cF2lpT+/V1UZJSaW6Zr2jyPgFj2NFv0d7/SnaRrN7CXd4IVlmyreLeBT8t9SvOfDrm5JS+/F2Eiap7YFMlsH8bMRvz1SLKB5K1HK2aj7O+0U4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7E7A83857B8C From: Sam James To: binutils@sourceware.org Cc: amodra@gmail.com, Sam James Subject: [PATCH 3/3] binutils: fix -std=gnu23 compatibility wrt _Bool Date: Sat, 16 Nov 2024 06:32:24 +0000 Message-ID: X-Mailer: git-send-email 2.47.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org GCC trunk now defaults to -std=gnu23. We return false in a few places which can't work when true/false are a proper type (_Bool). Return NULL where appropriate instead of false. All callers handle this appropriately. ChangeLog: PR ld/32372 * binutils/prdbg.c (visibility_name): Return NULL. --- binutils/prdbg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/binutils/prdbg.c b/binutils/prdbg.c index 3941d6e1791..d6e828ee545 100644 --- a/binutils/prdbg.c +++ b/binutils/prdbg.c @@ -2818,7 +2818,7 @@ visibility_name (enum debug_visibility visibility) break; default: abort (); - return false; + return NULL; } return s; }