[PATCH 65/89] linux-user: Move elf parameters to sparc/target_elf.h

Richard Henderson posted 89 patches 3 months, 2 weeks ago
Maintainers: Riku Voipio <riku.voipio@iki.fi>, Laurent Vivier <laurent@vivier.eu>, Brian Cain <brian.cain@oss.qualcomm.com>, Paolo Bonzini <pbonzini@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>
There is a newer version of this series
[PATCH 65/89] linux-user: Move elf parameters to sparc/target_elf.h
Posted by Richard Henderson 3 months, 2 weeks ago
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/sparc/target_elf.h | 11 +++++++++++
 linux-user/elfload.c          | 15 ---------------
 2 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/linux-user/sparc/target_elf.h b/linux-user/sparc/target_elf.h
index 7e46748d26..8bd6e3e427 100644
--- a/linux-user/sparc/target_elf.h
+++ b/linux-user/sparc/target_elf.h
@@ -8,4 +8,15 @@
 #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
+
 #endif
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index dec27496ff..429d343adc 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -138,21 +138,6 @@ typedef abi_uint        target_gid_t;
 #endif
 typedef abi_int         target_pid_t;
 
-#ifdef TARGET_SPARC
-
-#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
-
-#endif /* TARGET_SPARC */
-
 #ifdef TARGET_PPC
 
 #define ELF_MACHINE    PPC_ELF_MACHINE
-- 
2.43.0
Re: [PATCH 65/89] linux-user: Move elf parameters to sparc/target_elf.h
Posted by Peter Maydell 3 months, 2 weeks ago
On Wed, 30 Jul 2025 at 01:34, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  linux-user/sparc/target_elf.h | 11 +++++++++++
>  linux-user/elfload.c          | 15 ---------------
>  2 files changed, 11 insertions(+), 15 deletions(-)
>
> diff --git a/linux-user/sparc/target_elf.h b/linux-user/sparc/target_elf.h
> index 7e46748d26..8bd6e3e427 100644
> --- a/linux-user/sparc/target_elf.h
> +++ b/linux-user/sparc/target_elf.h
> @@ -8,4 +8,15 @@
>  #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

Why does sparc share 64 and 32 bit in one header file with an ifdef
when the other archs like mips and arm have separate headers,
by the way ?

-- PMM
Re: [PATCH 65/89] linux-user: Move elf parameters to sparc/target_elf.h
Posted by Richard Henderson 3 months, 2 weeks ago
On 8/3/25 06:28, Peter Maydell wrote:
> Why does sparc share 64 and 32 bit in one header file with an ifdef
> when the other archs like mips and arm have separate headers,
> by the way ?

Hysterical raisins?  PPC and RISC-V also share a header for 32+64 bit.


r~
Re: [PATCH 65/89] linux-user: Move elf parameters to sparc/target_elf.h
Posted by Peter Maydell 3 months, 2 weeks ago
On Wed, 30 Jul 2025 at 01:34, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  linux-user/sparc/target_elf.h | 11 +++++++++++
>  linux-user/elfload.c          | 15 ---------------
>  2 files changed, 11 insertions(+), 15 deletions(-)

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM