diff options
| author | Vlad Tsyrklevich <vlad@tsyrklevich.net> | 2018-07-13 19:48:35 +0000 |
|---|---|---|
| committer | Vlad Tsyrklevich <vlad@tsyrklevich.net> | 2018-07-13 19:48:35 +0000 |
| commit | be9a9fd3dd8fdabb78566bea93baa33b22999d10 (patch) | |
| tree | 45812f275f1cab595cabab0dc1c31d108dbbff26 | |
| parent | f702b029f46e1644f9d4b859e88c09e121009562 (diff) | |
| download | bcm5719-llvm-be9a9fd3dd8fdabb78566bea93baa33b22999d10.tar.gz bcm5719-llvm-be9a9fd3dd8fdabb78566bea93baa33b22999d10.zip | |
SafeStack: Add builtins to read unsafe stack top/bottom
Summary:
Introduce built-ins to read the unsafe stack top and bottom. The unsafe
stack top is required to implement garbage collection scanning for
Oilpan. Currently there is already a built-in 'get_unsafe_stack_start'
to read the bottom of the unsafe stack, but I chose to duplicate this
API because 'start' is ambiguous (e.g. Oilpan uses WTF::GetStackStart to
read the safe stack top.)
Reviewers: pcc
Reviewed By: pcc
Subscribers: llvm-commits, kcc
Differential Revision: https://reviews.llvm.org/D49152
llvm-svn: 337037
| -rw-r--r-- | clang/docs/SafeStack.rst | 16 | ||||
| -rw-r--r-- | clang/include/clang/Basic/Builtins.def | 2 | ||||
| -rw-r--r-- | compiler-rt/lib/safestack/safestack.cc | 11 |
3 files changed, 26 insertions, 3 deletions
diff --git a/clang/docs/SafeStack.rst b/clang/docs/SafeStack.rst index f01b75f5cb3..866a8060aa4 100644 --- a/clang/docs/SafeStack.rst +++ b/clang/docs/SafeStack.rst @@ -165,11 +165,23 @@ never be stored on the heap, as it would leak the location of the SafeStack. This builtin function returns current unsafe stack pointer of the current thread. +``__builtin___get_unsafe_stack_bottom()`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +This builtin function returns a pointer to the bottom of the unsafe stack of the +current thread. + +``__builtin___get_unsafe_stack_top()`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +This builtin function returns a pointer to the top of the unsafe stack of the +current thread. + ``__builtin___get_unsafe_stack_start()`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -This builtin function returns a pointer to the start of the unsafe stack of the -current thread. +Deprecated: This builtin function is an alias for +``__builtin___get_unsafe_stack_bottom()``. Design ====== diff --git a/clang/include/clang/Basic/Builtins.def b/clang/include/clang/Basic/Builtins.def index 39105a9b372..edd823754a3 100644 --- a/clang/include/clang/Basic/Builtins.def +++ b/clang/include/clang/Basic/Builtins.def @@ -1412,6 +1412,8 @@ BUILTIN(__builtin_dump_struct, "ivC*v*", "tn") // Safestack builtins BUILTIN(__builtin___get_unsafe_stack_start, "v*", "Fn") +BUILTIN(__builtin___get_unsafe_stack_bottom, "v*", "Fn") +BUILTIN(__builtin___get_unsafe_stack_top, "v*", "Fn") BUILTIN(__builtin___get_unsafe_stack_ptr, "v*", "Fn") // Nontemporal loads/stores builtins diff --git a/compiler-rt/lib/safestack/safestack.cc b/compiler-rt/lib/safestack/safestack.cc index 8b1fdb788fe..cc6d81b2eef 100644 --- a/compiler-rt/lib/safestack/safestack.cc +++ b/compiler-rt/lib/safestack/safestack.cc @@ -257,11 +257,20 @@ __attribute__((section(".preinit_array"), #endif extern "C" - __attribute__((visibility("default"))) void *__get_unsafe_stack_start() { + __attribute__((visibility("default"))) void *__get_unsafe_stack_bottom() { return unsafe_stack_start; } extern "C" + __attribute__((visibility("default"))) void *__get_unsafe_stack_top() { + return (char*)unsafe_stack_start + unsafe_stack_size; +} + +extern "C" + __attribute__((visibility("default"), alias("__get_unsafe_stack_bottom"))) + void *__get_unsafe_stack_start(); + +extern "C" __attribute__((visibility("default"))) void *__get_unsafe_stack_ptr() { return __safestack_unsafe_stack_ptr; } |

