]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
linux-user: Standardize on ELF_MACHINE not ELF_ARCH
authorRichard Henderson <richard.henderson@linaro.org>
Tue, 29 Jul 2025 21:23:31 +0000 (11:23 -1000)
committerRichard Henderson <richard.henderson@linaro.org>
Fri, 29 Aug 2025 21:04:04 +0000 (07:04 +1000)
PowerPC was the one outlier that defined both ELF_ARCH and
ELF_MACHINE; ELF_ARCH was defined incorrectly, necessitating
the definition of elf_check_arch.

However, the elf file header field in question is called
e_machine, so ELF_MACHINE is in fact the better name.

Mechanically change most target/target_elf.h files,
then adjust ppc/target_elf.h manually.

Do not provide a default for ELF_MACHINE.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
20 files changed:
linux-user/aarch64/target_elf.h
linux-user/alpha/target_elf.h
linux-user/arm/target_elf.h
linux-user/elfload.c
linux-user/hexagon/target_elf.h
linux-user/hppa/target_elf.h
linux-user/i386/target_elf.h
linux-user/loongarch64/target_elf.h
linux-user/m68k/target_elf.h
linux-user/microblaze/target_elf.h
linux-user/mips/target_elf.h
linux-user/mips64/target_elf.h
linux-user/openrisc/target_elf.h
linux-user/ppc/target_elf.h
linux-user/riscv/target_elf.h
linux-user/s390x/target_elf.h
linux-user/sh4/target_elf.h
linux-user/sparc/target_elf.h
linux-user/x86_64/target_elf.h
linux-user/xtensa/target_elf.h

index 3c9fef93785bbc9ab595d2d8f225c59da8d6eedb..9ec51f6237fd75d1520e35b4f9003b643f9456a6 100644 (file)
@@ -10,7 +10,7 @@
 
 #include "target_ptrace.h"
 
-#define ELF_ARCH                EM_AARCH64
+#define ELF_MACHINE             EM_AARCH64
 #define ELF_CLASS               ELFCLASS64
 
 #define HAVE_ELF_HWCAP          1
index f9d6372c9f4fa729305fca29c273dfdbed76ed00..864dc6e2e6fe753c0740680833df9be93306fe0e 100644 (file)
@@ -9,6 +9,6 @@
 #define ALPHA_TARGET_ELF_H
 
 #define ELF_CLASS               ELFCLASS64
-#define ELF_ARCH                EM_ALPHA
+#define ELF_MACHINE             EM_ALPHA
 
 #endif
index d871d6d665f3ca202a5c002235e337fd2e3a6115..12cdc8e5a71a0ab02cf84d9b335787c2d1d6e8a9 100644 (file)
@@ -10,7 +10,7 @@
 
 #include "target_ptrace.h"
 
-#define ELF_ARCH                EM_ARM
+#define ELF_MACHINE             EM_ARM
 #define ELF_CLASS               ELFCLASS32
 #define EXSTACK_DEFAULT         true
 
index 33c4214c95a7cc3cca8dd4aa56a89f77775f6dff..c4817597104d270ef861715c5cb4d8ad84ff7db5 100644 (file)
@@ -130,12 +130,8 @@ typedef abi_uint        target_gid_t;
 #endif
 typedef abi_int         target_pid_t;
 
-#ifndef ELF_MACHINE
-#define ELF_MACHINE ELF_ARCH
-#endif
-
 #ifndef elf_check_arch
-#define elf_check_arch(x) ((x) == ELF_ARCH)
+#define elf_check_arch(x) ((x) == ELF_MACHINE)
 #endif
 
 #ifndef elf_check_abi
index a9f6d77fc6e7ffb6e5be49a201f705954d266fbe..f81ae3895a6b966675746049ffc5b61702e92a86 100644 (file)
@@ -19,6 +19,6 @@
 #define HEXAGON_TARGET_ELF_H
 
 #define ELF_CLASS               ELFCLASS32
-#define ELF_ARCH                EM_HEXAGON
+#define ELF_MACHINE             EM_HEXAGON
 
 #endif
