[binutils-gdb] bfd/pe*.c including bfd/coff*.c

Alan Modra amodra@sourceware.org
Sun Aug 24 22:59:06 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2c193469846d9b8ca6a62ae32e9b093a3dccf197

commit 2c193469846d9b8ca6a62ae32e9b093a3dccf197
Author: Alan Modra <amodra@gmail.com>
Date:   Sat Aug 23 16:27:12 2025 +0930

    bfd/pe*.c including bfd/coff*.c
    
    The model of a coff-<arch>.c file providing older COFF support, with a
    pe-<arch>.c file defining some macros then including the coff-<arch>.c
    file to provide PE support has been followed by a number of
    architectures.
    
    Some of them have PE specific code in their coff-<arch>.c files,
    unconditionally compiled.  ie. they are not for old COFF support, and
    there was no reason to follow the model.  They now get an error if
    they are compiled stand-alone rather than being included from
    pe-<arch>.c or pei-<arch>.c.
    
            * coff-aarch64.c (COFF_WITH_peAArch64): Don't define here.
            (COFF_WITH_PE): Error if not defined.
            * coff-ia64.c (COFF_WITH_PE): Error if not defined.
            * coff-loongarch64.c (COFF_WITH_peLoongArch64): Don't define here.
            (COFF_WITH_PE): Error if not defined.
            * coff-mcore.c (COFF_WITH_PE): Error if not defined.
            * coff-riscv64.c (COFF_WITH_PE): Error if not defined.
            * pei-aarch64.c: Remove duplicate includes.
            * pei-loongarch64.c: Likewise.
            * pei-riscv64.c: Likewise.
            * pei-x86_64.c: Likewise.

Diff:
---
 bfd/coff-aarch64.c     | 5 ++---
 bfd/coff-ia64.c        | 4 ++++
 bfd/coff-loongarch64.c | 5 ++---
 bfd/coff-mcore.c       | 4 ++++
 bfd/coff-riscv64.c     | 4 ++++
 bfd/pei-aarch64.c      | 4 +---
 bfd/pei-loongarch64.c  | 4 +---
 bfd/pei-riscv64.c      | 4 +---
 bfd/pei-x86_64.c       | 4 +---
 9 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/bfd/coff-aarch64.c b/bfd/coff-aarch64.c
index af4a44dede0..48b8bfaf496 100644
--- a/bfd/coff-aarch64.c
+++ b/bfd/coff-aarch64.c
@@ -18,9 +18,8 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
-
-#ifndef COFF_WITH_peAArch64
-#define COFF_WITH_peAArch64
+#ifndef COFF_WITH_PE
+#error non-PE COFF unsupported
 #endif
 
 #include "sysdep.h"
diff --git a/bfd/coff-ia64.c b/bfd/coff-ia64.c
index 3a947ef17a3..b2873ae8684 100644
--- a/bfd/coff-ia64.c
+++ b/bfd/coff-ia64.c
@@ -19,6 +19,10 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
+#ifndef COFF_WITH_PE
+#error non-PE COFF unsupported
+#endif
+
 #include "sysdep.h"
 #include "bfd.h"
 #include "libbfd.h"
diff --git a/bfd/coff-loongarch64.c b/bfd/coff-loongarch64.c
index c1fe70ba593..a85210864ae 100644
--- a/bfd/coff-loongarch64.c
+++ b/bfd/coff-loongarch64.c
@@ -18,9 +18,8 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
-
-#ifndef COFF_WITH_peLoongArch64
-#define COFF_WITH_peLoongArch64
+#ifndef COFF_WITH_PE
+#error non-PE COFF unsupported
 #endif
 
 #include "sysdep.h"
diff --git a/bfd/coff-mcore.c b/bfd/coff-mcore.c
index e15c4b4a6e2..fab10a7ae08 100644
--- a/bfd/coff-mcore.c
+++ b/bfd/coff-mcore.c
@@ -18,6 +18,10 @@
    Foundation, 51 Franklin Street - Fifth Floor,
    Boston, MA 02110-1301, USA.  */
 
