]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
linux-user: Move CPU type name selection to a function
authorLaurent Vivier <laurent@vivier.eu>
Tue, 20 Feb 2018 17:33:04 +0000 (18:33 +0100)
committerLaurent Vivier <laurent@vivier.eu>
Sun, 25 Feb 2018 16:27:41 +0000 (17:27 +0100)
Instead of a sequence of "#if ... #endif" move the
selection to a function in linux-user/*/target_elf.h

We can't add them in linux-user/*/target_cpu.h
because we will need to include "elf.h" to
use ELF flags with eflags, and including
"elf.h" in "target_cpu.h" introduces some
conflicts in elfload.c

Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20180220173307.25125-2-laurent@vivier.eu>

21 files changed:
linux-user/aarch64/target_elf.h [new file with mode: 0644]
linux-user/alpha/target_elf.h [new file with mode: 0644]
linux-user/arm/target_elf.h [new file with mode: 0644]
linux-user/cris/target_elf.h [new file with mode: 0644]
linux-user/hppa/target_elf.h [new file with mode: 0644]
linux-user/i386/target_elf.h [new file with mode: 0644]
linux-user/m68k/target_elf.h [new file with mode: 0644]
linux-user/main.c
linux-user/microblaze/target_elf.h [new file with mode: 0644]
linux-user/mips/target_elf.h [new file with mode: 0644]
linux-user/mips64/target_elf.h [new file with mode: 0644]
linux-user/nios2/target_elf.h [new file with mode: 0644]
linux-user/openrisc/target_elf.h [new file with mode: 0644]
linux-user/ppc/target_elf.h [new file with mode: 0644]
linux-user/s390x/target_elf.h [new file with mode: 0644]
linux-user/sh4/target_elf.h [new file with mode: 0644]
linux-user/sparc/target_elf.h [new file with mode: 0644]
linux-user/sparc64/target_elf.h [new file with mode: 0644]
linux-user/tilegx/target_elf.h [new file with mode: 0644]
linux-user/unicore32/target_elf.h [new file with mode: 0644]
linux-user/x86_64/target_elf.h [new file with mode: 0644]

diff --git a/linux-user/aarch64/target_elf.h b/linux-user/aarch64/target_elf.h
new file mode 100644 (file)
index 0000000..a7eb962
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation, or (at your option) any
+ * later version. See the COPYING file in the top-level directory.
+ */
+
+#ifndef AARCH64_TARGET_ELF_H
+#define AARCH64_TARGET_ELF_H
+static inline const char *cpu_get_model(uint32_t eflags)
+{
+    return "any";
+}
+#endif
diff --git a/linux-user/alpha/target_elf.h b/linux-user/alpha/target_elf.h
new file mode 100644 (file)
index 0000000..344e9f4
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation, or (at your option) any
+ * later version. See the COPYING file in the top-level directory.
+ */
+
+#ifndef ALPHA_TARGET_ELF_H
+#define ALPHA_TARGET_ELF_H
+static inline const char *cpu_get_model(uint32_t eflags)
+{
+    return "any";
+}
+#endif
diff --git a/linux-user/arm/target_elf.h b/linux-user/arm/target_elf.h
new file mode 100644 (file)
index 0000000..58ff6a0
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation, or (at your option) any
+ * later version. See the COPYING file in the top-level directory.
+ */
+
+#ifndef ARM_TARGET_ELF_H
+#define ARM_TARGET_ELF_H
+static inline const char *cpu_get_model(uint32_t eflags)
+{
+    return "any";
+}
+#endif
diff --git a/linux-user/cris/target_elf.h b/linux-user/cris/target_elf.h
new file mode 100644 (file)
index 0000000..99eb4ec
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation, or (at your option) any
+ * later version. See the COPYING file in the top-level directory.
+ */
+
+#ifndef CRIS_TARGET_ELF_H
+#define CRIS_TARGET_ELF_H
+static inline const char *cpu_get_model(uint32_t eflags)
+{
+    return "any";
+}
+#endif
diff --git a/linux-user/hppa/target_elf.h b/linux-user/hppa/target_elf.h
new file mode 100644 (file)
index 0000000..82b4e95
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation, or (at your option) any
+ * later version. See the COPYING file in the top-level directory.
+ */
+
+#ifndef HPPA_TARGET_ELF_H
+#define HPPA_TARGET_ELF_H
+static inline const char *cpu_get_model(uint32_t eflags)
+{
+    return "any";
+}
+#endif
diff --git a/linux-user/i386/target_elf.h b/linux-user/i386/target_elf.h
new file mode 100644 (file)
index 0000000..1c6142e
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation, or (at your option) any
+ * later version. See the COPYING file in the top-level directory.
+ */
+
+#ifndef I386_TARGET_ELF_H
+#define I386_TARGET_ELF_H
+static inline const char *cpu_get_model(uint32_t eflags)
+{
+    return "qemu32";
+}
+#endif
diff --git a/linux-user/m68k/target_elf.h b/linux-user/m68k/target_elf.h
new file mode 100644 (file)
index 0000000..df375ad
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation, or (at your option) any
+ * later version. See the COPYING file in the top-level directory.
+ */
+
+#ifndef M68K_TARGET_ELF_H
+#define M68K_TARGET_ELF_H
+static inline const char *cpu_get_model(uint32_t eflags)
+{
+    return "any";
+}
+#endif
index fd7900628b844b0176a54692494ba46d6ebaa7c1..079b98235bd111ea613c755895a251f8d99ddde9 100644 (file)
@@ -35,6 +35,7 @@
 #include "elf.h"
 #include "exec/log.h"
 #include "trace/control.h"
