You are not logged in.
I'm failing to compile a library that requires binutils (libiberty and libbfd to be precise). The command that fails is the following:
libtool: link: gcc -shared -fPIC -DPIC .libs/libseqtrace_la-calltrace.o .libs/libseqtrace_la-signals.o .libs/libseqtrace_la-xml-parse.o .libs/libseqtrace_la-UF_gcc_instrument.o .libs/libseqtrace_la-UF_xl_instrument.o .libs/libseqtrace_la-mode.o .libs/libseqtrace_la-threadid.o .libs/libseqtrace_la-taskid.o wrappers/API/.libs/libseqtrace_la-buffers.o wrappers/API/.libs/libseqtrace_la-wrapper.o wrappers/API/.libs/libseqtrace_la-misc_wrapper.o wrappers/API/.libs/libseqtrace_la-threadinfo.o .libs/libseqtrace_la-auto_init.o .libs/libseqtrace_la-auto_fini.o -Wl,--whole-archive ../../src/common/.libs/libcommon.a ../../src/tracer/clocks/.libs/libclock.a ../../src/tracer/hwc/.libs/libhwc.a ../../src/tracer/wrappers/MALLOC/.libs/libwrap_malloc.a ../../src/tracer/wrappers/IO/.libs/libwrap_io.a ../../src/tracer/wrappers/fork/.libs/libwrap_fork.a sampling/common/.libs/libsampling_common.a sampling/timer/.libs/libsampling_timer.a ../../src/tracer/interfaces/API/.libs/libiface_api.a ../../src/merger/.libs/libmpi2prv.a -Wl,--no-whole-archive -Wl,-rpath -Wl,/usr/lib64 -L/usr/lib64 -lpapi -lunwind -lxml2 -ldl -lz -lbfd -liberty -g -O2 -Wl,-soname -Wl,libseqtrace-3.3.0.so -o .libs/libseqtrace-3.3.0.so
And the error is:
/usr/bin/ld: /usr/lib/libbfd.a(bfd.o): relocation R_X86_64_32S against symbol `bfd_errmsgs' can not be used when making a shared object; recompile with -fPIC
It seems to me that it could be related to what is happening here: https://bugs.archlinux.org/task/40174, but perhaps I'm completely mistaken.
Any help is highly appreciated.
Last edited by poinu (2017-03-19 11:28:55)
Offline
This minimum example here fails with the same error:
// Code for "test.c"
#define PACKAGE 1
#define PACKAGE_VERSION 1
#include <bfd.h>
void foo(bfd *file)
{
bfd_init();
file = bfd_openr("a.out", 0);
bfd_close(file);
}Compile with (shouldn't need to install anything aside from the base-devel group, as binutils is included in it):
gcc --shared -fPIC -o libtest.so test.c -lbfd -liberty
I don't have any Linux distro other that arch to test whether this should work or not, any idea?
Thanks
Last edited by poinu (2017-03-18 23:23:28)
Offline
You can file a bug report asking for that library to be compiled with PIC.
Offline
Thank you for the response, I'll do it straightaway!
Offline
Just for completion, here the filed bug report: https://bugs.archlinux.org/task/53367
Offline