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 -O0 -DDLL1 %s -Fe%t1.dll 6// RUN: %clang_cl_asan -LD -O0 -DDLL2 %s -Fe%t2.dll 7// RUN: %clang_cl_asan -O0 -DEXE %s %t1.lib %t2.lib -Fe%t 8// RUN: not %run %t 2>&1 | FileCheck %s 9 10#include <malloc.h> 11#include <string.h> 12 13extern "C" { 14#if defined(EXE) 15__declspec(dllimport) void foo1(); 16__declspec(dllimport) void foo2(); 17 18int main() { 19 foo1(); 20 foo2(); 21} 22#elif defined(DLL1) 23__declspec(dllexport) void foo1() {} 24#elif defined(DLL2) 25__attribute__((noinline)) 26static void NullDeref(int *ptr) { 27 // CHECK: ERROR: AddressSanitizer: access-violation on unknown address 28 // CHECK: {{0x0*000.. .*pc 0x.*}} 29 ptr[10]++; // BOOM 30} 31 32__declspec(dllexport) void foo2() { 33 NullDeref((int*)0); 34 // CHECK: {{ #1 0x.* in foo2.*null_deref_multiple_dlls.cc:}}[[@LINE-1]] 35 // CHECK: AddressSanitizer can not provide additional info. 36} 37#else 38# error oops! 39#endif 40} 41