Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/coreclr/vm/nativeimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,20 @@ NativeImage *NativeImage::Open(
LPWSTR searchPathsConfig;
IfFailThrow(CLRConfig::GetConfigValue(CLRConfig::INTERNAL_NativeImageSearchPaths, &searchPathsConfig));

NewHolder<PEImageLayout> peLoadedImage;
PEImageLayoutHolder peLoadedImage;

BundleFileLocation bundleFileLocation = Bundle::ProbeAppBundle(fullPath, /*pathIsBundleRelative */ true);
if (bundleFileLocation.IsValid())
{
PEImageHolder pImage = PEImage::OpenImage(fullPath, MDInternalImport_Default, bundleFileLocation);
peLoadedImage = pImage->GetOrCreateLayout(PEImageLayout::LAYOUT_MAPPED);
peLoadedImage.SuppressRelease();
// No need to use cache for this PE image.
// Composite r2r PE image is not a part of anyone's identity.
// We only need it to obtain the native image, which will be cached at AppDomain level.
PEImageHolder pImage = PEImage::OpenImage(fullPath, MDInternalImport_NoCache, bundleFileLocation);
PEImageLayout* mapped = pImage->GetOrCreateLayout(PEImageLayout::LAYOUT_MAPPED);
// We will let pImage instance be freed after exiting this scope, but we will keep the layout,
// thus the layout needs an AddRef, or it will be gone together with pImage.
mapped->AddRef();
peLoadedImage = mapped;
}

if (peLoadedImage.IsNull())
Expand Down