+#include "target_elf.h"
 
 char *exec_path;
 
@@ -4344,45 +4345,7 @@ int main(int argc, char **argv, char **envp)
     init_qemu_uname_release();
 
     if (cpu_model == NULL) {
-#if defined(TARGET_I386)
-#ifdef TARGET_X86_64
-        cpu_model = "qemu64";
-#else
-        cpu_model = "qemu32";
-#endif
-#elif defined(TARGET_ARM)
-        cpu_model = "any";
-#elif defined(TARGET_UNICORE32)
-        cpu_model = "any";
-#elif defined(TARGET_M68K)
-        cpu_model = "any";
-#elif defined(TARGET_SPARC)
-#ifdef TARGET_SPARC64
-        cpu_model = "TI UltraSparc II";
-#else
-        cpu_model = "Fujitsu MB86904";
-#endif
-#elif defined(TARGET_MIPS)
-#if defined(TARGET_ABI_MIPSN32) || defined(TARGET_ABI_MIPSN64)
-        cpu_model = "5KEf";
-#else
-        cpu_model = "24Kf";
-#endif
-#elif defined TARGET_OPENRISC
-        cpu_model = "or1200";
-#elif defined(TARGET_PPC)
-# ifdef TARGET_PPC64
-        cpu_model = "POWER8";
-# else
-        cpu_model = "750";
-# endif
-#elif defined TARGET_SH4
-        cpu_model = "sh7785";
-#elif defined TARGET_S390X
-        cpu_model = "qemu";
-#else
-        cpu_model = "any";
-#endif
+        cpu_model = cpu_get_model(0);
     }
     tcg_exec_init(0);
     /* NOTE: we need to init the CPU at this stage to get
diff --git a/linux-user/microblaze/target_elf.h b/linux-user/microblaze/target_elf.h
new file mode 100644 (file)
index 0000000..8a8f1de
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation, or (at your option) any
+ * later version. See the COPYING file in the top-level directory.
+ */
+
+#ifndef MICROBLAZE_TARGET_ELF_H
+#define MICROBLAZE_TARGET_ELF_H
+static inline const char *cpu_get_model(uint32_t eflags)
+{
+    return "any";
+}
+#endif
diff --git a/linux-user/mips/target_elf.h b/linux-user/mips/target_elf.h
new file mode 100644 (file)
index 0000000..bed0b43
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation, or (at your option) any
+ * later version. See the COPYING file in the top-level directory.
+ */
+
+#ifndef MIPS_TARGET_ELF_H
+#define MIPS_TARGET_ELF_H
+static inline const char *cpu_get_model(uint32_t eflags)
+{
+    return "24Kf";
+}
+#endif
diff --git a/linux-user/mips64/target_elf.h b/linux-user/mips64/target_elf.h
new file mode 100644 (file)
index 0000000..5b6f469
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation, or (at your option) any
+ * later version. See the COPYING file in the top-level directory.
+ */
+
+#ifndef MIPS64_TARGET_ELF_H
+#define MIPS64_TARGET_ELF_H
+static inline const char *cpu_get_model(uint32_t eflags)
+{
+    return "5KEf";
+}
+#endif
diff --git a/linux-user/nios2/target_elf.h b/linux-user/nios2/target_elf.h
new file mode 100644 (file)
index 0000000..801e20a
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation, or (at your option) any
+ * later version. See the COPYING file in the top-level directory.
+ */
+
+#ifndef NIOS2_TARGET_ELF_H
+#define NIOS2_TARGET_ELF_H
+static inline const char *cpu_get_model(uint32_t eflags)
+{
+    return "any";
+}
+#endif
diff --git a/linux-user/openrisc/target_elf.h b/linux-user/openrisc/target_elf.h
new file mode 100644 (file)
index 0000000..40ceb02
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation, or (at your option) any
+ * later version. See the COPYING file in the top-level directory.
+ */
+
+#ifndef OPENRISC_TARGET_ELF_H
+#define OPENRISC_TARGET_ELF_H
+static inline const char *cpu_get_model(uint32_t eflags)
+{
+    return "or1200";
+}
+#endif
diff --git a/linux-user/ppc/target_elf.h b/linux-user/ppc/target_elf.h
new file mode 100644 (file)
index 0000000..576a5b9
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation, or (at your option) any
+ * later version. See the COPYING file in the top-level directory.
+ */
+
+#ifndef PPC_TARGET_ELF_H
+#define PPC_TARGET_ELF_H
+static inline const char *cpu_get_model(uint32_t eflags)
+{
+#ifdef TARGET_PPC64
+    return "POWER8";
+#else
+    return "750";
+#endif
+}
+#endif
diff --git a/linux-user/s390x/target_elf.h b/linux-user/s390x/target_elf.h
new file mode 100644 (file)
index 0000000..8114b59
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation, or (at your option) any
+ * later version. See the COPYING file in the top-level directory.
+ */
+
+#ifndef S390X_TARGET_ELF_H
+#define S390X_TARGET_ELF_H
+static inline const char *cpu_get_model(uint32_t eflags)
+{
+    return "qemu";
+}
+#endif
diff --git a/linux-user/sh4/target_elf.h b/linux-user/sh4/target_elf.h
new file mode 100644 (file)
index 0000000..f485e0c
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation, or (at your option) any
+ * later version. See the COPYING file in the top-level directory.
+ */
+
+#ifndef SH4_TARGET_ELF_H
+#define SH4_TARGET_ELF_H
+static inline const char *cpu_get_model(uint32_t eflags)
+{
+    return "sh7785";
+}
+#endif
diff --git a/linux-user/sparc/target_elf.h b/linux-user/sparc/target_elf.h
new file mode 100644 (file)
index 0000000..a510ceb
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation, or (at your option) any
+ * later version. See the COPYING file in the top-level directory.
+ */
+
+#ifndef SPARC_TARGET_ELF_H
+#define SPARC_TARGET_ELF_H
+static inline const char *cpu_get_model(uint32_t eflags)
+{
+#ifdef TARGET_SPARC64
+    return "TI UltraSparc II";
+#else
+    return "Fujitsu MB86904";
+#endif
+}
+#endif
diff --git a/linux-user/sparc64/target_elf.h b/linux-user/sparc64/target_elf.h
new file mode 100644 (file)
index 0000000..d6e388f
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation, or (at your option) any
+ * later version. See the COPYING file in the top-level directory.
+ */
+
+#ifndef SPARC64_TARGET_ELF_H
+#define SPARC64_TARGET_ELF_H
+static inline const char *cpu_get_model(uint32_t eflags)
+{
+    return "TI UltraSparc II";
+}
+#endif
diff --git a/linux-user/tilegx/target_elf.h b/linux-user/tilegx/target_elf.h
new file mode 100644 (file)
index 0000000..7197bb0
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation, or (at your option) any
+ * later version. See the COPYING file in the top-level directory.
+ */
+
+#ifndef TILEGX_TARGET_ELF_H
+#define TILEGX_TARGET_ELF_H
+static inline const char *cpu_get_model(uint32_t eflags)
+{
+    return "any";
+}
+#endif
diff --git a/linux-user/unicore32/target_elf.h b/linux-user/unicore32/target_elf.h
new file mode 100644 (file)
index 0000000..e2bfcb2
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation, or (at your option) any
+ * later version. See the COPYING file in the top-level directory.
+ */
+
+#ifndef UNICORE32_TARGET_ELF_H
+#define UNICORE32_TARGET_ELF_H
+static inline const char *cpu_get_model(uint32_t eflags)
+{
+    return "any";
+}
+#endif
diff --git a/linux-user/x86_64/target_elf.h b/linux-user/x86_64/target_elf.h
new file mode 100644 (file)
index 0000000..7b76a90
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation, or (at your option) any
+ * later version. See the COPYING file in the top-level directory.
+ */
+
+#ifndef X86_64_TARGET_ELF_H
+#define X86_64_TARGET_ELF_H
+static inline const char *cpu_get_model(uint32_t eflags)
+{
+    return "qemu64";
+}
+#endif