1## If the original of a wrapped symbol becomes unreferenced after wrapping, it 2## should be dropped from the dynamic symbol table even if defined in a shared 3## library. 4 5# REQUIRES: x86 6 7# RUN: rm -rf %t && split-file %s %t 8# RUN: llvm-mc -filetype=obj -triple=x86_64-elf %t/original.s -o %t/original.o 9# RUN: llvm-mc -filetype=obj -triple=x86_64-elf %t/wrapped.s -o %t/wrapped.o 10# RUN: llvm-mc -filetype=obj -triple=x86_64-elf %t/ref.s -o %t/ref.o 11# RUN: ld.lld -shared -o %t/liboriginal.so -soname liboriginal.so %t/original.o 12# RUN: ld.lld -shared -o %t/liboriginal-and-wrapped.so \ 13# RUN: -soname liboriginal-and-wrapped.so %t/original.o %t/wrapped.o 14# RUN: ld.lld -shared -o %t/libref-with-original.so %t/ref.o \ 15# RUN: --as-needed %t/liboriginal.so --wrap foo 16# RUN: llvm-readelf --dynamic --dyn-syms %t/libref-with-original.so | \ 17# RUN: FileCheck --check-prefix=ORIGINAL %s 18# RUN: ld.lld -shared -o %t/libref-with-original-and-wrapped.so %t/ref.o \ 19# RUN: --as-needed %t/liboriginal-and-wrapped.so --wrap foo 20# RUN: llvm-readelf --dynamic --dyn-syms %t/libref-with-original-and-wrapped.so | \ 21# RUN: FileCheck --check-prefix=ORIGINAL-AND-WRAPPED %s 22 23# ORIGINAL-NOT: (NEEDED) Shared library: [liboriginal.so] 24# ORIGINAL: Symbol table '.dynsym' contains 3 entries: 25# ORIGINAL: NOTYPE LOCAL DEFAULT UND 26# ORIGINAL-NEXT: NOTYPE GLOBAL DEFAULT UND __wrap_foo 27# ORIGINAL-NEXT: NOTYPE GLOBAL DEFAULT 6 ref 28 29# ORIGINAL-AND-WRAPPED: (NEEDED) Shared library: [liboriginal-and-wrapped.so] 30# ORIGINAL-AND-WRAPPED: Symbol table '.dynsym' contains 3 entries: 31# ORIGINAL-AND-WRAPPED: NOTYPE LOCAL DEFAULT UND 32# ORIGINAL-AND-WRAPPED-NEXT: NOTYPE GLOBAL DEFAULT UND __wrap_foo 33# ORIGINAL-AND-WRAPPED-NEXT: NOTYPE GLOBAL DEFAULT 6 ref 34 35#--- original.s 36.globl foo 37foo: 38 retq 39 40#--- wrapped.s 41.globl __wrap_foo 42__wrap_foo: 43 retq 44 45#--- ref.s 46.globl ref 47ref: 48 jmp foo@plt 49