From: Andrew Au Date: Fri, 27 Jan 2023 23:43:56 +0000 (-0800) Subject: Fix x86 clrgc loading (#81176) X-Git-Tag: accepted/tizen/unified/riscv/20231226.055536~4369 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ec06321141611cc131c18761808abce15d097db3;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Fix x86 clrgc loading (#81176) Co-authored-by: Jan Kotas --- diff --git a/docs/design/features/standalone-gc-loading.md b/docs/design/features/standalone-gc-loading.md index 118b5cb..a417798 100644 --- a/docs/design/features/standalone-gc-loading.md +++ b/docs/design/features/standalone-gc-loading.md @@ -110,7 +110,7 @@ struct VersionInfo { const char* Name; }; -extern "C" void GC_VersionInfo( +extern "C" void LOCALGC_CALLCONV GC_VersionInfo( /* Out */ VersionInfo* ); ``` @@ -142,7 +142,7 @@ Once the EE has verified that the version of the candidate GC is valid, it then GC. It does so by loading (via `GetProcAddress`) and executing a function with this signature: ```c++ -extern "C" HRESULT GC_Initialize( +extern "C" HRESULT LOCALGC_CALLCONV GC_Initialize( /* In */ IGCToCLR*, /* Out */ IGCHeap**. /* Out */ IGCHandleManager**, diff --git a/src/coreclr/gc/gcinterface.h b/src/coreclr/gc/gcinterface.h index 112cf3a..d04e1f8 100644 --- a/src/coreclr/gc/gcinterface.h +++ b/src/coreclr/gc/gcinterface.h @@ -1061,11 +1061,17 @@ struct VersionInfo { const char* Name; }; -typedef void (*GC_VersionInfoFunction)( +#ifdef TARGET_X86 +#define LOCALGC_CALLCONV __cdecl +#else +#define LOCALGC_CALLCONV +#endif + +typedef void (LOCALGC_CALLCONV *GC_VersionInfoFunction)( /* Out */ VersionInfo* ); -typedef HRESULT (*GC_InitializeFunction)( +typedef HRESULT (LOCALGC_CALLCONV *GC_InitializeFunction)( /* In */ IGCToCLR*, /* Out */ IGCHeap**, /* Out */ IGCHandleManager**, diff --git a/src/coreclr/gc/gcload.cpp b/src/coreclr/gc/gcload.cpp index cd3a0b4..48c1715 100644 --- a/src/coreclr/gc/gcload.cpp +++ b/src/coreclr/gc/gcload.cpp @@ -42,7 +42,7 @@ namespace SVR extern void PopulateHandleTableDacVars(GcDacVars* dacVars); GC_EXPORT -void +void LOCALGC_CALLCONV GC_VersionInfo(/* InOut */ VersionInfo* info) { #ifdef BUILD_AS_STANDALONE @@ -59,7 +59,7 @@ GC_VersionInfo(/* InOut */ VersionInfo* info) } GC_EXPORT -HRESULT +HRESULT LOCALGC_CALLCONV GC_Initialize( /* In */ IGCToCLR* clrToGC, /* Out */ IGCHeap** gcHeap, diff --git a/src/coreclr/gc/sample/GCSample.cpp b/src/coreclr/gc/sample/GCSample.cpp index c102efc..41e2750 100644 --- a/src/coreclr/gc/sample/GCSample.cpp +++ b/src/coreclr/gc/sample/GCSample.cpp @@ -47,6 +47,12 @@ #include "gcdesc.h" +#ifdef TARGET_X86 +#define LOCALGC_CALLCONV __cdecl +#else +#define LOCALGC_CALLCONV +#endif + // // The fast paths for object allocation and write barriers is performance critical. They are often // hand written in assembly code, etc. @@ -106,7 +112,7 @@ void WriteBarrier(Object ** dst, Object * ref) ErectWriteBarrier(dst, ref); } -extern "C" HRESULT GC_Initialize(IGCToCLR* clrToGC, IGCHeap** gcHeap, IGCHandleManager** gcHandleManager, GcDacVars* gcDacVars); +extern "C" HRESULT LOCALGC_CALLCONV GC_Initialize(IGCToCLR* clrToGC, IGCHeap** gcHeap, IGCHandleManager** gcHandleManager, GcDacVars* gcDacVars); int __cdecl main(int argc, char* argv[]) { diff --git a/src/coreclr/vm/gcheaputilities.cpp b/src/coreclr/vm/gcheaputilities.cpp index ab93ae5..ed4e89f 100644 --- a/src/coreclr/vm/gcheaputilities.cpp +++ b/src/coreclr/vm/gcheaputilities.cpp @@ -66,8 +66,8 @@ bool GCHeapUtilities::s_useThreadAllocationContexts; // GC entrypoints for the linked-in GC. These symbols are invoked // directly if we are not using a standalone GC. -extern "C" void GC_VersionInfo(/* Out */ VersionInfo* info); -extern "C" HRESULT GC_Initialize( +extern "C" void LOCALGC_CALLCONV GC_VersionInfo(/* Out */ VersionInfo* info); +extern "C" HRESULT LOCALGC_CALLCONV GC_Initialize( /* In */ IGCToCLR* clrToGC, /* Out */ IGCHeap** gcHeap, /* Out */ IGCHandleManager** gcHandleManager,