summaryrefslogtreecommitdiff
path: root/lib/hwasan/hwasan.h
diff options
context:
space:
mode:
authorAlex Shlyapnikov <alekseys@google.com>2018-03-23 23:38:04 +0000
committerAlex Shlyapnikov <alekseys@google.com>2018-03-23 23:38:04 +0000
commit2f90bfba89ad7ac272dcb1cae064681fce98f1b9 (patch)
treed20207c6f632108c9609fee38d093966e6638068 /lib/hwasan/hwasan.h
parent0691287972d44894b7fa3ca57af9c03133e45d26 (diff)
downloadcompiler-rt-2f90bfba89ad7ac272dcb1cae064681fce98f1b9.tar.gz
[HWASan] Port HWASan to Linux x86-64 (compiler-rt)
Summary: Porting HWASan to Linux x86-64, first of the three patches, compiler-rt part. The approach is similar to ARM case, trap signal is used to communicate memory tag check failure. int3 instruction is used to generate a signal, access parameters are stored in nop [eax + offset] instruction immediately following the int3 one Had to add HWASan init on malloc because, due to much less interceptors defined (most other sanitizers intercept much more and get initalized via one of those interceptors or don't care about malloc), HWASan was not initialized yet when libstdc++ was trying to allocate memory for its own fixed-size heap, which led to CHECK-fail in AllocateFromLocalPool. Also added the CHECK() failure handler with more detailed message and stack reporting. Reviewers: eugenis Subscribers: kubamracek, dberris, mgorny, kristof.beyls, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D44705 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@328385 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/hwasan/hwasan.h')
-rw-r--r--lib/hwasan/hwasan.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/hwasan/hwasan.h b/lib/hwasan/hwasan.h
index 30fc947b6..604c97024 100644
--- a/lib/hwasan/hwasan.h
+++ b/lib/hwasan/hwasan.h
@@ -137,6 +137,15 @@ const int STACK_TRACE_TAG_POISON = StackTrace::TAG_CUSTOM + 1;
GetStackTrace(&stack, kStackTraceMax, pc, bp, nullptr, \
common_flags()->fast_unwind_on_fatal)
+#define GET_FATAL_STACK_TRACE_HERE \
+ GET_FATAL_STACK_TRACE_PC_BP(StackTrace::GetCurrentPc(), GET_CURRENT_FRAME())
+
+#define PRINT_CURRENT_STACK_CHECK() \
+ { \
+ GET_FATAL_STACK_TRACE_HERE; \
+ stack.Print(); \
+ }
+
class ScopedThreadLocalStateBackup {
public:
ScopedThreadLocalStateBackup() { Backup(); }