[committed v4 1/2] LD/PE: Make arch identifiers enumeration constants

Maciej W. Rozycki macro@orcam.me.uk
Mon Oct 13 21:05:55 GMT 2025


Convert internal PE architecture identifiers from macros to enumeration 
constants so as to make any further updates less disruptive to code.

Add a PE_ARCH_none dummy placeholder so as to start the numbering of 
actual architectures from 1 without the need to specify the numeric 
value for any of the constants.

No functional change.  Suggested by Richard Earnshaw.
---
On Thu, 9 Oct 2025, Jan Beulich wrote:

> > Convert internal PE architecture identifiers from macros to enumeration 
> > constants so as to make any further updates less disruptive to code.
> 
> Okay.

 Thank you for your review.  I have rebased the change on top of commit 
f72471128d1a ("ld/PE: adjust pe_detail_list[]"), re-verified it, and 
pushed now.

  Maciej

Changes from v3:

- Factor in PE_ARCH_mcore.

New change in v3.
---
 ld/pe-dll.c |   19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

binutils-ld-pe-arch-enum.diff
Index: binutils-gdb/ld/pe-dll.c
===================================================================
--- binutils-gdb.orig/ld/pe-dll.c
+++ binutils-gdb/ld/pe-dll.c
@@ -245,13 +245,18 @@ static const autofilter_entry_type autof
   { NULL, 0 }
 };
 
-#define PE_ARCH_i386	 1
-#define PE_ARCH_sh	 2
-#define PE_ARCH_mips	 3
-#define PE_ARCH_arm	 4
-#define PE_ARCH_arm_wince 5
-#define PE_ARCH_aarch64  6
-#define PE_ARCH_mcore	 7
+/* Internal identification of PE architectures.  */
+enum
+{
+  PE_ARCH_none,
+  PE_ARCH_i386,
+  PE_ARCH_sh,
+  PE_ARCH_mips,
+  PE_ARCH_arm,
+  PE_ARCH_arm_wince,
+  PE_ARCH_aarch64,
+  PE_ARCH_mcore,
+};
 
 /* Don't make it constant as underscore mode gets possibly overriden
    by target or -(no-)leading-underscore option.  */


More information about the Binutils mailing list