From 7b75b5e611d157ec77e4be3ac7f5ff1301380440 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Tue, 29 Jul 2025 10:19:10 -1000 Subject: linux-user: Move elf parameters to sparc/target_elf.h Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- linux-user/sparc/target_elf.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'linux-user/sparc') diff --git a/linux-user/sparc/target_elf.h b/linux-user/sparc/target_elf.h index b7544db..f89c708 100644 --- a/linux-user/sparc/target_elf.h +++ b/linux-user/sparc/target_elf.h @@ -8,6 +8,17 @@ #ifndef SPARC_TARGET_ELF_H #define SPARC_TARGET_ELF_H +#ifndef TARGET_SPARC64 +# define ELF_CLASS ELFCLASS32 +# define ELF_ARCH 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 +#endif + #define HAVE_ELF_HWCAP 1 #endif -- cgit v1.1 From e6b7635c9a33918c671e1f2ef4b17b5c2f279d66 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Tue, 29 Jul 2025 11:23:31 -1000 Subject: linux-user: Standardize on ELF_MACHINE not ELF_ARCH 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 Signed-off-by: Richard Henderson --- linux-user/sparc/target_elf.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'linux-user/sparc') diff --git a/linux-user/sparc/target_elf.h b/linux-user/sparc/target_elf.h index f89c708..6b0cac3 100644 --- a/linux-user/sparc/target_elf.h +++ b/linux-user/sparc/target_elf.h @@ -10,13 +10,13 @@ #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 -- cgit v1.1 From eb727cc45a352ff259c4c2d85456f0412e738d43 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Tue, 29 Jul 2025 11:26:43 -1000 Subject: linux-user: Rename elf_check_arch Rename to elf_check_machine to match ELF_MACHINE. Remove the unnecessary definition for loongarch64. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- linux-user/sparc/target_elf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'linux-user/sparc') diff --git a/linux-user/sparc/target_elf.h b/linux-user/sparc/target_elf.h index 6b0cac3..7827767 100644 --- a/linux-user/sparc/target_elf.h +++ b/linux-user/sparc/target_elf.h @@ -13,7 +13,7 @@ # define ELF_MACHINE EM_SPARC #elif defined(TARGET_ABI32) # define ELF_CLASS ELFCLASS32 -# define elf_check_arch(x) ((x) == EM_SPARC32PLUS || (x) == EM_SPARC) +# define elf_check_machine(x) ((x) == EM_SPARC32PLUS || (x) == EM_SPARC) #else # define ELF_CLASS ELFCLASS64 # define ELF_MACHINE EM_SPARCV9 -- cgit v1.1 From 8bb7873f28e82944ab6fb2c633c09877fd4eeda8 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Thu, 28 Aug 2025 21:51:46 +1000 Subject: linux-user/sparc: Create target_ptrace.h Move target_pt_regs to target_ptrace.h. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- linux-user/sparc/signal.c | 2 ++ linux-user/sparc/target_ptrace.h | 24 ++++++++++++++++++++++++ linux-user/sparc/target_syscall.h | 19 ------------------- 3 files changed, 26 insertions(+), 19 deletions(-) create mode 100644 linux-user/sparc/target_ptrace.h (limited to 'linux-user/sparc') diff --git a/linux-user/sparc/signal.c b/linux-user/sparc/signal.c index 8181b8b..d339f89 100644 --- a/linux-user/sparc/signal.c +++ b/linux-user/sparc/signal.c @@ -21,6 +21,8 @@ #include "user-internals.h" #include "signal-common.h" #include "linux-user/trace.h" +#include "target_ptrace.h" + /* A Sparc register window */ struct target_reg_window { diff --git a/linux-user/sparc/target_ptrace.h b/linux-user/sparc/target_ptrace.h new file mode 100644 index 0000000..a4d5416 --- /dev/null +++ b/linux-user/sparc/target_ptrace.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#ifndef SPARC_TARGET_PTRACE_H +#define SPARC_TARGET_PTRACE_H + +/* See arch/sparc/include/uapi/asm/ptrace.h. */ +struct target_pt_regs { +#if defined(TARGET_SPARC64) && !defined(TARGET_ABI32) + abi_ulong u_regs[16]; + abi_ulong tstate; + abi_ulong pc; + abi_ulong npc; + uint32_t y; + uint32_t magic; +#else + abi_ulong psr; + abi_ulong pc; + abi_ulong npc; + abi_ulong y; + abi_ulong u_regs[16]; +#endif +}; + +#endif /* SPARC_TARGET_PTRACE_H */ diff --git a/linux-user/sparc/target_syscall.h b/linux-user/sparc/target_syscall.h index e421165..a90ed29 100644 --- a/linux-user/sparc/target_syscall.h +++ b/linux-user/sparc/target_syscall.h @@ -1,25 +1,6 @@ #ifndef SPARC_TARGET_SYSCALL_H #define SPARC_TARGET_SYSCALL_H -#if defined(TARGET_SPARC64) && !defined(TARGET_ABI32) -struct target_pt_regs { - abi_ulong u_regs[16]; - abi_ulong tstate; - abi_ulong pc; - abi_ulong npc; - uint32_t y; - uint32_t magic; -}; -#else -struct target_pt_regs { - abi_ulong psr; - abi_ulong pc; - abi_ulong npc; - abi_ulong y; - abi_ulong u_regs[16]; -}; -#endif - #ifdef TARGET_SPARC64 # define UNAME_MACHINE "sparc64" #else -- cgit v1.1