From: Steve MacLean Date: Wed, 5 Feb 2020 20:15:01 +0000 (-0500) Subject: Add cross OS support for MAKEDLLNAME (#31746) X-Git-Tag: submit/tizen/20210909.063632~9984 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=852fa33030065b5367722756899004e092f704ad;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Add cross OS support for MAKEDLLNAME (#31746) * Add MAKE_TARGET_DLLNAME * Add TARGET_MAIN_CLR_DLL_NAME_[WA] * Use TARGET_MAIN_CLR_DLL_NAME_[AW] for DAC * Remove MSCOREE_SHIM_[WA] --- diff --git a/src/coreclr/src/debug/daccess/daccess.cpp b/src/coreclr/src/debug/daccess/daccess.cpp index 1b60d23..72a9c51 100644 --- a/src/coreclr/src/debug/daccess/daccess.cpp +++ b/src/coreclr/src/debug/daccess/daccess.cpp @@ -5572,16 +5572,14 @@ ClrDataAccess::Initialize(void) if (m_globalBase == 0) { - // Caller didn't specify which CLR to debug. This supports Whidbey SOS cases, so we should - // be using a legacy data target. + // Caller didn't specify which CLR to debug, we should be using a legacy data target. if (m_pLegacyTarget == NULL) { DacError(E_INVALIDARG); UNREACHABLE(); } - // Since this is Whidbey, assume there's only 1 CLR named "mscorwks.dll" and pick that. - IfFailRet(m_pLegacyTarget->GetImageBase(MAIN_CLR_DLL_NAME_W, &base)); + IfFailRet(m_pLegacyTarget->GetImageBase(TARGET_MAIN_CLR_DLL_NAME_W, &base)); m_globalBase = TO_TADDR(base); } @@ -7136,11 +7134,11 @@ HRESULT ClrDataAccess::VerifyDlls() "error. If you really want to try and use the mimatched DLLs, you can disable this\n"\ "check by setting COMPlus_DbgDACSkipVerifyDlls=1. However, using a mismatched DAC\n"\ "DLL will usually result in arbitrary debugger failures.\n", - MAIN_CLR_DLL_NAME_A, - MAIN_CLR_DLL_NAME_A, - MAIN_CLR_DLL_NAME_A, + TARGET_MAIN_CLR_DLL_NAME_A, + TARGET_MAIN_CLR_DLL_NAME_A, + TARGET_MAIN_CLR_DLL_NAME_A, szExpectedTime, - MAIN_CLR_DLL_NAME_A, + TARGET_MAIN_CLR_DLL_NAME_A, szActualTime); _ASSERTE_MSG(false, szMsgBuf); } @@ -7276,7 +7274,7 @@ ClrDataAccess::GetDacGlobals() if (FAILED(status = GetMachineAndResourceSectionRVA(m_pTarget, m_globalBase, NULL, &resourceSectionRVA))) { - _ASSERTE_MSG(false, "DAC fatal error: can't locate resource section in " MAIN_CLR_DLL_NAME_A); + _ASSERTE_MSG(false, "DAC fatal error: can't locate resource section in " TARGET_MAIN_CLR_DLL_NAME_A); return CORDBG_E_MISSING_DEBUGGER_EXPORTS; } @@ -7284,7 +7282,7 @@ ClrDataAccess::GetDacGlobals() resourceSectionRVA, (DWORD)RT_RCDATA, _WIDE(DACCESS_TABLE_RESOURCE), 0, &rsrcRVA, &rsrcSize))) { - _ASSERTE_MSG(false, "DAC fatal error: can't locate DAC table resource in " MAIN_CLR_DLL_NAME_A); + _ASSERTE_MSG(false, "DAC fatal error: can't locate DAC table resource in " TARGET_MAIN_CLR_DLL_NAME_A); return CORDBG_E_MISSING_DEBUGGER_EXPORTS; } @@ -7294,7 +7292,7 @@ ClrDataAccess::GetDacGlobals() if (FAILED(status = ReadFromDataTarget(m_pTarget, m_globalBase + rsrcRVA, (BYTE*)rsrcData, rsrcSize))) { - _ASSERTE_MSG(false, "DAC fatal error: can't load DAC table resource from " MAIN_CLR_DLL_NAME_A); + _ASSERTE_MSG(false, "DAC fatal error: can't load DAC table resource from " TARGET_MAIN_CLR_DLL_NAME_A); return CORDBG_E_MISSING_DEBUGGER_EXPORTS; } diff --git a/src/coreclr/src/inc/cor.h b/src/coreclr/src/inc/cor.h index a93da15..e8a3ac2 100644 --- a/src/coreclr/src/inc/cor.h +++ b/src/coreclr/src/inc/cor.h @@ -141,9 +141,8 @@ typedef UNALIGNED void const *UVCP_CONSTANT; #define MAIN_CLR_DLL_NAME_W MAKEDLLNAME_W(MAIN_CLR_MODULE_NAME_W) #define MAIN_CLR_DLL_NAME_A MAKEDLLNAME_A(MAIN_CLR_MODULE_NAME_A) - -#define MSCOREE_SHIM_W MAIN_CLR_DLL_NAME_W -#define MSCOREE_SHIM_A MAIN_CLR_DLL_NAME_A +#define TARGET_MAIN_CLR_DLL_NAME_W MAKE_TARGET_DLLNAME_W(MAIN_CLR_MODULE_NAME_W) +#define TARGET_MAIN_CLR_DLL_NAME_A MAKE_TARGET_DLLNAME_A(MAIN_CLR_MODULE_NAME_A) #define SWITCHOUT_HANDLE_VALUE ((HANDLE)(LONG_PTR)-2) diff --git a/src/coreclr/src/inc/crosscomp.h b/src/coreclr/src/inc/crosscomp.h index ae18245..9d3a29e 100644 --- a/src/coreclr/src/inc/crosscomp.h +++ b/src/coreclr/src/inc/crosscomp.h @@ -12,6 +12,27 @@ #define CROSSBITNESS_COMPILE #endif +// Target platform-specific library naming +// +#ifdef TARGET_WINDOWS +#define MAKE_TARGET_DLLNAME_W(name) name W(".dll") +#define MAKE_TARGET_DLLNAME_A(name) name ".dll" +#else // TARGET_WINDOWS +#ifdef TARGET_OSX +#define MAKE_TARGET_DLLNAME_W(name) W("lib") name W(".dylib") +#define MAKE_TARGET_DLLNAME_A(name) "lib" name ".dylib" +#else +#define MAKE_TARGET_DLLNAME_W(name) W("lib") name W(".so") +#define MAKE_TARGET_DLLNAME_A(name) "lib" name ".so" +#endif +#endif // TARGET_WINDOWS + +#ifdef UNICODE +#define MAKE_TARGET_DLLNAME(name) MAKE_TARGET_DLLNAME_W(name) +#else +#define MAKE_TARGET_DLLNAME(name) MAKE_TARGET_DLLNAME_A(name) +#endif + #if !defined(HOST_ARM) && defined(TARGET_ARM) // Non-ARM Host managing ARM related code #ifndef CROSS_COMPILE diff --git a/src/coreclr/src/utilcode/pedecoder.cpp b/src/coreclr/src/utilcode/pedecoder.cpp index c5267a7..33d0bf4 100644 --- a/src/coreclr/src/utilcode/pedecoder.cpp +++ b/src/coreclr/src/utilcode/pedecoder.cpp @@ -3102,8 +3102,6 @@ BOOL PEDecoder::GetForceRelocs() BOOL PEDecoder::ForceRelocForDLL(LPCWSTR lpFileName) { - // Use static contracts to avoid recursion, as the dynamic contracts - // do WszLoadLibrary(MSCOREE_SHIM_W). #ifdef _DEBUG STATIC_CONTRACT_NOTHROW; \ ANNOTATION_DEBUG_ONLY; \ @@ -3114,11 +3112,6 @@ BOOL PEDecoder::ForceRelocForDLL(LPCWSTR lpFileName) return TRUE; #else - // Contracts in ConfigDWORD do WszLoadLibrary(MSCOREE_SHIM_W). - // This check prevents recursion. - if (wcsstr(lpFileName, MSCOREE_SHIM_W) != 0) - return TRUE; - if (!GetForceRelocs()) return TRUE;