From patchwork Wed Aug 2 16:47:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 129965 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp588497vqx; Wed, 2 Aug 2023 09:47:41 -0700 (PDT) X-Google-Smtp-Source: APBJJlGL2Zn7fr1vEL/+Pc3GegtfiRQOqy7mO7c+mFx9OEuRPzQCx71rlreO+MW3UB3NjlbFFG/A X-Received: by 2002:a05:6512:214a:b0:4fe:279b:7603 with SMTP id s10-20020a056512214a00b004fe279b7603mr4636544lfr.14.1690994861309; Wed, 02 Aug 2023 09:47:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690994861; cv=none; d=google.com; s=arc-20160816; b=hh9jkzXwxoAKm4sLU/Bo7b9NIAMSJsYPKQWTPlQCa2Ievem8J+AoCXWH87KB7lYRFm PWVvUVB931LcAuAYR/caSThwW+k63H0rQ7ExuzJ16SF7eg7ubO6532bN1W18wIYw7n2P 609QR2UOgUmAtmT+8WzQMz49jwxt2BAseC4KqhNqyWfv5Jw/C6b0PkxtHtw6a8F3EMAE ejiCWHonG5EZJcSnmy9mJtiA+MFzOnOVn9M6i92HVKgFk6grZtaGGVhHidtgakoU5N7Q y7rFkhBoOrdzGYv7zwHBBp8xjsMmr1nRZxeS9zhT8+dJMmdfWsYp1G7vEN+1dV2OavZc ERdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=CIm9C8cLWWKqCWt8eXniWYbwfE8sQIyu2WryjLFhdD0=; fh=qCwYT7nEL4nYQAyxI1D7nx76EboM0jqq/cFTt9x3qIg=; b=gTHktaOpIiWxTFpshse5E8F8p2MQJBCiViSbi0V+d9LoxNB+UG3/0lCppr6UmSvnnO EGjjI+VthmXuBpRt/Wf6lqAydEcNvLMf+16jd47fV4bSseQ9vfSELNfFW/3QVJA+hjC8 L+zbOuRXIZgST+Z+6sP3+B7XXryWxdTOT5ojVxBkrlGlj23rytQR10/jdfEG5JWRK4k7 ZIuDV8Gibxaxn1WAzn2ONCNz6GAa4EY2GISdyCiuLmGPC7N9dVWb3u9gyka/PYlk04ct tnVp8QxVRhhNml2TX5TwAtEGCz/AP0Wv//F1RKWaVeazEm6Tqb2MtYzTfWXwOys4y/nz oQrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=OOS5TSuN; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id l10-20020aa7c30a000000b00522aaf71df1si8283330edq.687.2023.08.02.09.47.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 09:47:41 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=OOS5TSuN; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1626C385842A for ; Wed, 2 Aug 2023 16:47:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1626C385842A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1690994859; bh=CIm9C8cLWWKqCWt8eXniWYbwfE8sQIyu2WryjLFhdD0=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=OOS5TSuNlVThkMn2cM3ea5IRkG8mSMNORvOOK6fIKBgdiNfcwRvQVUNOsa/bJjFN0 S76DloyOltp4L9Q5zNiF89tphrDfrQxVgkt0OeqwYilDk3+nvW1JxFSCU7GCKGWkm/ mNUeaL1Ygm+738B+Ebgd7jXUUQgOgCOnMvWSYCI4= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by sourceware.org (Postfix) with ESMTPS id 475A93858D39 for ; Wed, 2 Aug 2023 16:47:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 475A93858D39 Received: by mail-io1-xd29.google.com with SMTP id ca18e2360f4ac-786bb09e595so29005239f.1 for ; Wed, 02 Aug 2023 09:47:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690994848; x=1691599648; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=CIm9C8cLWWKqCWt8eXniWYbwfE8sQIyu2WryjLFhdD0=; b=GEwX7iAUxlKVVJi6e/cx2Kx019GCFU2gd6L8l5F4tYniixz1tXrKu3zNv6G8lzxTWn qDaQZnbwt3hkY98kQAs/GOv9yfKT2Kx7RKcMT09c4ZYRSX63lpLiMgxI/f+YljfBjHsE jvNK7FJrN1xsvg4oyrdkCv+5BbxBZiOC+Yd3dIcKY6Bcb8Wc34WBaNt3sdy46amPzxD1 qzRVKx3H8nqvPO9zsNgHsUmOW/ULF28HF4B/y9uzILIJsyvS3qyWAvIioUWl3rnV11mB L9ewKKyhhZ5aK1Cj7qimOp0omKiH2Iam/enJ+wAAInM14WxG+0KN6evzzIyzocvZObxS LGbg== X-Gm-Message-State: AOJu0Yzr0p3jUJJxTkkUZ5ZZW2M3Mew+XPI9gywLw8QWIrHZBBwmSYp8 qWWEjHi4uKfbDhkYBDSJVOhs9mTVMZxprQ9B2eGPiw== X-Received: by 2002:a05:6e02:b4c:b0:349:4053:4778 with SMTP id f12-20020a056e020b4c00b0034940534778mr1206002ilu.0.1690994848307; Wed, 02 Aug 2023 09:47:28 -0700 (PDT) Received: from localhost.localdomain (75-166-148-59.hlrn.qwest.net. [75.166.148.59]) by smtp.gmail.com with ESMTPSA id r16-20020a92d450000000b00345cce526cdsm4667964ilm.54.2023.08.02.09.47.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 09:47:27 -0700 (PDT) To: binutils@sourceware.org Cc: Tom Tromey Subject: [PATCH] Remove PEI_HEADERS define Date: Wed, 2 Aug 2023 10:47:20 -0600 Message-Id: <20230802164720.519587-1-tromey@adacore.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tom Tromey via Binutils From: Tom Tromey Reply-To: Tom Tromey Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773136627929709671 X-GMAIL-MSGID: 1773136627929709671 From: Tom Tromey I noticed a few files double-included libcoff.h, and digging deeper I found that the PEI_HEADERS define is a sort of external include guard. This patch adds include guards to the few files in include/coff that were missing one, and then removes the PEI_HEADERS workaround and the redundant includes. I didn't see anything in these files that indicated that double-inclusion would be useful, so it seems to me that this approach is ok. Tested by rebuilding with --enable-targets=all. bfd/ChangeLog 2023-08-02 Tom Tromey * pei-x86_64.c (PEI_HEADERS): Do not define. * pei-loongarch64.c (PEI_HEADERS): Do not define. * pei-aarch64.c (PEI_HEADERS): Do not define. * pe-x86_64.c (PEI_HEADERS): Do not define. * pe-aarch64.c (PEI_HEADERS): Do not define. * libpei.h (_LIBPEI_H): Add include guard. * coff-x86_64.c (PEI_HEADERS): Do not check. * coff-loongarch64.c (PEI_HEADERS): Do not check. * coff-aarch64.c (PEI_HEADERS): Do not check. include/ChangeLog 2023-08-02 Tom Tromey * coff/x86_64.h (COFF_X86_64_H): Add include guard. * coff/loongarch64.h (COFF_LOONGARCH64_H): Add include guard. * coff/aarch64.h (COFF_AARCH64_H): Add include guard. --- bfd/ChangeLog | 12 ++++++++++++ bfd/coff-aarch64.c | 7 ------- bfd/coff-loongarch64.c | 7 ------- bfd/coff-x86_64.c | 5 ----- bfd/libpei.h | 3 +++ bfd/pe-aarch64.c | 1 - bfd/pe-x86_64.c | 1 - bfd/pei-aarch64.c | 1 - bfd/pei-loongarch64.c | 1 - bfd/pei-x86_64.c | 4 ---- include/ChangeLog | 6 ++++++ include/coff/aarch64.h | 5 +++++ include/coff/loongarch64.h | 5 +++++ include/coff/x86_64.h | 5 +++++ 14 files changed, 36 insertions(+), 27 deletions(-) diff --git a/bfd/coff-aarch64.c b/bfd/coff-aarch64.c index 659cd4f162d..60e23134344 100644 --- a/bfd/coff-aarch64.c +++ b/bfd/coff-aarch64.c @@ -23,10 +23,6 @@ #define COFF_WITH_peAArch64 #endif -/* Note we have to make sure not to include headers twice. - Not all headers are wrapped in #ifdef guards, so we define - PEI_HEADERS to prevent double including here. */ -#ifndef PEI_HEADERS #include "sysdep.h" #include "bfd.h" #include "libbfd.h" @@ -35,9 +31,6 @@ #include "coff/pe.h" #include "libcoff.h" #include "libiberty.h" -#endif - -#include "libcoff.h" /* For these howto special functions, output_bfd == NULL => final link, or objdump -W and other calls to diff --git a/bfd/coff-loongarch64.c b/bfd/coff-loongarch64.c index 9136e06fea2..8ae3f842271 100644 --- a/bfd/coff-loongarch64.c +++ b/bfd/coff-loongarch64.c @@ -23,10 +23,6 @@ #define COFF_WITH_peLoongArch64 #endif -/* Note we have to make sure not to include headers twice. - Not all headers are wrapped in #ifdef guards, so we define - PEI_HEADERS to prevent double including here. */ -#ifndef PEI_HEADERS #include "sysdep.h" #include "bfd.h" #include "libbfd.h" @@ -35,9 +31,6 @@ #include "coff/pe.h" #include "libcoff.h" #include "libiberty.h" -#endif - -#include "libcoff.h" /* The page size is a guess based on ELF. */ diff --git a/bfd/coff-x86_64.c b/bfd/coff-x86_64.c index f5bd5a27c40..9a3f85cd1e5 100644 --- a/bfd/coff-x86_64.c +++ b/bfd/coff-x86_64.c @@ -20,10 +20,6 @@ Written by Kai Tietz, OneVision Software GmbH&CoKg. */ -/* Note we have to make sure not to include headers twice. - Not all headers are wrapped in #ifdef guards, so we define - PEI_HEADERS to prevent double including here. */ -#ifndef PEI_HEADERS #include "sysdep.h" #include "bfd.h" #include "libbfd.h" @@ -31,7 +27,6 @@ #include "coff/internal.h" #include "libcoff.h" #include "libiberty.h" -#endif #define BADMAG(x) AMD64BADMAG(x) diff --git a/bfd/libpei.h b/bfd/libpei.h index eafb9cf92c2..9837d4628dd 100644 --- a/bfd/libpei.h +++ b/bfd/libpei.h @@ -19,6 +19,8 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ +#ifndef _LIBPEI_H +#define _LIBPEI_H /* Most of this hacked by Steve Chamberlain, sac@cygnus.com @@ -445,3 +447,4 @@ bool _bfd_peAArch64_print_ce_compressed_pdata (bfd *, void *); bool _bfd_peLoongArch64_print_ce_compressed_pdata (bfd *, void *); bool _bfd_pep_print_ce_compressed_pdata (bfd *, void *); +#endif /* _LIBPEI_H */ diff --git a/bfd/pe-aarch64.c b/bfd/pe-aarch64.c index 9abc1cce5ea..2d5a7e25cea 100644 --- a/bfd/pe-aarch64.c +++ b/bfd/pe-aarch64.c @@ -55,7 +55,6 @@ { COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi."), \ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 } -#define PEI_HEADERS #include "sysdep.h" #include "bfd.h" #include "libbfd.h" diff --git a/bfd/pe-x86_64.c b/bfd/pe-x86_64.c index 04bf98e007c..b9c241edc7f 100644 --- a/bfd/pe-x86_64.c +++ b/bfd/pe-x86_64.c @@ -20,7 +20,6 @@ Written by Kai Tietz, OneVision Software GmbH&CoKg. */ -#define PEI_HEADERS #include "sysdep.h" #include "bfd.h" #include "libbfd.h" diff --git a/bfd/pei-aarch64.c b/bfd/pei-aarch64.c index 3fa2ff84b70..2ec1254ea85 100644 --- a/bfd/pei-aarch64.c +++ b/bfd/pei-aarch64.c @@ -56,7 +56,6 @@ { COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi."), \ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 } -#define PEI_HEADERS #include "sysdep.h" #include "bfd.h" #include "libbfd.h" diff --git a/bfd/pei-loongarch64.c b/bfd/pei-loongarch64.c index 89401291da4..3b7751a2b38 100644 --- a/bfd/pei-loongarch64.c +++ b/bfd/pei-loongarch64.c @@ -56,7 +56,6 @@ { COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi."), \ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 } -#define PEI_HEADERS #include "sysdep.h" #include "bfd.h" #include "libbfd.h" diff --git a/bfd/pei-x86_64.c b/bfd/pei-x86_64.c index 4d2ba71def9..65bd83e917d 100644 --- a/bfd/pei-x86_64.c +++ b/bfd/pei-x86_64.c @@ -58,10 +58,6 @@ { COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi."), \ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 } -/* Note we have to make sure not to include headers twice. - Not all headers are wrapped in #ifdef guards, so we define - PEI_HEADERS to prevent double including in coff-x86_64.c */ -#define PEI_HEADERS #include "sysdep.h" #include "bfd.h" #include "libbfd.h" diff --git a/include/coff/aarch64.h b/include/coff/aarch64.h index 4616cfef2b8..a3f2bcb76f7 100644 --- a/include/coff/aarch64.h +++ b/include/coff/aarch64.h @@ -17,6 +17,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ +#ifndef COFF_AARCH64_H +#define COFF_AARCH64_H + #define COFFAARCH64 1 #define L_LNNO_SIZE 2 @@ -82,3 +85,5 @@ struct external_reloc #define IMAGE_REL_ARM64_REL32 0x0011 /* The 32-bit relative address from the byte following the relocation. */ #define ARM_NOTE_SECTION ".note" + +#endif /* COFF_AARCH64_H */ diff --git a/include/coff/loongarch64.h b/include/coff/loongarch64.h index 5a21bcf9976..d273881623a 100644 --- a/include/coff/loongarch64.h +++ b/include/coff/loongarch64.h @@ -17,6 +17,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ +#ifndef COFF_LOONGARCH64_H +#define COFF_LOONGARCH64_H + #define COFFLOONGARCH64 1 #define L_LNNO_SIZE 2 @@ -59,3 +62,5 @@ struct external_reloc #define RELOC struct external_reloc #define RELSZ 14 + +#endif /* COFF_LOONGARCH64_H */ diff --git a/include/coff/x86_64.h b/include/coff/x86_64.h index 9980a84a835..3be9ee3874c 100644 --- a/include/coff/x86_64.h +++ b/include/coff/x86_64.h @@ -20,6 +20,9 @@ Written by Kai Tietz, OneVision Software GmbH&CoKg. */ +#ifndef COFF_X86_64_H +#define COFF_X86_64_H + #define L_LNNO_SIZE 2 #define INCLUDE_COMDAT_FIELDS_IN_AUXENT @@ -105,3 +108,5 @@ struct external_reloc #define R_PCRBYTE 18 #define R_PCRWORD 19 #define R_PCRLONG 20 + +#endif /* COFF_X86_64_H */