Fix x86 clrgc loading (#81176)
authorAndrew Au <andrewau@microsoft.com>
Fri, 27 Jan 2023 23:43:56 +0000 (15:43 -0800)
committerGitHub <noreply@github.com>
Fri, 27 Jan 2023 23:43:56 +0000 (15:43 -0800)
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
docs/design/features/standalone-gc-loading.md
src/coreclr/gc/gcinterface.h
src/coreclr/gc/gcload.cpp
src/coreclr/gc/sample/GCSample.cpp
src/coreclr/vm/gcheaputilities.cpp

index 118b5cb..a417798 100644 (file)
@@ -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**,
index 112cf3a..d04e1f8 100644 (file)
@@ -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**,
index cd3a0b4..48c1715 100644 (file)
@@ -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,
index c102efc..41e2750 100644 (file)
 
 #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[])
 {
index ab93ae5..ed4e89f 100644 (file)
@@ -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,