Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[safestack] Inline safestack pointer access when possible.
Summary: This adds an -mllvm flag that forces the use of a runtime function call to get the unsafe stack pointer, the same that is currently used on non-x86, non-aarch64 android. The call may be inlined. Reviewers: pcc Subscribers: aemerson, kristof.beyls, hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D37405 llvm-svn: 323259
- Loading branch information
Showing
3 changed files
with
88 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
; RUN: sed -e "s/ATTR//" %s | llc -mtriple=x86_64-linux -safestack-use-pointer-address | FileCheck --check-prefix=INLINE %s | ||
; RUN: sed -e "s/ATTR/noinline/" %s | llc -mtriple=x86_64-linux -safestack-use-pointer-address | FileCheck --check-prefix=CALL %s | ||
|
||
@p = external thread_local global i8*, align 8 | ||
|
||
define nonnull i8** @__safestack_pointer_address() local_unnamed_addr ATTR { | ||
entry: | ||
ret i8** @p | ||
} | ||
|
||
define void @_Z1fv() safestack { | ||
entry: | ||
%x = alloca i32, align 4 | ||
%0 = bitcast i32* %x to i8* | ||
call void @_Z7CapturePi(i32* nonnull %x) | ||
ret void | ||
} | ||
|
||
declare void @_Z7CapturePi(i32*) | ||
|
||
; INLINE: movq p@GOTTPOFF(%rip), %[[A:.*]] | ||
; INLINE: movq %fs:(%[[A]]), %[[B:.*]] | ||
; INLINE: leaq -16(%[[B]]), %[[C:.*]] | ||
; INLINE: movq %[[C]], %fs:(%[[A]]) | ||
|
||
; CALL: callq __safestack_pointer_address | ||
; CALL: movq %rax, %[[A:.*]] | ||
; CALL: movq (%[[A]]), %[[B:.*]] | ||
; CALL: leaq -16(%[[B]]), %[[C:.*]] | ||
; CALL: movq %[[C]], (%[[A]]) |