From patchwork Thu Dec 5 19:09:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Don Slutz X-Patchwork-Id: 297367 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 19ADB2C00A6 for ; Fri, 6 Dec 2013 06:12:46 +1100 (EST) Received: from localhost ([::1]:55295 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VoeLq-0002mB-OY for incoming@patchwork.ozlabs.org; Thu, 05 Dec 2013 14:12:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58536) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VoeLO-0002fu-5W for qemu-devel@nongnu.org; Thu, 05 Dec 2013 14:12:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VoeLI-0002dX-JC for qemu-devel@nongnu.org; Thu, 05 Dec 2013 14:12:14 -0500 Received: from omzsmtpe03.verizonbusiness.com ([199.249.25.208]:53808) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VoeLI-0002dM-Dy for qemu-devel@nongnu.org; Thu, 05 Dec 2013 14:12:08 -0500 X-IronPort-Anti-Spam-Filtered: false Received: from unknown (HELO fldsmtpi01.verizon.com) ([166.68.71.143]) by omzsmtpe03.verizonbusiness.com with ESMTP; 05 Dec 2013 19:12:06 +0000 From: Don Slutz X-IronPort-AV: E=Sophos;i="4.93,835,1378857600"; d="scan'208";a="621055612" Received: from unknown (HELO MIA20725CAS892.apps.tmrk.corp) ([162.47.0.51]) by fldsmtpi01.verizon.com with ESMTP; 05 Dec 2013 19:12:05 +0000 Received: from don-760.CloudSwitch.com (10.25.89.94) by MIA20725CAS892.apps.tmrk.corp (10.1.3.224) with Microsoft SMTP Server (TLS) id 14.2.318.1; Thu, 5 Dec 2013 14:09:43 -0500 Message-ID: <52A0CF76.7060706@terremark.com> Date: Thu, 5 Dec 2013 14:09:42 -0500 User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 MIME-Version: 1.0 To: Paolo Bonzini , Don Slutz References: <20131202223641.6000.456.malonedeb@chaenomeles.canonical.com> <20131202223641.6000.456.malonedeb@chaenomeles.canonical.com> <529E1194.9060504@redhat.com> <529E8638.2010102@terremark.com> <52A09933.5090302@redhat.com> In-Reply-To: <52A09933.5090302@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 199.249.25.208 Cc: 1257099@bugs.launchpad.net, Ian Campbell , xen-devel@lists.xensource.com, qemu-devel@nongnu.org, Stefano Stabellini Subject: Re: [Qemu-devel] [Bug 1257099] [NEW] QEMU fails to build on CentOS 5.10 with relocation R_X86_64_PC32 error X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org On 12/05/13 10:18, Paolo Bonzini wrote: > Il 04/12/2013 02:32, Don Slutz ha scritto: >> Any hints or pointers about the bug in RHEL5 binutils? I can try and >> make a patch to auto detect this. > Actually it's RHEL5 GCC: > > $ cat f.c > void * > f(unsigned char *buf, int len) > { > return (void*)0L; > } > > > void * > g(unsigned char *buf, int len) > { > return f(buf, len); > } > $ gcc -shared -o f.so f.c -fPIE -fPIC > /usr/bin/ld: /tmp/ccQc9els.o: relocation R_X86_64_PC32 against `f' can not be used when making a shared object; recompile with -fPIC > /usr/bin/ld: final link failed: Bad value > collect2: ld returned 1 exit status > > > The bug is simply that "-fPIE -fPIC" counts as -fPIE rather than -fPIC: > > $ gcc -S -o - f.c -fPIE |grep call > call f # PC32 relocation > $ gcc -S -o - f.c -fPIC |grep call > call f@PLT # PLT32 relocation > > On RHEL5: > $ gcc -S -o - f.c -fPIE -fPIC |grep call > call f > > On RHEL6: > $ gcc -S -o - f.c -fPIE -fPIC |grep call > call f@PLT > > Paolo How about this as a patch: From 282fba086186ff3b8e2b2b15e647df2b58d082dd Mon Sep 17 00:00:00 2001 From: Don Slutz Date: Thu, 5 Dec 2013 18:50:18 +0000 Subject: [PATCH] configure: Auto disabling of PIE due to broken toolchain support (bug #1257099) See https://bugs.launchpad.net/bugs/1257099 On RHEL5 GCC, you can get 'relocation R_X86_64_PC32' errors from ld. So disable PIE is this is true. Signed-off-by: Don Slutz --- configure | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/configure b/configure index cf8123b..a51a9dd 100755 --- a/configure +++ b/configure @@ -1339,23 +1339,50 @@ if test "$pie" != "no" ; then # define THREAD #endif +void *f(unsigned char *buf, int len); +void *g(unsigned char *buf, int len); + +void * +f(unsigned char *buf, int len) +{ + return (void*)0L; +} + + +void * +g(unsigned char *buf, int len) +{ + return f(buf, len); +} + +#ifdef PIE static THREAD int tls_var; int main(void) { return tls_var; } +#endif EOF - if compile_prog "-fPIE -DPIE" "-pie"; then - QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS" - LDFLAGS="-pie $LDFLAGS" - pie="yes" - if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then - LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS" + if compile_prog "-shared -fPIE -fPIC" ""; then + if compile_prog "-fPIE -DPIE" "-pie"; then + QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS" + LDFLAGS="-pie $LDFLAGS" + pie="yes" + if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then + LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS" + fi + else + if test "$pie" = "yes"; then + error_exit "PIE not available due to missing toolchain support" + else + echo "Disabling PIE due to missing toolchain support" + pie="no" + fi fi else if test "$pie" = "yes"; then - error_exit "PIE not available due to missing toolchain support" + error_exit "PIE not available due to broken toolchain support" else - echo "Disabling PIE due to missing toolchain support" + echo "Disabling PIE due to broken toolchain support" pie="no" fi fi