1 // Load this DLL at the default 32-bit ASan shadow base, and test how we dump
2 // the process memory layout.
3 // REQUIRES: asan-32-bits
4 //
5 // RUN: %clang_cl_asan -DBUILD_DLL -LD %s -Fe%t_dll.dll -link -base:0x30000000 -fixed -dynamicbase:no
6 // RUN: %clang_cl_asan %s -Fe%t.exe -link %t_dll.lib
7 // RUN: not %run %t.exe 2>&1 | FileCheck %s
8 
9 #ifndef BUILD_DLL
10 #include <stdio.h>
11 
12 extern "C" __declspec(dllimport) int test_function();
13 
14 int main() {
15   fprintf(stderr, "should have failed to initialize, DLL got loaded near 0x%p\n",
16           (void *)&test_function);
17 }
18 
19 #else
20 extern "C" __declspec(dllexport) int test_function() { return 0; }
21 #endif
22 
23 // CHECK: =={{[0-9:]+}}==Shadow memory range interleaves with an existing memory mapping. ASan cannot proceed correctly. ABORTING.
24 // CHECK: =={{[0-9:]+}}==ASan shadow was supposed to be located in the [0x2fff0000-0x3fffffff] range.
25 // CHECK: =={{[0-9:]+}}==Dumping process modules
26 
27 // CHECK-DAG: {{0x30000000-0x300.....}} {{.*}}\shadow_conflict_32.cpp.tmp_dll.dll
28 // CHECK-DAG: {{0x........-0x........}} {{.*}}\shadow_conflict_32.cpp.tmp.exe
29 // CHECK-DAG: {{0x........-0x........}} {{.*}}\ntdll.dll
30