Linking problem with lld
Tijl Coosemans
tijl at FreeBSD.org
Sun Mar 3 15:10:33 UTC 2019
On Sun, 3 Mar 2019 15:21:56 +0100 Willem Jan Withagen <wjw at digiware.nl>
wrote:
> First success.
> I used this map, but also needed to fix a .symver:
> ====
> #define LIBRADOS_C_API_BASE_DEFAULT(fn) \
> - asm(".symver _" #fn ", " #fn "@@")
> + asm(".symver _" #fn ", " #fn "@")
> ====
> That last was more or less guessed from the binutils/docs/ld page.
It's really a bug in lld. You can add LLD_UNSAFE=yes to the port
Makefile for now.
Here's a simple test case:
% cat test.c
void _test1() {
}
asm(".symver _test1, test1@@");
void test2() {
}
% cat test.map
{
local: *;
};
% clang70 -shared -o libtest.so test.c -fPIC -Wl,--version-script=test.map
% readelf -s libtest.so | grep test
8: 0000000000000000 0 FILE LOCAL DEFAULT ABS test.c
9: 0000000000001090 5 FUNC LOCAL DEFAULT 9 _test1
10: 0000000000001090 5 FUNC LOCAL DEFAULT 9 test1
11: 00000000000010a0 5 FUNC LOCAL DEFAULT 9 test2
% clang70 -shared -o libtest.so test.c -fPIC -Wl,--version-script=test.map -fuse-ld=bfd
% readelf -s libtest.so | grep test
3: 0000000000000280 5 FUNC GLOBAL DEFAULT 11 test1
34: 0000000000000000 0 FILE LOCAL DEFAULT ABS test.c
38: 0000000000000280 5 FUNC LOCAL DEFAULT 11 _test1
42: 0000000000000290 5 FUNC LOCAL DEFAULT 11 test2
46: 0000000000000280 5 FUNC GLOBAL DEFAULT 11 test1@@
With lld test1 is local. With GNU ld it's global. The .symver
directive should override the version script.
More information about the freebsd-toolchain
mailing list