113 lines · plain
1// Test how BOLT handles indirect branch sequence of instructions in2// AArch64MCPlus builder.3 4// clang-format off5 6// REQUIRES: system-linux, asserts7 8// RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown -mattr=+pauth %s -o %t.o9// RUN: %clang %cflags --target=aarch64-unknown-linux %t.o -o %t.exe -Wl,-q10// RUN: llvm-bolt %t.exe -o %t.bolt --print-cfg --debug-only=mcplus -v=1 2>&1 \11// RUN: | FileCheck %s12 13// Pattern 1: there is no shift amount after the 'add' instruction.14//15// adr x6, 0x219fb0 <sigall_set+0x88>16// add x6, x6, x14, lsl #217// ldr w7, [x6]18// add x6, x6, w7, sxtw => no shift amount19// br x620//21 22// Pattern 2: nop/adr pair is used in place of adrp/add23//24// nop => nop/adr instead of adrp/add25// adr x13, 0x215a18 <_nl_value_type_LC_COLLATE+0x50>26// ldrh w13, [x13, w12, uxtw #1]27// adr x12, 0x247b30 <__gettextparse+0x5b0>28// add x13, x12, w13, sxth #229// br x1330 31 .section .text32 .align 433 .globl _start34 .type _start, %function35_start:36 bl test137 bl test238// mov x0, #439// mov w8, #9340// svc #041 42// Pattern 143// CHECK: BOLT-DEBUG: failed to match indirect branch: ShiftVAL != 244 .globl test145 .type test1, %function46test1:47 mov x1, #048 nop49 adr x3, datatable50 add x3, x3, x1, lsl #251 ldr w2, [x3]52 add x3, x3, w2, sxtw53 br x354test1_0:55 ret56test1_1:57 ret58test1_2:59 ret60 .size test1, .-test161 62// Temporary workaround for PC-relative relocations from datatable leaking into63// test2 function and creating phantom entry points.64.skip 0x10065 66// Pattern 267// CHECK: BOLT-DEBUG: failed to match indirect branch: nop/adr instead of adrp/add68 .globl test269 .type test2, %function70test2:71 nop72 adr x3, jump_table73 ldrh w3, [x3, x1, lsl #1]74 nop75 adr x1, test2_076 add x3, x1, w3, sxth #277 br x378test2_0:79 ret80test2_1:81 ret82 83// Make sure BOLT does not crash trying to disassemble BRA* instructions.84 .globl test_braa85 .type test_braa, %function86test_braa:87 braa x0, x188 89 .globl test_brab90 .type test_brab, %function91test_brab:92 brab x0, x193 94 .globl test_braaz95 .type test_braaz, %function96test_braaz:97 braaz x098 99 .globl test_brabz100 .type test_brabz, %function101test_brabz:102 brabz x0103 104 .section .rodata,"a",@progbits105datatable:106 .word test1_0-datatable107 .word test1_1-datatable108 .word test1_2-datatable109 110jump_table:111 .hword (test2_0-test2_0)>>2112 .hword (test2_1-test2_0)>>2113