https://bugs.llvm.org/show_bug.cgi?id=45797
Bug ID: 45797
Summary: .dynsym reference in linked DSO should not bring in
STV_HIDDEN symbol from archive
Product: lld
Version: unspecified
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: ELF
Assignee: unassignedb...@nondot.org
Reporter: rol...@hack.frob.com
CC: llvm-bugs@lists.llvm.org, smithp...@googlemail.com
```
echo > libimpl.c 'void impl_symbol() {}'
echo > libapi.c 'void impl_symbol(); void api_symbol() { impl_symbol(); }'
echo > plugin.c 'void api_symbol(); void plugin_symbol() { api_symbol(); }'
clang -fPIC -shared -o libimpl.so -Wl,-soname,libimpl.so libimpl.c
clang -fPIC -shared -o libapi.so -Wl,-soname,libapi.so libapi.c libimpl.so
clang -fPIC -c -o libimpl-public.o libimpl.c
ar cq libimpl-public.a
clang -fPIC -c -fvisibility=hidden -o libimpl-hermetic.o libimpl.c
ar cq libimpl-hermetic.a
clang -fPIC -c plugin.c
for linker in lld gold bfd; do
ld.$linker -o plugin-preempts.$linker -shared plugin.o --start-group
libimpl-public.a libapi.so --end-group
ld.$linker -o plugin-hermetic.$linker -shared plugin.o --start-group
libimpl-hermetic.a libapi.so --end-group
done
readelf -Ws plugin-preempts.lld
# 3: 0000000000001370 6 FUNC GLOBAL DEFAULT 7 impl_symbol
# as expected: impl_symbol is public and libapi.so has UND impl_symbol so
# it preempts libimpl.so. GNU linkers behave the same.
readelf -Ws plugin-hermetic.lld
# 3: 0000000000001340 6 FUNC LOCAL HIDDEN 7 impl_symbol
# should not be there, it's pure dead code!
# BFD behaves the same (buggy), but Gold does not (correct).
#
# An STV_HIDDEN symbol can never satisfy a DSO's reference, so it should
# not be brought into the link from an archive (nor preserved from GC if
# brought in otherwise) because of such a reference.
```
--
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