mirror of
https://github.com/intel/llvm.git
synced 2026-02-06 06:31:50 +08:00
[asan] add option: handle_sigill
llvm-svn: 255588
This commit is contained in:
@@ -77,6 +77,8 @@ void AsanOnDeadlySignal(int signo, void *siginfo, void *context) {
|
||||
ReportStackOverflow(sig);
|
||||
else if (signo == SIGFPE)
|
||||
ReportDeadlySignal("FPE", sig);
|
||||
else if (signo == SIGILL)
|
||||
ReportDeadlySignal("ILL", sig);
|
||||
else
|
||||
ReportDeadlySignal("SEGV", sig);
|
||||
}
|
||||
|
||||
@@ -79,6 +79,8 @@ COMMON_FLAG(bool, handle_segv, SANITIZER_NEEDS_SEGV,
|
||||
"If set, registers the tool's custom SIGSEGV/SIGBUS handler.")
|
||||
COMMON_FLAG(bool, handle_abort, false,
|
||||
"If set, registers the tool's custom SIGABRT handler.")
|
||||
COMMON_FLAG(bool, handle_sigill, false,
|
||||
"If set, registers the tool's custom SIGILL handler.")
|
||||
COMMON_FLAG(bool, handle_sigfpe, true,
|
||||
"If set, registers the tool's custom SIGFPE handler.")
|
||||
COMMON_FLAG(bool, allow_user_segv_handler, false,
|
||||
|
||||
@@ -1114,6 +1114,8 @@ AndroidApiLevel AndroidGetApiLevel() {
|
||||
bool IsDeadlySignal(int signum) {
|
||||
if (common_flags()->handle_abort && signum == SIGABRT)
|
||||
return true;
|
||||
if (common_flags()->handle_sigill && signum == SIGILL)
|
||||
return true;
|
||||
if (common_flags()->handle_sigfpe && signum == SIGFPE)
|
||||
return true;
|
||||
return (signum == SIGSEGV || signum == SIGBUS) && common_flags()->handle_segv;
|
||||
|
||||
@@ -190,6 +190,7 @@ void InstallDeadlySignalHandlers(SignalHandlerType handler) {
|
||||
MaybeInstallSigaction(SIGBUS, handler);
|
||||
MaybeInstallSigaction(SIGABRT, handler);
|
||||
MaybeInstallSigaction(SIGFPE, handler);
|
||||
MaybeInstallSigaction(SIGILL, handler);
|
||||
}
|
||||
#endif // SANITIZER_GO
|
||||
|
||||
|
||||
25
compiler-rt/test/sanitizer_common/TestCases/Linux/ill.cc
Normal file
25
compiler-rt/test/sanitizer_common/TestCases/Linux/ill.cc
Normal file
@@ -0,0 +1,25 @@
|
||||
// Test the handle_sigill option.
|
||||
// RUN: %clang %s -o %t -O1
|
||||
// RUN: not --crash %run %t 2>&1 | FileCheck --check-prefix=CHECK0 %s
|
||||
// RUN: %env_tool_opts=handle_sigill=0 not --crash %run %t 2>&1 | FileCheck --check-prefix=CHECK0 %s
|
||||
// RUN: %env_tool_opts=handle_sigill=1 not %run %t 2>&1 | FileCheck --check-prefix=CHECK1 %s
|
||||
// FIXME: implement in other sanitizers, not just asan.
|
||||
// XFAIL: msan
|
||||
// XFAIL: lsan
|
||||
// XFAIL: tsan
|
||||
//
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <sanitizer/asan_interface.h>
|
||||
|
||||
void death() {
|
||||
fprintf(stderr, "DEATH CALLBACK\n");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
__sanitizer_set_death_callback(death);
|
||||
__builtin_trap();
|
||||
}
|
||||
// CHECK1: ERROR: {{.*}}Sanitizer:
|
||||
// CHECK1: DEATH CALLBACK
|
||||
// CHECK0-NOT: Sanitizer
|
||||
Reference in New Issue
Block a user