From patchwork Fri Sep 11 23:17:54 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kirill A. Shutemov" X-Patchwork-Id: 33488 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by bilbo.ozlabs.org (Postfix) with ESMTPS id 39244B7099 for ; Sat, 12 Sep 2009 06:22:27 +1000 (EST) Received: from localhost ([127.0.0.1]:58272 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MmCdU-0005F9-1B for incoming@patchwork.ozlabs.org; Fri, 11 Sep 2009 16:22:24 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MmCZQ-00029P-Iy for qemu-devel@nongnu.org; Fri, 11 Sep 2009 16:18:12 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MmCZI-00023O-5N for qemu-devel@nongnu.org; Fri, 11 Sep 2009 16:18:10 -0400 Received: from [199.232.76.173] (port=34642 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MmCZH-00023G-RN for qemu-devel@nongnu.org; Fri, 11 Sep 2009 16:18:03 -0400 Received: from mail-fx0-f211.google.com ([209.85.220.211]:55773) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MmCZG-0005fP-Ng for qemu-devel@nongnu.org; Fri, 11 Sep 2009 16:18:03 -0400 Received: by fxm7 with SMTP id 7so1000731fxm.34 for ; Fri, 11 Sep 2009 13:18:01 -0700 (PDT) Received: by 10.86.227.1 with SMTP id z1mr2682645fgg.56.1252700281864; Fri, 11 Sep 2009 13:18:01 -0700 (PDT) Received: from localhost.localdomain (a88-114-220-92.elisa-laajakaista.fi [88.114.220.92]) by mx.google.com with ESMTPS id e11sm361208fga.26.2009.09.11.13.18.00 (version=SSLv3 cipher=RC4-MD5); Fri, 11 Sep 2009 13:18:01 -0700 (PDT) From: "Kirill A. Shutemov" To: qemu-devel@nongnu.org Date: Sat, 12 Sep 2009 02:17:54 +0300 Message-Id: <1252711075-32404-2-git-send-email-kirill@shutemov.name> X-Mailer: git-send-email 1.6.4.2 In-Reply-To: <1252711075-32404-1-git-send-email-kirill@shutemov.name> References: <1252711075-32404-1-git-send-email-kirill@shutemov.name> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: "Kirill A. Shutemov" Subject: [Qemu-devel] [PATCH 2/3] Fix text relocations in linux-user targets X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org There is a link hack in linux-user which produces an executable that looks like PIE, but always has text relocations since all object files isn't position-independent (compiled without -fpic/-fpie). Dynamic loader has to do more work to load a binary with text relocations. The best way to keep this functionality is to build a true PIE without text relocations. Signed-off-by: Kirill A. Shutemov --- configure | 12 +----------- linux-user/main.c | 26 -------------------------- 2 files changed, 1 insertions(+), 37 deletions(-) diff --git a/configure b/configure index 1ecb1ab..b2f52b2 100755 --- a/configure +++ b/configure @@ -2357,16 +2357,6 @@ fi linker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/\$(ARCH).ld" if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then case "$ARCH" in - i386) - if test "$gprof" = "yes" -o "$static" = "yes" ; then - ldflags="$linker_script $ldflags" - else - # WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object - # that the kernel ELF loader considers as an executable. I think this - # is the simplest way to make it self virtualizable! - ldflags="-Wl,-shared $ldflags" - fi - ;; sparc) # -static is used to avoid g1/g3 usage by the dynamic linker ldflags="$linker_script -static $ldflags" @@ -2374,7 +2364,7 @@ if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then ia64) ldflags="-Wl,-G0 $linker_script -static $ldflags" ;; - x86_64|ppc|ppc64|s390|sparc64|alpha|arm|m68k|mips|mips64) + i386|x86_64|ppc|ppc64|s390|sparc64|alpha|arm|m68k|mips|mips64) ldflags="$linker_script $ldflags" ;; esac diff --git a/linux-user/main.c b/linux-user/main.c index a628c01..81a1ada 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -48,32 +48,6 @@ int have_guest_base; static const char *interp_prefix = CONFIG_QEMU_PREFIX; const char *qemu_uname_release = CONFIG_UNAME_RELEASE; -#if defined(__i386__) && !defined(CONFIG_STATIC) -/* Force usage of an ELF interpreter even if it is an ELF shared - object ! */ -const char interp[] __attribute__((section(".interp"))) = "/lib/ld-linux.so.2"; -#endif - -/* for recent libc, we add these dummy symbols which are not declared - when generating a linked object (bug in ld ?) */ -#if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined(CONFIG_STATIC) -asm(".globl __preinit_array_start\n" - ".globl __preinit_array_end\n" - ".globl __init_array_start\n" - ".globl __init_array_end\n" - ".globl __fini_array_start\n" - ".globl __fini_array_end\n" - ".section \".rodata\"\n" - "__preinit_array_start:\n" - "__preinit_array_end:\n" - "__init_array_start:\n" - "__init_array_end:\n" - "__fini_array_start:\n" - "__fini_array_end:\n" - ".long 0\n" - ".previous\n"); -#endif - /* XXX: on x86 MAP_GROWSDOWN only works if ESP <= address + 32, so we allocate a bigger stack. Need a better solution, for example by remapping the process stack directly at the right place */