forked from OSchip/llvm-project
[ASan] Split interception-in-shared-lib-test.cc into two tests with platform-specific RUN commands.
Get rid of a TestCases/SharedLibs/shared-lib-test-so.cc dependency in these tests. llvm-svn: 202267
This commit is contained in:
parent
78443cfda6
commit
4b1a7fe33a
|
@ -0,0 +1,30 @@
|
|||
// Check that memset() call from a shared library gets intercepted.
|
||||
|
||||
// RUN: %clangxx_asan -O0 %s -DSHARED_LIB \
|
||||
// RUN: -shared -o %T/libinterception-in-shared-lib-test.so \
|
||||
// RUN: -fPIC
|
||||
// TODO(glider): figure out how to set rpath in a more portable way and unite
|
||||
// this test with ../Linux/interception-in-shared-lib-test.cc.
|
||||
// RUN: %clangxx_asan -O0 %s -o %t -Wl,-rpath,@executable-path -L%T -linterception-in-shared-lib-test && \
|
||||
// RUN: not %t 2>&1 | FileCheck %s
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(SHARED_LIB)
|
||||
extern "C"
|
||||
void my_memset(void *p, size_t sz) {
|
||||
memset(p, 0, sz);
|
||||
}
|
||||
#else
|
||||
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}}
|
||||
// CHECK: {{ #0 0x.* in my_memset .*interception-in-shared-lib-test.cc:17}}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
|
@ -1,14 +1,22 @@
|
|||
// Check that memset() call from a shared library gets intercepted.
|
||||
|
||||
// RUN: %clangxx_asan -O0 %p/SharedLibs/shared-lib-test-so.cc \
|
||||
// RUN: %clangxx_asan -O0 %s -DSHARED_LIB \
|
||||
// RUN: -shared -o %T/libinterception-in-shared-lib-test.so \
|
||||
// RUN: -fPIC
|
||||
// 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.
|
||||
// RUN: %clangxx_asan -O0 %s -o %t -Wl,-R,\$ORIGIN -L%T -linterception-in-shared-lib-test && \
|
||||
// RUN: not %t 2>&1 | FileCheck %s
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(SHARED_LIB)
|
||||
extern "C"
|
||||
void my_memset(void *p, size_t sz) {
|
||||
memset(p, 0, sz);
|
||||
}
|
||||
#else
|
||||
extern "C" void my_memset(void *p, size_t sz);
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
@ -16,6 +24,7 @@ int main(int argc, char *argv[]) {
|
|||
my_memset(buf, 11);
|
||||
// CHECK: {{.*ERROR: AddressSanitizer: stack-buffer-overflow}}
|
||||
// CHECK: {{WRITE of size 11 at 0x.* thread T0}}
|
||||
// CHECK: {{ #0 0x.* in my_memset .*shared-lib-test-so.cc:31}}
|
||||
// CHECK: {{ #0 0x.* in my_memset .*interception-in-shared-lib-test.cc:17}}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
|
@ -25,8 +25,3 @@ extern "C"
|
|||
void inc2(int *a, int index) {
|
||||
a[index]++;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
void my_memset(void *p, size_t sz) {
|
||||
memset(p, 0, sz);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue