]> git.proxmox.com Git - rustc.git/blame - src/compiler-rt/test/asan/TestCases/Linux/asan_preload_test-2.cc
Imported Upstream version 1.6.0+dfsg1
[rustc.git] / src / compiler-rt / test / asan / TestCases / Linux / asan_preload_test-2.cc
CommitLineData
1a4d82fc
JJ
1// Test that preloaded runtime works with unsanitized executables.
2//
3// RUN: %clangxx %s -o %t
92a42be0 4// RUN: env LD_PRELOAD=%shared_libasan not %run %t 2>&1 | FileCheck %s
1a4d82fc
JJ
5
6// REQUIRES: asan-dynamic-runtime
7
92a42be0
SL
8// This way of setting LD_PRELOAD does not work with Android test runner.
9// REQUIRES: not-android
10
1a4d82fc
JJ
11#include <stdlib.h>
12
92a42be0 13extern "C" ssize_t write(int fd, const void *buf, size_t count);
1a4d82fc
JJ
14
15void do_access(void *p) {
16 // CHECK: AddressSanitizer: heap-buffer-overflow
92a42be0 17 write(1, p, 2);
1a4d82fc
JJ
18}
19
20int main(int argc, char **argv) {
21 void *p = malloc(1);
22 do_access(p);
23 return 0;
24}