| 1 | // Make sure everything works even if the main module doesn't have any stack |
| 2 | // variables, thus doesn't explicitly reference any symbol exported by the |
| 3 | // runtime thunk. |
| 4 | // |
| 5 | // RUN: %clang_cl_asan %LD %Od -DDLL1 %s %Fe%t1.dll \ |
| 6 | // RUN: %if target={{.*-windows-gnu}} %{ -Wl,--out-implib,%t1.lib %} |
| 7 | // RUN: %clang_cl_asan %LD %Od -DDLL2 %s %Fe%t2.dll \ |
| 8 | // RUN: %if target={{.*-windows-gnu}} %{ -Wl,--out-implib,%t2.lib %} |
| 9 | // RUN: %clang_cl_asan %Od -DEXE %s %t1.lib %t2.lib %Fe%t |
| 10 | // RUN: not %run %t 2>&1 | FileCheck %s |
| 11 | |
| 12 | #include "../defines.h" |
| 13 | #include <malloc.h> |
| 14 | #include <string.h> |
| 15 | |
| 16 | #if defined(EXE) |
| 17 | extern "C" { |
| 18 | __declspec(dllimport) void foo1(); |
| 19 | __declspec(dllimport) void foo2(); |
| 20 | } |
| 21 | |
| 22 | int main() { |
| 23 | foo1(); |
| 24 | foo2(); |
| 25 | } |
| 26 | #elif defined(DLL1) |
| 27 | extern "C" { |
| 28 | __declspec(dllexport) void foo1() {} |
| 29 | } |
| 30 | #elif defined(DLL2) |
| 31 | extern "C" { |
| 32 | ATTRIBUTE_NOINLINE |
| 33 | static void NullDeref(int *ptr) { |
| 34 | // CHECK: ERROR: AddressSanitizer: access-violation on unknown address |
| 35 | // CHECK: {{0x0*000.. .*pc 0x.*}} |
| 36 | ptr[10]++; // BOOM |
| 37 | } |
| 38 | |
| 39 | __declspec(dllexport) void foo2() { |
| 40 | NullDeref((int *)0); |
| 41 | // CHECK: {{ #1 0x.* in foo2.*null_deref_multiple_dlls.cpp:}}[[@LINE-1]] |
| 42 | // CHECK: AddressSanitizer can not provide additional info. |
| 43 | } |
| 44 | } |
| 45 | #else |
| 46 | # error oops! |
| 47 | #endif |
| 48 | |