llvm-project/compiler-rt/test/asan/TestCases/Posix/interception-in-shared-lib-test.cpp
Kamil Rytarowski 90d2be0163 Stop marking 5 ASan tests as failing on NetBSD/i386
Unexpected Passing Tests (4):
    AddressSanitizer-i386-netbsd :: TestCases/Posix/coverage-reset.cpp
    AddressSanitizer-i386-netbsd :: TestCases/Posix/coverage.cpp
    AddressSanitizer-i386-netbsd :: TestCases/Posix/interception-in-shared-lib-test.cpp
    AddressSanitizer-i386-netbsd :: TestCases/suppressions-library.cpp

llvm-svn: 371337
2019-09-08 16:15:18 +00:00

28 lines
761 B
C++

// Check that memset() call from a shared library gets intercepted.
// RUN: %clangxx_asan -O0 %s -DSHARED_LIB \
// RUN: -shared -o %dynamiclib -fPIC %ld_flags_rpath_so
// RUN: %clangxx_asan -O0 %s -o %t %ld_flags_rpath_exe && \
// RUN: not %run %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: {{0x.* in my_memset .*interception-in-shared-lib-test.cpp:}}[[@LINE-10]]
return 0;
}
#endif