904b1d4
From 8f4d4cb4e4e73d0533aa2cb421c14210c75f6edc Mon Sep 17 00:00:00 2001
081ecc8
From: Mark McLoughlin <markmc@redhat.com>
081ecc8
Date: Mon, 29 Jun 2009 14:49:03 +0100
a4e9458
Subject: [PATCH] Fix linux-user build on ppc
081ecc8
081ecc8
kvm-87 build fails on ppc:
081ecc8
081ecc8
  https://koji.fedoraproject.org/koji/getfile?taskID=1441042&name=build.log
081ecc8
081ecc8
  gcc -I. -I.. -I/builddir/build/BUILD/qemu-kvm-devel-87/target-i386
081ecc8
  -I/builddir/build/BUILD/qemu-kvm-devel-87 -MMD -MT elfload.o -MP
081ecc8
  -DNEED_CPU_H -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
081ecc8
  -D__user= -I/builddir/build/BUILD/qemu-kvm-devel-87/tcg
081ecc8
  -I/builddir/build/BUILD/qemu-kvm-devel-87/tcg/ppc64
081ecc8
  -I/builddir/build/BUILD/qemu-kvm-devel-87/fpu
081ecc8
  -I/builddir/build/BUILD/qemu-kvm-devel-87/linux-user
081ecc8
  -I/builddir/build/BUILD/qemu-kvm-devel-87/linux-user/i386 -O2 -g -pipe
081ecc8
  -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
081ecc8
  --param=ssp-buffer-size=4 -m64 -mminimal-toc -g -fno-strict-aliasing
081ecc8
  -O2 -Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes
081ecc8
  -Wstrict-prototypes -Wredundant-decls    -c -o elfload.o
081ecc8
  /builddir/build/BUILD/qemu-kvm-devel-87/linux-user/elfload.c
081ecc8
  /builddir/build/BUILD/qemu-kvm-devel-87/linux-user/elfload.c:214: error: conflicting types for 'elf_greg_t'
081ecc8
  /usr/include/asm/elf.h:123: note: previous declaration of 'elf_greg_t' was here
081ecc8
  /builddir/build/BUILD/qemu-kvm-devel-87/linux-user/elfload.c:220: error: conflicting types for 'elf_gregset_t'
081ecc8
  /usr/include/asm/elf.h:124: note: previous declaration of 'elf_gregset_t' was here
081ecc8
  In file included from /builddir/build/BUILD/qemu-kvm-devel-87/linux-user/elfload.c:697:
081ecc8
  ../elf.h:457:1: warning: "R_PPC_NUM" redefined
081ecc8
  In file included from /usr/include/asm/sigcontext.h:13,
081ecc8
                   from /usr/include/bits/sigcontext.h:28,
081ecc8
                   from /usr/include/signal.h:339,
081ecc8
                   from /builddir/build/BUILD/qemu-kvm-devel-87/linux-user/qemu.h:4,
081ecc8
                   from /builddir/build/BUILD/qemu-kvm-devel-87/linux-user/elfload.c:16:
081ecc8
  /usr/include/asm/elf.h:81:1: warning: this is the location of the previous definition
081ecc8
081ecc8
Problem seems to be that signal.h is pulling in a bunch of ppc
081ecc8
headers which expose elf_greg_t, R_PPC_* and PPC_FEATURE_*.
081ecc8
081ecc8
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
6614511
Fedora-patch: qemu-fix-linux-user-build-on-ppc.patch
081ecc8
---
081ecc8
 elf.h                |    2 ++
081ecc8
 linux-user/elfload.c |   10 ++++++++++
081ecc8
 2 files changed, 12 insertions(+), 0 deletions(-)
