31 lines · c
1// RUN: %clang_cl_asan %Od %p/dll_host.cpp %Fe%t2//3// RUN: %clang_cl_nocxx_asan %Gw %LD %Od %s %Fe%t.dll4// RUN: %env_asan_opts=report_globals=2 %run %t %t.dll 2>&1 | FileCheck %s --check-prefix=NOSTRIP5// RUN: %clang_cl_nocxx_asan %Gw %LD -O2 %s %Fe%t.dll \6// RUN: %if target={{.*-windows-gnu}} %{ -Wl,--gc-sections %} \7// RUN: %else %{ -link -opt:ref %}8// RUN: %env_asan_opts=report_globals=2 %run %t %t.dll 2>&1 | FileCheck %s --check-prefix=STRIP9 10#include <stdio.h>11 12int dead_global = 42;13int live_global = 0;14 15__declspec(dllexport)16int test_function() {17 puts("main");18 return live_global;19}20 21// Check that our global registration scheme works with MSVC's linker dead22// stripping (/OPT:REF).23 24// NOSTRIP: Added Global{{.*}}name=dead_global25// NOSTRIP: Added Global{{.*}}name=live_global26// NOSTRIP: main27 28// STRIP-NOT: Added Global{{.*}}name=dead_global29// STRIP: Added Global{{.*}}name=live_global30// STRIP: main31