index 9b6363a0a7519ebbec437230d49055a87ad7fed2..76930c9369ea60c4fe6a654ac3f426318388a971 100644 (file)
@@ -9,7 +9,7 @@
 #define HPPA_TARGET_ELF_H
 
 #define ELF_CLASS               ELFCLASS32
-#define ELF_ARCH                EM_PARISC
+#define ELF_MACHINE             EM_PARISC
 
 #define HAVE_ELF_PLATFORM       1
 
index dc58c0017ab50bfd5a8c4f4779151a0a5249c0b8..c3caad68b91fd12b9764d0b1fa39bb18e51fd54e 100644 (file)
@@ -11,7 +11,7 @@
 #include "target_ptrace.h"
 
 #define ELF_CLASS               ELFCLASS32
-#define ELF_ARCH                EM_386
+#define ELF_MACHINE             EM_386
 #define EXSTACK_DEFAULT         true
 #define VDSO_HEADER             "vdso.c.inc"
 
index 47bf51a41c2a92b197f4a5807cb68a9270f2403b..b9885929934282dd3cf189d14f472fddb61c302c 100644 (file)
@@ -9,7 +9,7 @@
 #include "target_ptrace.h"
 
 #define ELF_CLASS               ELFCLASS64
-#define ELF_ARCH                EM_LOONGARCH
+#define ELF_MACHINE             EM_LOONGARCH
 #define EXSTACK_DEFAULT         true
 #define elf_check_arch(x)       ((x) == EM_LOONGARCH)
 #define VDSO_HEADER             "vdso.c.inc"
index 073c85becc9197b5eb7b5977cfd9990ea6f4792d..b997fa0b6d662c5d3a607337b473a27579174506 100644 (file)
@@ -9,7 +9,7 @@
 #define M68K_TARGET_ELF_H
 
 #define ELF_CLASS               ELFCLASS32
-#define ELF_ARCH                EM_68K
+#define ELF_MACHINE             EM_68K
 
 #define HAVE_ELF_CORE_DUMP      1
 
index a622cd8e4380dbb483c561079a9ad7350997bd95..1ec91ea5a962107c4b6cd5d74c54cee977fe1267 100644 (file)
@@ -11,7 +11,7 @@
 #include "target_ptrace.h"
 
 #define ELF_CLASS               ELFCLASS32
-#define ELF_ARCH                EM_MICROBLAZE
+#define ELF_MACHINE             EM_MICROBLAZE
 
 #define elf_check_arch(x)   ((x) == EM_MICROBLAZE || (x) == EM_MICROBLAZE_OLD)
 
index f400bc2fdb7ee85820cab14d9b73fa6b8983483d..157306f7a0ab41515222e3a8b4892d4c27f67a43 100644 (file)
@@ -11,7 +11,7 @@
 #include "target_ptrace.h"
 
 #define ELF_CLASS               ELFCLASS32
-#define ELF_ARCH                EM_MIPS
+#define ELF_MACHINE             EM_MIPS
 #define EXSTACK_DEFAULT         true
 
 #define HAVE_ELF_HWCAP          1
index c455985a76b74af743b858da3ecbb7fed16e2ce9..061471a0f129f0681c25c85c6aa4794ab642b552 100644 (file)
@@ -11,7 +11,7 @@
 #include "target_ptrace.h"
 
 #define ELF_CLASS               ELFCLASS64
-#define ELF_ARCH                EM_MIPS
+#define ELF_MACHINE             EM_MIPS
 #define EXSTACK_DEFAULT         true
 
 #ifdef TARGET_ABI_MIPSN32
index ed9739380fd940ebbbec34f422d4b781ab2e8f14..e8554f5339e86c69a24b45c72e6c3ad72449c226 100644 (file)
@@ -10,7 +10,7 @@
 
 #include "target_ptrace.h"
 
-#define ELF_ARCH                EM_OPENRISC
+#define ELF_MACHINE             EM_OPENRISC
 #define ELF_CLASS               ELFCLASS32
 
 #define HAVE_ELF_CORE_DUMP      1