+#ifndef COFF_WITH_PE
+#error non-PE COFF unsupported
+#endif
+
 #include "sysdep.h"
 #include "bfd.h"
 #include "libbfd.h"
diff --git a/bfd/coff-riscv64.c b/bfd/coff-riscv64.c
index 870eef35305..2356a6bb94d 100644
--- a/bfd/coff-riscv64.c
+++ b/bfd/coff-riscv64.c
@@ -18,6 +18,10 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
+#ifndef COFF_WITH_PE
+#error non-PE COFF unsupported
+#endif
+
 #include "sysdep.h"
 #include "bfd.h"
 #include "libbfd.h"
diff --git a/bfd/pei-aarch64.c b/bfd/pei-aarch64.c
index 00f38e0f9bb..835b547ebc6 100644
--- a/bfd/pei-aarch64.c
+++ b/bfd/pei-aarch64.c
@@ -20,6 +20,7 @@
 
 #include "sysdep.h"
 #include "bfd.h"
+#include "libbfd.h"
 
 #define TARGET_SYM		aarch64_pei_le_vec
 #define TARGET_NAME		"pei-aarch64-little"
@@ -58,9 +59,6 @@
 { COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi."), \
   COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }
 
-#include "sysdep.h"
-#include "bfd.h"
-#include "libbfd.h"
 #include "coff/aarch64.h"
 #include "coff/internal.h"
 #include "coff/pe.h"
diff --git a/bfd/pei-loongarch64.c b/bfd/pei-loongarch64.c
index f22498cab21..0b00cb2d557 100644
--- a/bfd/pei-loongarch64.c
+++ b/bfd/pei-loongarch64.c
@@ -20,6 +20,7 @@
 
 #include "sysdep.h"
 #include "bfd.h"
+#include "libbfd.h"
 
 #define TARGET_SYM		loongarch64_pei_vec
 #define TARGET_NAME		"pei-loongarch64"
@@ -58,9 +59,6 @@
 { COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi."), \
   COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }
 
-#include "sysdep.h"
-#include "bfd.h"
-#include "libbfd.h"
 #include "coff/loongarch64.h"
 #include "coff/internal.h"
 #include "coff/pe.h"
diff --git a/bfd/pei-riscv64.c b/bfd/pei-riscv64.c
index c4ae7bfb89a..d8d4b5de145 100644
--- a/bfd/pei-riscv64.c
+++ b/bfd/pei-riscv64.c
@@ -20,6 +20,7 @@
 
 #include "sysdep.h"
 #include "bfd.h"
+#include "libbfd.h"
 
 #define TARGET_SYM		riscv64_pei_vec
 #define TARGET_NAME		"pei-riscv64-little"
@@ -58,9 +59,6 @@
 { COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi."), \
   COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }
 
-#include "sysdep.h"
-#include "bfd.h"
-#include "libbfd.h"
 #include "coff/riscv64.h"
 #include "coff/internal.h"
 #include "coff/pe.h"
diff --git a/bfd/pei-x86_64.c b/bfd/pei-x86_64.c
index a5c2fd85f06..045fedb79a5 100644
--- a/bfd/pei-x86_64.c
+++ b/bfd/pei-x86_64.c
@@ -22,6 +22,7 @@
 
 #include "sysdep.h"
 #include "bfd.h"
+#include "libbfd.h"
 
 #define TARGET_SYM		x86_64_pei_vec
 #define TARGET_NAME		"pei-x86-64"
@@ -60,9 +61,6 @@
 { COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi."), \
   COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }
 
-#include "sysdep.h"
-#include "bfd.h"
-#include "libbfd.h"
 #include "coff/x86_64.h"
 #include "coff/internal.h"
 #include "coff/pe.h"


More information about the Binutils-cvs mailing list