diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ToolBox/SOS/Strike/CMakeLists.txt | 10 | ||||
-rw-r--r-- | src/ToolBox/SOS/lldbplugin/CMakeLists.txt | 93 | ||||
-rw-r--r-- | src/debug/createdump/CMakeLists.txt | 7 | ||||
-rw-r--r-- | src/dlls/mscordac/CMakeLists.txt | 55 | ||||
-rw-r--r-- | src/dlls/mscordac/libredefines.S | 12 | ||||
-rw-r--r-- | src/dlls/mscordac/mscordac_unixexports.src | 338 | ||||
-rw-r--r-- | src/dlls/mscordac/palredefines.S | 12 | ||||
-rw-r--r-- | src/dlls/mscordbi/CMakeLists.txt | 37 | ||||
-rw-r--r-- | src/pal/inc/pal.h | 52 | ||||
-rw-r--r-- | src/pal/src/exception/seh.cpp | 42 | ||||
-rw-r--r-- | src/pal/src/include/pal/thread.hpp | 16 | ||||
-rw-r--r-- | src/palrt/guid.cpp | 2 | ||||
-rw-r--r-- | src/palrt/guiddef.h | 26 |
13 files changed, 411 insertions, 291 deletions
diff --git a/src/ToolBox/SOS/Strike/CMakeLists.txt b/src/ToolBox/SOS/Strike/CMakeLists.txt index 65c3f9585e..a9bd176dad 100644 --- a/src/ToolBox/SOS/Strike/CMakeLists.txt +++ b/src/ToolBox/SOS/Strike/CMakeLists.txt @@ -38,6 +38,7 @@ elseif(CLR_CMAKE_PLATFORM_ARCH_ARM64) add_definitions(-DDBG_TARGET_64BIT) add_definitions(-DDBG_TARGET_WIN64=1) endif() + add_definitions(-DSTRIKE) remove_definitions(-DUNICODE) @@ -183,6 +184,11 @@ endif() list(APPEND SOS_SOURCES ${SOS_SOURCES_ARCH}) +# Add the DAC PAL export mapping file +if(CLR_CMAKE_PLATFORM_LINUX) + list(APPEND SOS_SOURCES ${PAL_REDEFINES_FILE}) +endif(CLR_CMAKE_PLATFORM_LINUX) + if(CLR_CMAKE_PLATFORM_LINUX OR CLR_CMAKE_PLATFORM_FREEBSD OR CLR_CMAKE_PLATFORM_NETBSD) # Add linker exports file option set(EXPORTS_LINKER_OPTION -Wl,--version-script=${EXPORTS_FILE}) @@ -195,6 +201,10 @@ endif(CLR_CMAKE_PLATFORM_DARWIN) add_library_clr(sos SHARED ${SOS_SOURCES}) +if(CLR_CMAKE_PLATFORM_LINUX) + add_dependencies(sos pal_redefines_file) +endif(CLR_CMAKE_PLATFORM_LINUX) + if(CLR_CMAKE_PLATFORM_UNIX) add_custom_target(sos_exports DEPENDS ${EXPORTS_FILE}) add_dependencies(sos sos_exports) diff --git a/src/ToolBox/SOS/lldbplugin/CMakeLists.txt b/src/ToolBox/SOS/lldbplugin/CMakeLists.txt index e87ac8bf02..96aec3019b 100644 --- a/src/ToolBox/SOS/lldbplugin/CMakeLists.txt +++ b/src/ToolBox/SOS/lldbplugin/CMakeLists.txt @@ -45,57 +45,72 @@ elseif(CLR_CMAKE_PLATFORM_ARCH_ARM64) SET(REQUIRE_LLDBPLUGIN false) endif() -set(LLVM_HOST_DIR "$ENV{LLVM_HOME}") -set(WITH_LLDB_LIBS "${LLVM_HOST_DIR}/lib" CACHE PATH "Path to LLDB libraries") -set(WITH_LLDB_INCLUDES "${LLVM_HOST_DIR}/include" CACHE PATH "Path to LLDB headers") +if(NOT $ENV{LLVM_HOME} STREQUAL "") + set(LLDB_INCLUDE_DIR "$ENV{LLVM_HOME}/include") + set(LLDB_LIB_DIR "$ENV{LLVM_HOME}/lib") +else() + if(NOT $ENV{LLDB_INCLUDE_DIR} STREQUAL "") + set(LLDB_INCLUDE_DIR "$ENV{LLDB_INCLUDE_DIR}") + endif() + if(NOT $ENV{LLDB_LIB_DIR} STREQUAL "") + set(LLDB_LIB_DIR "$ENV{LLDB_LIB_DIR}") + endif() +endif() if(NOT ENABLE_LLDBPLUGIN) return() endif() -if (CLR_CMAKE_PLATFORM_DARWIN) +if(NOT $ENV{LLDB_LIB} STREQUAL "") + set(LLDB_LIB "$ENV{LLDB_LIB}") +else() # Check for LLDB library - find_library(LLDB NAMES LLDB lldb lldb-6.0 lldb-5.0 lldb-4.0 lldb-3.9 lldb-3.8 lldb-3.7 lldb-3.6 lldb-3.5 PATHS "${WITH_LLDB_LIBS}" PATH_SUFFIXES llvm NO_DEFAULT_PATH) - find_library(LLDB NAMES LLDB lldb lldb-6.0 lldb-5.0 lldb-4.0 lldb-3.9 lldb-3.8 lldb-3.7 lldb-3.6 lldb-3.5 PATH_SUFFIXES llvm) - if(LLDB STREQUAL LLDB-NOTFOUND) + if(CLR_CMAKE_PLATFORM_DARWIN) + find_library(LLDB_LIB NAMES LLDB lldb lldb-6.0 lldb-5.0 lldb-4.0 lldb-3.9 lldb-3.8 lldb-3.7 lldb-3.6 lldb-3.5 PATHS "${WITH_LLDB_LIBS}" PATH_SUFFIXES llvm NO_DEFAULT_PATH) + find_library(LLDB_LIB NAMES LLDB lldb lldb-6.0 lldb-5.0 lldb-4.0 lldb-3.9 lldb-3.8 lldb-3.7 lldb-3.6 lldb-3.5 PATH_SUFFIXES llvm) + if(LLDB_LIB STREQUAL LLDB_LIB-NOTFOUND) + if(REQUIRE_LLDBPLUGIN) + set(MESSAGE_MODE FATAL_ERROR) + else() + set(MESSAGE_MODE WARNING) + endif() + message(${MESSAGE_MODE} "Cannot find lldb library. Try installing Xcode. You may need to set LLVM_HOME, LLDB_LIB_DIR or LLDB_LIB if the build still can't find it.") + return() + endif() + endif() +endif() + +message(STATUS "LLDB_LIB: ${LLDB_LIB}") + +if(NOT $ENV{LLDB_H} STREQUAL "") + set(LLDB_H "$ENV{LLDB_H}") +else() + # Check for LLDB headers + # Multiple versions of LLDB can install side-by-side, so we need to check for lldb in various locations. + # If the file in a directory is found the result is stored in the variable and the search will not be repeated unless the variable is cleared. + find_path(LLDB_H "lldb/API/LLDB.h" PATHS "${WITH_LLDB_INCLUDES}" NO_DEFAULT_PATH) + find_path(LLDB_H "lldb/API/LLDB.h") + find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-6.0/include") + find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-5.0/include") + find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-4.0/include") + find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-3.9/include") + find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-3.8/include") + find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-3.7/include") + find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-3.6/include") + find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-3.5/include") + #FreeBSD + find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/local/llvm39/include") + find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/local/llvm38/include") + + if(LLDB_H STREQUAL LLDB_H-NOTFOUND) if(REQUIRE_LLDBPLUGIN) set(MESSAGE_MODE FATAL_ERROR) else() set(MESSAGE_MODE WARNING) endif() - message(${MESSAGE_MODE} "Cannot find lldb-3.5, lldb-3.6, lldb-3.8, lldb-3.9, lldb-4.0, lldb-5.0 or lldb-6.0. Try installing liblldb-3.9-dev (or the appropriate package for your platform). You may need to set LLVM_HOME if the build still can't find it.") - + message(${MESSAGE_MODE} "Cannot find LLDB.h Try installing lldb-3.9-dev (or the appropriate package for your platform). You may need to set LLVM_HOME or LLDB_INCLUDE_DIR if the build still can't find it.") return() endif() - - message(STATUS "LLDB: ${LLDB}") -endif() - -# Check for LLDB headers -# Multiple versions of LLDB can install side-by-side, so we need to check for lldb in various locations. -# If the file in a directory is found the result is stored in the variable and the search will not be repeated unless the variable is cleared. -find_path(LLDB_H "lldb/API/LLDB.h" PATHS "${WITH_LLDB_INCLUDES}" NO_DEFAULT_PATH) -find_path(LLDB_H "lldb/API/LLDB.h") -find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-6.0/include") -find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-5.0/include") -find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-4.0/include") -find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-3.9/include") -find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-3.8/include") -find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-3.7/include") -find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-3.6/include") -find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-3.5/include") -#FreeBSD -find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/local/llvm39/include") -find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/local/llvm38/include") - -if(LLDB_H STREQUAL LLDB_H-NOTFOUND) - if(REQUIRE_LLDBPLUGIN) - set(MESSAGE_MODE FATAL_ERROR) - else() - set(MESSAGE_MODE WARNING) - endif() - message(${MESSAGE_MODE} "Cannot find LLDB.h Try installing lldb-3.9-dev (or the appropriate package for your platform). You may need to set LLVM_HOME if the build still can't find it.") - return() endif() message(STATUS "LLDB_H: ${LLDB_H}") @@ -121,7 +136,7 @@ _add_library(sosplugin SHARED ${SOURCES}) add_dependencies(sosplugin sos) if (CLR_CMAKE_PLATFORM_DARWIN) - target_link_libraries(sosplugin ${LLDB}) + target_link_libraries(sosplugin ${LLDB_LIB}) endif() # add the install targets diff --git a/src/debug/createdump/CMakeLists.txt b/src/debug/createdump/CMakeLists.txt index 4272cfcb87..4e5b7a15f1 100644 --- a/src/debug/createdump/CMakeLists.txt +++ b/src/debug/createdump/CMakeLists.txt @@ -20,7 +20,7 @@ include_directories(BEFORE ${VM_DIR}) add_definitions(-DPAL_STDCPP_COMPAT=1) -add_compile_options(-fPIC) +add_compile_options(-fPIE) set(CREATEDUMP_SOURCES createdump.cpp @@ -36,11 +36,14 @@ _add_library(createdump_lib _add_executable(createdump main.cpp + ${PAL_REDEFINES_FILE} ) +add_dependencies(createdump pal_redefines_file) + target_link_libraries(createdump createdump_lib - # share the PAL in the dac module + # share the PAL/corguids in the dac module mscordaccore ) diff --git a/src/dlls/mscordac/CMakeLists.txt b/src/dlls/mscordac/CMakeLists.txt index fba524a405..ec52903758 100644 --- a/src/dlls/mscordac/CMakeLists.txt +++ b/src/dlls/mscordac/CMakeLists.txt @@ -20,10 +20,10 @@ if(WIN32) set(CURRENT_BINARY_DIR_FOR_CONFIG ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}) - #Preprocess exports definition file + # Preprocess exports definition file preprocess_def_file(${CMAKE_CURRENT_SOURCE_DIR}/${DEF_SOURCES} ${CURRENT_BINARY_DIR_FOR_CONFIG}/mscordac.def) - #create target to add file dependency on mscordac.def + # Create target to add file dependency on mscordac.def add_custom_target(mscordaccore_def DEPENDS ${CURRENT_BINARY_DIR_FOR_CONFIG}/mscordac.def) # No library groups for Win32 @@ -32,7 +32,50 @@ if(WIN32) else(WIN32) set(DEF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/mscordac_unixexports.src) set(EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/mscordac.exports) - generate_exports_file(${DEF_SOURCES} ${EXPORTS_FILE}) + + # Add dependency on export file + add_custom_target(mscordaccore_exports DEPENDS ${EXPORTS_FILE}) + + if(CLR_CMAKE_PLATFORM_DARWIN) + generate_exports_file(${DEF_SOURCES} ${EXPORTS_FILE}) + endif(CLR_CMAKE_PLATFORM_DARWIN) + + if(CLR_CMAKE_PLATFORM_LINUX) + + # Generate DAC export file with the DAC_ prefix + generate_exports_file_prefix(${DEF_SOURCES} ${EXPORTS_FILE} DAC_) + + set(REDEFINES_FILE_AWK_SCRIPT ${CMAKE_SOURCE_DIR}/generateredefinesfile.awk) + + if (CLR_CMAKE_PLATFORM_ARCH_ARM OR CLR_CMAKE_PLATFORM_ARCH_ARM64) + set(JUMP_INSTRUCTION b) + else() + set(JUMP_INSTRUCTION jmp) + endif() + + # Generate the palredefines.inc file to map from the imported prefixed APIs (foo to DAC_foo) + set(PAL_REDEFINES_INC ${GENERATED_INCLUDE_DIR}/palredefines.inc) + add_custom_command( + OUTPUT ${PAL_REDEFINES_INC} + COMMAND ${AWK} -f ${REDEFINES_FILE_AWK_SCRIPT} -v jump=${JUMP_INSTRUCTION} -v prefix2=DAC_ ${DEF_SOURCES} > ${PAL_REDEFINES_INC} + DEPENDS ${DEF_SOURCES} ${REDEFINES_FILE_AWK_SCRIPT} + COMMENT "Generating PAL redefines file -> ${PAL_REDEFINES_INC}" + ) + add_custom_target(pal_redefines_file DEPENDS ${PAL_REDEFINES_INC}) + + # Generate the libredefines.inc file for the DAC to export the prefixed APIs (DAC_foo to foo) + set(LIB_REDEFINES_INC ${GENERATED_INCLUDE_DIR}/libredefines.inc) + add_custom_command( + OUTPUT ${LIB_REDEFINES_INC} + COMMAND ${AWK} -f ${REDEFINES_FILE_AWK_SCRIPT} -v jump=${JUMP_INSTRUCTION} -v prefix1=DAC_ ${DEF_SOURCES} > ${LIB_REDEFINES_INC} + DEPENDS ${DEF_SOURCES} ${REDEFINES_FILE_AWK_SCRIPT} + COMMENT "Generating DAC export redefines file -> ${LIB_REDEFINES_INC}" + ) + add_custom_target(lib_redefines_inc DEPENDS ${LIB_REDEFINES_INC}) + + # Add lib redefines file to DAC + list(APPEND CLR_DAC_SOURCES libredefines.S) + endif(CLR_CMAKE_PLATFORM_LINUX) endif(WIN32) if(CLR_CMAKE_PLATFORM_LINUX OR CLR_CMAKE_PLATFORM_FREEBSD OR CLR_CMAKE_PLATFORM_NETBSD) @@ -64,10 +107,12 @@ _add_library(mscordacobj OBJECT mscordac.cpp) add_library_clr(mscordaccore SHARED ${CLR_DAC_SOURCES} $<TARGET_OBJECTS:mscordacobj>) +if(CLR_CMAKE_PLATFORM_LINUX) + add_dependencies(mscordaccore lib_redefines_inc) +endif(CLR_CMAKE_PLATFORM_LINUX) + if(CLR_CMAKE_PLATFORM_UNIX) - add_custom_target(mscordaccore_exports DEPENDS ${EXPORTS_FILE}) add_dependencies(mscordaccore mscordaccore_exports) - set_property(TARGET mscordaccore APPEND_STRING PROPERTY LINK_FLAGS ${EXPORTS_LINKER_OPTION}) set_property(TARGET mscordaccore APPEND_STRING PROPERTY LINK_DEPENDS ${EXPORTS_FILE}) endif(CLR_CMAKE_PLATFORM_UNIX) diff --git a/src/dlls/mscordac/libredefines.S b/src/dlls/mscordac/libredefines.S new file mode 100644 index 0000000000..2449b9e3b1 --- /dev/null +++ b/src/dlls/mscordac/libredefines.S @@ -0,0 +1,12 @@ +#if defined(_X86_) || defined(_AMD64_) +.intel_syntax noprefix +#endif + +#include "unixasmmacros.inc" + +#if defined(_ARM_) +.syntax unified +.thumb +#endif + +#include "libredefines.inc" diff --git a/src/dlls/mscordac/mscordac_unixexports.src b/src/dlls/mscordac/mscordac_unixexports.src index 77a53d7871..60fae97efd 100644 --- a/src/dlls/mscordac/mscordac_unixexports.src +++ b/src/dlls/mscordac/mscordac_unixexports.src @@ -10,179 +10,179 @@ DllMain PAL_RegisterModule PAL_UnregisterModule -PAL_BindResources -PAL_bsearch -PAL_errno -PAL_fflush -PAL__flushall -PAL_free -PAL_fwprintf -PAL_GetPALDirectoryW -PAL_GetResourceString -PAL_get_stdout -PAL_get_stderr -PAL_GetCurrentThread -PAL_GetCpuLimit -PAL_GetSymbolModuleBase -PAL_GetTransportPipeName -PAL_InitializeDLL -PAL_TerminateEx -PAL_IsDebuggerPresent -PAL_ProbeMemory -PAL_Random -PAL_iswspace -PAL_memcpy -PAL_malloc -PAL_realloc -PAL_printf -PAL_qsort -PAL_Reenter -PAL_fprintf -PAL__wcstoui64 -PAL_wcstoul -PAL_iswprint -PAL_VirtualReserveFromExecutableMemoryAllocatorWithinRange -PAL_VirtualUnwindOutOfProc -PAL_wcslen -PAL_wcsncmp -PAL_wcsrchr -PAL_wcscmp -PAL_wcschr -PAL_wcscspn -PAL_wcscat -PAL_wcsstr - -_wcsicmp -_stricmp -sprintf_s -swprintf_s -vsprintf_s -_snprintf_s -_snwprintf_s -_vsnprintf_s -_vsnwprintf_s -_itow_s -_i64tow_s -memcpy_s -sscanf_s - -CopyFileW -CreateDirectoryW -CreateFileMappingA -CreateFileMappingW -CreateFileA -CreateFileW -CreateMutexW -CreateMutexExW -CreateEventW -CreateEventExW -CreateProcessW -CreateSemaphoreExW -CreateStreamOnHGlobal -CreateThread -CloseHandle -DebugBreak -DeleteCriticalSection -DeleteFileW -DuplicateHandle -EnterCriticalSection -FindClose -FindFirstFileW -FindNextFileW -FlushFileBuffers -FlushInstructionCache -FormatMessageW -FreeLibrary -FileTimeToSystemTime -GetACP -GetCPInfo -GetCurrentDirectoryW -GetCurrentProcess -GetCurrentProcessId -GetCurrentThreadId -GetEnvironmentVariableA -GetEnvironmentVariableW -GetFileAttributesExW -GetFileAttributesW -GetFileSize -GetFullPathNameW -GetLastError -GetLongPathNameW -GetModuleFileNameW -GetProcAddress -GetProcessAffinityMask -GetProcessHeap -GetShortPathNameW -GetStdHandle -GetSystemInfo -GetSystemTime -GetSystemTimeAsFileTime -GetTempFileNameW -GetTempPathW -HeapAlloc -HeapFree -HeapSetInformation -IIDFromString +; Data exports (not prefixed) +IID_IUnknown IID_IClassFactory IID_ISequentialStream IID_IStream -IID_IUnknown IID_ICLRDataTarget IID_ICorDebugDataTarget4 IID_ICLRDataEnumMemoryRegionsCallback -InitializeCriticalSection -IsDBCSLeadByte -LeaveCriticalSection -LoadLibraryA -LoadLibraryW -LoadLibraryExW -LocalAlloc -LocalReAlloc -LocalFree -MapViewOfFile -MoveFileExW -MultiByteToWideChar -OpenProcess -OutputDebugStringW -OpenEventW -OutputDebugStringA -QueryPerformanceCounter -QueryPerformanceFrequency -RaiseException -ReadFile -ReleaseMutex -ReleaseSemaphore -RemoveDirectoryW -ResetEvent -ResumeThread -SearchPathW -SetEvent -SetFileAttributesW -SetFilePointer -SetLastError -SetErrorMode -Sleep -SleepEx -SwitchToThread -TerminateProcess -TlsAlloc -TlsFree -TlsGetValue -TlsSetValue -VirtualAlloc -VirtualFree -VirtualProtect -VirtualQuery -UnmapViewOfFile -WaitForMultipleObjectsEx -WaitForSingleObject -WaitForSingleObjectEx -WideCharToMultiByte -WriteFile - nativeStringResourceTable_mscorrc_debug -_ZN25NativeExceptionHolderBase4PushEv -_ZN25NativeExceptionHolderBaseC2Ev -_ZN25NativeExceptionHolderBaseD2Ev -_ZN28CatchHardwareExceptionHolderC1Ev -_ZN28CatchHardwareExceptionHolderD1Ev + +; All the # exports are prefixed with DAC_ +#PAL_BindResources +#PAL_CatchHardwareExceptionHolderEnter +#PAL_CatchHardwareExceptionHolderExit +#PAL_bsearch +#PAL_errno +#PAL_fflush +#PAL__flushall +#PAL_free +#PAL_fwprintf +#PAL_GetPALDirectoryW +#PAL_GetResourceString +#PAL_get_stdout +#PAL_get_stderr +#PAL_GetCurrentThread +#PAL_GetCpuLimit +#PAL_GetNativeExceptionHolderHead +#PAL_GetSymbolModuleBase +#PAL_GetTransportPipeName +#PAL_InitializeDLL +#PAL_TerminateEx +#PAL_IsDebuggerPresent +#PAL_ProbeMemory +#PAL_Random +#PAL_iswspace +#PAL_memcpy +#PAL_malloc +#PAL_realloc +#PAL_printf +#PAL_qsort +#PAL_Reenter +#PAL_fprintf +#PAL__wcstoui64 +#PAL_wcstoul +#PAL_iswprint +#PAL_VirtualReserveFromExecutableMemoryAllocatorWithinRange +#PAL_VirtualUnwindOutOfProc +#PAL_wcslen +#PAL_wcsncmp +#PAL_wcsrchr +#PAL_wcscmp +#PAL_wcschr +#PAL_wcscspn +#PAL_wcscat +#PAL_wcsstr + +#_wcsicmp +#_stricmp +#sprintf_s +#swprintf_s +#vsprintf_s +#_snprintf_s +#_snwprintf_s +#_vsnprintf_s +#_vsnwprintf_s +#_itow_s +#_i64tow_s +#memcpy_s +#sscanf_s + +#CopyFileW +#CreateDirectoryW +#CreateFileMappingA +#CreateFileMappingW +#CreateFileA +#CreateFileW +#CreateMutexW +#CreateMutexExW +#CreateEventW +#CreateEventExW +#CreateProcessW +#CreateSemaphoreExW +#CreateThread +#CloseHandle +#DebugBreak +#DeleteCriticalSection +#DeleteFileW +#DuplicateHandle +#EnterCriticalSection +#FindClose +#FindFirstFileW +#FindNextFileW +#FlushFileBuffers +#FlushInstructionCache +#FormatMessageW +#FreeLibrary +#FileTimeToSystemTime +#GetACP +#GetCPInfo +#GetCurrentDirectoryW +#GetCurrentProcess +#GetCurrentProcessId +#GetCurrentThreadId +#GetEnvironmentVariableA +#GetEnvironmentVariableW +#GetFileAttributesExW +#GetFileAttributesW +#GetFileSize +#GetFullPathNameW +#GetLastError +#GetLongPathNameW +#GetModuleFileNameW +#GetProcAddress +#GetProcessAffinityMask +#GetProcessHeap +#GetShortPathNameW +#GetStdHandle +#GetSystemInfo +#GetSystemTime +#GetSystemTimeAsFileTime +#GetTempFileNameW +#GetTempPathW +#HeapAlloc +#HeapFree +#HeapSetInformation +#InitializeCriticalSection +#IsDBCSLeadByte +#LeaveCriticalSection +#LoadLibraryA +#LoadLibraryW +#LoadLibraryExW +#LocalAlloc +#LocalReAlloc +#LocalFree +#MapViewOfFile +#MoveFileExW +#MultiByteToWideChar +#OpenProcess +#OutputDebugStringW +#OpenEventW +#OutputDebugStringA +#QueryPerformanceCounter +#QueryPerformanceFrequency +#RaiseException +#ReadFile +#ReleaseMutex +#ReleaseSemaphore +#RemoveDirectoryW +#ResetEvent +#ResumeThread +#SearchPathW +#SetEvent +#SetFileAttributesW +#SetFilePointer +#SetLastError +#SetErrorMode +#Sleep +#SleepEx +#SwitchToThread +#SysAllocStringLen +#SysFreeString +#TerminateProcess +#TlsAlloc +#TlsFree +#TlsGetValue +#TlsSetValue +#VirtualAlloc +#VirtualFree +#VirtualProtect +#VirtualQuery +#UnmapViewOfFile +#WaitForMultipleObjectsEx +#WaitForSingleObject +#WaitForSingleObjectEx +#WideCharToMultiByte +#WriteFile diff --git a/src/dlls/mscordac/palredefines.S b/src/dlls/mscordac/palredefines.S new file mode 100644 index 0000000000..b0cd6159d3 --- /dev/null +++ b/src/dlls/mscordac/palredefines.S @@ -0,0 +1,12 @@ +#if defined(_X86_) || defined(_AMD64_) +.intel_syntax noprefix +#endif + +#include "unixasmmacros.inc" + +#if defined(_ARM_) +.syntax unified +.thumb +#endif + +#include "palredefines.inc" diff --git a/src/dlls/mscordbi/CMakeLists.txt b/src/dlls/mscordbi/CMakeLists.txt index 5f5ad5139e..e979960e07 100644 --- a/src/dlls/mscordbi/CMakeLists.txt +++ b/src/dlls/mscordbi/CMakeLists.txt @@ -11,9 +11,14 @@ if(CORECLR_SET_RPATH) endif(CORECLR_SET_RPATH) set(MSCORDBI_SOURCES - mscordbi.cpp + mscordbi.cpp ) +# Add the DAC PAL export mapping file +if(CLR_CMAKE_PLATFORM_LINUX) + list(APPEND MSCORDBI_SOURCES ${PAL_REDEFINES_FILE}) +endif(CLR_CMAKE_PLATFORM_LINUX) + if(WIN32) add_precompiled_header(stdafx.h stdafx.cpp MSCORDBI_SOURCES) @@ -24,7 +29,7 @@ if(WIN32) ) set(DEF_SOURCES - mscordbi.src + mscordbi.src ) convert_to_absolute_path(DEF_SOURCES ${DEF_SOURCES}) @@ -63,15 +68,15 @@ if(CLR_CMAKE_PLATFORM_UNIX) endif(CLR_CMAKE_PLATFORM_UNIX) set(COREDBI_LIBRARIES - debug-pal - cordbdi - utilcodestaticnohost - ildbsymlib - mdcompiler-dbi - mdruntime-dbi - mdruntimerw-dbi - mddatasource_dbi - corguids + debug-pal + cordbdi + utilcodestaticnohost + ildbsymlib + mdcompiler-dbi + mdruntime-dbi + mdruntimerw-dbi + mddatasource_dbi + corguids ) if(WIN32) @@ -101,14 +106,18 @@ elseif(CLR_CMAKE_PLATFORM_UNIX) mscordaccore ) - add_dependencies(mscordbi mscordaccore) - # COREDBI_LIBRARIES is mentioned twice because ld is one pass linker and will not find symbols # if they are defined after they are used. Having all libs twice makes sure that ld will actually # find all symbols. target_link_libraries(mscordbi ${COREDBI_LIBRARIES} ${COREDBI_LIBRARIES}) + add_dependencies(mscordbi mscordaccore) + + if(CLR_CMAKE_PLATFORM_LINUX) + add_dependencies(mscordbi pal_redefines_file) + endif(CLR_CMAKE_PLATFORM_LINUX) + endif(WIN32) # add the install targets -install_clr(mscordbi)
\ No newline at end of file +install_clr(mscordbi) diff --git a/src/pal/inc/pal.h b/src/pal/inc/pal.h index d5587b9f41..98d0ae2f11 100644 --- a/src/pal/inc/pal.h +++ b/src/pal/inc/pal.h @@ -5030,6 +5030,16 @@ PALAPI PAL_SetTerminationRequestHandler( IN PTERMINATION_REQUEST_HANDLER terminationRequestHandler); +PALIMPORT +VOID +PALAPI +PAL_CatchHardwareExceptionHolderEnter(); + +PALIMPORT +VOID +PALAPI +PAL_CatchHardwareExceptionHolderExit(); + // // This holder is used to indicate that a hardware // exception should be raised as a C++ exception @@ -5038,9 +5048,15 @@ PAL_SetTerminationRequestHandler( class CatchHardwareExceptionHolder { public: - CatchHardwareExceptionHolder(); + CatchHardwareExceptionHolder() + { + PAL_CatchHardwareExceptionHolderEnter(); + } - ~CatchHardwareExceptionHolder(); + ~CatchHardwareExceptionHolder() + { + PAL_CatchHardwareExceptionHolderExit(); + } static bool IsEnabled(); }; @@ -5058,6 +5074,13 @@ public: #ifdef FEATURE_PAL_SXS +class NativeExceptionHolderBase; + +PALIMPORT +NativeExceptionHolderBase ** +PALAPI +PAL_GetNativeExceptionHolderHead(); + extern "C++" { // @@ -5076,9 +5099,22 @@ class NativeExceptionHolderBase NativeExceptionHolderBase *m_next; protected: - NativeExceptionHolderBase(); + NativeExceptionHolderBase() + { + m_head = nullptr; + m_next = nullptr; + } - ~NativeExceptionHolderBase(); + ~NativeExceptionHolderBase() + { + // Only destroy if Push was called + if (m_head != nullptr) + { + *m_head = m_next; + m_head = nullptr; + m_next = nullptr; + } + } public: // Calls the holder's filter handler. @@ -5087,7 +5123,13 @@ public: // Adds the holder to the "stack" of holders. This is done explicitly instead // of in the constructor was to avoid the mess of move constructors combined // with return value optimization (in CreateHolder). - void Push(); + void Push() + { + NativeExceptionHolderBase **head = PAL_GetNativeExceptionHolderHead(); + m_head = head; + m_next = *head; + *head = this; + } // Given the currentHolder and locals stack range find the next holder starting with this one // To find the first holder, pass nullptr as the currentHolder. diff --git a/src/pal/src/exception/seh.cpp b/src/pal/src/exception/seh.cpp index b05707076b..39779beb0b 100644 --- a/src/pal/src/exception/seh.cpp +++ b/src/pal/src/exception/seh.cpp @@ -364,16 +364,22 @@ PAL_ERROR SEHDisable(CPalThread *pthrCurrent) --*/ -CatchHardwareExceptionHolder::CatchHardwareExceptionHolder() +extern "C" +void +PALAPI +PAL_CatchHardwareExceptionHolderEnter() { CPalThread *pThread = InternalGetCurrentThread(); - ++pThread->m_hardwareExceptionHolderCount; + pThread->IncrementHardwareExceptionHolderCount(); } -CatchHardwareExceptionHolder::~CatchHardwareExceptionHolder() +extern "C" +void +PALAPI +PAL_CatchHardwareExceptionHolderExit() { CPalThread *pThread = InternalGetCurrentThread(); - --pThread->m_hardwareExceptionHolderCount; + pThread->DecrementHardwareExceptionHolderCount(); } bool CatchHardwareExceptionHolder::IsEnabled() @@ -395,30 +401,12 @@ __declspec(thread) #endif // !__llvm__ static NativeExceptionHolderBase *t_nativeExceptionHolderHead = nullptr; -NativeExceptionHolderBase::NativeExceptionHolderBase() -{ - m_head = nullptr; - m_next = nullptr; -} - -NativeExceptionHolderBase::~NativeExceptionHolderBase() -{ - // Only destroy if Push was called - if (m_head != nullptr) - { - *m_head = m_next; - m_head = nullptr; - m_next = nullptr; - } -} - -void -NativeExceptionHolderBase::Push() +extern "C" +NativeExceptionHolderBase ** +PALAPI +PAL_GetNativeExceptionHolderHead() { - NativeExceptionHolderBase **head = &t_nativeExceptionHolderHead; - m_head = head; - m_next = *head; - *head = this; + return &t_nativeExceptionHolderHead; } NativeExceptionHolderBase * diff --git a/src/pal/src/include/pal/thread.hpp b/src/pal/src/include/pal/thread.hpp index 2a03bcfdd4..a1ad599ddd 100644 --- a/src/pal/src/include/pal/thread.hpp +++ b/src/pal/src/include/pal/thread.hpp @@ -207,7 +207,7 @@ namespace CorUnix { friend PAL_ERROR - CorUnix::InternalCreateThread( + InternalCreateThread( CPalThread *, LPSECURITY_ATTRIBUTES, DWORD, @@ -250,8 +250,6 @@ namespace CorUnix HANDLE *phThread ); - friend CatchHardwareExceptionHolder; - private: CPalThread *m_pNext; @@ -552,6 +550,18 @@ namespace CorUnix return m_hardwareExceptionHolderCount > 0; } + inline void + IncrementHardwareExceptionHolderCount() + { + ++m_hardwareExceptionHolderCount; + } + + inline void + DecrementHardwareExceptionHolderCount() + { + --m_hardwareExceptionHolderCount; + } + LPTHREAD_START_ROUTINE GetStartAddress( void diff --git a/src/palrt/guid.cpp b/src/palrt/guid.cpp index 14cd3bb490..4ec5c8c628 100644 --- a/src/palrt/guid.cpp +++ b/src/palrt/guid.cpp @@ -11,7 +11,7 @@ // =========================================================================== #define INITGUID -#include "guiddef.h" +#include <guiddef.h> // These are GUIDs and IIDs that would normally be provided by the system via uuid.lib, // and that the PALRT exposes through headers. diff --git a/src/palrt/guiddef.h b/src/palrt/guiddef.h deleted file mode 100644 index a082619b95..0000000000 --- a/src/palrt/guiddef.h +++ /dev/null @@ -1,26 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// - -// -// =========================================================================== -// File: guiddef.h -// -// =========================================================================== -// simplified guiddef.h for PAL - -#include "common.h" - -#ifdef DEFINE_GUID -#undef DEFINE_GUID -#endif - -#ifdef INITGUID -#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ - EXTERN_C const GUID DECLSPEC_SELECTANY name \ - = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } -#else -#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ - EXTERN_C const GUID FAR name -#endif // INITGUID |