FS#53367 - [binutils] compile libbfd with PIC support

Attached to Project: Arch Linux
Opened by Ferran Pallarès (poinu) - Sunday, 19 March 2017, 11:41 GMT
Last edited by Anatol Pomozov (anatolik) - Friday, 24 March 2017, 03:03 GMT
Task Type Feature Request
Category Packages: Core
Status Closed
Assigned To Allan McRae (Allan)
Architecture All
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 2
Private No

Details

Description:

I am trying to compile a library that requires binutils (libbfd and libiberty to be precise) and fails when linking with the error:

/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 that this should be solved by compiling libbfd with PIC, letting it be linked into shared libraries.

Additional info:
* package version(s): 2.28-1

Steps to reproduce:

1. Create a file with the following code:

#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);
}

2. Try to compile it with:

gcc --shared -fPIC -o libtest.so <file>.c -lbfd -liberty
This task depends upon

Closed by  Anatol Pomozov (anatolik)
Friday, 24 March 2017, 03:03 GMT
Reason for closing:  Fixed
Additional comments about closing:  2.8.0-2
Comment by Ferran Pallarès (poinu) - Monday, 20 March 2017, 08:32 GMT
This problem didn't show in the previous version of binutils (2.27-1), perhaps some compilation flag changed in the latest?
Comment by Anatol Pomozov (anatolik) - Wednesday, 22 March 2017, 07:17 GMT
I have the same issue trying to compile community/tarantool package https://bugs.archlinux.org/task/53407
Comment by Allan McRae (Allan) - Wednesday, 22 March 2017, 07:45 GMT
@Anatol: I just fixed on trunk. I am away for a few days - can you rebuild?
Comment by Anatol Pomozov (anatolik) - Wednesday, 22 March 2017, 08:04 GMT
Allan, sure will do it. I will check if it fixes tarantool package first.
Comment by Anatol Pomozov (anatolik) - Wednesday, 22 March 2017, 08:23 GMT
The latest binutils helps tarantool package. Pushed 2.8.0-2 with -fPIC enabled to [testing]. Ferran, please check if [testing] version helps to resolve your issues as well.

Allan, feel free to move it to [stable] when you are ready.
Comment by Ferran Pallarès (poinu) - Wednesday, 22 March 2017, 09:17 GMT
Latest build in [testing] works for me as well.

Loading...