2323
2424#define ASSERTE_ALL_BUILDS (expr ) _ASSERTE_ALL_BUILDS((expr))
2525
26+ #ifdef TARGET_UNIX
27+ #define NO_HOSTING_API_RETURN_ADDRESS ((void *)ULONG_PTR_MAX )
28+ void * g_hostingApiReturnAddress = NO_HOSTING_API_RETURN_ADDRESS ;
29+
30+ class HostingApiFrameHolder
31+ {
32+ public:
33+ HostingApiFrameHolder (void * returnAddress)
34+ {
35+ g_hostingApiReturnAddress = returnAddress;
36+ }
37+
38+ ~HostingApiFrameHolder ()
39+ {
40+ g_hostingApiReturnAddress = NO_HOSTING_API_RETURN_ADDRESS ;
41+ }
42+ };
43+ #endif // TARGET_UNIX
44+
2645// Holder for const wide strings
2746typedef NewArrayHolder<const WCHAR > ConstWStringHolder;
2847
@@ -194,6 +213,7 @@ extern "C" int coreclr_create_delegate(void*, unsigned int, const char*, const c
194213// HRESULT indicating status of the operation. S_OK if the assembly was successfully executed
195214//
196215extern " C"
216+ NOINLINE
197217DLLEXPORT
198218int coreclr_initialize (
199219 const char * exePath,
@@ -212,6 +232,10 @@ int coreclr_initialize(
212232 bool hostPolicyEmbedded = false ;
213233 PInvokeOverrideFn* pinvokeOverride = nullptr ;
214234
235+ #ifdef TARGET_UNIX
236+ HostingApiFrameHolder apiFrameHolder (_ReturnAddress ());
237+ #endif
238+
215239 ConvertConfigPropertiesToUnicode (
216240 propertyKeys,
217241 propertyValues,
@@ -420,6 +444,7 @@ int coreclr_create_delegate(
420444// HRESULT indicating status of the operation. S_OK if the assembly was successfully executed
421445//
422446extern " C"
447+ NOINLINE
423448DLLEXPORT
424449int coreclr_execute_assembly (
425450 void * hostHandle,
@@ -435,6 +460,10 @@ int coreclr_execute_assembly(
435460 }
436461 *exitCode = -1 ;
437462
463+ #ifdef TARGET_UNIX
464+ HostingApiFrameHolder apiFrameHolder (_ReturnAddress ());
465+ #endif
466+
438467 ICLRRuntimeHost4* host = reinterpret_cast <ICLRRuntimeHost4*>(hostHandle);
439468
440469 ConstWStringArrayHolder argvW;
0 commit comments