Bug 1304277 - when hardening enabled linker says relocation R_X86_64_PC32 against undefined symbol can not be used when making a shared object; recompile with -fPIC
when hardening enabled linker says relocation R_X86_64_PC32 against undefined...
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: binutils (Show other bugs)
23
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Nick Clifton
Fedora Extras Quality Assurance
:
Depends On:
Blocks: 1284714
  Show dependency treegraph
 
Reported: 2016-02-03 04:02 EST by Tom Hughes
Modified: 2016-07-09 23:22 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-02-03 04:06:07 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Tom Hughes 2016-02-03 04:02:26 EST
Description of problem:

Trying to link a trivial test program against libgeos_c fails when linker hardening is enabled. Compiling this program with:

#include "geos_c.h"

int main ()
{
  GEOSversion();
  return 0;
}

with:

gcc -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -o geostest geostest.c -lgeos_c

reports:

/usr/bin/ld: /tmp/cc6TBrjv.o: relocation R_X86_64_PC32 against undefined symbol `GEOSversion' can not be used when making a shared object; recompile with -fPIC

That appears to be saying that geos_c was not compiled as PIC but objdump on the debuginfo tells me that geos_ts_c.cpp which contains that function was compiled with:

-m64 -mtune=generic -march=x86-64 -g -O2 -ansi -ffloat-store -fexceptions -fstack-protector-strong -fPIC --param ssp-buffer-size=4

which does include the -fPIC switch.

Version-Release number of selected component (if applicable):

binutils-2.25-15.fc23.x86_64
Comment 1 Jakub Jelinek 2016-02-03 04:06:07 EST
No, that is just user error.
If you are using -specs=/usr/lib/rpm/redhat/redhat-hardened-ld at link time, you also need to use -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 at compile time, and as you are compiling and linking at the same time, you need either both, or drop the -specs=/usr/lib/rpm/redhat/redhat-hardened-ld .
Comment 2 Tom Hughes 2016-02-03 04:12:44 EST
Thanks. Think I've found the real problem now...
Comment 3 Sergio Monteiro Basto 2016-07-09 23:11:24 EDT
ah, that's it ! , This "R_X86_64_PC32 against undefined symbol can not be used when making a shared object; recompile with -fPIC" happens when LDFLAGS are set with hardening and CFLAGS not .

here is my fix for dvd95.spec

--- dvd95-code-01dd592f7a8352d61fd5d8faa75463ebfd954980/configure.in.orig   2016-07-09 18:35:26.738348447 +0100
+++ dvd95-code-01dd592f7a8352d61fd5d8faa75463ebfd954980/configure.in    2016-07-10 04:00:33.515939022 +0100
@@ -13,7 +13,7 @@ AC_ISC_POSIX
 dnl
 dnl warning flags; always add -Wall
 dnl
-CFLAGS="-Wall -O3"
+#CFLAGS="-Wall -O3"

 AC_PROG_CC
 AM_PROG_CC_STDC

Note You need to log in before you can comment on or make changes to this bug.