1// REQUIRES: x86
2// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o
3// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/wrap-no-real.s -o %t2.o
4// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/wrap-no-real2.s -o %t3.o
5// RUN: ld.lld -o %t3.so -shared --soname=t3 %t3.o
6
7// RUN: ld.lld -o %t %t1.o %t2.o -wrap foo
8// RUN: llvm-objdump -d %t | FileCheck %s
9// RUN: llvm-readelf -s -x .got %t | FileCheck --check-prefix=READELF --implicit-check-not=__real_ %s
10
11// CHECK: <_start>:
12// CHECK-NEXT: movq {{.*}}(%rip), %rax  # 0x2021a8
13// CHECK-NEXT: movq {{.*}}(%rip), %rbx  # 0x2021a8
14// CHECK-NEXT: movq {{.*}}(%rip), %rcx  # 0x2021b0
15
16// READELF:      0000000000011000  0 NOTYPE GLOBAL DEFAULT ABS foo
17// READELF:      0000000000011010  0 NOTYPE GLOBAL DEFAULT ABS __wrap_foo
18// READELF:      Hex dump of section '.got':
19// READELF-NEXT: 0x[[#%x,ADDR:]] 10100100 00000000 00100100 00000000
20
21// RUN: ld.lld -o %t2 %t1.o %t2.o %t3.so --wrap foo
22// RUN: llvm-objdump -d %t2 | FileCheck --check-prefix=CHECK2 %s
23// RUN: llvm-readelf -s -x .got %t2 | FileCheck --check-prefix=READELF --implicit-check-not=__real_ %s
24
25// CHECK2: <_start>:
26// CHECK2-NEXT: movq {{.*}}(%rip), %rax  # 0x2022e0
27// CHECK2-NEXT: movq {{.*}}(%rip), %rbx  # 0x2022e0
28// CHECK2-NEXT: movq {{.*}}(%rip), %rcx  # 0x2022e8
29
30.global _start
31_start:
32  mov foo@gotpcrel(%rip), %rax
33  mov __wrap_foo@gotpcrel(%rip), %rbx
34  mov __real_foo@gotpcrel(%rip), %rcx
35