1# REQUIRES: x86 2 3# RUN: split-file %s %t.dir 4# RUN: llvm-mc -filetype=obj -triple=x86_64 %t.dir/main.s -o %t.o 5# RUN: echo '.globl bar; bar: call __real_foo' | llvm-mc -filetype=obj -triple=x86_64 - -o %t1.o 6# RUN: ld.lld -shared -soname=t.so %t1.o -o %t.so 7 8## --no-allow-shlib-undefined errors because __real_foo is not defined. 9# RUN: not ld.lld %t.o %t.so -o /dev/null 2>&1 | FileCheck --check-prefix=ERR %s 10# ERR: {{.*}}.so: undefined reference to __real_foo [--no-allow-shlib-undefined] 11 12## --wrap=foo defines __real_foo. 13# RUN: ld.lld %t.o %t.so --wrap=foo -o %t 14# RUN: llvm-readelf --dyn-syms %t | FileCheck %s 15 16## The reference __real_foo from %t.so causes foo to be exported. 17## __wrap_foo is not used, thus not exported. 18# CHECK: Symbol table '.dynsym' contains 3 entries: 19# CHECK: NOTYPE LOCAL DEFAULT UND 20# CHECK-NEXT: NOTYPE GLOBAL DEFAULT UND bar 21# CHECK-NEXT: NOTYPE GLOBAL DEFAULT 6 foo 22 23# RUN: llvm-mc -filetype=obj -triple=x86_64 %t.dir/wrap.s -o %twrap.o 24# RUN: ld.lld -shared --soname=fixed %twrap.o -o %twrap.so 25# RUN: ld.lld %t.o %twrap.so --wrap bar -o %t1 26# RUN: llvm-readelf --dyn-syms %t1 | FileCheck %s --check-prefix=DYNSYM 27# RUN: llvm-objdump -d %t1 | FileCheck %s --check-prefix=ASM 28 29# DYNSYM: Symbol table '.dynsym' contains 2 entries: 30# DYNSYM: NOTYPE LOCAL DEFAULT UND 31# DYNSYM-NEXT: NOTYPE GLOBAL DEFAULT UND __wrap_bar 32 33# ASM: <_start>: 34# ASM-NEXT: callq {{.*}} <__wrap_bar@plt> 35 36#--- main.s 37.globl _start, foo 38_start: 39 call bar 40foo: 41 42#--- wrap.s 43.globl __wrap_bar 44__wrap_bar: 45 retq 46