-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cranelift AArch64: Fix the get_return_address lowering
The previous implementation assumed that nothing had clobbered the LR register since the current function had started executing, so it would be incorrect for a non-leaf function, for example, that contains the `get_return_address` operation right after a call. The operation is valid only if the `preserve_frame_pointers` flag is enabled, which implies that the presence of a frame record on the stack is guaranteed. Copyright (c) 2022, Arm Limited.
- Loading branch information
1 parent
d2e19b8
commit 4b0847d
Showing
7 changed files
with
97 additions
and
11 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
47 changes: 47 additions & 0 deletions
47
cranelift/filetests/filetests/isa/aarch64/fp_sp_pc-pauth.clif
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,47 @@ | ||
test compile precise-output | ||
set preserve_frame_pointers=true | ||
target aarch64 sign_return_address | ||
|
||
function %fp() -> i64 { | ||
block0: | ||
v0 = get_frame_pointer.i64 | ||
return v0 | ||
} | ||
|
||
; paciasp | ||
; stp fp, lr, [sp, #-16]! | ||
; mov fp, sp | ||
; block0: | ||
; mov x0, fp | ||
; ldp fp, lr, [sp], #16 | ||
; autiasp ; ret | ||
|
||
function %sp() -> i64 { | ||
block0: | ||
v0 = get_stack_pointer.i64 | ||
return v0 | ||
} | ||
|
||
; paciasp | ||
; stp fp, lr, [sp, #-16]! | ||
; mov fp, sp | ||
; block0: | ||
; mov x0, sp | ||
; ldp fp, lr, [sp], #16 | ||
; autiasp ; ret | ||
|
||
function %return_address() -> i64 { | ||
block0: | ||
v0 = get_return_address.i64 | ||
return v0 | ||
} | ||
|
||
; paciasp | ||
; stp fp, lr, [sp, #-16]! | ||
; mov fp, sp | ||
; block0: | ||
; ldr lr, [fp, #8] | ||
; xpaclri | ||
; mov x0, lr | ||
; ldp fp, lr, [sp], #16 | ||
; autiasp ; ret |
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