binutils bfd links against system iberty instead of built iberty

402 Views Asked by At

When building binutils, the bfd component is failing to link because it is linking against the system version of libiberty instead of the built version under binutuils/libiberty/lib64/libiberty.a.

I can't see a configure argument to allow me to override this. What's the best way to instruct configure to construct an LD_LIBRARY_PATH that prefers libraries from other components of its build over system versions? Obviously, it needs system libraries that are prerequisites, so I can't exclude this path entirely.

This is the error, due to the system version having not been compiled correctly. The version under binutils/libiberty/lib64 is compiled with -fPIC, so I need to tell configure to use that.

/lib64/libiberty.a(cplus-dem.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC

It doesn't seem as trivial to specify .:/usr/lib64:/lib64 since . is binutils/bfd.

1

There are 1 best solutions below

0
On

I had a look at the generated automakefile and LDFLAGS was only specifying the system libraries:

LDFLAGS := -L/usr/lib64 -L/usr/lib

So I specified this as an argument to configure. Slightly hacky, but can't see a better way out:

LDFLAGS="-L./ -L../ -L../libiberty/pic -L/usr/lib64 -L/usr/lib" ./confgiure --enable-shared