From patchwork Thu May 3 21:38:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 908312 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=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu 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 40cT8Y4blDz9s4n for ; Fri, 4 May 2018 07:40:28 +1000 (AEST) Received: from localhost ([::1]:59200 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fELxg-0004jk-Mx for incoming@patchwork.ozlabs.org; Thu, 03 May 2018 17:40:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54814) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fELwo-0004jF-Bz for qemu-devel@nongnu.org; Thu, 03 May 2018 17:39:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fELwk-00055v-CZ for qemu-devel@nongnu.org; Thu, 03 May 2018 17:39:30 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:58883) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fELwk-000542-35 for qemu-devel@nongnu.org; Thu, 03 May 2018 17:39:26 -0400 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue105 [212.227.15.183]) with ESMTPSA (Nemesis) id 0Mdund-1ezsO23A5N-00PhwJ; Thu, 03 May 2018 23:39:12 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Thu, 3 May 2018 23:38:58 +0200 Message-Id: <20180503213903.30335-2-laurent@vivier.eu> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180503213903.30335-1-laurent@vivier.eu> References: <20180503213903.30335-1-laurent@vivier.eu> X-Provags-ID: V03:K1:87NQNua0dHp7eh3yi1/MBklG7Ft4P6KZzFrh+7KxpuTjbMidmPl AiIVfpXpy53Fh+06ZSPTLzG5YgDpVTpjpDFWBpBiN5eP1HpHbXHoZhd2b9nlx6OTwmPxrOJ IlZychUISu2tB9XoLy7BMuOWS8QMHeiFPid6cvxbnDqIWm+i7gPqzMH4hEZLtJmzxJzRbKh heiFNgvIzeIvybL+BmvAQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:bEuhkjQWoeo=:ZHeaB3H5yMpMZ5LNmOkFFF muwxj6VlcwFNYYywT+L2iHCFKOWiQGnyel/SfYfx8MaGDaaXNKX9masYhjYp0bWiiLpRF/LhS iYBC6ntnbYYS6/UV15ce9QdSAe1cRsC3BrvaGrAVje1Ukc9r6h9WmrhfYe6QY7sm+1TTviQTA AZJafCdO6obvXedibKoxSrT5OoUd5/KN3DyahawVC8xl0BjnjWZcTSgtkRSHxcTEqfbnVkR2i qTQYux1D0eh2eCvUvJo9SMt4OvafXfMPvBqBswlNvDo7uEcsg5out1TrnmnCH/kxyfLCn8U5X NZp6lOoQGiysisp5lNifU7MqqQ6tdgGZ8+Bu1i/7RXHFIB/kH/2tIE3V+ZYfmphXVE2Evue+D q6ZTKObmd3aEOBbJ/lBa+eoact9YkOZDfWinQ42PqV6XCQ/drsXIonWF85ClUfrwZ3N3nct06 Sradw7avZ2bNTJ68fbGl0UWdz89RdFJLlSpw4WcbRwV0uYObGFKkfxIDvw/GeX+HJ9ZSfBy32 kl9qH2u/LjZYcCWe0gdipzoJS4cXN5UlmLYSbUvllLUorZnTkZ5Kp6dYMjSr/jnPWV7OrZNJX M+G2w77g/eJHCzaivmP/JucmJIbma9B1tO1/3mMRfhBoyx2Kls9rjrEyNZN2McIFJGYVMpblR pnFpVRb8DCui1nTzUgEMa5c6Sbjk8oLaz+/LEhuiXPL0uDnKry2AiOaRXStDtRebBC7E= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.17.13 Subject: [Qemu-devel] [PULL 1/6] Remove CONFIG_USE_FDPIC. 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: Christophe Lyon , Riku Voipio , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Christophe Lyon We want to avoid code disabled by default, because it ends up less tested. This patch removes all instances of #ifdef CONFIG_USE_FDPIC, most of which can be safely kept. For the ones that should be conditionally executed, we define elf_is_fdpic(). Without this patch, defining CONFIG_USE_FDPIC would prevent QEMU from building precisely because elf_is_fdpic is not defined. Signed-off-by: Christophe Lyon Reviewed-by: Peter Maydell Message-Id: <20180430080404.7323-2-christophe.lyon@st.com> Signed-off-by: Laurent Vivier --- linux-user/elfload.c | 18 +++++++----------- linux-user/qemu.h | 4 ++-- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index c77ed1bb01..bbe93b03b6 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1681,7 +1681,12 @@ static void zero_bss(abi_ulong elf_bss, abi_ulong last_bss, int prot) } } -#ifdef CONFIG_USE_FDPIC +/* Default implementation, always false. */ +static int elf_is_fdpic(struct elfhdr *exec) +{ + return 0; +} + static abi_ulong loader_build_fdpic_loadmap(struct image_info *info, abi_ulong sp) { uint16_t n; @@ -1706,7 +1711,6 @@ static abi_ulong loader_build_fdpic_loadmap(struct image_info *info, abi_ulong s return sp; } -#endif static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc, struct elfhdr *exec, @@ -1725,7 +1729,6 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc, sp = p; -#ifdef CONFIG_USE_FDPIC /* Needs to be before we load the env/argc/... */ if (elf_is_fdpic(exec)) { /* Need 4 byte alignment for these structs */ @@ -1737,7 +1740,6 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc, sp = loader_build_fdpic_loadmap(interp_info, sp); } } -#endif u_platform = 0; k_platform = ELF_PLATFORM; @@ -2153,10 +2155,8 @@ static void load_elf_image(const char *image_name, int image_fd, } bswap_phdr(phdr, ehdr->e_phnum); -#ifdef CONFIG_USE_FDPIC info->nsegs = 0; info->pt_dynamic_addr = 0; -#endif mmap_lock(); @@ -2173,9 +2173,7 @@ static void load_elf_image(const char *image_name, int image_fd, if (a > hiaddr) { hiaddr = a; } -#ifdef CONFIG_USE_FDPIC ++info->nsegs; -#endif } } @@ -2200,8 +2198,7 @@ static void load_elf_image(const char *image_name, int image_fd, } load_bias = load_addr - loaddr; -#ifdef CONFIG_USE_FDPIC - { + if (elf_is_fdpic(ehdr)) { struct elf32_fdpic_loadseg *loadsegs = info->loadsegs = g_malloc(sizeof(*loadsegs) * info->nsegs); @@ -2219,7 +2216,6 @@ static void load_elf_image(const char *image_name, int image_fd, } } } -#endif info->load_bias = load_bias; info->load_addr = load_addr; diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 192a0d2fef..da3b51724c 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -51,13 +51,13 @@ struct image_info { abi_ulong file_string; uint32_t elf_flags; int personality; -#ifdef CONFIG_USE_FDPIC + + /* The fields below are used in FDPIC mode. */ abi_ulong loadmap_addr; uint16_t nsegs; void *loadsegs; abi_ulong pt_dynamic_addr; struct image_info *other_info; -#endif }; #ifdef TARGET_I386