diff options
author | Mitch Phillips <mitchphillips@outlook.com> | 2019-07-02 20:33:19 +0000 |
---|---|---|
committer | Mitch Phillips <mitchphillips@outlook.com> | 2019-07-02 20:33:19 +0000 |
commit | b5326fc731401e53530f9d9d474e3ef3829bc838 (patch) | |
tree | 27a4ac96a2f97ea804735f56f23475bd448276e3 /lib/scudo | |
parent | 81479e2f9ffcfbccbdaabea0e1354f30e0168f8f (diff) | |
download | compiler-rt-b5326fc731401e53530f9d9d474e3ef3829bc838.tar.gz |
[GWP-ASan] [Scudo] Add GWP-ASan backtrace for alloc/free to Scudo.
Summary:
Adds allocation and deallocation stack trace support to Scudo. The
default provided backtrace library for GWP-ASan is supplied by the libc
unwinder, and is suitable for production variants of Scudo. If Scudo in future
has its own unwinder, it may choose to use its own over the generic unwinder
instead.
Reviewers: cryptoad
Reviewed By: cryptoad
Subscribers: kubamracek, mgorny, #sanitizers, llvm-commits, morehouse, vlad.tsyrklevich, eugenis
Tags: #sanitizers, #llvm
Differential Revision: https://reviews.llvm.org/D64085
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@364966 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/scudo')
-rw-r--r-- | lib/scudo/CMakeLists.txt | 7 | ||||
-rw-r--r-- | lib/scudo/scudo_allocator.cpp | 6 |
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/scudo/CMakeLists.txt b/lib/scudo/CMakeLists.txt index a3be506d8..dde89ddc7 100644 --- a/lib/scudo/CMakeLists.txt +++ b/lib/scudo/CMakeLists.txt @@ -12,6 +12,10 @@ append_list_if(COMPILER_RT_HAS_LIBDL dl SCUDO_MINIMAL_DYNAMIC_LIBS) append_list_if(COMPILER_RT_HAS_LIBRT rt SCUDO_MINIMAL_DYNAMIC_LIBS) append_list_if(COMPILER_RT_HAS_LIBPTHREAD pthread SCUDO_MINIMAL_DYNAMIC_LIBS) append_list_if(COMPILER_RT_HAS_LIBLOG log SCUDO_MINIMAL_DYNAMIC_LIBS) +append_list_if(COMPILER_RT_HAS_OMIT_FRAME_POINTER_FLAG -fno-omit-frame-pointer + SCUDO_CFLAGS) +append_list_if(COMPILER_RT_HAS_OMIT_FRAME_POINTER_FLAG + -mno-omit-leaf-frame-pointer SCUDO_CFLAGS) set(SCUDO_DYNAMIC_LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS}) # Use gc-sections by default to avoid unused code being pulled in. @@ -35,7 +39,8 @@ if (COMPILER_RT_HAS_GWP_ASAN) # Currently, Scudo uses the GwpAsan flag parser. This backs onto the flag # parsing mechanism of sanitizer_common. Once Scudo has its own flag parsing, # and parses GwpAsan options, you can remove this dependency. - list(APPEND SCUDO_MINIMAL_OBJECT_LIBS RTGwpAsan RTGwpAsanOptionsParser) + list(APPEND SCUDO_MINIMAL_OBJECT_LIBS RTGwpAsan RTGwpAsanOptionsParser + RTGwpAsanBacktraceLibc) list(APPEND SCUDO_CFLAGS -DGWP_ASAN_HOOKS) endif() diff --git a/lib/scudo/scudo_allocator.cpp b/lib/scudo/scudo_allocator.cpp index f9044393c..b2ebc9705 100644 --- a/lib/scudo/scudo_allocator.cpp +++ b/lib/scudo/scudo_allocator.cpp @@ -27,6 +27,7 @@ #ifdef GWP_ASAN_HOOKS # include "gwp_asan/guarded_pool_allocator.h" +# include "gwp_asan/optional/backtrace.h" # include "gwp_asan/optional/options_parser.h" #endif // GWP_ASAN_HOOKS @@ -671,7 +672,10 @@ void initScudo() { Instance.init(); #ifdef GWP_ASAN_HOOKS gwp_asan::options::initOptions(); - GuardedAlloc.init(gwp_asan::options::getOptions()); + gwp_asan::options::Options &Opts = gwp_asan::options::getOptions(); + Opts.Backtrace = gwp_asan::options::getBacktraceFunction(); + Opts.PrintBacktrace = gwp_asan::options::getPrintBacktraceFunction(); + GuardedAlloc.init(Opts); #endif // GWP_ASAN_HOOKS } |