summaryrefslogtreecommitdiff
path: root/src/vm/assemblynative.cpp
diff options
context:
space:
mode:
authorGaurav Khanna <gkhanna@microsoft.com>2016-07-26 09:24:38 -0700
committerGaurav Khanna <gkhanna@microsoft.com>2016-07-28 11:16:40 -0700
commit2d2e7661556b4c9f4c7197ead2224bd58a89d251 (patch)
tree851f07406933779564225e1286249244ec9db107 /src/vm/assemblynative.cpp
parent4c5d72ffcdc0a9472aecd32f09fbf266a337dffa (diff)
downloadcoreclr-2d2e7661556b4c9f4c7197ead2224bd58a89d251.tar.gz
coreclr-2d2e7661556b4c9f4c7197ead2224bd58a89d251.tar.bz2
coreclr-2d2e7661556b4c9f4c7197ead2224bd58a89d251.zip
Enable RefEmitted assemblies to have Fallback LoadContext notion
Diffstat (limited to 'src/vm/assemblynative.cpp')
-rw-r--r--src/vm/assemblynative.cpp28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/vm/assemblynative.cpp b/src/vm/assemblynative.cpp
index c8251711ad..29e0a451f0 100644
--- a/src/vm/assemblynative.cpp
+++ b/src/vm/assemblynative.cpp
@@ -179,6 +179,7 @@ FCIMPL9(Object*, AssemblyNative::Load, AssemblyNameBaseObject* assemblyNameUNSAF
CheckPointHolder cph(pThread->m_MarshalAlloc.GetCheckpoint()); //hold checkpoint for autorelease
DomainAssembly * pParentAssembly = NULL;
+ Assembly * pRefAssembly = NULL;
if(gc.assemblyName->GetSimpleName() == NULL)
{
@@ -194,7 +195,6 @@ FCIMPL9(Object*, AssemblyNative::Load, AssemblyNameBaseObject* assemblyNameUNSAF
gc.codeBase = NULL;
// Compute parent assembly
- Assembly * pRefAssembly;
if (gc.requestingAssembly == NULL)
{
pRefAssembly = SystemDomain::GetCallersAssembly(stackMark);
@@ -241,7 +241,17 @@ FCIMPL9(Object*, AssemblyNative::Load, AssemblyNameBaseObject* assemblyNameUNSAF
if (pParentAssembly != NULL)
spec.SetParentAssembly(pParentAssembly);
-
+
+#if defined(FEATURE_HOST_ASSEMBLY_RESOLVER)
+ // If the requesting assembly has Fallback LoadContext binder available,
+ // then set it up in the AssemblySpec.
+ if (pRefAssembly != NULL)
+ {
+ PEFile *pRefAssemblyManifestFile = pRefAssembly->GetManifestFile();
+ spec.SetFallbackLoadContextBinderForRequestingAssembly(pRefAssemblyManifestFile->GetFallbackLoadContextBinder());
+ }
+#endif // defined(FEATURE_HOST_ASSEMBLY_RESOLVER)
+
AssemblyLoadSecurity loadSecurity;
loadSecurity.m_pAdditionalEvidence = &gc.security;
loadSecurity.m_fCheckLoadFromRemoteSource = !!(gc.codeBase != NULL);
@@ -2552,20 +2562,26 @@ INT_PTR QCALLTYPE AssemblyNative::GetLoadContextForAssembly(QCall::AssemblyHandl
{
// Get the binding context for the assembly.
//
+ ICLRPrivBinder *pOpaqueBinder = nullptr;
+ AppDomain *pCurDomain = AppDomain::GetCurrentDomain();
+ CLRPrivBinderCoreCLR *pTPABinder = pCurDomain->GetTPABinderContext();
+
+
// GetBindingContext returns a ICLRPrivAssembly which can be used to get access to the
// actual ICLRPrivBinder instance in which the assembly was loaded.
PTR_ICLRPrivBinder pBindingContext = pPEAssembly->GetBindingContext();
UINT_PTR assemblyBinderID = 0;
IfFailThrow(pBindingContext->GetBinderID(&assemblyBinderID));
- AppDomain *pCurDomain = AppDomain::GetCurrentDomain();
- CLRPrivBinderCoreCLR *pTPABinder = pCurDomain->GetTPABinderContext();
-
// If the assembly was bound using the TPA binder,
// then we will return the reference to "Default" binder from the managed implementation when this QCall returns.
//
// See earlier comment about "Default" binder for additional context.
- ICLRPrivBinder *pOpaqueBinder = reinterpret_cast<ICLRPrivBinder *>(assemblyBinderID);
+ pOpaqueBinder = reinterpret_cast<ICLRPrivBinder *>(assemblyBinderID);
+
+ // We should have a load context binder at this point.
+ _ASSERTE(pOpaqueBinder != nullptr);
+
if (!AreSameBinderInstance(pTPABinder, pOpaqueBinder))
{
// Only CLRPrivBinderAssemblyLoadContext instance contains the reference to its