]> git.proxmox.com Git - rustc.git/blob - src/compiler-rt/test/asan/TestCases/Linux/asan_preload_test-1.cc
Merge tag 'upstream-tar/1.0.0_0alpha'
[rustc.git] / src / compiler-rt / test / asan / TestCases / Linux / asan_preload_test-1.cc
1 // Test that non-sanitized executables work with sanitized shared libs
2 // and preloaded runtime.
3 //
4 // RUN: %clangxx -DBUILD_SO=1 -fPIC -shared %s -o %t.so
5 // RUN: %clangxx %s %t.so -o %t
6 //
7 // RUN: %clangxx_asan -DBUILD_SO=1 -fPIC -shared %s -o %t.so
8 // RUN: LD_PRELOAD=%shared_libasan not %run %t 2>&1 | FileCheck %s
9
10 // REQUIRES: asan-dynamic-runtime
11
12 #if BUILD_SO
13 char dummy;
14 void do_access(const void *p) {
15 // CHECK: AddressSanitizer: heap-buffer-overflow
16 dummy = ((const char *)p)[1];
17 }
18 #else
19 #include <stdlib.h>
20 extern void do_access(const void *p);
21 int main(int argc, char **argv) {
22 void *p = malloc(1);
23 do_access(p);
24 free(p);
25 return 0;
26 }
27 #endif