[PATCH 62/89] linux-user: Move ppc uabi/asm/elf.h workaround to osdep.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 62/89] linux-user: Move ppc uabi/asm/elf.h workaround to osdep.h
Posted by Richard Henderson 3 months, 2 weeks ago
Move the workaround out of linux-user/elfload.c, so that
we don't have to replicate it in many places.  Place it
immediately after the include of <signal.h>, which draws
in the relevant symbols.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 include/qemu/osdep.h | 8 ++++++++
 linux-user/elfload.c | 7 -------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index 96fe51bc39..be3460b32f 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -133,6 +133,14 @@ QEMU_EXTERN_C int daemon(int, int);
 #include <setjmp.h>
 #include <signal.h>
 
+/*
+ * Avoid conflict with linux/arch/powerpc/include/uapi/asm/elf.h, included
+ * from <asm/sigcontext.h>, but we might as well do this unconditionally.
+ */
+#undef ELF_CLASS
+#undef ELF_DATA
+#undef ELF_ARCH
+
 #ifdef CONFIG_IOVEC
 #include <sys/uio.h>
 #endif
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 1ac3a20813..70bfd18de6 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -35,13 +35,6 @@
 #include "target/arm/cpu-features.h"
 #endif
 
-#ifdef _ARCH_PPC64
-#undef ARCH_DLINFO
-#undef ELF_CLASS
-#undef ELF_DATA
-#undef ELF_ARCH
-#endif
-
 #ifndef TARGET_ARCH_HAS_SIGTRAMP_PAGE
 #define TARGET_ARCH_HAS_SIGTRAMP_PAGE 0
 #endif
-- 
2.43.0
Re: [PATCH 62/89] linux-user: Move ppc uabi/asm/elf.h workaround to osdep.h
Posted by Peter Maydell 3 months, 2 weeks ago
On Wed, 30 Jul 2025 at 01:42, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> Move the workaround out of linux-user/elfload.c, so that
> we don't have to replicate it in many places.  Place it
> immediately after the include of <signal.h>, which draws
> in the relevant symbols.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  include/qemu/osdep.h | 8 ++++++++
>  linux-user/elfload.c | 7 -------
>  2 files changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
> index 96fe51bc39..be3460b32f 100644
> --- a/include/qemu/osdep.h
> +++ b/include/qemu/osdep.h
> @@ -133,6 +133,14 @@ QEMU_EXTERN_C int daemon(int, int);
>  #include <setjmp.h>
>  #include <signal.h>
>
> +/*
> + * Avoid conflict with linux/arch/powerpc/include/uapi/asm/elf.h, included
> + * from <asm/sigcontext.h>, but we might as well do this unconditionally.
> + */
> +#undef ELF_CLASS
> +#undef ELF_DATA
> +#undef ELF_ARCH
> +

This should allow us also to remove the hw/core/loader.c

#ifdef ELF_CLASS
#undef ELF_CLASS
#endif

(added in commit 3efa9a672e4a in 2009 with a commit message
and other PPC related changes suggesting it was for the same
ppc include problem).


> -#ifdef _ARCH_PPC64
> -#undef ARCH_DLINFO
> -#undef ELF_CLASS
> -#undef ELF_DATA
> -#undef ELF_ARCH
> -#endif

Your osdep.h change is missing ARCH_DLINFO -- did our uses of
that symbol get renamed to something else in an earlier patch?

thanks
-- PMM
Re: [PATCH 62/89] linux-user: Move ppc uabi/asm/elf.h workaround to osdep.h
Posted by Richard Henderson 3 months, 2 weeks ago
On 8/3/25 06:22, Peter Maydell wrote:
> This should allow us also to remove the hw/core/loader.c
> 
> #ifdef ELF_CLASS
> #undef ELF_CLASS
> #endif

Oh, excellent.  I forgot about that.

>> -#ifdef _ARCH_PPC64
>> -#undef ARCH_DLINFO
>> -#undef ELF_CLASS
>> -#undef ELF_DATA
>> -#undef ELF_ARCH
>> -#endif
> 
> Your osdep.h change is missing ARCH_DLINFO -- did our uses of
> that symbol get renamed to something else in an earlier patch?
My osdep.h change includes the symbols in the actual 
linux/arch/powerpc/include/uapi/asm/elf.h file.  The undef of ARCH_DLINFO here was 
knee-jerk, I think.


r~