diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:45:36 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:45:36 +0000 |
commit | 6f08730ec5f639f05f2f15354171e4a3c9af9dc1 (patch) | |
tree | 7374e9d4448083010ada98d17976199c7e945d47 /test/safestack | |
parent | c003a57e2e4a1ad9be0338806bc1038b6987155f (diff) | |
download | src-6f08730ec5f639f05f2f15354171e4a3c9af9dc1.tar.gz src-6f08730ec5f639f05f2f15354171e4a3c9af9dc1.zip |
Vendor import of compiler-rt release_39 branch r276489:vendor/compiler-rt/compiler-rt-release_39-r276489
Notes
Notes:
svn path=/vendor/compiler-rt/dist/; revision=303235
svn path=/vendor/compiler-rt/compiler-rt-release_39-r276489/; revision=303236; tag=vendor/compiler-rt/compiler-rt-release_39-r276489
Diffstat (limited to 'test/safestack')
-rw-r--r-- | test/safestack/CMakeLists.txt | 2 | ||||
-rw-r--r-- | test/safestack/canary.c | 37 | ||||
-rw-r--r-- | test/safestack/lit.site.cfg.in | 3 |
3 files changed, 39 insertions, 3 deletions
diff --git a/test/safestack/CMakeLists.txt b/test/safestack/CMakeLists.txt index 6f5c2f9b0af4..c56e81a3ce21 100644 --- a/test/safestack/CMakeLists.txt +++ b/test/safestack/CMakeLists.txt @@ -26,4 +26,4 @@ configure_lit_site_cfg( add_lit_testsuite(check-safestack "Running the SafeStack tests" ${CMAKE_CURRENT_BINARY_DIR} DEPENDS ${SAFESTACK_TEST_DEPS}) -set_target_properties(check-safestack PROPERTIES FOLDER "SafeStack tests") +set_target_properties(check-safestack PROPERTIES FOLDER "Compiler-RT Misc") diff --git a/test/safestack/canary.c b/test/safestack/canary.c new file mode 100644 index 000000000000..c6b81f24327f --- /dev/null +++ b/test/safestack/canary.c @@ -0,0 +1,37 @@ +// RUN: %clang_safestack -fno-stack-protector -D_FORTIFY_SOURCE=0 -g %s -o %t.nossp +// RUN: %run %t.nossp 2>&1 | FileCheck --check-prefix=NOSSP %s + +// RUN: %clang_safestack -fstack-protector-all -D_FORTIFY_SOURCE=0 -g %s -o %t.ssp +// RUN: not --crash %run %t.ssp 2>&1 | FileCheck -check-prefix=SSP %s + +// Test stack canaries on the unsafe stack. + +// REQUIRES: stable-runtime + +#include <assert.h> +#include <stdio.h> +#include <string.h> + +__attribute__((noinline)) void f(unsigned *y) { + char x; + char *volatile p = &x; + char *volatile q = (char *)y; + assert(p < q); + assert(q - p < 1024); // sanity + // This has technically undefined behavior, but we know the actual layout of + // the unsafe stack and this should not touch anything important. + memset(&x, 0xab, q - p + sizeof(*y)); +} + +int main(int argc, char **argv) +{ + unsigned y; + // NOSSP: main 1 + // SSP: main 1 + fprintf(stderr, "main 1\n"); + f(&y); + // NOSSP: main 2 + // SSP-NOT: main 2 + fprintf(stderr, "main 2\n"); + return 0; +} diff --git a/test/safestack/lit.site.cfg.in b/test/safestack/lit.site.cfg.in index cb1e7292e5f2..6864f39dfb31 100644 --- a/test/safestack/lit.site.cfg.in +++ b/test/safestack/lit.site.cfg.in @@ -1,5 +1,4 @@ -## Autogenerated by LLVM/Clang configuration. -# Do not edit! +@LIT_SITE_CFG_IN_HEADER@ # Load common config for all compiler-rt lit tests. lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") |