Move elf_core_copy_regs to elfload.c.
Move ELF_NREG to target_elf.h.

Signed-off-by: Richard Henderson <richard.hender...@linaro.org>
---
 linux-user/mips/target_elf.h   |  3 +++
 linux-user/mips64/target_elf.h |  3 +++
 linux-user/elfload.c           | 44 ----------------------------------
 linux-user/mips/elfload.c      | 41 +++++++++++++++++++++++++++++++
 4 files changed, 47 insertions(+), 44 deletions(-)

diff --git a/linux-user/mips/target_elf.h b/linux-user/mips/target_elf.h
index 08e699c085..a36ca5a83f 100644
--- a/linux-user/mips/target_elf.h
+++ b/linux-user/mips/target_elf.h
@@ -11,4 +11,7 @@
 #define HAVE_ELF_HWCAP          1
 #define HAVE_ELF_BASE_PLATFORM  1
 
+/* See linux kernel: arch/mips/include/asm/elf.h.  */
+#define ELF_NREG                45
+
 #endif
diff --git a/linux-user/mips64/target_elf.h b/linux-user/mips64/target_elf.h
index 24bb7fcd3f..ebfd62348f 100644
--- a/linux-user/mips64/target_elf.h
+++ b/linux-user/mips64/target_elf.h
@@ -11,4 +11,7 @@
 #define HAVE_ELF_HWCAP          1
 #define HAVE_ELF_BASE_PLATFORM  1
 
+/* See linux kernel: arch/mips/include/asm/elf.h.  */
+#define ELF_NREG                45
+
 #endif
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 834120c9f2..e5833ec3b4 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -395,50 +395,6 @@ static const VdsoImageInfo *vdso_image_info(uint32_t 
elf_flags)
 #define elf_check_abi(x) (!((x) & EF_MIPS_ABI2))
 #endif
 
-/* See linux kernel: arch/mips/include/asm/elf.h.  */
-#define ELF_NREG 45
-
-/* See linux kernel: arch/mips/include/asm/reg.h.  */
-enum {
-#ifdef TARGET_MIPS64
-    TARGET_EF_R0 = 0,
-#else
-    TARGET_EF_R0 = 6,
-#endif
-    TARGET_EF_R26 = TARGET_EF_R0 + 26,
-    TARGET_EF_R27 = TARGET_EF_R0 + 27,
-    TARGET_EF_LO = TARGET_EF_R0 + 32,
-    TARGET_EF_HI = TARGET_EF_R0 + 33,
-    TARGET_EF_CP0_EPC = TARGET_EF_R0 + 34,
-    TARGET_EF_CP0_BADVADDR = TARGET_EF_R0 + 35,
-    TARGET_EF_CP0_STATUS = TARGET_EF_R0 + 36,
-    TARGET_EF_CP0_CAUSE = TARGET_EF_R0 + 37
-};
-
-/* See linux kernel: arch/mips/kernel/process.c:elf_dump_regs.  */
-void elf_core_copy_regs(target_ulong *regs, const CPUMIPSState *env)
-{
-    int i;
-
-    for (i = 0; i < TARGET_EF_R0; i++) {
-        regs[i] = 0;
-    }
-    regs[TARGET_EF_R0] = 0;
-
-    for (i = 1; i < ARRAY_SIZE(env->active_tc.gpr); i++) {
-        regs[TARGET_EF_R0 + i] = tswapl(env->active_tc.gpr[i]);
-    }
-
-    regs[TARGET_EF_R26] = 0;
-    regs[TARGET_EF_R27] = 0;
-    regs[TARGET_EF_LO] = tswapl(env->active_tc.LO[0]);
-    regs[TARGET_EF_HI] = tswapl(env->active_tc.HI[0]);
-    regs[TARGET_EF_CP0_EPC] = tswapl(env->active_tc.PC);
-    regs[TARGET_EF_CP0_BADVADDR] = tswapl(env->CP0_BadVAddr);
-    regs[TARGET_EF_CP0_STATUS] = tswapl(env->CP0_Status);
-    regs[TARGET_EF_CP0_CAUSE] = tswapl(env->CP0_Cause);
-}
-
 #define ELF_EXEC_PAGESIZE        4096
 
 #endif /* TARGET_MIPS */
diff --git a/linux-user/mips/elfload.c b/linux-user/mips/elfload.c
index c353ccc1ad..b54e0d8d1c 100644
--- a/linux-user/mips/elfload.c
+++ b/linux-user/mips/elfload.c
@@ -122,3 +122,44 @@ const char *get_elf_base_platform(CPUState *cs)
 }
 
 #undef MATCH_PLATFORM_INSN
+
+/* See linux kernel: arch/mips/include/asm/reg.h.  */
+enum {
+#ifdef TARGET_MIPS64
+    TARGET_EF_R0 = 0,
+#else
+    TARGET_EF_R0 = 6,
+#endif
+    TARGET_EF_R26 = TARGET_EF_R0 + 26,
+    TARGET_EF_R27 = TARGET_EF_R0 + 27,
+    TARGET_EF_LO = TARGET_EF_R0 + 32,
+    TARGET_EF_HI = TARGET_EF_R0 + 33,
+    TARGET_EF_CP0_EPC = TARGET_EF_R0 + 34,
+    TARGET_EF_CP0_BADVADDR = TARGET_EF_R0 + 35,
+    TARGET_EF_CP0_STATUS = TARGET_EF_R0 + 36,
+    TARGET_EF_CP0_CAUSE = TARGET_EF_R0 + 37
+};
+
+/* See linux kernel: arch/mips/kernel/process.c:elf_dump_regs.  */
+void elf_core_copy_regs(target_ulong *regs, const CPUMIPSState *env)
+{
+    int i;
+
+    for (i = 0; i < TARGET_EF_R0; i++) {
+        regs[i] = 0;
+    }
+    regs[TARGET_EF_R0] = 0;
+
+    for (i = 1; i < ARRAY_SIZE(env->active_tc.gpr); i++) {
+        regs[TARGET_EF_R0 + i] = tswapl(env->active_tc.gpr[i]);
+    }
+
+    regs[TARGET_EF_R26] = 0;
+    regs[TARGET_EF_R27] = 0;
+    regs[TARGET_EF_LO] = tswapl(env->active_tc.LO[0]);
+    regs[TARGET_EF_HI] = tswapl(env->active_tc.HI[0]);
+    regs[TARGET_EF_CP0_EPC] = tswapl(env->active_tc.PC);
+    regs[TARGET_EF_CP0_BADVADDR] = tswapl(env->CP0_BadVAddr);
+    regs[TARGET_EF_CP0_STATUS] = tswapl(env->CP0_Status);
+    regs[TARGET_EF_CP0_CAUSE] = tswapl(env->CP0_Cause);
+}
-- 
2.43.0


Reply via email to