2014-04-01 21:16:30 +08:00
|
|
|
// Test that preloaded runtime works with unsanitized executables.
|
|
|
|
//
|
|
|
|
// RUN: %clangxx %s -o %t
|
2015-06-16 04:43:42 +08:00
|
|
|
// RUN: env LD_PRELOAD=%shared_libasan not %run %t 2>&1 | FileCheck %s
|
2014-04-01 21:16:30 +08:00
|
|
|
|
|
|
|
// REQUIRES: asan-dynamic-runtime
|
2014-11-26 23:44:15 +08:00
|
|
|
|
|
|
|
// This way of setting LD_PRELOAD does not work with Android test runner.
|
|
|
|
// REQUIRES: not-android
|
2014-04-01 21:16:30 +08:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2014-12-24 19:48:40 +08:00
|
|
|
extern "C" ssize_t write(int fd, const void *buf, size_t count);
|
2014-04-01 21:16:30 +08:00
|
|
|
|
|
|
|
void do_access(void *p) {
|
|
|
|
// CHECK: AddressSanitizer: heap-buffer-overflow
|
2014-12-24 19:48:40 +08:00
|
|
|
write(1, p, 2);
|
2014-04-01 21:16:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
void *p = malloc(1);
|
|
|
|
do_access(p);
|
|
|
|
return 0;
|
|
|
|
}
|