diff options
author | Sven Boemer <sbomer@gmail.com> | 2018-03-19 20:23:39 -0700 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2018-03-19 20:23:39 -0700 |
commit | 77d4c11fcd67414d2195a63287e9c8e0b6f32958 (patch) | |
tree | 0e5e9835a0f047815a3c4e8f7955262032de4f24 | |
parent | 66758f48163b90700f0551fd9df4f15bcd1a8a45 (diff) | |
download | coreclr-77d4c11fcd67414d2195a63287e9c8e0b6f32958.tar.gz coreclr-77d4c11fcd67414d2195a63287e9c8e0b6f32958.tar.bz2 coreclr-77d4c11fcd67414d2195a63287e9c8e0b6f32958.zip |
Use flat layout for GetAssemblyName (#17052)
* Use flat layout for GetAssemblyName
This change will result in the use flat layouts for the temporary
layouts created by GetAssemblyName. This allows crossgen'd PE images
created for a different OS to be loaded in the code path that
retrieves the assembly name.
* Respond to PR feedback
Add comment, and remove dead code.
-rw-r--r-- | src/vm/assemblyname.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/vm/assemblyname.cpp b/src/vm/assemblyname.cpp index f0ed60bb6d..4fd6e20ee8 100644 --- a/src/vm/assemblyname.cpp +++ b/src/vm/assemblyname.cpp @@ -56,15 +56,18 @@ FCIMPL1(Object*, AssemblyNameNative::GetFileInformation, StringObject* filenameU SString sFileName(gc.filename->GetBuffer()); PEImageHolder pImage = PEImage::OpenImage(sFileName, MDInternalImport_NoCache); + // Load the temporary image using a flat layout, instead of + // waiting for it to happen during HasNTHeaders. This allows us to + // get the assembly name for images that contain native code for a + // non-native platform. + PEImageLayoutHolder pLayout(pImage->GetLayout(PEImageLayout::LAYOUT_FLAT, PEImage::LAYOUT_CREATEIFNEEDED)); + // Allow AssemblyLoadContext.GetAssemblyName for native images on CoreCLR if (pImage->HasNTHeaders() && pImage->HasCorHeader() && pImage->HasNativeHeader()) pImage->VerifyIsNIAssembly(); else pImage->VerifyIsAssembly(); - SString sUrl = sFileName; - PEAssembly::PathToUrl(sUrl); - AssemblySpec spec; spec.InitializeSpec(TokenFromRid(mdtAssembly,1),pImage->GetMDImport(),NULL,TRUE); spec.AssemblyNameInit(&gc.result, pImage); |