Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/native/corehost/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ if ((NOT DEFINED CLR_CMAKE_USE_SYSTEM_RAPIDJSON) OR (NOT CLR_CMAKE_USE_SYSTEM_RA
include_directories(${CLR_SRC_NATIVE_DIR}/external/)
endif()

add_subdirectory(${CLR_SRC_NATIVE_DIR}/minipal/ minipal)
add_subdirectory(hostcommon)
add_subdirectory(hostmisc)
add_subdirectory(fxr)
Expand Down
9 changes: 9 additions & 0 deletions src/native/minipal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,17 @@ endif()
add_library(minipal STATIC)
target_link_libraries(minipal PRIVATE minipal_objects)

set(SANITIZER_EXPORTS_FILE ${CMAKE_CURRENT_SOURCE_DIR}/sanitizer_exports.def)

add_library(minipal_sanitizer_support OBJECT
sansupport.c)

set_source_files_properties(sansupport.c PROPERTIES OBJECT_DEPENDS ${SANITIZER_EXPORTS_FILE})

if (MSVC)
target_link_options(minipal_sanitizer_support INTERFACE /DEF:${SANITIZER_EXPORTS_FILE})
endif()

# Exclude this target from the default build as we may not have sanitzer headers available
# in a non-sanitized build.
set_target_properties(minipal_sanitizer_support PROPERTIES EXCLUDE_FROM_ALL ON)
6 changes: 6 additions & 0 deletions src/native/minipal/sanitizer_exports.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
; Licensed to the .NET Foundation under one or more agreements.
; The .NET Foundation licenses this file to you under the MIT license.

EXPORTS
__asan_default_options
__asan_on_error
9 changes: 9 additions & 0 deletions src/native/minipal/sansupport.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
// Use a typedef here as __declspec + pointer return type causes a parse error in MSVC
typedef const char* charptr_t;

// This file may be built as C++ in our Windows builds. Make sure we get the linkage right.
#ifdef __cplusplus
extern "C"
{
#endif

charptr_t SANITIZER_CALLBACK_CALLCONV __asan_default_options(void) {
// symbolize=1 to get symbolized stack traces
Expand All @@ -20,3 +25,7 @@ charptr_t SANITIZER_CALLBACK_CALLCONV __asan_default_options(void) {

void SANITIZER_CALLBACK_CALLCONV __asan_on_error(void) {
}

#ifdef __cplusplus
}
#endif
9 changes: 2 additions & 7 deletions src/native/minipal/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,8 @@
#endif

#if defined(_MSC_VER)
# ifdef SANITIZER_SHARED_RUNTIME
# define SANITIZER_CALLBACK_CALLCONV __declspec(dllexport no_sanitize_address) __cdecl
# define SANITIZER_INTERFACE_CALLCONV __declspec(dllimport) __cdecl
# else
# define SANITIZER_CALLBACK_CALLCONV __declspec(no_sanitize_address) __cdecl
# define SANITIZER_INTERFACE_CALLCONV __cdecl
# endif
# define SANITIZER_CALLBACK_CALLCONV __declspec(no_sanitize_address) __cdecl
# define SANITIZER_INTERFACE_CALLCONV __cdecl
#else
# ifdef SANITIZER_SHARED_RUNTIME
# define SANITIZER_CALLBACK_CALLCONV __attribute__((no_address_safety_analysis)) __attribute__((visibility("default")))
Expand Down
Loading