]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Remove PEI_HEADERS define
authorTom Tromey <tom@tromey.com>
Sun, 30 Jul 2023 16:26:07 +0000 (10:26 -0600)
committerTom Tromey <tromey@adacore.com>
Thu, 3 Aug 2023 13:39:15 +0000 (07:39 -0600)
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.

2023-08-02  Tom Tromey  <tromey@adacore.com>

* 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  <tromey@adacore.com>

* 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.

14 files changed:
bfd/ChangeLog
bfd/coff-aarch64.c
bfd/coff-loongarch64.c
bfd/coff-x86_64.c
bfd/libpei.h
bfd/pe-aarch64.c
bfd/pe-x86_64.c
bfd/pei-aarch64.c
bfd/pei-loongarch64.c
bfd/pei-x86_64.c
include/ChangeLog
include/coff/aarch64.h
include/coff/loongarch64.h
include/coff/x86_64.h

index 56c858e6ce4c878c494802843e1e5e6721cb44c4..0087aed06a0ecef9f3323a75f55f696c1aa60874 100644 (file)
@@ -1,3 +1,15 @@
+2023-08-02  Tom Tromey  <tromey@adacore.com>
+
+       * 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.
+
 2023-07-24  Johannes Schauer Marin Rodrigues  <josch@debian.org>
 
        * peXXigen.c (_bfd_XXi_only_swap_filehdr_out): If inserting a
index 659cd4f162d1c920cfa38040093188020e4af701..60e231343440bb73231bf00d62439faf61cef219 100644 (file)
 #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
index 9136e06fea22a7ac85f20720a1ca2d7a7e5b2388..8ae3f842271886027eb225608772dc37f5928ca9 100644 (file)
 #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.  */
 
index f5bd5a27c40739826b325d1e577bb6ecd63957d3..9a3f85cd1e5f33694a3675152ffe41514954a147 100644 (file)
 
    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)
 
index eafb9cf92c2ea41ab43e1f9800455426fe1c73c4..9837d4628ddb92a27fd1c1cecf3a6282aa544d25 100644 (file)
@@ -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 */
index 9abc1cce5eaa0765759f3748bee826062ad2f3a1..2d5a7e25cea9d92c7c794876eeaa6103aab0d43e 100644 (file)
@@ -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"
index 04bf98e007c080c97017dc893e6231f30ac6fcbd..b9c241edc7f2db7624b4fe0cc9d24083e7caa851 100644 (file)
@@ -20,7 +20,6 @@
 
    Written by Kai Tietz, OneVision Software GmbH&CoKg.  */
 
-#define PEI_HEADERS
 #include "sysdep.h"
 #include "bfd.h"
 #include "libbfd.h"
index 3fa2ff84b700862816074a3a2ebc1fac51f98a62..2ec1254ea85d688197600be9792fc404190bdd0d 100644 (file)
@@ -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"
index 89401291da4166076366dc8d4fe9d5808acde082..3b7751a2b3842ff6b4c9189162b5181ccc30df4b 100644 (file)
@@ -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"
index 4d2ba71def922239bbdb6d485886c098f962966c..65bd83e917d71a0e381575c81877bcc66db3ab54 100644 (file)
 { 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"
index 4d407403944376adac95360d5e6fd181a2384be6..eb54da4414656cd842c28ce239c84a6dc05a1a30 100644 (file)
@@ -1,3 +1,9 @@
+2023-08-02  Tom Tromey  <tromey@adacore.com>
+
+       * 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.
+
 2023-07-30  Jose E. Marchesi  <jose.marchesi@oracle.com>
 
        * elf/bpf.h (EF_BPF_CPUVER): Define.
index 4616cfef2b831310ea7ece4cefef0e20d466acd7..a3f2bcb76f74e24a2948b00d54b6ef7d6e2992f2 100644 (file)
@@ -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 */
index 5a21bcf99762ea3f17c23b7e0a52072d618f66f2..d273881623ad8c2a7987b1518acfc2f2b8c8669c 100644 (file)
@@ -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 */
index 9980a84a83521de440c32eb4167653c3c4b2186c..3be9ee3874cbf050aa6e62b98d368d775b67acfb 100644 (file)
@@ -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 */