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 <malloc.h> 13 #include <string.h> 14 15 #if defined(EXE) 16 extern "C" { 17 __declspec(dllimport) void foo1(); 18 __declspec(dllimport) void foo2(); 19 } 20 21 int main() { 22 foo1(); 23 foo2(); 24 } 25 #elif defined(DLL1) 26 extern "C" { 27 __declspec(dllexport) void foo1() {} 28 } 29 #elif defined(DLL2) 30 extern "C" { 31 __attribute__((noinline)) static void NullDeref(int *ptr) { 32 // CHECK: ERROR: AddressSanitizer: access-violation on unknown address 33 // CHECK: {{0x0*000.. .*pc 0x.*}} 34 ptr[10]++; // BOOM 35 } 36 37 __declspec(dllexport) void foo2() { 38 NullDeref((int *)0); 39 // CHECK: {{ #1 0x.* in foo2.*null_deref_multiple_dlls.cpp:}}[[@LINE-1]] 40 // CHECK: AddressSanitizer can not provide additional info. 41 } 42 } 43 #else 44 # error oops! 45 #endif 46