diff options
Diffstat (limited to 'test/asan/TestCases/asan-symbolize-sanity-test.cc')
-rw-r--r-- | test/asan/TestCases/asan-symbolize-sanity-test.cc | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/test/asan/TestCases/asan-symbolize-sanity-test.cc b/test/asan/TestCases/asan-symbolize-sanity-test.cc index 8daeac9e4..077187836 100644 --- a/test/asan/TestCases/asan-symbolize-sanity-test.cc +++ b/test/asan/TestCases/asan-symbolize-sanity-test.cc @@ -1,9 +1,11 @@ // Check that asan_symbolize.py script works (for binaries, ASan RTL and // shared object files. -// RUN: %clangxx_asan -O0 %p/SharedLibs/shared-lib-test-so.cc -fPIC -shared -o %t-so.so +// RUN: %clangxx_asan -O0 -DSHARED_LIB %s -fPIC -shared -o %t-so.so // RUN: %clangxx_asan -O0 %s -ldl -o %t // RUN: ASAN_OPTIONS=symbolize=0 not %run %t 2>&1 | %asan_symbolize | FileCheck %s + +#if !defined(SHARED_LIB) #include <dlfcn.h> #include <stdio.h> #include <stdlib.h> @@ -30,10 +32,27 @@ int main(int argc, char *argv[]) { inc2(array, -1); // BOOM // CHECK: ERROR: AddressSanitizer: heap-buffer-overflow // CHECK: READ of size 4 at 0x{{.*}} - // CHECK: #0 {{.*}} in inc2 {{.*}}shared-lib-test-so.cc:26 + // CHECK: #0 {{.*}} in inc2 {{.*}}asan-symbolize-sanity-test.cc:56 // CHECK: #1 {{.*}} in main {{.*}}asan-symbolize-sanity-test.cc:[[@LINE-4]] // CHECK: allocated by thread T{{.*}} here: // CHECK: #{{.*}} in {{(wrap_|__interceptor_)?}}malloc // CHECK: #{{.*}} in main {{.*}}asan-symbolize-sanity-test.cc:[[@LINE-9]] return 0; } +#else // SHARED_LIBS +#include <stdio.h> +#include <string.h> + +int pad[10]; +int GLOB[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + +extern "C" +void inc(int index) { + GLOB[index]++; +} + +extern "C" +void inc2(int *a, int index) { + a[index]++; +} +#endif // SHARED_LIBS |