https://bugs.llvm.org/show_bug.cgi?id=45318
Fangrui Song <i...@maskray.me> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |i...@maskray.me
Resolution|--- |INVALID
Status|NEW |RESOLVED
--- Comment #2 from Fangrui Song <i...@maskray.me> ---
You can get a reproduce file via LLD_REPRODUCE= or -Wl,--reproduce=
After deleting the first line --chroot . from response.txt, you can link it
with GNU ld. GNU ld errors as well
% aarch64-linux-gnu-ld @response.txt -y clntudp_create -y
clntudp_create@GLIBC_2.17 --no-undefined
aarch64-linux-gnu-ld: tmp/c/lld.error/libsigar.a(sigar_util.o): reference to
clntudp_create
aarch64-linux-gnu-ld: tmp/c/lld.error/sysroot/lib/libc.so.6: definition of
clntudp_create@GLIBC_2.17
aarch64-linux-gnu-ld: tmp/c/lld.error/libsigar.a(sigar_util.o): in function
`sigar_rpc_ping':
sigar_util.c:(.text+0x11cc): undefined reference to `clntudp_create'
aarch64-linux-gnu-ld: sigar_util.c:(.text+0x11dc): undefined reference to
`xdr_void'
aarch64-linux-gnu-ld: sigar_util.c:(.text+0x11ec): undefined reference to
`xdr_void'
aarch64-linux-gnu-ld: sigar_util.c:(.text+0x1238): undefined reference to
`clnttcp_create'
I agree that the 'did you mean: ' diagnostic is confusing.
% ld.lld @response.txt -y clntudp_create -y clntudp_create@GLIBC_2.17
--no-undefined
tmp/c/lld.error/libsigar.a(sigar_util.o): reference to clntudp_create
tmp/c/lld.error/sysroot/lib/libc.so.6: shared definition of
clntudp_create@GLIBC_2.17
ld.lld: error: undefined symbol: clntudp_create
>>> referenced by sigar_util.c
>>> sigar_util.o:(sigar_rpc_ping) in archive
>>> tmp/c/lld.error/libsigar.a
>>> did you mean: clntudp_create
>>> defined in: tmp/c/lld.error/sysroot/lib/libc.so.6
The definition in libc.so.6 is actually 'clntudp_create@GLIBC_2.17'
(VERSYM_HIDDEN), not 'clntudp_create' . It cannot resolve an unversioned
reference named 'clntudp_create'. This mechanism is a bit obscure but the
intention is that the linker should reject it.
A proper fix is to annotate the source code with .symver
clntudp_create,clntudp_create@GLIBC_2.17
If you don't do that, you can drop -Wl,--no-undefined as a workaround. There is
an obscure runtime behavior making this hack work. According to Linux Standard
Base 10.7.6 Symbol Resolution:
> The object with the reference does not use versioning, while the object with
> the definitions does. In this instance, only the definitions with index
> numbers 1 and 2 will be used in the reference match, the same identified by
> the static linker as the base definition. In cases where the static linker
> was not used, such as in calls to dlopen(), a version that does not have the
> base definition index shall be acceptable if it is the only version for which
> the symbol is defined.
GLIBC_2.17 has index number 2 so glibc ld.so can resolve it at runtime.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs