1 ## Check that llvm-bolt correctly recognizes veneers/thunks for absolute code
4 # RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
5 # RUN: %clang %cflags -fno-PIC -no-pie %t.o -o %t.exe -nostdlib \
6 # RUN: -fuse-ld=lld -Wl,-q
7 # RUN: llvm-objdump -d %t.exe | FileCheck --check-prefix=CHECK-INPUT %s
8 # RUN: llvm-objcopy --remove-section .rela.mytext %t.exe
9 # RUN: llvm-bolt %t.exe -o %t.bolt --elim-link-veneers=true --lite=0
10 # RUN: llvm-objdump -d -j .text %t.bolt | \
11 # RUN: FileCheck --check-prefix=CHECK-OUTPUT %s
16 .type far_function, %function
19 .size far_function, .-far_function
22 .type near_function, %function
25 .size near_function, .-near_function
27 ## Force relocations against .text.
28 .reloc 0, R_AARCH64_NONE
30 .section ".mytext", "ax"
33 ## This version of a thunk is always generated by LLD for function calls
34 ## spanning more than 256MB.
35 .global __AArch64AbsLongThunk_far_function
36 .type __AArch64AbsLongThunk_far_function, %function
37 __AArch64AbsLongThunk_far_function
:
40 # CHECK-INPUT-LABEL: <__AArch64AbsLongThunk_far_function>:
41 # CHECK-INPUT-NEXT: ldr
42 # CHECK-INPUT-NEXT: br
45 .size __AArch64AbsLongThunk_far_function, .-__AArch64AbsLongThunk_far_function
47 ## If a callee is closer than 256MB away, LLD may generate a thunk with a direct
48 ## jump to the callee. Note, that the name might still include "AbsLong".
49 .global __AArch64AbsLongThunk_near_function
50 .type __AArch64AbsLongThunk_near_function, %function
51 __AArch64AbsLongThunk_near_function
:
53 # CHECK-INPUT-LABEL: <__AArch64AbsLongThunk_near_function>:
54 # CHECK-INPUT-NEXT: b {{.*}} <near_function>
55 .size __AArch64AbsLongThunk_near_function, .-__AArch64AbsLongThunk_near_function
57 ## Check that thunks were removed from .text, and _start calls functions
60 # CHECK-OUTPUT-NOT: __AArch64AbsLongThunk_{{.*}}
63 .type _start, %function
65 # CHECK-INPUT-LABEL: <_start>:
66 # CHECK-OUTPUT-LABEL: <_start>:
67 bl __AArch64AbsLongThunk_far_function
68 bl __AArch64AbsLongThunk_near_function
69 # CHECK-INPUT-NEXT: bl {{.*}} <__AArch64AbsLongThunk_far_function>
70 # CHECK-INPUT-NEXT: bl {{.*}} <__AArch64AbsLongThunk_near_function>
71 # CHECK-OUTPUT-NEXT: bl {{.*}} <far_function>
72 # CHECK-OUTPUT-NEXT: bl {{.*}} <near_function>
74 .size _start, .-_start