81 lines · plain
1# REQUIRES: x862 3# RUN: rm -rf %t && split-file %s %t4# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/main.s -o %t/main.o5# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/call-foo.s -o %t/call-foo.o6# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/bar.s -o %t/bar.o7# RUN: ld.lld -shared -soname=t.so %t/bar.o -o %t/bar.so8# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/wrap.s -o %t/wrap.o9# RUN: ld.lld -shared --soname=fixed %t/wrap.o -o %t/wrap.so10 11## foo is defined, then referenced in another object file.12# RUN: ld.lld -shared %t/main.o %t/call-foo.o --wrap foo -o %t1.so13# RUN: llvm-readelf -r %t1.so | FileCheck %s --check-prefix=CHECK114 15# CHECK1: R_X86_64_JUMP_SLOT 0000000000000000 bar + 016# CHECK1-NEXT: R_X86_64_JUMP_SLOT 0000000000000000 __wrap_foo + 017 18## --no-allow-shlib-undefined errors because __real_foo is not defined.19# RUN: not ld.lld %t/main.o %t/bar.so -o /dev/null 2>&1 | FileCheck --check-prefix=ERR %s20# ERR: error: undefined reference: __real_foo21 22## --wrap=foo defines __real_foo.23# RUN: ld.lld %t/main.o %t/bar.so --wrap=foo -o %t224# RUN: llvm-readelf --dyn-syms %t2 | FileCheck %s --check-prefix=CHECK225 26## See wrap-plt2.s why __wrap_foo is retained.27# CHECK2: Symbol table '.dynsym' contains 3 entries:28# CHECK2: NOTYPE LOCAL DEFAULT UND29# CHECK2-NEXT: NOTYPE GLOBAL DEFAULT UND bar30# CHECK2-NEXT: NOTYPE GLOBAL DEFAULT UND __wrap_foo31 32## __wrap_bar is undefined.33# RUN: ld.lld -shared %t/main.o --wrap=bar -o %t3.so34# RUN: llvm-readelf -r --dyn-syms %t3.so | FileCheck %s --check-prefix=CHECK335# CHECK3: R_X86_64_JUMP_SLOT 0000000000000000 __wrap_bar + 036# CHECK3: Symbol table '.dynsym' contains 4 entries:37# CHECK3: NOTYPE LOCAL DEFAULT UND38# CHECK3-NEXT: NOTYPE GLOBAL DEFAULT UND __wrap_bar39# CHECK3-NEXT: NOTYPE GLOBAL DEFAULT 6 _start40# CHECK3-NEXT: NOTYPE GLOBAL DEFAULT 6 foo41 42## __wrap_bar is defined in %t/wrap.so.43# RUN: ld.lld -shared %t/main.o %t/wrap.so --wrap=bar -o %t4.so44# RUN: llvm-readelf -r --dyn-syms %t4.so | FileCheck %s --check-prefix=CHECK445# CHECK4: R_X86_64_JUMP_SLOT {{.*}} __wrap_bar + 046# CHECK4: Symbol table '.dynsym' contains 4 entries:47# CHECK4: NOTYPE LOCAL DEFAULT UND48# CHECK4-NEXT: NOTYPE GLOBAL DEFAULT UND __wrap_bar49# CHECK4-NEXT: NOTYPE GLOBAL DEFAULT 6 _start50# CHECK4-NEXT: NOTYPE GLOBAL DEFAULT 6 foo51 52# RUN: ld.lld %t/main.o %t/wrap.so --wrap bar -o %t153# RUN: llvm-readelf --dyn-syms %t1 | FileCheck %s --check-prefix=DYNSYM54# RUN: llvm-objdump -d %t1 | FileCheck %s --check-prefix=ASM55 56# DYNSYM: Symbol table '.dynsym' contains 2 entries:57# DYNSYM: NOTYPE LOCAL DEFAULT UND58# DYNSYM-NEXT: NOTYPE GLOBAL DEFAULT UND __wrap_bar59 60# ASM: <_start>:61# ASM-NEXT: callq {{.*}} <__wrap_bar@plt>62 63#--- main.s64.globl _start, foo65_start:66 call bar67foo:68 69#--- call-foo.s70 call foo71 72#--- bar.s73.globl bar74bar:75 call __real_foo76 77#--- wrap.s78.globl __wrap_bar79__wrap_bar:80 retq81