Index: test/asan/TestCases/Windows/check_interface_md.cc =================================================================== --- /dev/null +++ test/asan/TestCases/Windows/check_interface_md.cc @@ -0,0 +1,51 @@ +// Check that the interface exported by asan dll matches the list of functions +// mentioned in sanitizer_interface.inc files. +// +// Get path to the import library for asan dll. +// RUN: %clang_cl_asan -O0 %s -Fe%t -v 2>&1 | grep -o "[^\"]*dynamic-\S*lib" \ +// RUN: > %t.import_lib_path +// +// note: The mangling decoration (i.e. @4 )is removed because calling convention +// differ from 32-bit and 64-bit. +// +// RUN: cat %t.import_lib_path | xargs dumpbin //EXPORTS \ +// RUN: | grep -o "\(__asan_\|__ubsan_\|__sanitizer_\|__sancov_\)[^ ]*" \ +// RUN: | grep -v "__asan_wrap" | sed -e s/@.*// > %t.exports +// +// Get the list of ASan wrappers imported by the DLL RTL: +// [BEWARE: be really careful with the sed commands, as this test can be run +// from different environemnts with different shells and seds] +// +// RUN: grep "INTERFACE_FUNCTION" %p/../../../../lib/asan/asan_interface.inc \ +// RUN: %p/../../../../lib/ubsan/ubsan_interface.inc \ +// RUN: %p/../../../../lib/sanitizer_common/sanitizer_common_interface.inc \ +// RUN: %p/../../../../lib/sanitizer_common/sanitizer_coverage_interface.inc \ +// RUN: | sed -e s/.*(// | sed -e s/).*// > %t.imports1 +// +// RUN: grep "INTERFACE_WEAK_FUNCTION" \ +// RUN: %p/../../../../lib/asan/asan_interface.inc \ +// RUN: %p/../../../../lib/ubsan/ubsan_interface.inc \ +// RUN: %p/../../../../lib/sanitizer_common/sanitizer_common_interface.inc \ +// RUN: %p/../../../../lib/sanitizer_common/sanitizer_coverage_interface.inc \ +// RUN: | sed -e s/.*(// | sed -e s/).*/__dll/ > %t.imports2 +// +// Add functions intercepted in asan_dll_thunk. +// RUN: grep '[I]MPORT:' %s | sed -e 's/.*[I]MPORT: //' > %t.imports3 +// IMPORT: __asan_init +// IMPORT: __asan_shadow_memory_dynamic_address +// IMPORT: __asan_get_shadow_memory_dynamic_address +// IMPORT: __asan_option_detect_stack_use_after_return +// IMPORT: __asan_should_detect_stack_use_after_return +// +// RUN: cat %t.imports1 %t.imports2 %t.imports3 | sort | uniq > %t.imports-sorted +// RUN: cat %t.exports | sort | uniq > %t.exports-sorted +// +// Now make sure the DLL thunk imports everything: +// RUN: echo +// RUN: echo "=== NOTE === If you see a mismatch below, please update sanitizer_interface.inc files." +// RUN: diff %t.imports-sorted %t.exports-sorted +// REQUIRES: asan-dynamic-runtime + +int main(int argc, char **argv) { + return 0; +} Index: test/asan/TestCases/Windows/check_interface_mt.cc =================================================================== --- /dev/null +++ test/asan/TestCases/Windows/check_interface_mt.cc @@ -0,0 +1,70 @@ +// Check that the interface exported by asan static lib matches the list of +// functions mentioned in sanitizer_interface.inc files and the wrappers in +// asan_win_dll_thunk. +// +// Just make sure we can compile this. +// The actual compile&run sequence is to be done by the DLL tests. +// RUN: %clang_cl_asan -O0 %s -Fe%t +// +// Get the list of ASan wrappers exported by the main module RTL: +// note: The mangling decoration (i.e. @4 )is removed because calling convention +// differ from 32-bit and 64-bit. +// +// RUN: dumpbin /EXPORTS %t | sed s/=.*// \ +// RUN: | grep -o "\(__asan_\|__ubsan_\|__sanitizer_\|__sancov_\)[^ ]*" \ +// RUN: | sed -e s/@.*// > %t.exports1 +// +// The exception handlers differ in 32-bit and 64-bit, so we ignore them: +// RUN: grep '[E]XPORT:' %s | sed -e 's/.*[E]XPORT: //' > %t.exports2 +// EXPORT: __asan_wrap__except_handler3 +// EXPORT: __asan_wrap__except_handler4 +// EXPORT: __asan_wrap___C_specific_handler +// +// Get the list of ASan wrappers imported by the DLL RTL: +// [BEWARE: be really careful with the sed commands, as this test can be run +// from different environemnts with different shells and seds] +// +// RUN: grep INTERCEPT_LIBRARY_FUNCTION %p/../../../../lib/asan/asan_win_dll_thunk.cc \ +// RUN: | sed -e s/.*(/__asan_wrap_/ | sed -e s/).*// > %t.imports1 +// +// RUN: grep "INTERFACE_FUNCTION" %p/../../../../lib/asan/asan_interface.inc \ +// RUN: %p/../../../../lib/ubsan/ubsan_interface.inc \ +// RUN: %p/../../../../lib/sanitizer_common/sanitizer_common_interface.inc \ +// RUN: %p/../../../../lib/sanitizer_common/sanitizer_coverage_interface.inc \ +// RUN: | sed -e s/.*(// | sed -e s/).*// > %t.imports2 +// +// RUN: grep "INTERFACE_WEAK_FUNCTION" %p/../../../../lib/asan/asan_interface.inc \ +// RUN: %p/../../../../lib/ubsan/ubsan_interface.inc \ +// RUN: %p/../../../../lib/sanitizer_common/sanitizer_common_interface.inc \ +// RUN: %p/../../../../lib/sanitizer_common/sanitizer_coverage_interface.inc \ +// RUN: | sed -e s/.*(// | sed -e s/).*/__dll/ > %t.imports3 +// +// Add functions intercepted in asan_malloc.win.cc and asan_win.cc. +// RUN: grep '[I]MPORT:' %s | sed -e 's/.*[I]MPORT: //' > %t.imports4 +// IMPORT: __asan_wrap_HeapAlloc +// IMPORT: __asan_wrap_HeapFree +// IMPORT: __asan_wrap_HeapReAlloc +// IMPORT: __asan_wrap_HeapSize +// IMPORT: __asan_wrap_CreateThread +// IMPORT: __asan_wrap_RaiseException +// IMPORT: __asan_wrap_RtlRaiseException +// +// These functions are not included in the interfaces lists: +// IMPORT: __asan_init +// IMPORT: __asan_shadow_memory_dynamic_address +// IMPORT: __asan_get_shadow_memory_dynamic_address +// IMPORT: __asan_option_detect_stack_use_after_return +// IMPORT: __asan_should_detect_stack_use_after_return +// +// RUN: cat %t.imports1 %t.imports2 %t.imports3 %t.imports4 | sort | uniq > %t.imports-sorted +// RUN: cat %t.exports1 %t.exports2 | sort | uniq > %t.exports-sorted +// +// Now make sure the DLL thunk imports everything: +// RUN: echo +// RUN: echo "=== NOTE === If you see a mismatch below, please update asan_win_dll_thunk.cc and interface.inc files." +// RUN: diff %t.imports-sorted %t.exports-sorted +// REQUIRES: asan-static-runtime + +int main() { + return 0; +} Index: test/asan/TestCases/Windows/dll_host.cc =================================================================== --- test/asan/TestCases/Windows/dll_host.cc +++ test/asan/TestCases/Windows/dll_host.cc @@ -3,45 +3,6 @@ // Just make sure we can compile this. // The actual compile&run sequence is to be done by the DLL tests. // RUN: %clang_cl_asan -O0 %s -Fe%t -// -// Get the list of ASan wrappers exported by the main module RTL: -// note: The mangling decoration (i.e. @4 )is removed because calling convention -// differ from 32-bit and 64-bit. -// RUN: dumpbin /EXPORTS %t | grep -o "__asan_wrap[^ ]*" | sed -e s/@.*// > %t.exported_wrappers1 -// FIXME: we should really check the other __asan exports too. -// RUN: dumpbin /EXPORTS %t | grep -o "__sanitizer_[^ ]*" | sed -e s/@.*// > %t.exported_wrappers2 -// -// Get the list of ASan wrappers imported by the DLL RTL: -// [BEWARE: be really careful with the sed commands, as this test can be run -// from different environemnts with different shells and seds] -// RUN: grep INTERCEPT_LIBRARY_FUNCTION %p/../../../../lib/asan/asan_win_dll_thunk.cc | grep -v define | sed -e s/.*(/__asan_wrap_/ | sed -e s/).*// > %t.dll_imports1 -// RUN: grep "^INTERFACE_FUNCTION.*sanitizer" %p/../../../../lib/asan/asan_win_dll_thunk.cc | grep -v define | sed -e s/.*(// | sed -e s/).*// > %t.dll_imports2 -// -// Add functions interecepted in asan_malloc.win.cc and asan_win.cc. -// RUN: grep '[I]MPORT:' %s | sed -e 's/.*[I]MPORT: //' > %t.dll_imports3 -// IMPORT: __asan_wrap_HeapAlloc -// IMPORT: __asan_wrap_HeapFree -// IMPORT: __asan_wrap_HeapReAlloc -// IMPORT: __asan_wrap_HeapSize -// IMPORT: __asan_wrap_CreateThread -// IMPORT: __asan_wrap_RaiseException -// IMPORT: __asan_wrap_RtlRaiseException -// -// The exception handlers differ in 32-bit and 64-bit, so we ignore them: -// RUN: grep '[E]XPORT:' %s | sed -e 's/.*[E]XPORT: //' > %t.exported_wrappers3 -// EXPORT: __asan_wrap__except_handler3 -// EXPORT: __asan_wrap__except_handler4 -// EXPORT: __asan_wrap___C_specific_handler -// -// RUN: cat %t.dll_imports1 %t.dll_imports2 %t.dll_imports3 | sort | uniq > %t.dll_imports-sorted -// RUN: cat %t.exported_wrappers1 %t.exported_wrappers2 %t.exported_wrappers3 | sort | uniq > %t.exported_wrappers-sorted -// -// Now make sure the DLL thunk imports everything: -// RUN: echo -// RUN: echo "=== NOTE === If you see a mismatch below, please update asan_win_dll_thunk.cc" -// RUN: diff %t.dll_imports-sorted %t.exported_wrappers-sorted -// REQUIRES: asan-static-runtime -// XFAIL: win #include #include