2014-02-24 22:31:28 +08:00
|
|
|
// Check that memset() call from a shared library gets intercepted.
|
2014-04-22 18:53:57 +08:00
|
|
|
// Please always keep this file in sync with
|
|
|
|
// ../Darwin/interception-in-shared-lib-test.cc.
|
2014-02-24 22:31:28 +08:00
|
|
|
|
2014-02-26 22:05:57 +08:00
|
|
|
// RUN: %clangxx_asan -O0 %s -DSHARED_LIB \
|
2014-02-24 22:31:28 +08:00
|
|
|
// RUN: -shared -o %T/libinterception-in-shared-lib-test.so \
|
2014-02-25 23:25:37 +08:00
|
|
|
// RUN: -fPIC
|
2014-02-26 22:05:57 +08:00
|
|
|
// TODO(glider): figure out how to set rpath in a more portable way and unite
|
|
|
|
// this test with ../Darwin/interception-in-shared-lib-test.cc.
|
2014-02-24 22:31:28 +08:00
|
|
|
// RUN: %clangxx_asan -O0 %s -o %t -Wl,-R,\$ORIGIN -L%T -linterception-in-shared-lib-test && \
|
2014-05-01 05:34:17 +08:00
|
|
|
// RUN: not %run %t 2>&1 | FileCheck %s
|
2014-02-24 22:31:28 +08:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2014-02-26 22:05:57 +08:00
|
|
|
#if defined(SHARED_LIB)
|
|
|
|
extern "C"
|
|
|
|
void my_memset(void *p, size_t sz) {
|
|
|
|
memset(p, 0, sz);
|
|
|
|
}
|
|
|
|
#else
|
2014-02-24 22:31:28 +08:00
|
|
|
extern "C" void my_memset(void *p, size_t sz);
|
|
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
|
|
|
char buf[10];
|
|
|
|
my_memset(buf, 11);
|
|
|
|
// CHECK: {{.*ERROR: AddressSanitizer: stack-buffer-overflow}}
|
|
|
|
// CHECK: {{WRITE of size 11 at 0x.* thread T0}}
|
2014-04-22 18:53:57 +08:00
|
|
|
// CHECK: {{0x.* in my_memset .*interception-in-shared-lib-test.cc:19}}
|
2014-02-24 22:31:28 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-02-26 22:05:57 +08:00
|
|
|
#endif
|