diff options
author | Kostya Kortchinsky <kostyak@google.com> | 2017-10-23 16:27:47 +0000 |
---|---|---|
committer | Kostya Kortchinsky <kostyak@google.com> | 2017-10-23 16:27:47 +0000 |
commit | e378f8791d2d42e4c3f26033ba20a1bf4b43d2d5 (patch) | |
tree | ae8916ff500e211891b3a73b1c3a1cfc45e7ddaf /test/scudo | |
parent | 59dbe326d4bcc31f36ba363e08cad5c022f5fcc3 (diff) |
[scudo] Add a shared runtime
Summary:
Up to now, the Scudo cmake target only provided a static library that had to be
linked to an executable to benefit from the hardened allocator.
This introduces a shared library as well, that can be LD_PRELOAD'ed.
Reviewers: alekseyshl
Reviewed By: alekseyshl
Subscribers: srhines, mgorny, llvm-commits
Differential Revision: https://reviews.llvm.org/D38980
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@316342 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/scudo')
-rw-r--r-- | test/scudo/lit.cfg | 13 | ||||
-rw-r--r-- | test/scudo/preload.cpp | 20 |
2 files changed, 27 insertions, 6 deletions
diff --git a/test/scudo/lit.cfg b/test/scudo/lit.cfg index bd9e6aa31..f4b864777 100644 --- a/test/scudo/lit.cfg +++ b/test/scudo/lit.cfg @@ -8,10 +8,10 @@ config.name = 'Scudo' + config.name_suffix # Setup source root. config.test_source_root = os.path.dirname(__file__) -# Path to the static library -base_lib = os.path.join(config.compiler_rt_libdir, - "libclang_rt.scudo-%s.a" % config.target_arch) -whole_archive = "-Wl,-whole-archive %s -Wl,-no-whole-archive " % base_lib +# Path to the shared & static libraries +shared_libscudo = os.path.join(config.compiler_rt_libdir, "libclang_rt.scudo-%s.so" % config.target_arch) +static_libscudo = os.path.join(config.compiler_rt_libdir, "libclang_rt.scudo-%s.a" % config.target_arch) +whole_archive = "-Wl,-whole-archive %s -Wl,-no-whole-archive " % static_libscudo # Test suffixes. config.suffixes = ['.c', '.cc', '.cpp'] @@ -35,8 +35,9 @@ def build_invocation(compile_flags): return " " + " ".join([config.compile_wrapper, config.clang] + compile_flags) + " " # Add clang substitutions. -config.substitutions.append(("%clang_scudo ", - build_invocation(c_flags) + whole_archive)) +config.substitutions.append(("%clang ", build_invocation(c_flags))) +config.substitutions.append(("%clang_scudo ", build_invocation(c_flags) + whole_archive)) +config.substitutions.append(("%shared_libscudo", shared_libscudo)) # Platform-specific default SCUDO_OPTIONS for lit tests. default_scudo_opts = '' diff --git a/test/scudo/preload.cpp b/test/scudo/preload.cpp new file mode 100644 index 000000000..0da507b3c --- /dev/null +++ b/test/scudo/preload.cpp @@ -0,0 +1,20 @@ +// Test that the preloaded runtime works without linking the static library. + +// RUN: %clang %s -o %t +// RUN: env LD_PRELOAD=%shared_libscudo not %run %t 2>&1 | FileCheck %s + +// This way of setting LD_PRELOAD does not work with Android test runner. +// REQUIRES: !android + +#include <assert.h> +#include <stdlib.h> + +int main(int argc, char *argv[]) { + void *p = malloc(sizeof(int)); + assert(p); + free(p); + free(p); + return 0; +} + +// CHECK: ERROR: invalid chunk state |