Skip to content

Fix R2R files doublemap on UNIX #113082

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
31 changes: 26 additions & 5 deletions src/coreclr/vm/peimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,8 +705,18 @@ PTR_PEImageLayout PEImage::GetOrCreateLayoutInternal(DWORD imageLayoutMask)
{
bIsLoadedLayoutPreferred = TRUE;
}
#endif // !TARGET_UNIX
#elif defined (TARGET_UNIX)
// Check for R2R image, prefer LoadedLayout for R2R
if (bIsLoadedLayoutSuitable && bIsFlatLayoutSuitable)
{
pRetVal = PEImage::CreateFlatLayout(bIsLoadedLayoutSuitable);

if (pRetVal == NULL)
{
bIsLoadedLayoutPreferred = TRUE;
}
}
#endif // TARGET_UNIX
_ASSERTE(bIsLoadedLayoutSuitable || bIsFlatLayoutSuitable);

if (bIsLoadedLayoutPreferred)
Expand All @@ -718,7 +728,7 @@ PTR_PEImageLayout PEImage::GetOrCreateLayoutInternal(DWORD imageLayoutMask)
if (pRetVal == NULL)
{
_ASSERTE(bIsFlatLayoutSuitable);
pRetVal = PEImage::CreateFlatLayout();
pRetVal = PEImage::CreateFlatLayout(false);
_ASSERTE(pRetVal != NULL);
}
}
Expand Down Expand Up @@ -764,7 +774,7 @@ PTR_PEImageLayout PEImage::CreateLoadedLayout(bool throwOnFailure)
return pLoadLayout;
}

PTR_PEImageLayout PEImage::CreateFlatLayout()
PTR_PEImageLayout PEImage::CreateFlatLayout(BOOL bCheckReadyToRunHeader)
{
CONTRACTL
{
Expand All @@ -775,8 +785,19 @@ PTR_PEImageLayout PEImage::CreateFlatLayout()
CONTRACTL_END;

PTR_PEImageLayout pFlatLayout = PEImageLayout::LoadFlat(this);
SetLayout(IMAGE_FLAT, pFlatLayout);
return pFlatLayout;

if (bCheckReadyToRunHeader && pFlatLayout->HasReadyToRunHeader())
{
pFlatLayout->Release();

return NULL;
}
else
{
SetLayout(IMAGE_FLAT, pFlatLayout);

return pFlatLayout;
}
}

/* static */
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/peimage.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class PEImage final
PTR_PEImageLayout CreateLoadedLayout(bool throwOnFailure);

// Create the flat layout
PTR_PEImageLayout CreateFlatLayout();
PTR_PEImageLayout CreateFlatLayout(BOOL bIsLoadedLayoutSuitable);

void SetLayout(DWORD dwLayout, PTR_PEImageLayout pLayout);
#endif
Expand Down
Loading