[asterisk-dev] dahdi-tools 2.11.1 : fix for relocation error on build
Oron Peled
oron.peled at xorcom.com
Sun Mar 6 03:50:22 CST 2016
Hi,
On Saturday 05 March 2016 18:07:48 sean darcy wrote:
> ...
> Running standard Fedora 23.
Me too (but didn't use it for RPM build).
> Here's the bootstrap and configure in the rpm build:
> ...
> + LDFLAGS='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld'
Bingo. A failure can now be achieved by:
./configure LDFLAGS='-specs=/usr/lib/rpm/redhat/redhat-hardened-ld'
> FWIW, if -fPIC is not in CFLAGS the .configure compiler check fails:
> configure:3875: checking whether we are cross compiling
> configure:3883: gcc -o conftest -O2 -march=native -mtune=native
> -ftree-vectorize -ffast-math -Wl,-z,relro
> -specs=/usr/lib/rpm/redhat/redhat-hardened-ld conftest.c >&5
> /usr/bin/ld: /tmp/cciqZ1hg.o: relocation R_X86_64_32 against
> `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
> /tmp/cciqZ1hg.o: error adding symbols: Bad value
OK, the /usr/lib/rpm/redhat/redhat-hardended-ld contain:
*self_spec:
+ %{!shared:%{!r:-pie}}
*link:
+ -z now
So generating a "pie" (Position-Independent-Executable) logically require
linking object files compiled with -fPIC (Position-Independent-Code)
just like a shared library.
Now I add '-fPIC' (and --with-dahdi=..., so configure can complete):
./configure LDFLAGS='-specs=/usr/lib/rpm/redhat/redhat-hardened-ld' CFLAGS=-fPIC --with-dahdi=$PWD/../linux
And it pass the ./configure step.
However, with the original Makefile.am any executable we try to link fails
with the same error as the previous "conftest". By running "make V=1"
we can verify that the "-fPIC" isn't passed to the compiler.
Replacing in Makefile.am "CFLAGS = ..." with "CFLAGS += ..." fixed the bug.
I'll bet that until now this bug caused many compilations to pass with
wrong (but non-fatal) CFLAGS.
Thanks,
--
Oron Peled Voice: +972-4-8228492
oron at actcom.co.il http://users.actcom.co.il/~oron
Gratis is nice, Libre is an inalienable right.
More information about the asterisk-dev
mailing list