[asan] Move __asan_handle_no_return to public header

Heretofore asan_handle_no_return was used only by interceptors,
i.e. code private to the ASan runtime. However, on systems without
interceptors, code like libc++abi is built with -fsanitize=address
itself and should call asan_handle_no_return directly from
__cxa_throw so that no interceptor is required.

Patch by Roland McGrath

Differential Revision: https://reviews.llvm.org/D36811

llvm-svn: 311869
This commit is contained in:
Petr Hosek 2017-08-28 00:45:12 +00:00
parent 8b633447da
commit 00b760ed48
2 changed files with 12 additions and 0 deletions

View File

@ -144,6 +144,10 @@ extern "C" {
void *__asan_addr_is_in_fake_stack(void *fake_stack, void *addr, void **beg,
void **end);
// Performs cleanup before a [[noreturn]] function. Must be called
// before things like _exit and execl to avoid false positives on stack.
void __asan_handle_no_return(void);
#ifdef __cplusplus
} // extern "C"
#endif

View File

@ -423,3 +423,11 @@ TEST(AddressSanitizerInterface, GetOwnershipStressTest) {
free(pointers[i]);
}
TEST(AddressSanitizerInterface, HandleNoReturnTest) {
char array[40];
__asan_poison_memory_region(array, sizeof(array));
BAD_ACCESS(array, 20);
__asan_handle_no_return();
// It unpoisons the whole thread stack.
GOOD_ACCESS(array, 20);
}