This is an archive of the discontinued LLVM Phabricator instance.

[safestack] Experimental mode where stack pointer is accessed with a function call.
ClosedPublic

Authored by eugenis on Sep 1 2017, 4:26 PM.

Details

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.

Diff Detail

Repository
rL LLVM

Event Timeline

eugenis created this revision.Sep 1 2017, 4:26 PM

The function should really have coldcc or preserve_allcc but those are either not implemented (i.e. crash the compiler) or just not do anything useful on arm and aarch64.
As is, generated code is atrocious.

eugenis updated this revision to Diff 125397.Dec 4 2017, 12:01 PM

Attempt to use a custom calling convention for the safestack pointer accessor function.

Not ready for review.

eugenis updated this revision to Diff 130036.Jan 16 2018, 2:44 PM

An attempt to inline the safestack accessor function.

To use, add -mllvm -safestack-pointer-address-inline=1.
Function must be called safestack_pointer_address_inline.
"
attribute__((used)) static" is recommended so the function is not discarded early.

eugenis updated this revision to Diff 130980.Jan 22 2018, 3:51 PM

Remove -customcc code. Added inlining logic.

Please review.

eugenis updated this revision to Diff 130982.Jan 22 2018, 4:12 PM

removed one flag, fixed a condition, improved the test

eugenis updated this revision to Diff 131135.Jan 23 2018, 1:10 PM

fix one test

pcc accepted this revision.Jan 23 2018, 1:21 PM

LGTM

This revision is now accepted and ready to land.Jan 23 2018, 1:21 PM
This revision was automatically updated to reflect the committed changes.