xref: /llvm-project/bolt/test/X86/ifunc.test (revision 31ac3d092bd047ab2c0bdcb6d527736472b9d4a6)
1// Check if BOLT can process ifunc symbols from .plt section
2// RUN: %clang %cflags -nostdlib -no-pie %p/../Inputs/ifunc.c -fuse-ld=lld \
3// RUN:    -o %t.exe -Wl,-q
4// RUN: llvm-bolt %t.exe -o %t.bolt.exe \
5// RUN:   --print-disasm --print-only=_start | \
6// RUN:   FileCheck --check-prefix=CHECK %s
7// RUN: llvm-readelf -aW %t.bolt.exe | \
8// RUN:   FileCheck --check-prefix=REL_CHECK %s
9
10// Check if BOLT can process ifunc symbols from .plt section in non-pie static
11// executable case.
12// RUN: %clang %cflags -nostdlib %p/../Inputs/ifunc.c -fuse-ld=lld -no-pie \
13// RUN:   -o %t.nopie.exe -Wl,-q
14// RUN: llvm-readelf -l %t.nopie.exe | \
15// RUN:   FileCheck --check-prefix=NON_DYN_CHECK %s
16// RUN: llvm-bolt %t.nopie.exe -o %t.nopie.bolt.exe  \
17// RUN:   --print-disasm --print-only=_start | \
18// RUN:   FileCheck --check-prefix=CHECK %s
19// RUN: llvm-readelf -aW %t.nopie.bolt.exe | \
20// RUN:   FileCheck --check-prefix=REL_CHECK %s
21
22// Check if BOLT can process ifunc symbols from .plt section in pie executable
23// case.
24// RUN: %clang %cflags -nostdlib %p/../Inputs/ifunc.c -fuse-ld=lld -fPIC -pie \
25// RUN:   -o %t.pie.exe -Wl,-q
26// RUN: llvm-bolt %t.pie.exe -o %t.pie.bolt.exe  \
27// RUN:   --print-disasm --print-only=_start | \
28// RUN:   FileCheck --check-prefix=CHECK %s
29// RUN: llvm-readelf -aW %t.pie.bolt.exe | \
30// RUN:   FileCheck --check-prefix=REL_CHECK %s
31
32// Check that IPLT trampoline located in .plt section are normally handled by
33// BOLT. The gnu-ld linker doesn't use separate .iplt section.
34// RUN: %clang %cflags -nostdlib %p/../Inputs/ifunc.c -fuse-ld=lld -fPIC -pie \
35// RUN:   -T %p/../Inputs/iplt.ld -o %t.iplt_pie.exe -Wl,-q
36// RUN: llvm-bolt %t.iplt_pie.exe -o %t.iplt_pie.bolt.exe  \
37// RUN:   --print-disasm --print-only=_start  | \
38// RUN:   FileCheck --check-prefix=CHECK %s
39// RUN: llvm-readelf -aW %t.iplt_pie.bolt.exe | \
40// RUN:   FileCheck --check-prefix=REL_CHECK %s
41
42// NON_DYN_CHECK-NOT: DYNAMIC
43
44// CHECK: callq "resolver_foo/1@PLT"
45
46// REL_CHECK: R_X86_64_IRELATIVE [[#%x,REL_SYMB_ADDR:]]
47// REL_CHECK: [[#REL_SYMB_ADDR]] {{.*}} FUNC {{.*}} resolver_foo
48