Message ID | 52A1427D.6000307@terremark.com |
---|---|
State | New |
Headers | show |
On 12/05/13 22:20, Don Slutz wrote: > On 12/05/13 16:24, Richard Henderson wrote: >> On 12/06/2013 04:18 AM, Paolo Bonzini wrote: >>> $ 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 >> The easy workaround is to drop -fPIE when we're adding -fPIC. >> >> >> r~ [snip] Attached is a much better version. It drops -fPIE and adds -fPIC for libtool. -Don Slutz ** Patch added: "0001-configure-Switch-libtool-from-fPIE-to-fPIC-bug-12570.patch" https://bugs.launchpad.net/bugs/1257099/+attachment/3925944/+files/0001-configure-Switch-libtool-from-fPIE-to-fPIC-bug-12570.patch
diff --git a/configure b/configure index 0666228..5e34095 100755 --- a/configure +++ b/configure @@ -1310,6 +1310,33 @@ if compile_prog "-Werror -fno-gcse" "" ; then TRANSLATE_OPT_CFLAGS=-fno-gcse fi +# check for broken GCC in RHEL5 with PIE +if test -n "$libtool" -a "$pie" = "" ; then + cat > $TMPC << EOF + +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); +} + +EOF + if ! compile_prog "-shared -fPIE -fPIC" ""; then + echo "Disabling libtool due to broken toolchain support" + echo "Defaulting to --disable-smartcard-nss" + libtool= + fi +fi + if test "$static" = "yes" ; then if test "$pie" = "yes" ; then error_exit "static and pie are mutually incompatible"