1# This test checks relocations for control-flow instructions 2 3# REQUIRES: system-linux 4 5# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown \ 6# RUN: %s -o %t.o 7# RUN: %clang %cflags -no-pie %t.o -o %t.exe -Wl,-q 8# RUN: llvm-bolt %t.exe -o %t.bolt --use-old-text=0 --lite=0 --trap-old-code 9# RUN: %t.bolt 10 11 .macro panic 12.panic\@: 13 mov x0, #0 14 br x0 15 .endm 16 17 .text 18 .align 4 19 .global test_call_foo 20 .type test_call_foo, %function 21test_call_foo: 22 mov x0, x30 23 add x0, x0, #8 24 br x0 25 panic 26 .size test_call_foo, .-test_call_foo 27 28 .global main 29 .type main, %function 30main: 31 stp x30, x29, [sp, #-16]! 32 b test_branch 33 panic 34test_branch: 35 b test_cond_branch 36 panic 37 .size main, .-main 38 39 .global test_cond_branch 40 .type test_cond_branch, %function 41test_cond_branch: 42 mov x0, #0 43 cmp x0, #0 44 b.eq test_branch_reg 45 panic 46 .size test_cond_branch, .-test_cond_branch 47 48 .global test_branch_reg 49 .type test_branch_reg, %function 50test_branch_reg: 51 nop 52 adr x0, test_branch_zero 53 br x0 54 panic 55 .size test_branch_reg, .-test_branch_reg 56 57 .global test_branch_zero 58 .type test_branch_zero, %function 59test_branch_zero: 60 mov x0, #0 61 cbz x0, test_branch_non_zero 62 panic 63 .size test_branch_zero, .-test_branch_zero 64 65 .global test_branch_non_zero 66 .type test_branch_non_zero, %function 67test_branch_non_zero: 68 mov x0, #1 69 cbnz x0, test_bit_branch_zero 70 panic 71 .size test_branch_non_zero, .-test_branch_non_zero 72 73 .global test_bit_branch_zero 74 .type test_bit_branch_zero, %function 75test_bit_branch_zero: 76 mov x0, #0 77 tbz x0, 0, test_bit_branch_non_zero 78 panic 79 .size test_bit_branch_zero, .-test_bit_branch_zero 80 81 .global test_bit_branch_non_zero 82 .type test_bit_branch_non_zero, %function 83test_bit_branch_non_zero: 84 mov x0, #1 85 tbnz x0, 0, test_call 86 panic 87 .size test_bit_branch_non_zero, .-test_bit_branch_non_zero 88 89 .global test_call 90 .type test_call, %function 91test_call: 92 bl test_call_foo 93 panic 94 b test_call_reg 95 panic 96 .size test_call, .-test_call 97 98 .global test_call_reg 99 .type test_call_reg, %function 100test_call_reg: 101 nop 102 adr x0, test_call_foo 103 blr x0 104 panic 105 b finalize 106 panic 107 .size test_call_reg, .-test_call_reg 108 109 .global finalize 110 .type finalize, %function 111finalize: 112 ldp x30, x29, [sp], #16 113 mov x0, #0 114 ret 115 panic 116 .size finalize, .-finalize 117