Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
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
Summary: when hardening enabled linker says relocation R_X86_64_PC32 against undefined...
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: binutils
Version: 23
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Nick Clifton
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 1284714
TreeView+ depends on / blocked
 
Reported: 2016-02-03 09:02 UTC by Tom Hughes
Modified: 2016-07-10 03:22 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-02-03 09:06:07 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1210424 0 unspecified CLOSED magic_file() not found 2022-05-16 11:32:56 UTC

Internal Links: 1210424

Description Tom Hughes 2016-02-03 09:02:26 UTC
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 09:06:07 UTC
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 09:12:44 UTC
Thanks. Think I've found the real problem now...

Comment 3 Sergio Basto 2016-07-10 03:11:24 UTC
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.