[asterisk-dev] dahdi-tools 2.11.1 : fix for relocation error on build

sean darcy seandarcy2 at gmail.com
Sun Mar 6 10:46:28 CST 2016


On 03/06/2016 04:50 AM, Oron Peled wrote:
> 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,
>

Interestingly, fedora koji doesn't need -fPIC to build dahdi-tools (at 
least 2.10.0, the latest package), even though LDFLAGS includes 
-specs=/usr/lib/rpm/redhat/redhat-hardened-ld

https://kojipkgs.fedoraproject.org//packages/dahdi-tools/2.10.0/6.fc23/data/logs/x86_64/build.log

sean






More information about the asterisk-dev mailing list