081ecc8
081ecc8
diff --git a/elf.h b/elf.h
081ecc8
index b042002..14f8aa1 100644
081ecc8
--- a/elf.h
081ecc8
+++ b/elf.h
081ecc8
@@ -454,7 +454,9 @@ typedef struct {
081ecc8
 #define R_PPC_SECTOFF_HI	35
081ecc8
 #define R_PPC_SECTOFF_HA	36
081ecc8
 /* Keep this the last entry.  */
081ecc8
+#ifndef R_PPC_NUM
081ecc8
 #define R_PPC_NUM		37
081ecc8
+#endif /* R_PPC_NUM */
081ecc8
 
081ecc8
 /* ARM specific declarations */
081ecc8
 
081ecc8
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
6780ef8
index 3a8268b..d283f73 100644
081ecc8
--- a/linux-user/elfload.c
081ecc8
+++ b/linux-user/elfload.c
081ecc8
@@ -134,6 +134,7 @@ static inline void init_thread(struct target_pt_regs *regs, struct image_info *i
081ecc8
     regs->rip = infop->entry;
081ecc8
 }
081ecc8
 
081ecc8
+#ifdef FIX_BROKEN_PPC_BUILD
081ecc8
 typedef target_ulong    elf_greg_t;
081ecc8
 typedef uint32_t        target_uid_t;
081ecc8
 typedef uint32_t        target_gid_t;
081ecc8
@@ -179,6 +180,7 @@ static void elf_core_copy_regs(elf_gregset_t *regs, const CPUState *env)
081ecc8
     (*regs)[25] = env->segs[R_FS].selector & 0xffff;
081ecc8
     (*regs)[26] = env->segs[R_GS].selector & 0xffff;
081ecc8
 }
081ecc8
+#endif /* FIX_BROKEN_PPC_BUILD */
081ecc8
 
081ecc8
 #else
081ecc8
 
081ecc8
@@ -211,6 +213,7 @@ static inline void init_thread(struct target_pt_regs *regs, struct image_info *i
081ecc8
     regs->edx = 0;
081ecc8
 }
081ecc8
 
081ecc8
+#ifdef FIX_BROKEN_PPC_BUILD
081ecc8
 typedef target_ulong    elf_greg_t;
081ecc8
 typedef uint16_t        target_uid_t;
081ecc8
 typedef uint16_t        target_gid_t;
081ecc8
@@ -246,9 +249,12 @@ static void elf_core_copy_regs(elf_gregset_t *regs, const CPUState *env)
081ecc8
     (*regs)[15] = env->regs[R_ESP];
081ecc8
     (*regs)[16] = env->segs[R_SS].selector & 0xffff;
081ecc8
 }
081ecc8
+#endif /* FIX_BROKEN_PPC_BUILD */
081ecc8
 #endif
081ecc8
 
081ecc8
+#ifdef FIX_BROKEN_PPC_BUILD
081ecc8
 #define USE_ELF_CORE_DUMP
081ecc8
+#endif /* FIX_BROKEN_PPC_BUILD */
081ecc8
 #define ELF_EXEC_PAGESIZE	4096
081ecc8
 
081ecc8
 #endif
081ecc8
@@ -286,6 +292,7 @@ static inline void init_thread(struct target_pt_regs *regs, struct image_info *i
081ecc8
     regs->ARM_r10 = infop->start_data;
081ecc8
 }
081ecc8
 
081ecc8
+#ifdef FIX_BROKEN_PPC_BUILD
081ecc8
 typedef uint32_t elf_greg_t;
081ecc8
 typedef uint16_t target_uid_t;
081ecc8
 typedef uint16_t target_gid_t;
081ecc8
@@ -318,6 +325,7 @@ static void elf_core_copy_regs(elf_gregset_t *regs, const CPUState *env)
081ecc8
 }
081ecc8
 
081ecc8
 #define USE_ELF_CORE_DUMP
081ecc8
+#endif /* FIX_BROKEN_PPC_BUILD */
081ecc8
 #define ELF_EXEC_PAGESIZE	4096
081ecc8
 
081ecc8
 enum
081ecc8
@@ -421,6 +429,7 @@ static inline void init_thread(struct target_pt_regs *regs, struct image_info *i
081ecc8
 
081ecc8
 /* Feature masks for the Aux Vector Hardware Capabilities (AT_HWCAP).
081ecc8
    See arch/powerpc/include/asm/cputable.h.  */
081ecc8
+#ifndef PPC_FEATURE_32
081ecc8
 enum {
081ecc8
     PPC_FEATURE_32 = 0x80000000,
081ecc8
     PPC_FEATURE_64 = 0x40000000,
081ecc8
@@ -452,6 +461,7 @@ enum {
081ecc8
     PPC_FEATURE_TRUE_LE = 0x00000002,
081ecc8
     PPC_FEATURE_PPC_LE = 0x00000001,
081ecc8
 };
081ecc8
+#endif /* !defined(PPC_FEATURE_32) */
081ecc8
 
081ecc8
 #define ELF_HWCAP get_elf_hwcap()
081ecc8
 
081ecc8
-- 
a4e9458
1.6.2.5
081ecc8