Skip to content

Commit f559e52

Browse files
committed
Remove PEI_HEADERS define
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.
1 parent f8c4789 commit f559e52

File tree

14 files changed

+36
-27
lines changed

14 files changed

+36
-27
lines changed

bfd/ChangeLog

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
2023-08-02 Tom Tromey <tromey@adacore.com>
2+
3+
* pei-x86_64.c (PEI_HEADERS): Do not define.
4+
* pei-loongarch64.c (PEI_HEADERS): Do not define.
5+
* pei-aarch64.c (PEI_HEADERS): Do not define.
6+
* pe-x86_64.c (PEI_HEADERS): Do not define.
7+
* pe-aarch64.c (PEI_HEADERS): Do not define.
8+
* libpei.h (_LIBPEI_H): Add include guard.
9+
* coff-x86_64.c (PEI_HEADERS): Do not check.
10+
* coff-loongarch64.c (PEI_HEADERS): Do not check.
11+
* coff-aarch64.c (PEI_HEADERS): Do not check.
12+
113
2023-07-24 Johannes Schauer Marin Rodrigues <josch@debian.org>
214

315
* peXXigen.c (_bfd_XXi_only_swap_filehdr_out): If inserting a

bfd/coff-aarch64.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@
2323
#define COFF_WITH_peAArch64
2424
#endif
2525

26-
/* Note we have to make sure not to include headers twice.
27-
Not all headers are wrapped in #ifdef guards, so we define
28-
PEI_HEADERS to prevent double including here. */
29-
#ifndef PEI_HEADERS
3026
#include "sysdep.h"
3127
#include "bfd.h"
3228
#include "libbfd.h"
@@ -35,9 +31,6 @@
3531
#include "coff/pe.h"
3632
#include "libcoff.h"
3733
#include "libiberty.h"
38-
#endif
39-
40-
#include "libcoff.h"
4134

4235
/* For these howto special functions,
4336
output_bfd == NULL => final link, or objdump -W and other calls to

bfd/coff-loongarch64.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@
2323
#define COFF_WITH_peLoongArch64
2424
#endif
2525

26-
/* Note we have to make sure not to include headers twice.
27-
Not all headers are wrapped in #ifdef guards, so we define
28-
PEI_HEADERS to prevent double including here. */
29-
#ifndef PEI_HEADERS
3026
#include "sysdep.h"
3127
#include "bfd.h"
3228
#include "libbfd.h"
@@ -35,9 +31,6 @@
3531
#include "coff/pe.h"
3632
#include "libcoff.h"
3733
#include "libiberty.h"
38-
#endif
39-
40-
#include "libcoff.h"
4134

4235
/* The page size is a guess based on ELF. */
4336

bfd/coff-x86_64.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,13 @@
2020
2121
Written by Kai Tietz, OneVision Software GmbH&CoKg. */
2222

23-
/* Note we have to make sure not to include headers twice.
24-
Not all headers are wrapped in #ifdef guards, so we define
25-
PEI_HEADERS to prevent double including here. */
26-
#ifndef PEI_HEADERS
2723
#include "sysdep.h"
2824
#include "bfd.h"
2925
#include "libbfd.h"
3026
#include "coff/x86_64.h"
3127
#include "coff/internal.h"
3228
#include "libcoff.h"
3329
#include "libiberty.h"
34-
#endif
3530

3631
#define BADMAG(x) AMD64BADMAG(x)
3732

bfd/libpei.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
2020
MA 02110-1301, USA. */
2121

22+
#ifndef _LIBPEI_H
23+
#define _LIBPEI_H
2224

2325
/* Most of this hacked by Steve Chamberlain,
2426
sac@cygnus.com
@@ -445,3 +447,4 @@ bool _bfd_peAArch64_print_ce_compressed_pdata (bfd *, void *);
445447
bool _bfd_peLoongArch64_print_ce_compressed_pdata (bfd *, void *);
446448
bool _bfd_pep_print_ce_compressed_pdata (bfd *, void *);
447449

450+
#endif /* _LIBPEI_H */

bfd/pe-aarch64.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
{ COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi."), \
5656
COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }
5757

58-
#define PEI_HEADERS
5958
#include "sysdep.h"
6059
#include "bfd.h"
6160
#include "libbfd.h"

bfd/pe-x86_64.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
2121
Written by Kai Tietz, OneVision Software GmbH&CoKg. */
2222

23-
#define PEI_HEADERS
2423
#include "sysdep.h"
2524
#include "bfd.h"
2625
#include "libbfd.h"

bfd/pei-aarch64.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
{ COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi."), \
5757
COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }
5858

59-
#define PEI_HEADERS
6059
#include "sysdep.h"
6160
#include "bfd.h"
6261
#include "libbfd.h"

bfd/pei-loongarch64.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
{ COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi."), \
5757
COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }
5858

59-
#define PEI_HEADERS
6059
#include "sysdep.h"
6160
#include "bfd.h"
6261
#include "libbfd.h"

bfd/pei-x86_64.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@
5858
{ COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi."), \
5959
COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }
6060

61-
/* Note we have to make sure not to include headers twice.
62-
Not all headers are wrapped in #ifdef guards, so we define
63-
PEI_HEADERS to prevent double including in coff-x86_64.c */
64-
#define PEI_HEADERS
6561
#include "sysdep.h"
6662
#include "bfd.h"
6763
#include "libbfd.h"

0 commit comments

Comments
 (0)