未验证 提交 a86e2840 编写于 作者: S Sven Boemer 提交者: GitHub

Remove unaligned offsets for mapped layout (#42464)

* Remove unaligned offsets for mapped layout

* Assert on windows only

- Unix will use the mapped layout with an offset for bundled assemblies
- Windows still should't create a mapped layout for bundles
上级 127f4c35
......@@ -276,7 +276,7 @@ private:
LONG m_refCount;
BundleFileLocation m_bundleFileLocation; // If this image is located within a single-file bundle,
// the location within the bundle. If m_bundleFileLocation is vaild,
// the location within the bundle. If m_bundleFileLocation is valid,
// it takes precedence over m_path for loading.
// This variable will have the data of module name.
......
......@@ -502,13 +502,12 @@ MappedImageLayout::MappedImageLayout(PEImage* pOwner)
HANDLE hFile = pOwner->GetFileHandle();
INT64 offset = pOwner->GetOffset();
INT64 size = pOwner->GetSize();
// If mapping was requested, try to do SEC_IMAGE mapping
LOG((LF_LOADER, LL_INFO100, "PEImage: Opening OS mapped %S (hFile %p)\n", (LPCWSTR) GetPath(), hFile));
#ifndef TARGET_UNIX
_ASSERTE(!pOwner->IsInBundle());
// Let OS map file for us
......@@ -539,19 +538,16 @@ MappedImageLayout::MappedImageLayout(PEImage* pOwner)
return;
}
DWORD offsetLowPart = (DWORD)offset;
DWORD offsetHighPart = (DWORD)(offset >> 32);
#ifdef _DEBUG
// Force relocs by occuping the preferred base while the actual mapping is performed
CLRMapViewHolder forceRelocs;
if (PEDecoder::GetForceRelocs())
{
forceRelocs.Assign(CLRMapViewOfFile(m_FileMap, 0, offsetHighPart, offsetLowPart, (SIZE_T)size));
forceRelocs.Assign(CLRMapViewOfFile(m_FileMap, 0, 0, 0, 0));
}
#endif // _DEBUG
m_FileView.Assign(CLRMapViewOfFile(m_FileMap, 0, offsetHighPart, offsetLowPart, (SIZE_T)size));
m_FileView.Assign(CLRMapViewOfFile(m_FileMap, 0, 0, 0, 0));
if (m_FileView == NULL)
ThrowLastError();
IfFailThrow(Init((void *) m_FileView));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册