-
Notifications
You must be signed in to change notification settings - Fork 5.3k
PE loader/image cleanups. No-copy mapping of R2R PEs on Windows. #61938
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
Changes from 1 commit
515a1b3
0178294
49c759f
519fe5c
00ae715
230e9ef
3e2c617
23945fb
be5f1fe
2bf609d
1e0a933
5cc040e
30be65f
473f734
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -814,13 +814,6 @@ PTR_PEImageLayout PEImage::GetOrCreateLayoutInternal(DWORD imageLayoutMask) | |
|
|
||
| if (pRetVal==NULL) | ||
| { | ||
| // no-path layouts are filled up at creation, if image format permits. | ||
| if (!HasPath()) | ||
| { | ||
| // TODO: VS we should manually map flat layouts for R2R here. | ||
| ThrowHR(COR_E_BADIMAGEFORMAT); | ||
| } | ||
|
|
||
| BOOL bIsLoadedLayoutSuitable = ((imageLayoutMask & PEImageLayout::LAYOUT_LOADED) != 0); | ||
| BOOL bIsFlatLayoutSuitable = ((imageLayoutMask & PEImageLayout::LAYOUT_FLAT) != 0); | ||
|
|
||
|
|
@@ -862,7 +855,6 @@ PTR_PEImageLayout PEImage::CreateLoadedLayout(bool throwOnFailure) | |
| GC_TRIGGERS; | ||
| MODE_ANY; | ||
| PRECONDITION(m_pLayoutLock->IsWriterLock()); | ||
| PRECONDITION(IsFile()); | ||
| } | ||
| CONTRACTL_END; | ||
|
|
||
|
|
@@ -901,17 +893,6 @@ PTR_PEImageLayout PEImage::CreateFlatLayout() | |
|
|
||
| PTR_PEImageLayout pFlatLayout = PEImageLayout::LoadFlat(this); | ||
| SetLayout(IMAGE_FLAT, pFlatLayout); | ||
|
|
||
| if (m_pLayouts[IMAGE_LOADED] == NULL && | ||
| pFlatLayout->CheckNTHeaders() && | ||
| pFlatLayout->CheckILOnly() && | ||
| !pFlatLayout->HasWriteableSections() && | ||
| !pFlatLayout->HasReadyToRunHeader()) | ||
| { | ||
| pFlatLayout->AddRef(); | ||
| SetLayout(IMAGE_LOADED, pFlatLayout); | ||
| } | ||
|
|
||
| return pFlatLayout; | ||
| } | ||
|
|
||
|
|
@@ -930,16 +911,6 @@ PTR_PEImage PEImage::CreateFromByteArray(const BYTE* array, COUNT_T size) | |
|
|
||
| SimpleWriteLockHolder lock(pImage->m_pLayoutLock); | ||
| pImage->SetLayout(IMAGE_FLAT,pLayout); | ||
|
|
||
| // TODO: VS allow R2R for now, meaning it will run as IL-only | ||
| if (pLayout->CheckNTHeaders() && | ||
| pLayout->CheckILOnly() && | ||
| !pLayout->HasWriteableSections()) | ||
| { | ||
| pLayout->AddRef(); | ||
| pImage->SetLayout(IMAGE_LOADED, pLayout); | ||
| } | ||
|
|
||
| RETURN dac_cast<PTR_PEImage>(pImage.Extract()); | ||
| } | ||
|
|
||
|
|
@@ -996,7 +967,12 @@ HANDLE PEImage::GetFileHandle() | |
| { | ||
| ErrorModeHolder mode(SEM_NOOPENFILEERRORBOX|SEM_FAILCRITICALERRORS); | ||
| m_hFile=WszCreateFile((LPCWSTR) GetPathToLoad(), | ||
| GENERIC_READ, | ||
| GENERIC_READ | ||
| #if TARGET_WINDOWS | ||
| // the file may have native code sections, make sure we have execute permissions | ||
| | GENERIC_EXECUTE | ||
| #endif | ||
| , | ||
| FILE_SHARE_READ|FILE_SHARE_DELETE, | ||
| NULL, | ||
| OPEN_EXISTING, | ||
|
|
@@ -1027,7 +1003,12 @@ HRESULT PEImage::TryOpenFile() | |
| { | ||
| ErrorModeHolder mode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS); | ||
| m_hFile=WszCreateFile((LPCWSTR)GetPathToLoad(), | ||
| GENERIC_READ, | ||
| GENERIC_READ | ||
|
||
| #if TARGET_WINDOWS | ||
| // the file may have native code sections, make sure we have execute permissions | ||
| | GENERIC_EXECUTE | ||
| #endif | ||
| , | ||
| FILE_SHARE_READ|FILE_SHARE_DELETE, | ||
| NULL, | ||
| OPEN_EXISTING, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition
!target.IsWindows && is64BitTargetis apparently a negation of the conditiontarget.IsWindows || !is64BitTargetbut it takes a bit of Boolean algebra to double-check that. Could we use an if-else construct or a temporary boolean variable with a sufficiently descriptive name, e.g. isWindowsOr32Bit?