From a6cbdae05eaa017e8e11eb1954c9525c62e5dfe0 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Tue, 26 Nov 2019 18:01:42 -0800 Subject: [PATCH] Delete PAL_RegisterModule from the JIT (#263) * Delete PAL_RegisterModule from the JIT * I have deleted some other dead code too while I was on it. --- src/coreclr/src/dlls/mscoree/CMakeLists.txt | 1 - src/coreclr/src/dlls/mscoree/comcallunmarshal.cpp | 281 --------------------- src/coreclr/src/dlls/mscoree/comcallunmarshal.h | 70 ----- .../src/dlls/mscoree/coreclr/CMakeLists.txt | 2 - src/coreclr/src/dlls/mscoree/mscoree.cpp | 93 ++----- src/coreclr/src/dlls/mscoree/mscorwks_ntdef.src | 6 - .../src/dlls/mscoree/mscorwks_unixexports.src | 11 - src/coreclr/src/ilasm/assem.cpp | 2 - src/coreclr/src/ilasm/assembler.h | 6 - src/coreclr/src/ilasm/writer.cpp | 2 +- src/coreclr/src/jit/ClrJit.PAL.exports | 3 - src/coreclr/src/jit/ee_il_dll.cpp | 20 +- src/coreclr/src/pal/src/loader/module.cpp | 8 +- .../src/tools/Common/JitInterface/CorInfoImpl.cs | 11 - 14 files changed, 36 insertions(+), 480 deletions(-) delete mode 100644 src/coreclr/src/dlls/mscoree/comcallunmarshal.cpp delete mode 100644 src/coreclr/src/dlls/mscoree/comcallunmarshal.h diff --git a/src/coreclr/src/dlls/mscoree/CMakeLists.txt b/src/coreclr/src/dlls/mscoree/CMakeLists.txt index 36f6c988..dc5d2c8 100644 --- a/src/coreclr/src/dlls/mscoree/CMakeLists.txt +++ b/src/coreclr/src/dlls/mscoree/CMakeLists.txt @@ -11,7 +11,6 @@ set(CLR_SOURCES if(WIN32) list(APPEND CLR_SOURCES - comcallunmarshal.cpp delayloadhook.cpp Native.rc ) diff --git a/src/coreclr/src/dlls/mscoree/comcallunmarshal.cpp b/src/coreclr/src/dlls/mscoree/comcallunmarshal.cpp deleted file mode 100644 index 854213b..0000000 --- a/src/coreclr/src/dlls/mscoree/comcallunmarshal.cpp +++ /dev/null @@ -1,281 +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: ComCallUnmarshal.cpp -// - -// -// Classes used to unmarshal all COM call wrapper IPs. -// - - -#include "stdafx.h" // Standard header. - -#ifdef FEATURE_COMINTEROP - -#include "ComCallUnmarshal.h" -#include // Utility helpers. - -// For free-threaded marshaling, we must not be spoofed by out-of-process or cross-runtime marshal data. -// Only unmarshal data that comes from our own runtime. -extern BYTE g_UnmarshalSecret[sizeof(GUID)]; -extern bool g_fInitedUnmarshalSecret; - -STDMETHODIMP ComCallUnmarshal::QueryInterface(REFIID iid, void **ppv) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - PRECONDITION(CheckPointer(ppv, NULL_OK)); - } CONTRACTL_END; - - if (!ppv) - return E_POINTER; - - *ppv = NULL; - if (iid == IID_IUnknown) - { - *ppv = (IUnknown *)this; - AddRef(); - } else if (iid == IID_IMarshal) - { - *ppv = (IMarshal *)this; - AddRef(); - } - return (*ppv != NULL) ? S_OK : E_NOINTERFACE; -} - -STDMETHODIMP_(ULONG) ComCallUnmarshal::AddRef(void) -{ - LIMITED_METHOD_CONTRACT; - return 2; -} - -STDMETHODIMP_(ULONG) ComCallUnmarshal::Release(void) -{ - LIMITED_METHOD_CONTRACT; - return 1; -} - -STDMETHODIMP ComCallUnmarshal::GetUnmarshalClass (REFIID riid, void * pv, ULONG dwDestContext, - void * pvDestContext, ULONG mshlflags, - LPCLSID pclsid) -{ - LIMITED_METHOD_CONTRACT; - // Marshal side only. - _ASSERTE(FALSE); - return E_NOTIMPL; -} - -STDMETHODIMP ComCallUnmarshal::GetMarshalSizeMax (REFIID riid, void * pv, ULONG dwDestContext, - void * pvDestContext, ULONG mshlflags, - ULONG * pSize) -{ - LIMITED_METHOD_CONTRACT; - // Marshal side only. - _ASSERTE(FALSE); - return E_NOTIMPL; -} - -STDMETHODIMP ComCallUnmarshal::MarshalInterface (LPSTREAM pStm, REFIID riid, void * pv, - ULONG dwDestContext, LPVOID pvDestContext, - ULONG mshlflags) -{ - LIMITED_METHOD_CONTRACT; - // Marshal side only. - _ASSERTE(FALSE); - return E_NOTIMPL; -} - -STDMETHODIMP ComCallUnmarshal::UnmarshalInterface (LPSTREAM pStm, REFIID riid, void ** ppvObj) -{ - CONTRACTL { - NOTHROW; - GC_NOTRIGGER; - STATIC_CONTRACT_MODE_PREEMPTIVE; - PRECONDITION(CheckPointer(pStm)); - PRECONDITION(CheckPointer(ppvObj)); - } CONTRACTL_END; - - ULONG bytesRead; - ULONG mshlflags; - HRESULT hr = E_FAIL; - - // The marshal code added a reference to the object, but we return a - // reference to the object as well, so don't change the ref count on the - // success path. Need to release on error paths though (if we manage to - // retrieve the IP, that is). If the interface was marshalled - // TABLESTRONG or TABLEWEAK, there is going to be a ReleaseMarshalData - // in the future, so we should AddRef the IP we're about to give out. - // Note also that OLE32 requires us to advance the stream pointer even - // in failure cases. - - // Read the raw IP out of the marshalling stream. - hr = pStm->Read (ppvObj, sizeof (void *), &bytesRead); - if (FAILED (hr) || (bytesRead != sizeof (void *))) - IfFailGo(RPC_E_INVALID_DATA); - - // And then the marshal flags. - hr = pStm->Read (&mshlflags, sizeof (ULONG), &bytesRead); - if (FAILED (hr) || (bytesRead != sizeof (ULONG))) - IfFailGo(RPC_E_INVALID_DATA); - - // And then verify our secret, to be sure that cross-runtime clients aren't - // trying to trick us into mis-interpreting their data as a ppvObj. Note that - // it is guaranteed that the secret data is initialized, or else we certainly - // haven't written it into this buffer! - if (!g_fInitedUnmarshalSecret) - IfFailGo(E_UNEXPECTED); - - BYTE secret[sizeof(GUID)]; - - hr = pStm->Read(secret, sizeof(secret), &bytesRead); - if (FAILED(hr) || (bytesRead != sizeof(secret))) - IfFailGo(RPC_E_INVALID_DATA); - - if (memcmp(g_UnmarshalSecret, secret, sizeof(secret)) != 0) - IfFailGo(E_UNEXPECTED); - - if (ppvObj && ((mshlflags == MSHLFLAGS_TABLESTRONG) || (mshlflags == MSHLFLAGS_TABLEWEAK))) - { - // For table access we can just QI for the correct interface (this - // will addref the IP, but that's OK since we need to keep an extra - // ref on the IP until ReleaseMarshalData is called). - hr = ((IUnknown *)*ppvObj)->QueryInterface(riid, ppvObj); - } - else - { - // For normal access we QI for the correct interface then release - // the old IP. - NonVMComHolder pOldUnk = (IUnknown *)*ppvObj; - hr = pOldUnk->QueryInterface(riid, ppvObj); - } -ErrExit: - return hr; -} - -STDMETHODIMP ComCallUnmarshal::ReleaseMarshalData (LPSTREAM pStm) -{ - CONTRACTL { - NOTHROW; - GC_NOTRIGGER; - STATIC_CONTRACT_MODE_PREEMPTIVE; - PRECONDITION(CheckPointer(pStm)); - } CONTRACTL_END; - - IUnknown *pUnk; - ULONG bytesRead; - ULONG mshlflags; - HRESULT hr = S_OK; - - if (!pStm) - return E_POINTER; - - // Read the raw IP out of the marshalling stream. Do this first since we - // need to update the stream pointer even in case of failures. - hr = pStm->Read (&pUnk, sizeof (pUnk), &bytesRead); - if (FAILED (hr) || (bytesRead != sizeof (pUnk))) - IfFailGo(RPC_E_INVALID_DATA); - - // Now read the marshal flags. - hr = pStm->Read (&mshlflags, sizeof (mshlflags), &bytesRead); - if (FAILED (hr) || (bytesRead != sizeof (mshlflags))) - IfFailGo(RPC_E_INVALID_DATA); - - if (!g_fInitedUnmarshalSecret) - { - IfFailGo(E_UNEXPECTED); - } - - BYTE secret[sizeof(GUID)]; - - hr = pStm->Read(secret, sizeof(secret), &bytesRead); - if (FAILED(hr) || (bytesRead != sizeof(secret))) - IfFailGo(RPC_E_INVALID_DATA); - - if (memcmp(g_UnmarshalSecret, secret, sizeof(secret)) != 0) - IfFailGo(E_UNEXPECTED); - - pUnk->Release (); - -ErrExit: - return hr; -} - -STDMETHODIMP ComCallUnmarshal::DisconnectObject (ULONG dwReserved) -{ - LIMITED_METHOD_CONTRACT; - - // Nothing we can (or need to) do here. The client is using a raw IP to - // access this server, so the server shouldn't go away until the client - // Release()'s it. - - return S_OK; -} - -CComCallUnmarshalFactory::CComCallUnmarshalFactory() -{ - WRAPPER_NO_CONTRACT; -} - -STDMETHODIMP CComCallUnmarshalFactory::QueryInterface(REFIID iid, void **ppv) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - PRECONDITION(CheckPointer(ppv)); - } CONTRACTL_END; - - if (!ppv) - return E_POINTER; - - *ppv = NULL; - if (iid == IID_IClassFactory || iid == IID_IUnknown) { - *ppv = (IClassFactory *)this; - AddRef(); - } - return (*ppv != NULL) ? S_OK : E_NOINTERFACE; -} - -STDMETHODIMP_(ULONG) CComCallUnmarshalFactory::AddRef(void) -{ - LIMITED_METHOD_CONTRACT; - return 2; -} - -STDMETHODIMP_(ULONG) CComCallUnmarshalFactory::Release(void) -{ - LIMITED_METHOD_CONTRACT; - return 1; -} - -STDMETHODIMP CComCallUnmarshalFactory::CreateInstance(LPUNKNOWN punkOuter, REFIID iid, LPVOID FAR *ppv) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - PRECONDITION(CheckPointer(ppv)); - } CONTRACTL_END; - - if (!ppv) - return E_POINTER; - - *ppv = NULL; - - if (punkOuter != NULL) - return CLASS_E_NOAGGREGATION; - - return m_Unmarshaller.QueryInterface(iid, ppv); -} - -STDMETHODIMP CComCallUnmarshalFactory::LockServer(BOOL fLock) -{ - LIMITED_METHOD_CONTRACT; - return S_OK; -} - -#endif // FEATURE_COMINTEROP diff --git a/src/coreclr/src/dlls/mscoree/comcallunmarshal.h b/src/coreclr/src/dlls/mscoree/comcallunmarshal.h deleted file mode 100644 index 8ef6973..0000000 --- a/src/coreclr/src/dlls/mscoree/comcallunmarshal.h +++ /dev/null @@ -1,70 +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: ComCallUnmarshal.h -// - -// -// Classes used to unmarshal all COM call wrapper IPs. -// - - -#pragma once - -#ifndef FEATURE_COMINTEROP -#error FEATURE_COMINTEROP is required for this file -#endif // FEATURE_COMINTEROP - -// Class used to unmarshal all COM call wrapper IPs. In order for this to work in side-by-side -// scenarios, the CLSID of this class has to be changed with every side-by-side release. -// -// The class is identified by the following CLSID: -// CLR v1.0, v1.1, v2.0: 3F281000-E95A-11d2-886B-00C04F869F04 -// CLR v4.0: 45FB4600-E6E8-4928-B25E-50476FF79425 -// -class ComCallUnmarshal : public IMarshal -{ -public: - - // *** IUnknown methods *** - STDMETHODIMP QueryInterface(REFIID iid, void **ppv); - STDMETHODIMP_(ULONG) AddRef(void); - STDMETHODIMP_(ULONG) Release(void); - - // *** IMarshal methods *** - STDMETHODIMP GetUnmarshalClass (REFIID riid, void * pv, ULONG dwDestContext, - void * pvDestContext, ULONG mshlflags, - LPCLSID pclsid); - - STDMETHODIMP GetMarshalSizeMax (REFIID riid, void * pv, ULONG dwDestContext, - void * pvDestContext, ULONG mshlflags, - ULONG * pSize); - - STDMETHODIMP MarshalInterface (LPSTREAM pStm, REFIID riid, void * pv, - ULONG dwDestContext, LPVOID pvDestContext, - ULONG mshlflags); - - STDMETHODIMP UnmarshalInterface (LPSTREAM pStm, REFIID riid, void ** ppvObj); - STDMETHODIMP ReleaseMarshalData (LPSTREAM pStm); - STDMETHODIMP DisconnectObject (ULONG dwReserved); -}; - -// Class factory for the COM call wrapper unmarshaller. -class CComCallUnmarshalFactory : public IClassFactory -{ - ComCallUnmarshal m_Unmarshaller; - - public: - - CComCallUnmarshalFactory(); - - // *** IUnknown methods *** - STDMETHODIMP QueryInterface(REFIID iid, void **ppv); - STDMETHODIMP_(ULONG) AddRef(void); - STDMETHODIMP_(ULONG) Release(void); - - // *** IClassFactory methods *** - STDMETHODIMP CreateInstance(LPUNKNOWN punkOuter, REFIID iid, LPVOID FAR *ppv); - STDMETHODIMP LockServer(BOOL fLock); -}; diff --git a/src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt b/src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt index 7a064a8..34e09be 100644 --- a/src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt +++ b/src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt @@ -23,8 +23,6 @@ if (WIN32) set(END_LIBRARY_GROUP) else() - add_definitions(-DNO_CRT_INIT) - set(EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/coreclr.exports) generate_exports_file(${DEF_SOURCES} ${EXPORTS_FILE}) diff --git a/src/coreclr/src/dlls/mscoree/mscoree.cpp b/src/coreclr/src/dlls/mscoree/mscoree.cpp index 47323f9..95c15cd 100644 --- a/src/coreclr/src/dlls/mscoree/mscoree.cpp +++ b/src/coreclr/src/dlls/mscoree/mscoree.cpp @@ -18,10 +18,6 @@ #include "product_version.h" -#ifdef FEATURE_COMINTEROP -#include "ComCallUnmarshal.h" -#endif // FEATURE_COMINTEROP - #include // Locals. @@ -40,27 +36,20 @@ HINSTANCE g_hThisInst; // This library. #include -#include // for __security_init_cookie() - extern "C" IExecutionEngine* IEE(); -#ifdef NO_CRT_INIT -#define _CRT_INIT(hInstance, dwReason, lpReserved) (TRUE) -#else -extern "C" BOOL WINAPI _CRT_INIT(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved); -#endif +#ifdef PLATFORM_WINDOWS + +#include // for __security_init_cookie() +extern "C" BOOL WINAPI _CRT_INIT(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved); extern "C" BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved); // For the CoreClr, this is the real DLL entrypoint. We make ourselves the first entrypoint as // we need to capture coreclr's hInstance before the C runtime initializes. This function // will capture hInstance, let the C runtime initialize and then invoke the "classic" // DllMain that initializes everything else. -extern "C" -#ifdef FEATURE_PAL -DLLEXPORT // For Win32 PAL LoadLibrary emulation -#endif -BOOL WINAPI CoreDllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved) +extern "C" BOOL WINAPI CoreDllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved) { STATIC_CONTRACT_NOTHROW; @@ -68,12 +57,10 @@ BOOL WINAPI CoreDllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved) switch (dwReason) { case DLL_PROCESS_ATTACH: -#ifndef FEATURE_PAL // Make sure the /GS security cookie is initialized before we call anything else. // BinScope detects the call to __security_init_cookie in its "Has Non-GS-friendly // Initialization" check and makes it pass. __security_init_cookie(); -#endif // FEATURE_PAL // It's critical that we invoke InitUtilCode() before the CRT initializes. // We have a lot of global ctors that will break if we let the CRT initialize without @@ -112,6 +99,9 @@ BOOL WINAPI CoreDllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved) return result; } +#endif // PLATFORM_WINDOWS + + extern "C" #ifdef FEATURE_PAL DLLEXPORT // For Win32 PAL LoadLibrary emulation @@ -124,6 +114,18 @@ BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved) { case DLL_PROCESS_ATTACH: { +#ifndef PLATFORM_WINDOWS + // It's critical that we invoke InitUtilCode() before the CRT initializes. + // We have a lot of global ctors that will break if we let the CRT initialize without + // this step having been done. + + CoreClrCallbacks cccallbacks; + cccallbacks.m_hmodCoreCLR = (HINSTANCE)hInstance; + cccallbacks.m_pfnIEE = IEE; + cccallbacks.m_pfnGetCORSystemDirectory = GetCORSystemDirectoryInternaL; + InitUtilcode(cccallbacks); +#endif + // Save the module handle. g_hThisInst = (HINSTANCE)hInstance; @@ -154,61 +156,6 @@ BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved) return TRUE; } -#ifdef FEATURE_COMINTEROP -// --------------------------------------------------------------------------- -// %%Function: DllCanUnloadNowInternal -// -// Returns: -// S_FALSE - Indicating that COR, once loaded, may not be -// unloaded. -// --------------------------------------------------------------------------- -STDAPI DllCanUnloadNowInternal(void) -{ - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_ENTRY_POINT; - - //we should never unload unless the process is dying - return S_FALSE; -} // DllCanUnloadNowInternal - -// --------------------------------------------------------------------------- -// %%Function: DllRegisterServerInternal -// -// Description: -// Registers -// --------------------------------------------------------------------------- -STDAPI DllRegisterServerInternal(HINSTANCE hMod, LPCWSTR version) -{ - - CONTRACTL{ - NOTHROW; - GC_NOTRIGGER; - ENTRY_POINT; - PRECONDITION(CheckPointer(version)); - } CONTRACTL_END; - - return S_OK; -} // DllRegisterServerInternal - -// --------------------------------------------------------------------------- -// %%Function: DllUnregisterServerInternal -// --------------------------------------------------------------------------- -STDAPI DllUnregisterServerInternal(void) -{ - - CONTRACTL - { - GC_NOTRIGGER; - NOTHROW; - ENTRY_POINT; - } - CONTRACTL_END; - - return S_OK; - -} // DllUnregisterServerInternal -#endif // FEATURE_COMINTEROP - #endif // CROSSGEN_COMPILE HINSTANCE GetModuleInst() diff --git a/src/coreclr/src/dlls/mscoree/mscorwks_ntdef.src b/src/coreclr/src/dlls/mscoree/mscorwks_ntdef.src index 1266ec9..9c8ffa0 100644 --- a/src/coreclr/src/dlls/mscoree/mscorwks_ntdef.src +++ b/src/coreclr/src/dlls/mscoree/mscorwks_ntdef.src @@ -25,9 +25,3 @@ EXPORTS coreclr_initialize coreclr_shutdown coreclr_shutdown_2 - - ; il{d}asm - MetaDataGetDispenser - GetMetaDataInternalInterface - GetMetaDataInternalInterfaceFromPublic - GetMetaDataPublicInterfaceFromInternal diff --git a/src/coreclr/src/dlls/mscoree/mscorwks_unixexports.src b/src/coreclr/src/dlls/mscoree/mscorwks_unixexports.src index 98db67b..1085876 100644 --- a/src/coreclr/src/dlls/mscoree/mscorwks_unixexports.src +++ b/src/coreclr/src/dlls/mscoree/mscorwks_unixexports.src @@ -5,17 +5,6 @@ coreclr_initialize coreclr_shutdown coreclr_shutdown_2 -; il{d}asm -MetaDataGetDispenser -GetMetaDataInternalInterface -GetMetaDataInternalInterfaceFromPublic -GetMetaDataPublicInterfaceFromInternal - -; PAL module registration -PAL_RegisterModule -PAL_UnregisterModule - ; Functions exported by the coreclr -CoreDllMain DllMain GetCLRRuntimeHost diff --git a/src/coreclr/src/ilasm/assem.cpp b/src/coreclr/src/ilasm/assem.cpp index 6cdd2e0..99a4321 100644 --- a/src/coreclr/src/ilasm/assem.cpp +++ b/src/coreclr/src/ilasm/assem.cpp @@ -15,7 +15,6 @@ #define DECLARE_DATA #include "assembler.h" -MetaDataGetDispenserFunc metaDataGetDispenser; void indexKeywords(Indx* indx); // defined in asmparse.y @@ -231,7 +230,6 @@ Assembler::~Assembler() BOOL Assembler::Init() { - metaDataGetDispenser = (MetaDataGetDispenserFunc)MetaDataGetDispenser; if (m_pCeeFileGen != NULL) { if (m_pCeeFile) m_pCeeFileGen->DestroyCeeFile(&m_pCeeFile); diff --git a/src/coreclr/src/ilasm/assembler.h b/src/coreclr/src/ilasm/assembler.h index b02f78f..e08f526 100644 --- a/src/coreclr/src/ilasm/assembler.h +++ b/src/coreclr/src/ilasm/assembler.h @@ -54,12 +54,6 @@ #ifdef FEATURE_PAL extern char *g_pszExeFile; #endif -typedef int(STDAPICALLTYPE *MetaDataGetDispenserFunc) ( - REFCLSID rclsid, // The class to desired. - REFIID riid, // Interface wanted on class factory. - LPVOID FAR *ppv); // Return interface pointer here. - -extern MetaDataGetDispenserFunc metaDataGetDispenser; extern WCHAR wzUniBuf[]; // Unicode conversion global buffer (assem.cpp) diff --git a/src/coreclr/src/ilasm/writer.cpp b/src/coreclr/src/ilasm/writer.cpp index 0cbd375..cc28f6e 100644 --- a/src/coreclr/src/ilasm/writer.cpp +++ b/src/coreclr/src/ilasm/writer.cpp @@ -30,7 +30,7 @@ HRESULT Assembler::InitMetaData() if(bClock) bClock->cMDInitBegin = GetTickCount(); - hr = metaDataGetDispenser(CLSID_CorMetaDataDispenser, + hr = MetaDataGetDispenser(CLSID_CorMetaDataDispenser, IID_IMetaDataDispenserEx, (void **)&m_pDisp); if (FAILED(hr)) goto exit; diff --git a/src/coreclr/src/jit/ClrJit.PAL.exports b/src/coreclr/src/jit/ClrJit.PAL.exports index b27c61f..11e42d3 100644 --- a/src/coreclr/src/jit/ClrJit.PAL.exports +++ b/src/coreclr/src/jit/ClrJit.PAL.exports @@ -1,5 +1,2 @@ getJit jitStartup -DllMain -PAL_RegisterModule -PAL_UnregisterModule diff --git a/src/coreclr/src/jit/ee_il_dll.cpp b/src/coreclr/src/jit/ee_il_dll.cpp index e0e30e8..34a24e5 100644 --- a/src/coreclr/src/jit/ee_il_dll.cpp +++ b/src/coreclr/src/jit/ee_il_dll.cpp @@ -64,6 +64,14 @@ extern "C" DLLEXPORT void __stdcall jitStartup(ICorJitHost* jitHost) return; } +#ifdef FEATURE_PAL + int err = PAL_InitializeDLL(); + if (err != 0) + { + return; + } +#endif + g_jitHost = jitHost; assert(!JitConfig.isInitialized()); @@ -148,12 +156,7 @@ void jitShutdown(bool processIsTerminating) #ifndef FEATURE_MERGE_JIT_AND_ENGINE -extern "C" -#ifdef FEATURE_PAL - DLLEXPORT // For Win32 PAL LoadLibrary emulation -#endif - BOOL WINAPI - DllMain(HANDLE hInstance, DWORD dwReason, LPVOID pvReserved) +extern "C" DLLEXPORT BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID pvReserved) { if (dwReason == DLL_PROCESS_ATTACH) { @@ -205,6 +208,11 @@ ICorJitCompiler* g_realJitCompiler = nullptr; DLLEXPORT ICorJitCompiler* __stdcall getJit() { + if (!g_jitInitialized) + { + return nullptr; + } + if (ILJitter == nullptr) { ILJitter = new (CILJitSingleton) CILJit(); diff --git a/src/coreclr/src/pal/src/loader/module.cpp b/src/coreclr/src/pal/src/loader/module.cpp index c87f017..9695226 100644 --- a/src/coreclr/src/pal/src/loader/module.cpp +++ b/src/coreclr/src/pal/src/loader/module.cpp @@ -1709,13 +1709,7 @@ BOOL LOADInitializeCoreCLRModule() ERROR("Can not load the PAL module\n"); return FALSE; } - PDLLMAIN pRuntimeDllMain = (PDLLMAIN)dlsym(module->dl_handle, "CoreDllMain"); - if (!pRuntimeDllMain) - { - ERROR("Can not find the CoreDllMain entry point\n"); - return FALSE; - } - return pRuntimeDllMain(module->hinstance, DLL_PROCESS_ATTACH, nullptr); + return TRUE; } /*++ diff --git a/src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs index f9fe717..b23e1d3 100644 --- a/src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs @@ -58,9 +58,6 @@ namespace Internal.JitInterface private ExceptionDispatchInfo _lastException; - [DllImport(JitLibrary)] - private extern static IntPtr PAL_RegisterModule([MarshalAs(UnmanagedType.LPUTF8Str)] string moduleName); - [DllImport(JitLibrary, CallingConvention=CallingConvention.StdCall)] // stdcall in CoreCLR! private extern static IntPtr jitStartup(IntPtr host); @@ -123,14 +120,6 @@ namespace Internal.JitInterface NativeLibrary.SetDllImportResolver(typeof(CorInfoImpl).Assembly, JitLibraryResolver); } - if (Environment.OSVersion.Platform == PlatformID.Unix) - { - // TODO: The PAL_RegisterModule export should be removed from the JIT - // and the call to PAL_InitializeDLL should be moved to jitStartup. - // https://github.com/dotnet/coreclr/issues/27941 - PAL_RegisterModule("libclrjitilc.so"); - } - jitStartup(GetJitHost(jitConfig.UnmanagedInstance)); } -- 2.7.4