Index: clang/docs/SafeStack.rst =================================================================== --- clang/docs/SafeStack.rst +++ clang/docs/SafeStack.rst @@ -165,11 +165,23 @@ 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 ====== Index: clang/include/clang/Basic/Builtins.def =================================================================== --- clang/include/clang/Basic/Builtins.def +++ clang/include/clang/Basic/Builtins.def @@ -1412,6 +1412,8 @@ // 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 Index: compiler-rt/lib/safestack/safestack.cc =================================================================== --- compiler-rt/lib/safestack/safestack.cc +++ compiler-rt/lib/safestack/safestack.cc @@ -257,10 +257,19 @@ #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;