Pass in CPUState. Since this was the only instance of ELF_BASE_PLATFORM,
go ahead provide a weak fallback for all other targets.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
linux-user/loader.h | 1 +
linux-user/elfload.c | 42 ++++++---------------------------------
linux-user/mips/elfload.c | 30 ++++++++++++++++++++++++++++
3 files changed, 37 insertions(+), 36 deletions(-)
diff --git a/linux-user/loader.h b/linux-user/loader.h
index 1cc505832b..a5eef18eff 100644
--- a/linux-user/loader.h
+++ b/linux-user/loader.h
@@ -103,5 +103,6 @@ abi_ulong get_elf_hwcap2(CPUState *cs);
const char *elf_hwcap_str(uint32_t bit);
const char *elf_hwcap2_str(uint32_t bit);
const char *get_elf_platform(CPUState *cs);
+const char *get_elf_base_platform(CPUState *cs);
#endif /* LINUX_USER_LOADER_H */
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 7e218e8cec..b26daf925d 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -685,37 +685,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,
#define elf_check_abi(x) (!((x) & EF_MIPS_ABI2))
#endif
-#define ELF_BASE_PLATFORM get_elf_base_platform()
-
-#define MATCH_PLATFORM_INSN(_flags, _base_platform) \
- do { if ((cpu->env.insn_flags & (_flags)) == _flags) \
- { return _base_platform; } } while (0)
-
-static const char *get_elf_base_platform(void)
-{
- MIPSCPU *cpu = MIPS_CPU(thread_cpu);
-
- /* 64 bit ISAs goes first */
- MATCH_PLATFORM_INSN(CPU_MIPS64R6, "mips64r6");
- MATCH_PLATFORM_INSN(CPU_MIPS64R5, "mips64r5");
- MATCH_PLATFORM_INSN(CPU_MIPS64R2, "mips64r2");
- MATCH_PLATFORM_INSN(CPU_MIPS64R1, "mips64");
- MATCH_PLATFORM_INSN(CPU_MIPS5, "mips5");
- MATCH_PLATFORM_INSN(CPU_MIPS4, "mips4");
- MATCH_PLATFORM_INSN(CPU_MIPS3, "mips3");
-
- /* 32 bit ISAs */
- MATCH_PLATFORM_INSN(CPU_MIPS32R6, "mips32r6");
- MATCH_PLATFORM_INSN(CPU_MIPS32R5, "mips32r5");
- MATCH_PLATFORM_INSN(CPU_MIPS32R2, "mips32r2");
- MATCH_PLATFORM_INSN(CPU_MIPS32R1, "mips32");
- MATCH_PLATFORM_INSN(CPU_MIPS2, "mips2");
-
- /* Fallback */
- return "mips";
-}
-#undef MATCH_PLATFORM_INSN
-
static inline void init_thread(struct target_pt_regs *regs,
struct image_info *infop)
{
@@ -1175,10 +1144,6 @@ static inline void init_thread(struct target_pt_regs *regs,
#endif /* TARGET_HEXAGON */
-#ifndef ELF_BASE_PLATFORM
-#define ELF_BASE_PLATFORM (NULL)
-#endif
-
#ifndef ELF_MACHINE
#define ELF_MACHINE ELF_ARCH
#endif
@@ -1234,6 +1199,11 @@ const char * __attribute__((weak)) get_elf_platform(CPUState *cs)
return NULL;
}
+const char * __attribute__((weak)) get_elf_base_platform(CPUState *cs)
+{
+ return NULL;
+}
+
#include "elf.h"
/* We must delay the following stanzas until after "elf.h". */
@@ -1687,7 +1657,7 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
}
u_base_platform = 0;
- k_base_platform = ELF_BASE_PLATFORM;
+ k_base_platform = get_elf_base_platform(thread_cpu);
if (k_base_platform) {
size_t len = strlen(k_base_platform) + 1;
if (STACK_GROWS_DOWN) {
diff --git a/linux-user/mips/elfload.c b/linux-user/mips/elfload.c
index 07c30b5f4c..f2b132697e 100644
--- a/linux-user/mips/elfload.c
+++ b/linux-user/mips/elfload.c
@@ -54,3 +54,33 @@ abi_ulong get_elf_hwcap(CPUState *cs)
#undef GET_FEATURE_REG_EQU
#undef GET_FEATURE_REG_SET
#undef GET_FEATURE_INSN
+
+#define MATCH_PLATFORM_INSN(_flags, _base_platform) \
+ do { if ((cpu->env.insn_flags & (_flags)) == _flags) \
+ { return _base_platform; } } while (0)
+
+const char *get_elf_base_platform(CPUState *cs)
+{
+ MIPSCPU *cpu = MIPS_CPU(cs);
+
+ /* 64 bit ISAs goes first */
+ MATCH_PLATFORM_INSN(CPU_MIPS64R6, "mips64r6");
+ MATCH_PLATFORM_INSN(CPU_MIPS64R5, "mips64r5");
+ MATCH_PLATFORM_INSN(CPU_MIPS64R2, "mips64r2");
+ MATCH_PLATFORM_INSN(CPU_MIPS64R1, "mips64");
+ MATCH_PLATFORM_INSN(CPU_MIPS5, "mips5");
+ MATCH_PLATFORM_INSN(CPU_MIPS4, "mips4");
+ MATCH_PLATFORM_INSN(CPU_MIPS3, "mips3");
+
+ /* 32 bit ISAs */
+ MATCH_PLATFORM_INSN(CPU_MIPS32R6, "mips32r6");
+ MATCH_PLATFORM_INSN(CPU_MIPS32R5, "mips32r5");
+ MATCH_PLATFORM_INSN(CPU_MIPS32R2, "mips32r2");
+ MATCH_PLATFORM_INSN(CPU_MIPS32R1, "mips32");
+ MATCH_PLATFORM_INSN(CPU_MIPS2, "mips2");
+
+ /* Fallback */
+ return "mips";
+}
+
+#undef MATCH_PLATFORM_INSN
--
2.43.0