From patchwork Tue Jan 16 22:22:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 861920 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zLl9M5vm2z9s7v for ; Wed, 17 Jan 2018 09:23:19 +1100 (AEDT) Received: from localhost ([::1]:41295 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebZdV-0004rv-Tp for incoming@patchwork.ozlabs.org; Tue, 16 Jan 2018 17:23:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41683) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebZcr-0004p6-4Z for qemu-devel@nongnu.org; Tue, 16 Jan 2018 17:22:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ebZcn-0003NH-V0 for qemu-devel@nongnu.org; Tue, 16 Jan 2018 17:22:37 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:54094) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ebZcn-0003MJ-Hy for qemu-devel@nongnu.org; Tue, 16 Jan 2018 17:22:33 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue005 [212.227.15.167]) with ESMTPSA (Nemesis) id 0LgcCX-1fER5A2Ux3-00o0dA; Tue, 16 Jan 2018 23:22:18 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Tue, 16 Jan 2018 23:22:09 +0100 Message-Id: <20180116222212.1266-2-laurent@vivier.eu> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180116222212.1266-1-laurent@vivier.eu> References: <20180116222212.1266-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K0:cvgjkBtcqhaPYmcMunT+XWCLOXNVuYsPUBSwhhZKT6rbV6labr9 /1zAjD2Eunl4rrTHlopA27ZdLTf1CnWFwgziH56lmvvBK6CNmZ0wRKrTyCvY8XtOZMAUHn/ QlPCIJDqtAJusTcS7m2thXtq/KQktulGGaokXA0U64RrF9XtU2Qur5qjBHXzxYTD2tzjmCn D9yAP1nzLj47KWFw/5UYw== X-UI-Out-Filterresults: notjunk:1; V01:K0:MLsUhGyRNVk=:GhoyhhUS/FERnDTP9Oh4/0 T0xkZECMv/y5GrfHoLZRkNzs9wGToXWpFKeZvWjjHVrn8+m25W1z6GB28uhwE00Wkx0HNv72Y YQBl+nOsMTKnDeSrsrVlrbVXGOpx6lD35QYPZ1vzV+lK67NIArtPb6+wJGwH3Vmc+PjO57eo5 Cl2Qa0djryDNsO1Gp5T4BJ1ZfI+FqvIct1OuW7szqTOBrPXzT9EK8ZH9koBiFCwiJzlms9zCn 6ALotfaW82ihXQC69Ucne2AvZPfzH6EDFfr12aopbYH5GcLLjcbp9Ouy3R71UMHQYEb120ZAU AIfLlSu5cZNXv/uzlrvsriQPweQl2Gn0YqkzGAFrpkHi6IZQMcX0dura6OkCJfQ6U73fRyL3a tcSuO/PQSb5vUjJC0ykCxOB9gxtlvyJLw9S4VOL4JY/wN3rMxyQvq3/suXohQDqruHHP8FTnW hCh+X+Rt5gpDBvQcy1qBNt4ezlcB/DQpj6lejQNdctBfP0nIkJjnHXzCqUpyrJGh285bHiepN mt3svrVq4BDWTT0ef3BqH4sNSm9Om2kwmF/qXVOvMwn05b9eMWUOf1F2SeCwUsv7FFmQGrRk9 f5z62Lzd6MhkhNdKxUx/6WQxEenRtYsCUZseGkbJk76sjJ8GNxVN//KuEb2Eqa0/27fTrtKGc ELdfQSlT0cdoWIpxNtB/f5uw8XarB1+Wm8lYfSd+gqp7f68EpCaZS8bQKwCR0KQYoY+N/ts2E Ba6ZJ9bQU1k2BDJobP0mEhLZzg6IeBAbgiQM9z+LuEHLJrtcdHszEmCVhVM= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.126.134 Subject: [Qemu-devel] [PATCH v3 1/4] linux-user: Move CPU type name selection to a function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , YunQiang Su , Riku Voipio , Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Laurent Vivier , Aaron Sierra Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 Signed-off-by: Laurent Vivier Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- Notes: v3: change "#if ... #endif" structure for ppc v2: new patch in the series linux-user/aarch64/target_elf.h | 14 +++++++++++++ linux-user/alpha/target_elf.h | 14 +++++++++++++ linux-user/arm/target_elf.h | 14 +++++++++++++ linux-user/cris/target_elf.h | 14 +++++++++++++ linux-user/hppa/target_elf.h | 14 +++++++++++++ linux-user/i386/target_elf.h | 14 +++++++++++++ linux-user/m68k/target_elf.h | 14 +++++++++++++ linux-user/main.c | 41 ++------------------------------------ linux-user/microblaze/target_elf.h | 14 +++++++++++++ linux-user/mips/target_elf.h | 14 +++++++++++++ linux-user/mips64/target_elf.h | 14 +++++++++++++ linux-user/nios2/target_elf.h | 14 +++++++++++++ linux-user/openrisc/target_elf.h | 14 +++++++++++++ linux-user/ppc/target_elf.h | 18 +++++++++++++++++ linux-user/s390x/target_elf.h | 14 +++++++++++++ linux-user/sh4/target_elf.h | 14 +++++++++++++ linux-user/sparc/target_elf.h | 14 +++++++++++++ linux-user/sparc64/target_elf.h | 14 +++++++++++++ linux-user/tilegx/target_elf.h | 14 +++++++++++++ linux-user/unicore32/target_elf.h | 14 +++++++++++++ linux-user/x86_64/target_elf.h | 14 +++++++++++++ 21 files changed, 286 insertions(+), 39 deletions(-) create mode 100644 linux-user/aarch64/target_elf.h create mode 100644 linux-user/alpha/target_elf.h create mode 100644 linux-user/arm/target_elf.h create mode 100644 linux-user/cris/target_elf.h create mode 100644 linux-user/hppa/target_elf.h create mode 100644 linux-user/i386/target_elf.h create mode 100644 linux-user/m68k/target_elf.h create mode 100644 linux-user/microblaze/target_elf.h create mode 100644 linux-user/mips/target_elf.h create mode 100644 linux-user/mips64/target_elf.h create mode 100644 linux-user/nios2/target_elf.h create mode 100644 linux-user/openrisc/target_elf.h create mode 100644 linux-user/ppc/target_elf.h create mode 100644 linux-user/s390x/target_elf.h create mode 100644 linux-user/sh4/target_elf.h create mode 100644 linux-user/sparc/target_elf.h create mode 100644 linux-user/sparc64/target_elf.h create mode 100644 linux-user/tilegx/target_elf.h create mode 100644 linux-user/unicore32/target_elf.h create mode 100644 linux-user/x86_64/target_elf.h diff --git a/linux-user/aarch64/target_elf.h b/linux-user/aarch64/target_elf.h new file mode 100644 index 0000000000..a7eb962fba --- /dev/null +++ b/linux-user/aarch64/target_elf.h @@ -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 index 0000000000..344e9f4d39 --- /dev/null +++ b/linux-user/alpha/target_elf.h @@ -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 index 0000000000..58ff6a0986 --- /dev/null +++ b/linux-user/arm/target_elf.h @@ -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 index 0000000000..99eb4ec704 --- /dev/null +++ b/linux-user/cris/target_elf.h @@ -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 index 0000000000..82b4e9535e --- /dev/null +++ b/linux-user/hppa/target_elf.h @@ -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 index 0000000000..1c6142e7da --- /dev/null +++ b/linux-user/i386/target_elf.h @@ -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 index 0000000000..df375ad5d3 --- /dev/null +++ b/linux-user/m68k/target_elf.h @@ -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 diff --git a/linux-user/main.c b/linux-user/main.c index 450eb3ce65..3954e8996b 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -35,6 +35,7 @@ #include "elf.h" #include "exec/log.h" #include "trace/control.h" +#include "target_elf.h" char *exec_path; @@ -4319,45 +4320,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 index 0000000000..8a8f1debff --- /dev/null +++ b/linux-user/microblaze/target_elf.h @@ -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 index 0000000000..bed0b43259 --- /dev/null +++ b/linux-user/mips/target_elf.h @@ -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 index 0000000000..5b6f4692e0 --- /dev/null +++ b/linux-user/mips64/target_elf.h @@ -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 index 0000000000..801e20afaf --- /dev/null +++ b/linux-user/nios2/target_elf.h @@ -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 index 0000000000..40ceb025c9 --- /dev/null +++ b/linux-user/openrisc/target_elf.h @@ -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 index 0000000000..576a5b9959 --- /dev/null +++ b/linux-user/ppc/target_elf.h @@ -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 index 0000000000..8114b59c1d --- /dev/null +++ b/linux-user/s390x/target_elf.h @@ -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 index 0000000000..f485e0cef2 --- /dev/null +++ b/linux-user/sh4/target_elf.h @@ -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 index 0000000000..31d508c0df --- /dev/null +++ b/linux-user/sparc/target_elf.h @@ -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 SPARC_TARGET_ELF_H +#define SPARC_TARGET_ELF_H +static inline const char *cpu_get_model(uint32_t eflags) +{ + return "Fujitsu MB86904"; +} +#endif diff --git a/linux-user/sparc64/target_elf.h b/linux-user/sparc64/target_elf.h new file mode 100644 index 0000000000..d6e388f1cf --- /dev/null +++ b/linux-user/sparc64/target_elf.h @@ -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 index 0000000000..7197bb0005 --- /dev/null +++ b/linux-user/tilegx/target_elf.h @@ -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 index 0000000000..e2bfcb2ca3 --- /dev/null +++ b/linux-user/unicore32/target_elf.h @@ -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 index 0000000000..7b76a90de8 --- /dev/null +++ b/linux-user/x86_64/target_elf.h @@ -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