Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Dwarf/AArch64] Return address signing B key dwarf support
- When signing return addresses with -msign-return-address=<scope>{+<key>}, either the A key instructions or the B key instructions can be used. To correctly authenticate the return address, the unwinder/debugger must know which key was used to sign the return address. - When and exception is thrown or a break point reached, it may be necessary to unwind the stack. To accomplish this, the unwinder/debugger must be able to first authenticate an the return address if it has been signed. - To enable this, the augmentation string of CIEs has been extended to allow inclusion of a 'B' character. Functions that are signed using the B key variant of the instructions should have and FDE whose associated CIE has a 'B' in the augmentation string. - One must also be able to preserve these semantics when first stepping from a high level language into assembly and then, as a second step, into an object file. To achieve this, I have introduced a new assembly directive '.cfi_b_key_frame ', that tells the assembler the current frame uses return address signing with the B key. - This ensures that the FDE is associated with a CIE that has 'B' in the augmentation string. Differential Revision: https://reviews.llvm.org/D51798 llvm-svn: 349895
- Loading branch information
Luke Cheeseman
committed
Dec 21, 2018
1 parent
82fbb66
commit 41a9e53
Showing
14 changed files
with
161 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# RUN: llc -mtriple=aarch64-arm-none-eabi -run-pass=prologepilog -o - %s 2>&1 | FileCheck %s | ||
--- | | ||
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" | ||
target triple = "aarch64-arm-none-eabi" | ||
|
||
define dso_local i32 @foo() "sign-return-address"="all" "sign-return-address-key"="a_key" { | ||
entry: | ||
ret i32 2 | ||
} | ||
|
||
define dso_local i32 @bar() "sign-return-address"="all" "sign-return-address-key"="b_key" { | ||
entry: | ||
ret i32 2 | ||
} | ||
... | ||
--- | ||
#CHECK: foo | ||
name: foo | ||
alignment: 2 | ||
tracksRegLiveness: true | ||
frameInfo: | ||
maxCallFrameSize: 0 | ||
#CHECK: frame-setup PACIASP implicit-def $lr, implicit $lr, implicit $sp | ||
#CHECK: frame-setup CFI_INSTRUCTION negate_ra_sign_state | ||
#CHECK: frame-destroy AUTIASP implicit-def $lr, implicit $lr, implicit $sp | ||
body: | | ||
bb.0.entry: | ||
$w0 = MOVi32imm 2 | ||
RET_ReallyLR implicit killed $w0 | ||
... | ||
--- | ||
#CHECK: bar | ||
name: bar | ||
alignment: 2 | ||
tracksRegLiveness: true | ||
frameInfo: | ||
maxCallFrameSize: 0 | ||
#CHECK: frame-setup EMITBKEY | ||
#CHECK: frame-setup PACIBSP implicit-def $lr, implicit $lr, implicit $sp | ||
#CHECK: frame-setup CFI_INSTRUCTION negate_ra_sign_state | ||
#CHECK: frame-destroy AUTIBSP implicit-def $lr, implicit $lr, implicit $sp | ||
body: | | ||
bb.0.entry: | ||
$w0 = MOVi32imm 2 | ||
RET_ReallyLR implicit killed $w0 | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
; RUN: llc -mtriple=aarch64-arm-none-eabi < %s -filetype=obj -o - \ | ||
; RUN: | llvm-dwarfdump -v - | FileCheck -check-prefix=CHECK %s | ||
|
||
;CHECK: CIE | ||
;CHECK: Augmentation: "zR" | ||
define i32 @foo() "sign-return-address"="all" { | ||
ret i32 0 | ||
} | ||
|
||
;CHECK: CIE | ||
;CHECK: Augmentation: "zRB" | ||
|
||
define i32 @bar() "sign-return-address"="all" "sign-return-address-key"="b_key" { | ||
ret i32 0 | ||
} | ||
|
||
;CHECK-NOT: CIE | ||
|
||
define i32 @baz() "sign-return-address"="all" nounwind { | ||
ret i32 0 | ||
} | ||
|
||
;CHECK-NOT: CIE | ||
|
||
define i32 @qux() "sign-return-address"="all" "sign-return-address-key"="b_key" nounwind { | ||
ret i32 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// RUN: llvm-mc -filetype=obj -triple aarch64-arm-none-eabi %s -o - | llvm-dwarfdump - -v | FileCheck %s | ||
#CHECK: Augmentation: "zRB" | ||
f1: | ||
.cfi_startproc | ||
.cfi_b_key_frame | ||
.cfi_endproc |