86 lines · plain
1## Check that llvm-bolt correctly recognizes veneers/thunks for absolute code2## generated by LLD.3 4# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o5# RUN: %clang %cflags -fno-PIC -no-pie %t.o -o %t.exe -nostdlib \6# RUN: -fuse-ld=lld -Wl,-q7# RUN: llvm-objdump -d %t.exe | FileCheck --check-prefix=CHECK-INPUT %s8# RUN: llvm-objcopy --remove-section .rela.mytext %t.exe9# RUN: llvm-bolt %t.exe -o %t.bolt10# RUN: llvm-objdump -d -j .text %t.bolt | \11# RUN: FileCheck --check-prefix=CHECK-OUTPUT %s12 13## Occasionally, we see the linker not generating $d symbols for long veneers14## causing BOLT to fail veneer elimination.15# RUN: llvm-objcopy --remove-symbol-prefix='$d' %t.exe %t.no-marker.exe16# RUN: llvm-bolt %t.no-marker.exe -o %t.no-marker.bolt \17# RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-BOLT18# RUN: llvm-objdump -d -j .text %t.no-marker.bolt | \19# RUN: FileCheck --check-prefix=CHECK-OUTPUT %s20 21# CHECK-BOLT-NOT: BOLT-WARNING: unable to disassemble instruction22# CHECK-BOLT: BOLT-WARNING: missing data marker detected in veneer __AArch64AbsLongThunk_far_function23 24.text25.balign 426.global far_function27.type far_function, %function28far_function:29 ret30.size far_function, .-far_function31 32.global near_function33.type near_function, %function34near_function:35 ret36.size near_function, .-near_function37 38## Force relocations against .text.39.reloc 0, R_AARCH64_NONE40 41.section ".mytext", "ax"42.balign 443 44## This version of a thunk is always generated by LLD for function calls45## spanning more than 256MB.46.global __AArch64AbsLongThunk_far_function47.type __AArch64AbsLongThunk_far_function, %function48__AArch64AbsLongThunk_far_function:49 ldr x16, .L150 br x1651# CHECK-INPUT-LABEL: <__AArch64AbsLongThunk_far_function>:52# CHECK-INPUT-NEXT: ldr53# CHECK-INPUT-NEXT: br54.L1:55 .quad far_function56.size __AArch64AbsLongThunk_far_function, .-__AArch64AbsLongThunk_far_function57 58## If a callee is closer than 256MB away, LLD may generate a thunk with a direct59## jump to the callee. Note, that the name might still include "AbsLong".60.global __AArch64AbsLongThunk_near_function61.type __AArch64AbsLongThunk_near_function, %function62__AArch64AbsLongThunk_near_function:63 b near_function64# CHECK-INPUT-LABEL: <__AArch64AbsLongThunk_near_function>:65# CHECK-INPUT-NEXT: b {{.*}} <near_function>66.size __AArch64AbsLongThunk_near_function, .-__AArch64AbsLongThunk_near_function67 68## Check that thunks were removed from .text, and _start calls functions69## directly.70 71# CHECK-OUTPUT-NOT: __AArch64AbsLongThunk_{{.*}}72 73.global _start74.type _start, %function75_start:76# CHECK-INPUT-LABEL: <_start>:77# CHECK-OUTPUT-LABEL: <_start>:78 bl __AArch64AbsLongThunk_far_function79 bl __AArch64AbsLongThunk_near_function80# CHECK-INPUT-NEXT: bl {{.*}} <__AArch64AbsLongThunk_far_function>81# CHECK-INPUT-NEXT: bl {{.*}} <__AArch64AbsLongThunk_near_function>82# CHECK-OUTPUT-NEXT: bl {{.*}} <far_function>83# CHECK-OUTPUT-NEXT: bl {{.*}} <near_function>84 ret85.size _start, .-_start86