brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.4 KiB · 30786d4 Raw
77 lines · plain
1# Checking that .cfi-negate_ra_state directives are emitted in the same location as in the input in the case of no optimizations.2 3# The foo and bar functions are a pair, with the first signing the return address,4# and the second authenticating it. We have a tailcall between the two.5# This is testing that BOLT can handle functions starting in signed RA state.6 7# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o8# RUN: %clang %cflags  %t.o -o %t.exe -Wl,-q9# RUN: llvm-bolt %t.exe -o %t.exe.bolt --no-threads --print-all | FileCheck %s --check-prefix=CHECK-BOLT10 11# Check that the negate-ra-state at the start of bar is not discarded.12# If it was discarded, MarkRAState would report bar as having inconsistent RAStates.13# This is testing the handling of initialRAState on the BinaryFunction.14# CHECK-BOLT-NOT: BOLT-INFO: inconsistent RAStates in function foo15# CHECK-BOLT-NOT: BOLT-INFO: inconsistent RAStates in function bar16 17# Check that OpNegateRAState CFIs are generated correctly.18# CHECK-BOLT: Binary Function "foo" after insert-negate-ra-state-pass {19# CHECK-BOLT:         paciasp20# CHECK-BOLT-NEXT:    OpNegateRAState21 22# CHECK-BOLT:      DWARF CFI Instructions:23# CHECK-BOLT-NEXT:     0:  OpNegateRAState24# CHECK-BOLT-NEXT: End of Function "foo"25 26# CHECK-BOLT: Binary Function "bar" after insert-negate-ra-state-pass {27# CHECK-BOLT:         OpNegateRAState28# CHECK-BOLT-NEXT:    mov     x1, #0x029# CHECK-BOLT-NEXT:    mov     x1, #0x130# CHECK-BOLT-NEXT:    autiasp31# CHECK-BOLT-NEXT:    OpNegateRAState32# CHECK-BOLT-NEXT:    ret33 34# CHECK-BOLT:     DWARF CFI Instructions:35# CHECK-BOLT-NEXT:     0:  OpNegateRAState36# CHECK-BOLT-NEXT:     1:  OpNegateRAState37# CHECK-BOLT-NEXT: End of Function "bar"38 39# End of negate-ra-state insertion logs for foo and bar.40# CHECK: Binary Function "_start" after insert-negate-ra-state-pass {41 42# Check that the functions are in the new .text section43# RUN: llvm-objdump %t.exe.bolt -d -j .text | FileCheck %s --check-prefix=CHECK-OBJDUMP44# CHECK-OBJDUMP: <foo>:45# CHECK-OBJDUMP: <bar>:46 47 48  .text49  .globl  foo50  .p2align        251  .type   foo,@function52foo:53  .cfi_startproc54  paciasp55  .cfi_negate_ra_state56  mov x1, #057  b bar58  .cfi_endproc59  .size   foo, .-foo60 61 62 63  .text64  .globl  bar65  .p2align        266  .type   bar,@function67bar:68  .cfi_startproc69  .cfi_negate_ra_state    // Indicating that RA is signed from the start of bar.70  mov x1, #071  mov x1, #172  autiasp73  .cfi_negate_ra_state74  ret75  .cfi_endproc76  .size   bar, .-bar77