xref: /llvm-project/lld/test/ELF/wrap-plt.s (revision cf783be8d7a8594ab82f8215671dddbebcae39ec)
1// REQUIRES: x86
2
3/// Test we correctly wrap PLT calls.
4
5// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t
6
7// RUN: ld.lld -o %t2 %t -wrap foo -shared
8// RUN: llvm-readobj -S -r %t2 | FileCheck %s
9// RUN: llvm-objdump -d %t2 | FileCheck --check-prefix=DISASM %s
10
11// CHECK:      Relocations [
12// CHECK-NEXT:   Section ({{.*}}) .rela.plt {
13// CHECK-NEXT:     R_X86_64_JUMP_SLOT foo 0x0
14// CHECK-NEXT:     R_X86_64_JUMP_SLOT __wrap_foo 0x0
15// CHECK-NEXT:     R_X86_64_JUMP_SLOT _start 0x0
16// CHECK-NEXT:   }
17// CHECK-NEXT: ]
18
19// DISASM:      <_start>:
20// DISASM-NEXT:   jmp {{.*}} <__wrap_foo@plt>
21// DISASM-NEXT:   jmp {{.*}} <__wrap_foo@plt>
22// DISASM-NEXT:   jmp {{.*}} <foo@plt>
23// DISASM-NEXT:   jmp {{.*}} <_start@plt>
24
25.global foo
26foo:
27  nop
28
29.global __wrap_foo
30__wrap_foo:
31  nop
32
33.global _start
34_start:
35  jmp foo@plt
36  jmp __wrap_foo@plt
37  jmp __real_foo@plt
38  jmp _start@plt
39