index 9a47f18fb8820f896a11cc942197bf0c20694b0b..22854cf52fc4e33a5324c1353d86561f6c8333f1 100644 (file)
 #define ELF_MACHINE             PPC_ELF_MACHINE
 
 #ifdef TARGET_PPC64
-# define elf_check_arch(x)      ((x) == EM_PPC64)
 # define ELF_CLASS              ELFCLASS64
 #else
 # define ELF_CLASS              ELFCLASS32
 # define EXSTACK_DEFAULT        true
 #endif
-#define ELF_ARCH                EM_PPC
 
 #define HAVE_ELF_HWCAP          1
 #define HAVE_ELF_HWCAP2         1
index 51b8def1d16a84e16a117c389e269402f0635695..dbbfdf54d39c7eaaf5e48c06a2d841e5a5ce5bd4 100644 (file)
@@ -8,7 +8,7 @@
 #ifndef RISCV_TARGET_ELF_H
 #define RISCV_TARGET_ELF_H
 
-#define ELF_ARCH                EM_RISCV
+#define ELF_MACHINE             EM_RISCV
 
 #ifdef TARGET_RISCV32
 #define ELF_CLASS               ELFCLASS32
index b23e46ab468bbf8a1b5502fb371e21c31291130b..ef5edbd86099f3afa27a76fb9b72606c8be3aed9 100644 (file)
@@ -11,7 +11,7 @@
 #include "target_ptrace.h"
 
 #define ELF_CLASS               ELFCLASS64
-#define ELF_ARCH                EM_S390
+#define ELF_MACHINE             EM_S390
 #define VDSO_HEADER             "vdso.c.inc"
 
 #define HAVE_ELF_HWCAP          1
index 61aea237c44d9f82f39ca63c63e4baa5d2bee292..d9e253d4250e007d60f5e01b94a943ecd2e303ba 100644 (file)
@@ -11,7 +11,7 @@
 #include "target_ptrace.h"
 
 #define ELF_CLASS               ELFCLASS32
-#define ELF_ARCH                EM_SH
+#define ELF_MACHINE             EM_SH
 
 #define HAVE_ELF_HWCAP          1
 #define HAVE_ELF_CORE_DUMP      1
index f89c708c462a877419ccad926733aebfdd007b81..6b0cac3caf09d8ea941036fe4faf94527c8fa371 100644 (file)
 
 #ifndef TARGET_SPARC64
 # define ELF_CLASS              ELFCLASS32
-# define ELF_ARCH               EM_SPARC
+# define ELF_MACHINE            EM_SPARC
 #elif defined(TARGET_ABI32)
 # define ELF_CLASS              ELFCLASS32
 # define elf_check_arch(x)      ((x) == EM_SPARC32PLUS || (x) == EM_SPARC)
 #else
 # define ELF_CLASS              ELFCLASS64
-# define ELF_ARCH               EM_SPARCV9
+# define ELF_MACHINE            EM_SPARCV9
 #endif
 
 #define HAVE_ELF_HWCAP          1
index f3c09bb8da515c49bd1fee1b198ad43daf9ab6a6..840bddf5ec60fb2db5d63cb5ec5472cb8df5929b 100644 (file)
@@ -11,7 +11,7 @@
 #include "target_ptrace.h"
 
 #define ELF_CLASS               ELFCLASS64
-#define ELF_ARCH                EM_X86_64
+#define ELF_MACHINE             EM_X86_64
 #define VDSO_HEADER             "vdso.c.inc"
 
 #define HAVE_ELF_HWCAP          1
index 0689e79be520b8040462a9fe4848869cd25868ea..1bf8f2a14a4da2cee162df78527058e3a282458d 100644 (file)
@@ -11,7 +11,7 @@
 #include "target_ptrace.h"
 
 #define ELF_CLASS               ELFCLASS32
-#define ELF_ARCH                EM_XTENSA
+#define ELF_MACHINE             EM_XTENSA
 
 #define HAVE_ELF_CORE_DUMP      1