Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Kotas <jkotas@microsoft.com>2021-03-27 06:02:35 +0300
committerGitHub <noreply@github.com>2021-03-27 06:02:35 +0300
commit67983f7bd8e415e343ce4e5148208302a7049d4b (patch)
tree092635939aac82c2b05445ded7ac01067d0883c4 /src
parent01d724c1bd1ba9a21a307ee10f881be26f443dd8 (diff)
Delete unreachable code for emitting PE fixups and obj files (#50259)
* Delete unrechable code for emitting PE fixups and obj files * Fold ICeeGen into ICeeGenInternal and change IID
Diffstat (limited to 'src')
-rw-r--r--src/coreclr/dlls/mscorpe/ceefilegenwriter.cpp600
-rw-r--r--src/coreclr/dlls/mscorpe/ceefilegenwritertokens.cpp5
-rw-r--r--src/coreclr/dlls/mscorpe/iceefilegen.cpp209
-rw-r--r--src/coreclr/dlls/mscorpe/pewriter.cpp612
-rw-r--r--src/coreclr/dlls/mscorpe/pewriter.h3
-rw-r--r--src/coreclr/ilasm/assem.cpp10
-rw-r--r--src/coreclr/ilasm/assembler.cpp3
-rw-r--r--src/coreclr/ilasm/assembler.h2
-rw-r--r--src/coreclr/ilasm/main.cpp17
-rw-r--r--src/coreclr/inc/ceefilegenwriter.h58
-rw-r--r--src/coreclr/inc/ceegen.h29
-rw-r--r--src/coreclr/inc/cor.h198
-rw-r--r--src/coreclr/inc/corpriv.h153
-rw-r--r--src/coreclr/inc/iceefilegen.h47
-rw-r--r--src/coreclr/md/ceefilegen/cceegen.cpp55
-rw-r--r--src/coreclr/vm/ceeload.cpp2
-rw-r--r--src/coreclr/vm/ceeload.h4
-rw-r--r--src/coreclr/vm/comdynamic.cpp2
-rw-r--r--src/coreclr/vm/commodule.cpp2
-rw-r--r--src/coreclr/vm/reflectclasswriter.cpp2
-rw-r--r--src/coreclr/vm/reflectclasswriter.h6
21 files changed, 321 insertions, 1698 deletions
diff --git a/src/coreclr/dlls/mscorpe/ceefilegenwriter.cpp b/src/coreclr/dlls/mscorpe/ceefilegenwriter.cpp
index bce1fe53be6..6a0ba5a2499 100644
--- a/src/coreclr/dlls/mscorpe/ceefilegenwriter.cpp
+++ b/src/coreclr/dlls/mscorpe/ceefilegenwriter.cpp
@@ -174,51 +174,6 @@ const BYTE DllMainIA64Template[] =
#define DllMainIA64TemplateSize sizeof(DllMainIA64Template)
-#ifdef EMIT_FIXUPS
-
-// Emitted PEFIXUP structure looks like this
-struct PEFIXUP
-{
- WORD wType;
- WORD wSpare;
- DWORD rva;
- DWORD rvaTarget;
-};
-
-// Following structure is used to store the reloc information which
-// will be used at UpdateFixups time to get the final data from the section
-// bytes to update the fixup information.
-//
-struct DBG_FIXUP
-{
- WORD wType;
- WORD wSpare;
-
- union
- {
- DWORD rva;
- unsigned offset;
- };
-
- union
- {
- DWORD rvaTarget;
- CeeSection * sectionSource;
- };
-};
-
-enum
-{
- IMAGE_REL_I386_DIR24NB = 0x0081, // 24-bit base relative
- IMAGE_REL_I386_FILEPOS = 0x0082, // 32-bit file relative
- // all other relocation types are
- // in winnt.h, for some reason
- // this one is missing
- IMAGE_REL_I386_DIR30NB = 0x0083, // 30-bit base relative
-};
-
-#endif // EMIT_FIXUPS
-
// Get the Symbol entry given the head and a 0-based index
inline IMAGE_SYMBOL* GetSymbolEntry(IMAGE_SYMBOL* pHead, SIZE_T idx)
{
@@ -293,13 +248,6 @@ HRESULT CeeFileGenWriter::CreateNewInstanceEx(CCeeGen *pCeeFileGenFrom,
hr = pPrivateGenWriter->allocateCorHeader(); // get COR header near front
IfFailGo(hr);
-#if 0 // Need to add this if we want to propagate the old COM+ header
- if (seedFileName)
- {
- memcpy(m_corHeader, baseFileDecoder->ntHeaders32()->corHeader, sizeof(IMAGE_COR20_HEADER));
- }
-#endif
-
//If we were passed a CCeeGen at the beginning, copy it's data now.
if (pCeeFileGenFrom) {
pCeeFileGenFrom->cloneInstance((CCeeGen*)pPrivateGenWriter);
@@ -313,13 +261,6 @@ HRESULT CeeFileGenWriter::CreateNewInstanceEx(CCeeGen *pCeeFileGenFrom,
// set il RVA to be after the preallocated sections
pPEWriter->setIlRva(preallocatedOffset);
-#ifdef EMIT_FIXUPS
- if (createFlags & ICEE_CREATE_FILE_EMIT_FIXUPS)
- {
- pPrivateGenWriter->setEmitFixups();
- }
-#endif
-
pPEWriter.SuppressRelease();
pPrivateGenWriter.SuppressRelease();
pGenWriter = pPrivateGenWriter;
@@ -333,18 +274,12 @@ CeeFileGenWriter::CeeFileGenWriter() // ctor is protected
m_outputFileName = NULL;
m_resourceFileName = NULL;
m_dllSwitch = false;
- m_objSwitch = false;
- m_libraryName = NULL;
- m_libraryGuid = GUID_NULL;
m_entryPoint = 0;
m_comImageFlags = COMIMAGE_FLAGS_ILONLY; // ceegen PEs don't have native code
m_iatOffset = 0;
m_dllCount = 0;
- m_dwMacroDefinitionSize = 0;
- m_dwMacroDefinitionRVA = NULL;
-
m_dwManifestSize = 0;
m_dwManifestRVA = NULL;
@@ -359,15 +294,6 @@ CeeFileGenWriter::CeeFileGenWriter() // ctor is protected
m_linked = false;
m_fixed = false;
-#ifdef EMIT_FIXUPS
-
- m_fEmitFixups = false;
- m_fFixupsUpdated = false;
- m_sectionFixups = NULL;
- m_pDebugDir = NULL;
-
-#endif
-
} // CeeFileGenWriter::CeeFileGenWriter()
//*****************************************************************************
@@ -393,36 +319,12 @@ HRESULT CeeFileGenWriter::Cleanup() // virtual
return CCeeGen::Cleanup();
} // HRESULT CeeFileGenWriter::Cleanup()
-HRESULT CeeFileGenWriter::EmitMacroDefinitions(void *pData, DWORD cData)
-{
- // OBSOLETE
- m_dwMacroDefinitionSize = 0;
-
- return S_OK;
-} // HRESULT CeeFileGenWriter::EmitMacroDefinitions()
-
HRESULT CeeFileGenWriter::link()
{
HRESULT hr = checkForErrors();
if (! SUCCEEDED(hr))
return hr;
-#ifdef EMIT_FIXUPS
-
- // The fixups describe each relocation. Each fixup contains the relocation's
- // type, source RVA, and target RVA. Since the reloc target can be filled
- // in after the relocation creation, the fixup target RVA discovery needs to
- // be deferred.
- // At this point all bytes should be filled in, ensuring that the final
- // target information is available.
- // UpdateFixups is called at this point to discover the final relocation target info.
- //
- hr = UpdateFixups();
- if (! SUCCEEDED(hr))
- return hr;
-
-#endif
-
// Don't set this if SetManifestEntry was not called - zapper sets the
// resource directory explicitly
if (m_dwManifestSize != 0)
@@ -457,8 +359,6 @@ HRESULT CeeFileGenWriter::link()
m_corHeader->MinorRuntimeVersion = VAL16(COR_VERSION_MINOR);
if (m_dllSwitch)
getPEWriter().setCharacteristics(IMAGE_FILE_DLL);
- if (m_objSwitch)
- getPEWriter().clearCharacteristics(IMAGE_FILE_DLL | IMAGE_FILE_EXECUTABLE_IMAGE);
m_corHeader->Flags = VAL32(m_comImageFlags);
IMAGE_COR20_HEADER_FIELD(*m_corHeader, EntryPointToken) = VAL32(m_entryPoint);
_ASSERTE(TypeFromToken(m_entryPoint) == mdtMethodDef || m_entryPoint == mdTokenNil ||
@@ -466,7 +366,7 @@ HRESULT CeeFileGenWriter::link()
setDirectoryEntry(getCorHeaderSection(), IMAGE_DIRECTORY_ENTRY_COMHEADER, sizeof(IMAGE_COR20_HEADER), m_corHeaderOffset);
if ((m_comImageFlags & COMIMAGE_FLAGS_IL_LIBRARY) == 0
- && !m_linked && !m_objSwitch)
+ && !m_linked)
{
hr = emitExeMain();
if (FAILED(hr))
@@ -508,7 +408,7 @@ HRESULT CeeFileGenWriter::fixup()
}
// remap the entry point if entry point token has been moved
- if (pMapper != NULL && !m_objSwitch)
+ if (pMapper != NULL)
{
mdToken tk = m_entryPoint;
pMapper->HasTokenMoved(tk, tk);
@@ -558,10 +458,8 @@ HRESULT CeeFileGenWriter::generateImage(void **ppImage)
outputFileName = W("output.ill");
else if (m_dllSwitch)
outputFileName = W("output.dll");
- else if (m_objSwitch)
- outputFileName = W("output.exe");
else
- outputFileName = W("output.obj");
+ outputFileName = W("output.exe");
}
// output file name and ppImage are mutually exclusive
@@ -611,50 +509,6 @@ HRESULT CeeFileGenWriter::setResourceFileName(__in LPWSTR fileName)
return S_OK;
} // HRESULT CeeFileGenWriter::setResourceFileName()
-HRESULT CeeFileGenWriter::setLibraryName(__in LPWSTR libraryName)
-{
- if (m_libraryName)
- delete[] m_libraryName;
- size_t len = wcslen(libraryName) + 1;
- m_libraryName = (LPWSTR)new (nothrow) WCHAR[len];
- TESTANDRETURN(m_libraryName != NULL, E_OUTOFMEMORY);
- wcscpy_s(m_libraryName, len, libraryName);
- return S_OK;
-} // HRESULT CeeFileGenWriter::setLibraryName()
-
-HRESULT CeeFileGenWriter::setLibraryGuid(__in LPWSTR libraryGuid)
-{
- return IIDFromString(libraryGuid, &m_libraryGuid);
-} // HRESULT CeeFileGenWriter::setLibraryGuid()
-
-HRESULT CeeFileGenWriter::emitLibraryName(IMetaDataEmit *emitter)
-{
- HRESULT hr;
- IfFailRet(emitter->SetModuleProps(m_libraryName));
-
- // Set the GUID as a custom attribute, if it is not NULL_GUID.
- if (m_libraryGuid != GUID_NULL)
- {
- static COR_SIGNATURE _SIG[] = INTEROP_GUID_SIG;
- mdTypeRef tr;
- mdMemberRef mr;
- WCHAR wzGuid[40];
- BYTE rgCA[50];
- IfFailRet(emitter->DefineTypeRefByName(mdTypeRefNil, INTEROP_GUID_TYPE_W, &tr));
- IfFailRet(emitter->DefineMemberRef(tr, W(".ctor"), _SIG, sizeof(_SIG), &mr));
- StringFromGUID2(m_libraryGuid, wzGuid, lengthof(wzGuid));
- memset(rgCA, 0, sizeof(rgCA));
- // Tag is 0x0001
- rgCA[0] = 1;
- // Length of GUID string is 36 characters.
- rgCA[2] = 0x24;
- // Convert 36 characters, skipping opening {, into 3rd byte of buffer.
- WszWideCharToMultiByte(CP_ACP,0, wzGuid+1,36, reinterpret_cast<char*>(&rgCA[3]),36, 0,0);
- hr = emitter->DefineCustomAttribute(1,mr,rgCA,41,0);
- }
- return (hr);
-} // HRESULT CeeFileGenWriter::emitLibraryName()
-
HRESULT CeeFileGenWriter::setImageBase(size_t imageBase)
{
_ASSERTE(getPEWriter().isPE32());
@@ -1440,13 +1294,6 @@ HRESULT CeeFileGenWriter::setVTableEntry(ULONG size, ULONG offset)
return setVTableEntry64(size,(void*)(ULONG_PTR)offset);
} // HRESULT CeeFileGenWriter::setVTableEntry()
-HRESULT CeeFileGenWriter::setEnCRvaBase(ULONG dataBase, ULONG rdataBase)
-{
- setEnCMode();
- getPEWriter().setEnCRvaBase(dataBase, rdataBase);
- return S_OK;
-} // HRESULT CeeFileGenWriter::setEnCRvaBase()
-
HRESULT CeeFileGenWriter::computeSectionOffset(CeeSection &section, __in char *ptr,
unsigned *offset)
{
@@ -1482,444 +1329,3 @@ HRESULT CeeFileGenWriter::getCorHeader(IMAGE_COR20_HEADER **ppHeader)
*ppHeader = m_corHeader;
return S_OK;
} // HRESULT CeeFileGenWriter::getCorHeader()
-
-
-#ifdef EMIT_FIXUPS
-
-HRESULT CeeFileGenWriter::InitFixupSection()
-{
- if (!m_fEmitFixups)
- {
- return(E_UNEXPECTED);
- }
-
- HRESULT hr;
-
- hr = getSectionCreate(".fixups",
- IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ,
- &m_sectionFixups);
- if (SUCCEEDED(hr))
- {
- size_t cbDebugDir = sizeof(IMAGE_DEBUG_DIRECTORY);
- hr = GetSectionBlock(m_sectionFixups, (ULONG) cbDebugDir, 32, (void **) &m_pDebugDir);
- if (SUCCEEDED(hr))
- {
- memset(m_pDebugDir, 0, cbDebugDir);
- m_pDebugDir->Type = IMAGE_DEBUG_TYPE_FIXUP;
- m_fFixupsUpdated = false;
-
- return(S_OK);
- }
- }
-
- m_pDebugDir = NULL;
- m_sectionFixups = NULL;
- m_fEmitFixups = false;
-
- return(E_FAIL);
-
-} // HRESULT CeeFileGenWriter::InitFixupSection()
-
-HRESULT CeeFileGenWriter::addFixup(CeeSection& sectionSource, unsigned offset, CeeSectionRelocType relocType, CeeSection * psectionTarget, CeeSectionRelocExtra *extra)
-{
- if (!m_fEmitFixups)
- {
- return(S_OK);
- }
-
- _ASSERTE(sizeof(DBG_FIXUP) == sizeof(PEFIXUP));
- _ASSERTE(m_fFixupsUpdated == false);
-
- DBG_FIXUP * pfixup;
-
- if (m_sectionFixups == NULL)
- {
- HRESULT hr = InitFixupSection();
- if (FAILED(hr))
- {
- return(hr);
- }
-
- // The fixup section begins with a IMAGE_DEBUG_DIRECTORY containing a
- // IMAGE_DEBUG_TYPE_FIXUP directory entry, which describes the array
- // of fixups which follows it.
-
- // The very first item of this array is aligned on a 32 bit boundary.
- // All other fixup entries follow unaligned.
- pfixup = (DBG_FIXUP *) m_sectionFixups->getBlock(sizeof(DBG_FIXUP), 32);
- TESTANDRETURN(pfixup != NULL, E_OUTOFMEMORY);
-
- // Initialize the IMAGE_DEBUG_TYPE_FIXUP entry relocations
-#ifdef HOST_64BIT
- _ASSERTE(!"Base relocs are not yet implemented for 64-bit");
- m_pDebugDir->AddressOfRawData = 0; // @ToDo: srRelocAbsolutePtr can't take a 64-bit address
-#else
- m_pDebugDir->AddressOfRawData = (size_t) pfixup;
- m_sectionFixups->addSectReloc(offsetof(IMAGE_DEBUG_DIRECTORY, AddressOfRawData), *m_sectionFixups, srRelocAbsolutePtr);
-#endif
-
- m_pDebugDir->PointerToRawData = m_sectionFixups->computeOffset((char *) pfixup);
-
- m_sectionFixups->addSectReloc(offsetof(IMAGE_DEBUG_DIRECTORY, PointerToRawData), *m_sectionFixups, srRelocFilePos);
-
- unsigned offsetDir = m_sectionFixups->computeOffset((char *) m_pDebugDir);
- setDirectoryEntry(*m_sectionFixups, IMAGE_DIRECTORY_ENTRY_DEBUG, sizeof(IMAGE_DEBUG_DIRECTORY), offsetDir);
-
-#ifdef TEST_EMIT_FIXUPS
- TestEmitFixups();
-#endif
- }
- else
- {
- pfixup = (DBG_FIXUP *) m_sectionFixups->getBlock(sizeof(DBG_FIXUP), 1);
- TESTANDRETURN(pfixup != NULL, E_OUTOFMEMORY);
- }
-
- // Save off the relocation information for use later. The relocation's
- // target information can be filled in later.
- // The relocation target info is not always immediately available, so it needs
- // to be extracted later, during the link phase. For now the relocation info
- // is stored so the target can be extracted at link time in the UpdateFixups
- // function.
- //
- unsigned offsetFixup = m_sectionFixups->computeOffset((char *) pfixup);
- pfixup->wSpare = 0;
- pfixup->wType = relocType;
- _ASSERTE(pfixup->wType == relocType);
- pfixup->offset = offset;
- pfixup->sectionSource = &sectionSource;
-
- m_pDebugDir->SizeOfData += sizeof(DBG_FIXUP);
-
- // Add a relocation for the fixup's source RVA field, (no fixup on this reloc)
- m_sectionFixups->addSectReloc(offsetFixup + offsetof(DBG_FIXUP, rva), sectionSource, srRelocAbsolutePtr);
-
- // Add a relocation for the fixup's target RVA field. Correct target extracted
- // later in UpdateFixups, (no fixup on this reloc)
- CeeSectionRelocType tgtRelocType;
-
- switch (relocType)
- {
- case srRelocMapToken:
- // not an RVA
- tgtRelocType = srRelocMapToken;
- break;
-
- case srRelocFilePos:
- tgtRelocType = srRelocFilePos;
- break;
-
- case srRelocHighAdj:
- tgtRelocType = srRelocHighAdj;
- break;
-
- default:
- tgtRelocType = (relocType & srRelocPtr) ? srRelocAbsolutePtr : srRelocAbsolute;
- break;
- }
-
- if (psectionTarget != NULL)
- {
- m_sectionFixups->addSectReloc(offsetFixup + offsetof(DBG_FIXUP, rvaTarget), *psectionTarget, tgtRelocType, extra);
- }
- else
- {
- m_sectionFixups->addBaseReloc(offsetFixup + offsetof(DBG_FIXUP, rvaTarget), tgtRelocType, extra);
- }
-
- return(S_OK);
-} // HRESULT CeeFileGenWriter::addFixup()
-
-HRESULT CeeFileGenWriter::UpdateFixups()
-{
- // This method extracts the correct relocation target. See addFixup method.
-
- if (!m_fEmitFixups || m_fFixupsUpdated)
- {
- return(S_OK);
- }
- m_fFixupsUpdated = true; // prevent UpdateFixups from being called again.
-
- size_t cfixups = m_pDebugDir->SizeOfData / sizeof(DBG_FIXUP);
- _ASSERT(m_pDebugDir->SizeOfData % sizeof(DBG_FIXUP) == 0);
- unsigned ibFixup = m_pDebugDir->PointerToRawData;
-
- for (size_t idx = 0; idx < cfixups; idx++, ibFixup += sizeof(DBG_FIXUP))
- {
- DBG_FIXUP * pfixup = (DBG_FIXUP *) m_sectionFixups->computePointer(ibFixup);
- CeeSection * sectionSource = pfixup->sectionSource;
- CeeSectionRelocType relocType = (CeeSectionRelocType) pfixup->wType;
- unsigned offset = pfixup->offset;
-
- // Get current data for replacing fixup contents
- const DWORD * pdw = (DWORD *) sectionSource->computePointer(offset);
- pfixup->rva = (DWORD) (UINT_PTR) pdw;
- pfixup->rvaTarget = *pdw;
-
- switch (relocType)
- {
-#ifdef HOST_X86
- case srRelocAbsolute:
- // Emitted bytes: RVA, offset relative to image base
- // reloc src contains target offset relative to target section
- if ((*pdw & 0xFF000000) == 0)
- {
- pfixup->wType = IMAGE_REL_I386_DIR32NB;
- }
- else
- {
- // MethodDesc::Fixup function creates a 24 bit RVA, where the
- // high byte of the DWORD stores the flag value: METHOD_NEEDS_PRESTUB_RUN_FLAG.
- // work around it by converting the type to 24 bits here
- pfixup->wType = IMAGE_REL_I386_DIR24NB;
- pfixup->rvaTarget = *pdw & 0x00FFFFFF;
- }
- break;
-
- case srRelocAbsolutePtr:
- // Emitted bytes: RVA, offset relative to image base
- // reloc src contains target pointer
- pfixup->wType = IMAGE_REL_I386_DIR32NB;
- break;
-
- case srRelocHighLow:
- // Emitted bytes: full address of target
- // reloc src contains target offset relative to target section
- pfixup->wType = IMAGE_REL_I386_DIR32;
- break;
-
- case srRelocHighLowPtr:
- // Emitted bytes: full address of target
- // reloc src contains target pointer
- pfixup->wType = IMAGE_REL_I386_DIR32;
- break;
-
- case srRelocRelative:
- // Emitted bytes: value of reloc tgt - (reloc source + sizeof(DWORD))
- // reloc src contains offset relative to target section, minus sizeof(DWORD)
- // the reloc type for pFixup->rvaTarget is srRelocAbsolute
- // so contents of pFixup->rvaTarget need to be offset Target + sizeof(DWORD)
- // which is offset Target == Source contents + sizeof(DWORD) == *pdw + sizeof(DWORD)
- pfixup->wType = IMAGE_REL_I386_REL32;
- pfixup->rvaTarget = *pdw + sizeof(DWORD);
- break;
-
- case srRelocRelativePtr:
- // Emitted bytes: value of reloc tgt - (reloc source + sizeof(DWORD))
- // reloc src contains disp, disp = pTarget - (pSource + sizeof(DWORD))
- // the reloc type for pFixup->rvaTarget is srRelocAbsolutePtr
- // so contents of pFixup->rvaTarget need to be pTarget
- // which is pTarget == pSource + sizeof(DWORD) + disp == pdw + 4 + *pdw
- pfixup->wType = IMAGE_REL_I386_REL32;
- pfixup->rvaTarget = (int) (INT_PTR) pdw + sizeof(DWORD) + (int) *pdw;
- break;
-
- case srRelocMapToken:
- // Emitted bytes: contents of reloc source unchanged.
- // reloc src contains token value
- pfixup->wType = IMAGE_REL_I386_TOKEN;
- break;
-
-#elif defined(HOST_AMD64)
- /*
- //
- // X86-64 relocations
- //
- IMAGE_REL_AMD64_ABSOLUTE 0x0000 // Reference is absolute, no relocation is necessary
- IMAGE_REL_AMD64_ADDR64 0x0001 // 64-bit address (VA).
- IMAGE_REL_AMD64_ADDR32 0x0002 // 32-bit address (VA).
- IMAGE_REL_AMD64_ADDR32NB 0x0003 // 32-bit address w/o image base (RVA).
- IMAGE_REL_AMD64_REL32 0x0004 // 32-bit relative address from byte following reloc
- IMAGE_REL_AMD64_REL32_1 0x0005 // 32-bit relative address from byte distance 1 from reloc
- IMAGE_REL_AMD64_REL32_2 0x0006 // 32-bit relative address from byte distance 2 from reloc
- IMAGE_REL_AMD64_REL32_3 0x0007 // 32-bit relative address from byte distance 3 from reloc
- IMAGE_REL_AMD64_REL32_4 0x0008 // 32-bit relative address from byte distance 4 from reloc
- IMAGE_REL_AMD64_REL32_5 0x0009 // 32-bit relative address from byte distance 5 from reloc
- IMAGE_REL_AMD64_SECTION 0x000A // Section index
- IMAGE_REL_AMD64_SECREL 0x000B // 32 bit offset from base of section containing target
- IMAGE_REL_AMD64_SECREL7 0x000C // 7 bit unsigned offset from base of section containing target
- IMAGE_REL_AMD64_TOKEN 0x000D // 32 bit metadata token
- IMAGE_REL_AMD64_SREL32 0x000E // 32 bit signed span-dependent value emitted into object
- IMAGE_REL_AMD64_PAIR 0x000F
- IMAGE_REL_AMD64_SSPAN32 0x0010 // 32 bit signed span-dependent value applied at link time
- */
- case srRelocAbsolute:
- // Emitted bytes: RVA, offset relative to image base
- pfixup->wType = IMAGE_REL_AMD64_ADDR32NB;
- break;
-
- case srRelocAbsolutePtr:
- // Emitted bytes: RVA, offset relative to image base
- // reloc src contains target pointer
- pfixup->wType = IMAGE_REL_AMD64_ADDR32NB;
- break;
-
- case srRelocDir64Ptr:
- // Emitted bytes: full address of target
- // reloc src contains target pointer
- pfixup->wType = IMAGE_REL_IA64_DIR64;
- break;
-
- case srRelocMapToken:
- // Emitted bytes: contents of reloc source unchanged.
- // reloc src contains token value
- pfixup->wType = IMAGE_REL_AMD64_TOKEN;
- break;
-#endif
- case srRelocFilePos:
- // Emitted bytes: offset relative to start of file, differs from RVA.
- pfixup->wType = IMAGE_REL_I386_FILEPOS;
- break;
-
- case srRelocAbsoluteTagged:
- pfixup->wType = IMAGE_REL_I386_DIR30NB;
- pfixup->rvaTarget = (*pdw & ~0x80000001) >> 1;
- break;
-
- case srRelocHighAdj:
- // Emitted bytes: 2 part relocation, with high part adjusted by constant.
- pfixup->wType = IMAGE_REL_BASED_HIGHADJ;
- break;
-
- default:
- _ASSERTE(!"Unknown relocation type");
- return(E_UNEXPECTED);
- break;
- }
- }
-
- return(S_OK);
-
-} // HRESULT CeeFileGenWriter::UpdateFixups()
-
-
-HRESULT CeeFileGenWriter::setEmitFixups()
-{
- m_fEmitFixups = true;
- return(S_OK);
-
-} // HRESULT CeeFileGenWriter::setEmitFixups()
-
-#ifdef TEST_EMIT_FIXUPS
-
-HRESULT CeeFileGenWriter::TestEmitFixups()
-{
- HRESULT hr;
- // Test fixups
-
- CeeSection * testSection;
- hr = getSectionCreate(".test",
- IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ,
- &testSection);
- if (SUCCEEDED(hr))
- {
- struct FixupEntry
- {
- char sz[18];
- DWORD wTargets[8];
- };
-
- struct FixupTypes
- {
- char * pszType;
- CeeSectionRelocType relocType;
- };
-
- FixupTypes rgTypes[] =
- {
- { "srRelocAbsolute ", srRelocAbsolute },
- { "srRelocAbsolutePtr", srRelocAbsolutePtr },
- { "srRelocHighLow ", srRelocHighLow },
- { "srRelocHighLowPtr ", srRelocHighLowPtr },
- // { "srRelocRelative ", srRelocRelative },
- // { "srRelocRelativePtr", srRelocRelativePtr },
- { "srRelocMapToken ", srRelocMapToken },
- // { "srRelocFilePos ", srRelocFilePos },
- // { "srRelocHighAdj ", srRelocHighAdj },
- };
-
- const size_t cFixups = sizeof(rgTypes) / sizeof(rgTypes[0]);
-
- DWORD * pdwTargets[20];
-
- // Target Blocks:
-
- for (size_t idx = 0; idx < cFixups; idx++)
- {
- hr = GetSectionBlock(testSection, sizeof(DWORD), 1, (void **) &pdwTargets[idx]);
- _ASSERTE(SUCCEEDED(hr));
-
- DWORD * pdw = pdwTargets[idx];
- *pdw = idx;
- }
-
- for (size_t idxType = 0; idxType < cFixups; idxType++)
- {
- // Fixup Entries
- FixupEntry * pEntry;
- hr = GetSectionBlock(testSection, sizeof(FixupEntry), 1, (void **) &pEntry);
- _ASSERTE(SUCCEEDED(hr));
-
- memset(pEntry, 0, sizeof(FixupEntry));
- strcpy_s(pEntry->sz, sizeof(pEntry->sz), rgTypes[idxType].pszType);
-
- size_t ibBlock = testSection->computeOffset((char *) pEntry);
-
- for (size_t idx = 0; idx < cFixups; idx++)
- {
- size_t ibFixup = ((size_t) &pEntry->wTargets[idx]) - (size_t) pEntry;
-
- switch (rgTypes[idxType].relocType)
- {
- case srRelocAbsolute:
- pEntry->wTargets[idx] = idx * sizeof(DWORD);
- break;
-
- case srRelocAbsolutePtr:
- pEntry->wTargets[idx] = (DWORD) pdwTargets[idx];
- break;
-
- case srRelocHighLow:
- pEntry->wTargets[idx] = idx * sizeof(DWORD);
- break;
-
- case srRelocHighLowPtr:
- pEntry->wTargets[idx] = (DWORD) pdwTargets[idx];
- break;
-
- case srRelocRelative:
- pEntry->wTargets[idx] = idx;
- break;
-
- case srRelocRelativePtr:
- {
- size_t ibTgt = (size_t) pdwTargets[idx];
- size_t ibSrc = ((size_t) &pEntry->wTargets[idx]) + sizeof(DWORD);
- pEntry->wTargets[idx] = (DWORD)( ibTgt - ibSrc );
- ibFixup += sizeof(DWORD); // offset needs to point at end of DWORD
- break;
- }
-
- case srRelocHighAdj:
- pEntry->wTargets[idx] = idx * sizeof(DWORD);
- break;
-
- case srRelocMapToken:
- pEntry->wTargets[idx] = idx * sizeof(DWORD);
- break;
-
- case srRelocFilePos:
- pEntry->wTargets[idx] = idx * sizeof(DWORD);
- break;
- }
-
- addFixup(*testSection, ibBlock + ibFixup, rgTypes[idxType].relocType, testSection);
- testSection->addSectReloc(ibBlock + ibFixup, *testSection, rgTypes[idxType].relocType);
- }
- }
- }
-
- return(S_OK);
-}
-#endif // TEST_EMIT_FIXUPS
-#endif // EMIT_FIXUPS
diff --git a/src/coreclr/dlls/mscorpe/ceefilegenwritertokens.cpp b/src/coreclr/dlls/mscorpe/ceefilegenwritertokens.cpp
index 31b4d204119..beb0ee71d51 100644
--- a/src/coreclr/dlls/mscorpe/ceefilegenwritertokens.cpp
+++ b/src/coreclr/dlls/mscorpe/ceefilegenwritertokens.cpp
@@ -126,11 +126,6 @@ HRESULT CeeFileGenWriter::MapTokensForMethod(
COR_ILMETHOD_DECODER method((COR_ILMETHOD*) pCode);
- // If compressed IL is being emitted, this routine will have no idea how to walk the tokens,
- // so don't do it
- if (m_dwMacroDefinitionSize != 0)
- return S_OK;
-
pCode = const_cast<BYTE*>(method.Code);
PC = 0;
diff --git a/src/coreclr/dlls/mscorpe/iceefilegen.cpp b/src/coreclr/dlls/mscorpe/iceefilegen.cpp
index 44c939497d8..6714d355d0b 100644
--- a/src/coreclr/dlls/mscorpe/iceefilegen.cpp
+++ b/src/coreclr/dlls/mscorpe/iceefilegen.cpp
@@ -7,75 +7,6 @@
#include "iceefilegen.h"
#include "ceefilegenwriter.h"
-// Deprecated
-//****************************************************************************
- HRESULT ICeeFileGen::EmitMethod ()
- {
- _ASSERTE("Deprecated" && 0);
- return (E_FAIL);
- }
- HRESULT ICeeFileGen::EmitSignature ()
- {
- _ASSERTE("Deprecated" && 0);
- return (E_FAIL);
- }
- HRESULT ICeeFileGen::SetEntryClassToken ()
- {
- _ASSERTE("Deprecated" && 0);
- return (E_FAIL);
- }
- HRESULT ICeeFileGen::GetEntryClassToken ()
- {
- _ASSERTE("Deprecated" && 0);
- return (E_FAIL);
- }
- HRESULT ICeeFileGen::SetEntryPointDescr ()
- {
- _ASSERTE("Deprecated" && 0);
- return (E_FAIL);
- }
- HRESULT ICeeFileGen::GetEntryPointDescr ()
- {
- _ASSERTE("Deprecated" && 0);
- return (E_FAIL);
- }
- HRESULT ICeeFileGen::SetEntryPointFlags ()
- {
- _ASSERTE("Deprecated" && 0);
- return (E_FAIL);
- }
- HRESULT ICeeFileGen::GetEntryPointFlags ()
- {
- _ASSERTE("Deprecated" && 0);
- return (E_FAIL);
- }
- HRESULT ICeeFileGen::CreateSig ()
- {
- _ASSERTE("Deprecated" && 0);
- return (E_FAIL);
- }
- HRESULT ICeeFileGen::AddSigArg ()
- {
- _ASSERTE("Deprecated" && 0);
- return (E_FAIL);
- }
- HRESULT ICeeFileGen::SetSigReturnType ()
- {
- _ASSERTE("Deprecated" && 0);
- return (E_FAIL);
- }
- HRESULT ICeeFileGen::SetSigCallingConvention ()
- {
- _ASSERTE("Deprecated" && 0);
- return (E_FAIL);
- }
- HRESULT ICeeFileGen::DeleteSig ()
- {
- _ASSERTE("Deprecated" && 0);
- return (E_FAIL);
- }
-//****************************************************************************
-
EXTERN_C HRESULT __stdcall CreateICeeFileGen(ICeeFileGen** pCeeFileGen)
{
if (!pCeeFileGen)
@@ -125,7 +56,7 @@ HRESULT ICeeFileGen::CreateCeeFileEx2 (HCEEFILE *ceeFile, DWORD createFlags, LPC
return S_OK;
}
-HRESULT ICeeFileGen::CreateCeeFileFromICeeGen(ICeeGen *pICeeGen, HCEEFILE *ceeFile, DWORD createFlags)
+HRESULT ICeeFileGen::CreateCeeFileFromICeeGen(ICeeGenInternal *pICeeGen, HCEEFILE *ceeFile, DWORD createFlags)
{
if (!ceeFile)
return E_POINTER;
@@ -235,12 +166,6 @@ HRESULT ICeeFileGen::GetSectionBlock (HCEESECTION section, ULONG len,
return S_OK;
}
-HRESULT ICeeFileGen::TruncateSection (HCEESECTION section, ULONG len)
-{
- _ASSERTE(!"This is an obsolete function!");
- return E_NOTIMPL;
-}
-
HRESULT ICeeFileGen::AddSectionReloc (HCEESECTION section, ULONG offset, HCEESECTION relativeTo, CeeSectionRelocType relocType)
{
TESTANDRETURNPOINTER(section);
@@ -250,39 +175,14 @@ HRESULT ICeeFileGen::AddSectionReloc (HCEESECTION section, ULONG offset, HCEESEC
if (relSec)
{
-#ifdef EMIT_FIXUPS
- CeeFileGenWriter * gen = reinterpret_cast<CeeFileGenWriter*>(&sec->ceeFile());
- HRESULT hr = gen->addFixup(*sec, offset, relocType, relSec);
- if (FAILED(hr))
- {
- return(hr);
- }
-#endif
return(sec->addSectReloc(offset, *relSec, relocType));
}
else
{
-#ifdef EMIT_FIXUPS
- CeeFileGenWriter * gen = reinterpret_cast<CeeFileGenWriter*>(&sec->ceeFile());
- HRESULT hr = gen->addFixup(*sec, offset, relocType);
- if (FAILED(hr))
- {
- return(hr);
- }
-#endif
return(sec->addBaseReloc(offset, relocType));
}
}
-HRESULT ICeeFileGen::SetSectionDirectoryEntry(HCEESECTION section, ULONG num)
-{
- TESTANDRETURNPOINTER(section);
-
- printf("Warning: deprecated method. Use SetDirectoryEntry instead\n");
- CeeSection *sec = reinterpret_cast<CeeSection*>(section);
- return(sec->directoryEntry(num));
-}
-
HRESULT ICeeFileGen::SetOutputFileName (HCEEFILE ceeFile, __in LPWSTR outputFileName)
{
TESTANDRETURNPOINTER(ceeFile);
@@ -368,20 +268,6 @@ HRESULT ICeeFileGen::GetIMapTokenIface(HCEEFILE ceeFile, IMetaDataEmit *emitter,
return E_NOTIMPL;
}
-HRESULT ICeeFileGen::EmitMetaData (HCEEFILE ceeFile, IMetaDataEmit *emitter,
- mdScope scopeE)
-{
- _ASSERTE(!"This is an obsolete function!");
- return E_NOTIMPL;
-}
-
-HRESULT ICeeFileGen::EmitLibraryName (HCEEFILE ceeFile, IMetaDataEmit *emitter,
- mdScope scopeE)
-{
- _ASSERTE(!"This is an obsolete function!");
- return E_NOTIMPL;
-}
-
HRESULT ICeeFileGen::GetMethodRVA(HCEEFILE ceeFile, ULONG codeOffset, ULONG *codeRVA)
{
TESTANDRETURNARG(ceeFile != 0);
@@ -407,14 +293,6 @@ HRESULT ICeeFileGen::LinkCeeFile (HCEEFILE ceeFile)
return gen->link();
}
-HRESULT ICeeFileGen::FixupCeeFile (HCEEFILE ceeFile)
-{
- TESTANDRETURNPOINTER(ceeFile);
-
- CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
- return gen->fixup();
-}
-
HRESULT ICeeFileGen::GetHeaderInfo (HCEEFILE ceeFile, PIMAGE_NT_HEADERS *ppNtHeaders, PIMAGE_SECTION_HEADER *ppSections, ULONG *pNumSections)
{
TESTANDRETURNPOINTER(ceeFile);
@@ -432,17 +310,6 @@ HRESULT ICeeFileGen::GenerateCeeFile (HCEEFILE ceeFile)
return gen->generateImage(NULL); // NULL means don't write in-memory buffer, uses outputFileName
}
-// GenerateCeeMemoryImage - returns in ppImage an in-memory PE image allocated by CoTaskMemAlloc()
-// the caller is responsible for calling CoTaskMemFree on this memory image
-HRESULT ICeeFileGen::GenerateCeeMemoryImage (HCEEFILE ceeFile, void **ppImage)
-{
- TESTANDRETURNPOINTER(ceeFile);
- TESTANDRETURNPOINTER(ppImage);
-
- CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
- return gen->generateImage(ppImage);
-}
-
HRESULT ICeeFileGen::SetEntryPoint(HCEEFILE ceeFile, mdMethodDef method)
{
TESTANDRETURNPOINTER(ceeFile);
@@ -507,55 +374,6 @@ HRESULT ICeeFileGen::GetDllSwitch (HCEEFILE ceeFile, BOOL *dllSwitch)
return S_OK;
}
-HRESULT ICeeFileGen::SetObjSwitch (HCEEFILE ceeFile, BOOL objSwitch)
-{
- TESTANDRETURNPOINTER(ceeFile);
-
- CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
- return(gen->setObjSwitch(objSwitch==TRUE));
-}
-
-HRESULT ICeeFileGen::GetObjSwitch (HCEEFILE ceeFile, BOOL *objSwitch)
-{
- TESTANDRETURNPOINTER(ceeFile);
-
- CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
- TESTANDRETURNPOINTER(objSwitch);
- *objSwitch = gen->getObjSwitch();
- return S_OK;
-}
-
-
-HRESULT ICeeFileGen::SetLibraryName (HCEEFILE ceeFile, __in LPWSTR LibraryName)
-{
- TESTANDRETURNPOINTER(ceeFile);
- TESTANDRETURNPOINTER(LibraryName);
-
- CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
- return(gen->setLibraryName(LibraryName));
-}
-
-HRESULT ICeeFileGen::SetLibraryGuid (HCEEFILE ceeFile, __in LPWSTR LibraryGuid)
-{
- TESTANDRETURNPOINTER(ceeFile);
- TESTANDRETURNPOINTER(LibraryGuid);
-
- CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
- return(gen->setLibraryGuid(LibraryGuid));
-}
-
-__success(return == S_OK) HRESULT ICeeFileGen::GetLibraryName (HCEEFILE ceeFile, __out LPWSTR *LibraryName)
-{
- TESTANDRETURNPOINTER(ceeFile);
- TESTANDRETURNPOINTER(LibraryName);
-
- CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
- *LibraryName = gen->getLibraryName();
- return S_OK;
-}
-
-
-
HRESULT ICeeFileGen::EmitMetaDataEx (HCEEFILE ceeFile, IMetaDataEmit *emitter)
{
TESTANDRETURNPOINTER(ceeFile);
@@ -576,15 +394,6 @@ HRESULT ICeeFileGen::EmitMetaDataAt (HCEEFILE ceeFile, IMetaDataEmit *emitter, H
return(gen->emitMetaData(emitter, sec, offset, buffer, buffLen));
}
-HRESULT ICeeFileGen::EmitLibraryNameEx (HCEEFILE ceeFile, IMetaDataEmit *emitter)
-{
- TESTANDRETURNPOINTER(ceeFile);
- TESTANDRETURNPOINTER(emitter);
-
- CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
- return(gen->emitLibraryName(emitter));
-}
-
HRESULT ICeeFileGen::GetIMapTokenIfaceEx(HCEEFILE ceeFile, IMetaDataEmit *emitter, IUnknown **pIMapToken)
{
TESTANDRETURNPOINTER(ceeFile);
@@ -604,14 +413,6 @@ HRESULT ICeeFileGen::AddNotificationHandler(HCEEFILE ceeFile,
return gen->addNotificationHandler(pHandler);
}
-HRESULT ICeeFileGen::EmitMacroDefinitions(HCEEFILE ceeFile, void *pData, DWORD cData)
-{
- TESTANDRETURNPOINTER(ceeFile);
-
- CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
- return gen->EmitMacroDefinitions(pData, cData);
-}
-
HRESULT ICeeFileGen::SetManifestEntry(HCEEFILE ceeFile, ULONG size, ULONG offset)
{
TESTANDRETURNPOINTER(ceeFile);
@@ -670,14 +471,6 @@ HRESULT ICeeFileGen::ComputeOffset(HCEEFILE ceeFile, __in char *ptr,
return hr;
}
-HRESULT ICeeFileGen::SetEnCRVABase(HCEEFILE ceeFile, ULONG dataBase, ULONG rdataBase)
-{
- TESTANDRETURNPOINTER(ceeFile);
-
- CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
- return gen->setEnCRvaBase(dataBase, rdataBase);
-}
-
HRESULT ICeeFileGen::GetCorHeader(HCEEFILE ceeFile,
IMAGE_COR20_HEADER **header)
{
diff --git a/src/coreclr/dlls/mscorpe/pewriter.cpp b/src/coreclr/dlls/mscorpe/pewriter.cpp
index cc70bd88752..f1efec649c4 100644
--- a/src/coreclr/dlls/mscorpe/pewriter.cpp
+++ b/src/coreclr/dlls/mscorpe/pewriter.cpp
@@ -44,10 +44,6 @@ inline static unsigned padLen(unsigned len, unsigned align) {
return(roundUp(len, align) - len);
}
-inline static bool isExeOrDll(IMAGE_NT_HEADERS* ntHeaders) {
- return ((ntHeaders->FileHeader.Characteristics & VAL16(IMAGE_FILE_EXECUTABLE_IMAGE)) != 0);
-}
-
#ifndef IMAGE_DLLCHARACTERISTICS_NO_SEH
#define IMAGE_DLLCHARACTERISTICS_NO_SEH 0x400
#endif
@@ -877,7 +873,6 @@ HRESULT PEWriter::Init(PESectionMan *pFrom, DWORD createFlags, LPCWSTR seedFileN
m_dataRvaBase = 0;
m_rdataRvaBase = 0;
m_codeRvaBase = 0;
- m_encMode = FALSE;
virtualPos = 0;
filePos = 0;
@@ -1089,13 +1084,6 @@ HRESULT PEWriter::setDirectoryEntry(PEWriterSection *section, ULONG entry, ULONG
return S_OK;
}
-void PEWriter::setEnCRvaBase(ULONG dataBase, ULONG rdataBase)
-{
- m_dataRvaBase = dataBase;
- m_rdataRvaBase = rdataBase;
- m_encMode = TRUE;
-}
-
//-----------------------------------------------------------------------------
// These 2 write functions must be implemented here so that they're in the same
// .obj file as whoever creates the FILE struct. We can't pass a FILE struct
@@ -1276,8 +1264,6 @@ HRESULT PEWriter::linkSortSections(entry * entries,
// - empty sections receive no PE section
//
- bool ExeOrDll = isExeOrDll(m_ntHeaders);
-
entry *e = entries;
for (PEWriterSection **cur = getSectStart(); cur < getSectCur(); cur++) {
@@ -1294,13 +1280,6 @@ HRESULT PEWriter::linkSortSections(entry * entries,
if ((*cur)->dataLen() == 0)
continue;
- //
- // Special case: omit "text0" from obj's
- //
-
- if (!ExeOrDll && strcmp((*cur)->m_name, ".text0") == 0)
- continue;
-
e->name = (*cur)->m_name;
//
@@ -1571,8 +1550,6 @@ HRESULT PEWriter::link() {
// Assign base addresses to all sections, and layout & merge PE sections
//
- bool ExeOrDll = isExeOrDll(m_ntHeaders);
-
//
// Collate by name & sort by index
//
@@ -1605,17 +1582,7 @@ HRESULT PEWriter::link() {
// Figure out what file alignment to use.
//
- unsigned RoundUpVal;
-
- if (ExeOrDll)
- {
- RoundUpVal = 0x0200;
- }
- else
- {
- // Don't bother padding for objs
- RoundUpVal = 4;
- }
+ unsigned RoundUpVal = 0x0200;
m_ntHeaders->OptionalHeader.FileAlignment = VAL32(RoundUpVal);
}
@@ -1624,15 +1591,8 @@ HRESULT PEWriter::link() {
// Now, assign a section header & location to each section
//
- if (ExeOrDll)
- {
- iUniqueSections++; // One more for .reloc
- filePos = sizeof(IMAGE_DOS_HEADER)+sizeof(x86StubPgm) + m_ntHeadersSize;
- }
- else
- {
- filePos = sizeof(IMAGE_FILE_HEADER);
- }
+ iUniqueSections++; // One more for .reloc
+ filePos = sizeof(IMAGE_DOS_HEADER)+sizeof(x86StubPgm) + m_ntHeadersSize;
m_ntHeaders->FileHeader.NumberOfSections = VAL16(iUniqueSections);
@@ -1677,412 +1637,184 @@ class SectionRVASorter : public CQuickSort<PEWriterSection*>
}
};
-#ifdef _PREFAST_
-#pragma warning(push)
-#pragma warning(disable:21000) // Suppress PREFast warning about overly large function
-#endif
HRESULT PEWriter::fixup(CeeGenTokenMapper *pMapper)
{
HRESULT hr;
- bool ExeOrDll = isExeOrDll(m_ntHeaders);
const unsigned RoundUpVal = VAL32(m_ntHeaders->OptionalHeader.FileAlignment);
- if(ExeOrDll)
- {
- //
- // Apply manual relocation for entry point field
- //
-
- PESection *textSection;
- IfFailRet(getSectionCreate(".text", 0, &textSection));
+ //
+ // Apply manual relocation for entry point field
+ //
- if (m_ntHeaders->OptionalHeader.AddressOfEntryPoint != VAL32(0))
- m_ntHeaders->OptionalHeader.AddressOfEntryPoint = VAL32(VAL32(m_ntHeaders->OptionalHeader.AddressOfEntryPoint) + textSection->m_baseRVA);
+ PESection *textSection;
+ IfFailRet(getSectionCreate(".text", 0, &textSection));
- //
- // Apply normal relocs
- //
+ if (m_ntHeaders->OptionalHeader.AddressOfEntryPoint != VAL32(0))
+ m_ntHeaders->OptionalHeader.AddressOfEntryPoint = VAL32(VAL32(m_ntHeaders->OptionalHeader.AddressOfEntryPoint) + textSection->m_baseRVA);
- IfFailRet(getSectionCreate(".reloc", sdReadOnly | IMAGE_SCN_MEM_DISCARDABLE,
- (PESection **) &reloc));
- reloc->m_baseRVA = virtualPos;
- reloc->m_filePos = filePos;
- reloc->m_header = headersEnd++;
- strcpy_s((char *)reloc->m_header->Name, sizeof(reloc->m_header->Name),
- ".reloc");
- reloc->m_header->Characteristics = VAL32(reloc->m_flags);
- reloc->m_header->VirtualAddress = VAL32(virtualPos);
- reloc->m_header->PointerToRawData = VAL32(filePos);
+ //
+ // Apply normal relocs
+ //
-#ifdef _DEBUG
- if (m_encMode)
- printf("Applying relocs for .rdata section with RVA %x\n", m_rdataRvaBase);
-#endif
+ IfFailRet(getSectionCreate(".reloc", sdReadOnly | IMAGE_SCN_MEM_DISCARDABLE,
+ (PESection **) &reloc));
+ reloc->m_baseRVA = virtualPos;
+ reloc->m_filePos = filePos;
+ reloc->m_header = headersEnd++;
+ strcpy_s((char *)reloc->m_header->Name, sizeof(reloc->m_header->Name),
+ ".reloc");
+ reloc->m_header->Characteristics = VAL32(reloc->m_flags);
+ reloc->m_header->VirtualAddress = VAL32(virtualPos);
+ reloc->m_header->PointerToRawData = VAL32(filePos);
- //
- // Sort the sections by RVA
- //
+ //
+ // Sort the sections by RVA
+ //
- CQuickArray<PEWriterSection *> sections;
+ CQuickArray<PEWriterSection *> sections;
- SIZE_T count = getSectCur() - getSectStart();
- IfFailRet(sections.ReSizeNoThrow(count));
- UINT i = 0;
- PEWriterSection **cur;
- for(cur = getSectStart(); cur < getSectCur(); cur++, i++)
- sections[i] = *cur;
+ SIZE_T count = getSectCur() - getSectStart();
+ IfFailRet(sections.ReSizeNoThrow(count));
+ UINT i = 0;
+ PEWriterSection **cur;
+ for(cur = getSectStart(); cur < getSectCur(); cur++, i++)
+ sections[i] = *cur;
- SectionRVASorter sorter(sections.Ptr(), sections.Size());
+ SectionRVASorter sorter(sections.Ptr(), sections.Size());
- sorter.Sort();
+ sorter.Sort();
- PERelocSection relocSection(reloc);
+ PERelocSection relocSection(reloc);
- cur = sections.Ptr();
- PEWriterSection **curEnd = cur + sections.Size();
- while (cur < curEnd)
- {
- IfFailRet((*cur)->applyRelocs(m_ntHeaders,
- &relocSection,
- pMapper,
- m_dataRvaBase,
- m_rdataRvaBase,
- m_codeRvaBase));
- cur++;
- }
+ cur = sections.Ptr();
+ PEWriterSection **curEnd = cur + sections.Size();
+ while (cur < curEnd)
+ {
+ IfFailRet((*cur)->applyRelocs(m_ntHeaders,
+ &relocSection,
+ pMapper,
+ m_dataRvaBase,
+ m_rdataRvaBase,
+ m_codeRvaBase));
+ cur++;
+ }
- relocSection.Finish(isPE32());
- reloc->m_header->Misc.VirtualSize = VAL32(reloc->dataLen());
+ relocSection.Finish(isPE32());
+ reloc->m_header->Misc.VirtualSize = VAL32(reloc->dataLen());
- // Strip the reloc section if the flag is set
- if (m_ntHeaders->FileHeader.Characteristics & VAL16(IMAGE_FILE_RELOCS_STRIPPED))
- {
- reloc->m_header->Misc.VirtualSize = VAL32(0);
- }
+ // Strip the reloc section if the flag is set
+ if (m_ntHeaders->FileHeader.Characteristics & VAL16(IMAGE_FILE_RELOCS_STRIPPED))
+ {
+ reloc->m_header->Misc.VirtualSize = VAL32(0);
+ }
- reloc->m_header->SizeOfRawData = VAL32(roundUp(VAL32(reloc->m_header->Misc.VirtualSize), RoundUpVal));
- reloc->m_filePad = padLen(VAL32(reloc->m_header->Misc.VirtualSize), RoundUpVal);
- filePos += VAL32(reloc->m_header->SizeOfRawData);
- virtualPos += roundUp(VAL32(reloc->m_header->Misc.VirtualSize),
- VAL32(m_ntHeaders->OptionalHeader.SectionAlignment));
+ reloc->m_header->SizeOfRawData = VAL32(roundUp(VAL32(reloc->m_header->Misc.VirtualSize), RoundUpVal));
+ reloc->m_filePad = padLen(VAL32(reloc->m_header->Misc.VirtualSize), RoundUpVal);
+ filePos += VAL32(reloc->m_header->SizeOfRawData);
+ virtualPos += roundUp(VAL32(reloc->m_header->Misc.VirtualSize),
+ VAL32(m_ntHeaders->OptionalHeader.SectionAlignment));
- if (reloc->m_header->Misc.VirtualSize == VAL32(0))
+ if (reloc->m_header->Misc.VirtualSize == VAL32(0))
+ {
+ //
+ // Omit reloc section from section list. (It will
+ // still be there but the loader won't see it - this
+ // only works because we've allocated it as the last
+ // section.)
+ //
+ m_ntHeaders->FileHeader.NumberOfSections = VAL16(VAL16(m_ntHeaders->FileHeader.NumberOfSections) - 1);
+ }
+ else
+ {
+ IMAGE_DATA_DIRECTORY * pRelocDataDirectory;
+ //
+ // Put reloc address in header
+ //
+ if (isPE32())
{
- //
- // Omit reloc section from section list. (It will
- // still be there but the loader won't see it - this
- // only works because we've allocated it as the last
- // section.)
- //
- m_ntHeaders->FileHeader.NumberOfSections = VAL16(VAL16(m_ntHeaders->FileHeader.NumberOfSections) - 1);
+ pRelocDataDirectory = &(ntHeaders32()->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC]);
}
else
{
- IMAGE_DATA_DIRECTORY * pRelocDataDirectory;
- //
- // Put reloc address in header
- //
+ pRelocDataDirectory = &(ntHeaders64()->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC]);
+ }
+
+ pRelocDataDirectory->VirtualAddress = reloc->m_header->VirtualAddress;
+ pRelocDataDirectory->Size = reloc->m_header->Misc.VirtualSize;
+ }
+
+ // compute ntHeader fields that depend on the sizes of other things
+ for(IMAGE_SECTION_HEADER *h = headersEnd-1; h >= headers; h--) { // go backwards, so first entry takes precedence
+ if (h->Characteristics & VAL32(IMAGE_SCN_CNT_CODE)) {
+ m_ntHeaders->OptionalHeader.BaseOfCode = h->VirtualAddress;
+ m_ntHeaders->OptionalHeader.SizeOfCode =
+ VAL32(VAL32(m_ntHeaders->OptionalHeader.SizeOfCode) + VAL32(h->SizeOfRawData));
+ }
+ if (h->Characteristics & VAL32(IMAGE_SCN_CNT_INITIALIZED_DATA)) {
if (isPE32())
{
- pRelocDataDirectory = &(ntHeaders32()->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC]);
+ ntHeaders32()->OptionalHeader.BaseOfData = h->VirtualAddress;
}
- else
- {
- pRelocDataDirectory = &(ntHeaders64()->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC]);
- }
-
- pRelocDataDirectory->VirtualAddress = reloc->m_header->VirtualAddress;
- pRelocDataDirectory->Size = reloc->m_header->Misc.VirtualSize;
+ m_ntHeaders->OptionalHeader.SizeOfInitializedData =
+ VAL32(VAL32(m_ntHeaders->OptionalHeader.SizeOfInitializedData) + VAL32(h->SizeOfRawData));
}
-
- // compute ntHeader fields that depend on the sizes of other things
- for(IMAGE_SECTION_HEADER *h = headersEnd-1; h >= headers; h--) { // go backwards, so first entry takes precedence
- if (h->Characteristics & VAL32(IMAGE_SCN_CNT_CODE)) {
- m_ntHeaders->OptionalHeader.BaseOfCode = h->VirtualAddress;
- m_ntHeaders->OptionalHeader.SizeOfCode =
- VAL32(VAL32(m_ntHeaders->OptionalHeader.SizeOfCode) + VAL32(h->SizeOfRawData));
- }
- if (h->Characteristics & VAL32(IMAGE_SCN_CNT_INITIALIZED_DATA)) {
- if (isPE32())
- {
- ntHeaders32()->OptionalHeader.BaseOfData = h->VirtualAddress;
- }
- m_ntHeaders->OptionalHeader.SizeOfInitializedData =
- VAL32(VAL32(m_ntHeaders->OptionalHeader.SizeOfInitializedData) + VAL32(h->SizeOfRawData));
- }
- if (h->Characteristics & VAL32(IMAGE_SCN_CNT_UNINITIALIZED_DATA)) {
- m_ntHeaders->OptionalHeader.SizeOfUninitializedData =
- VAL32(VAL32(m_ntHeaders->OptionalHeader.SizeOfUninitializedData) + VAL32(h->SizeOfRawData));
- }
+ if (h->Characteristics & VAL32(IMAGE_SCN_CNT_UNINITIALIZED_DATA)) {
+ m_ntHeaders->OptionalHeader.SizeOfUninitializedData =
+ VAL32(VAL32(m_ntHeaders->OptionalHeader.SizeOfUninitializedData) + VAL32(h->SizeOfRawData));
}
+ }
- int index;
- IMAGE_DATA_DIRECTORY * pCurDataDirectory;
+ int index;
+ IMAGE_DATA_DIRECTORY * pCurDataDirectory;
- // go backwards, so first entry takes precedence
- for(cur = getSectCur()-1; getSectStart() <= cur; --cur)
- {
- index = (*cur)->getDirEntry();
+ // go backwards, so first entry takes precedence
+ for(cur = getSectCur()-1; getSectStart() <= cur; --cur)
+ {
+ index = (*cur)->getDirEntry();
- // Is this a valid directory entry
- if (index > 0)
+ // Is this a valid directory entry
+ if (index > 0)
+ {
+ if (isPE32())
{
- if (isPE32())
- {
- _ASSERTE((unsigned)(index) < VAL32(ntHeaders32()->OptionalHeader.NumberOfRvaAndSizes));
+ _ASSERTE((unsigned)(index) < VAL32(ntHeaders32()->OptionalHeader.NumberOfRvaAndSizes));
- pCurDataDirectory = &(ntHeaders32()->OptionalHeader.DataDirectory[index]);
- }
- else
- {
- _ASSERTE((unsigned)(index) < VAL32(ntHeaders64()->OptionalHeader.NumberOfRvaAndSizes));
-
- pCurDataDirectory = &(ntHeaders64()->OptionalHeader.DataDirectory[index]);
- }
-
- pCurDataDirectory->VirtualAddress = VAL32((*cur)->m_baseRVA);
- pCurDataDirectory->Size = VAL32((*cur)->dataLen());
+ pCurDataDirectory = &(ntHeaders32()->OptionalHeader.DataDirectory[index]);
}
- }
-
- // handle the directory entries specified using the file.
- for (index=0; index < cEntries; index++)
- {
- if (pEntries[index].section)
+ else
{
- PEWriterSection *section = pEntries[index].section;
- _ASSERTE(pEntries[index].offset < section->dataLen());
-
- if (isPE32())
- pCurDataDirectory = &(ntHeaders32()->OptionalHeader.DataDirectory[index]);
- else
- pCurDataDirectory = &(ntHeaders64()->OptionalHeader.DataDirectory[index]);
+ _ASSERTE((unsigned)(index) < VAL32(ntHeaders64()->OptionalHeader.NumberOfRvaAndSizes));
- pCurDataDirectory->VirtualAddress = VAL32(section->m_baseRVA + pEntries[index].offset);
- pCurDataDirectory->Size = VAL32(pEntries[index].size);
+ pCurDataDirectory = &(ntHeaders64()->OptionalHeader.DataDirectory[index]);
}
+
+ pCurDataDirectory->VirtualAddress = VAL32((*cur)->m_baseRVA);
+ pCurDataDirectory->Size = VAL32((*cur)->dataLen());
}
+ }
- m_ntHeaders->OptionalHeader.SizeOfImage = VAL32(virtualPos);
- } // end if(ExeOrDll)
- else //i.e., if OBJ
+ // handle the directory entries specified using the file.
+ for (index=0; index < cEntries; index++)
{
- //
- // Clean up note:
- // I've cleaned up the executable linking path, but the .obj linking
- // is still a bit strange, what with a "extra" reloc & strtab sections
- // which are created after the linking step and get treated specially.
- //
- reloc = new (nothrow) PEWriterSection(".reloc",
- sdReadOnly | IMAGE_SCN_MEM_DISCARDABLE, 0x4000, 0);
- if(reloc == NULL) return E_OUTOFMEMORY;
- strtab = new (nothrow) PEWriterSection(".strtab",
- sdReadOnly | IMAGE_SCN_MEM_DISCARDABLE, 0x4000, 0); //string table (if any)
- if(strtab == NULL) return E_OUTOFMEMORY;
-
- DWORD* TokInSymbolTable = new (nothrow) DWORD[16386];
- if (TokInSymbolTable == NULL) return E_OUTOFMEMORY;
-
- m_ntHeaders->FileHeader.SizeOfOptionalHeader = 0;
- //For each section set VirtualAddress to 0
- PEWriterSection **cur;
- for(cur = getSectStart(); cur < getSectCur(); cur++)
+ if (pEntries[index].section)
{
- IMAGE_SECTION_HEADER* header = (*cur)->m_header;
- header->VirtualAddress = VAL32(0);
- }
- // Go over section relocations and build the Symbol Table, use .reloc section as buffer:
- DWORD tk=0, rva=0, NumberOfSymbols=0;
- BOOL ToRelocTable = FALSE;
- IMAGE_SYMBOL is;
- IMAGE_RELOCATION ir;
- ULONG StrTableLen = 4; //size itself only
- char* szSymbolName = NULL;
- char* pch;
-
- PESection *textSection;
- getSectionCreate(".text", 0, &textSection);
-
- for(PESectionReloc* rcur = textSection->m_relocStart; rcur < textSection->m_relocCur; rcur++)
- {
- switch((int)rcur->type)
- {
- case 0x7FFA: // Ptr to symbol name
-#ifdef HOST_64BIT
- _ASSERTE(!"this is probably broken!!");
-#endif // HOST_64BIT
- szSymbolName = (char*)(UINT_PTR)(rcur->offset);
- break;
+ PEWriterSection *section = pEntries[index].section;
+ _ASSERTE(pEntries[index].offset < section->dataLen());
- case 0x7FFC: // Ptr to file name
- TokInSymbolTable[NumberOfSymbols++] = 0;
- memset(&is,0,sizeof(IMAGE_SYMBOL));
- memcpy(is.N.ShortName,".file\0\0\0",8);
- is.Value = 0;
- is.SectionNumber = VAL16(IMAGE_SYM_DEBUG);
- is.Type = VAL16(IMAGE_SYM_DTYPE_NULL);
- is.StorageClass = IMAGE_SYM_CLASS_FILE;
- is.NumberOfAuxSymbols = 1;
- if((pch = reloc->getBlock(sizeof(IMAGE_SYMBOL))))
- memcpy(pch,&is,sizeof(IMAGE_SYMBOL));
- else return E_OUTOFMEMORY;
- TokInSymbolTable[NumberOfSymbols++] = 0;
- memset(&is,0,sizeof(IMAGE_SYMBOL));
-#ifdef HOST_64BIT
- _ASSERTE(!"this is probably broken!!");
-#endif // HOST_64BIT
- strcpy_s((char*)&is,sizeof(is),(char*)(UINT_PTR)(rcur->offset));
- if((pch = reloc->getBlock(sizeof(IMAGE_SYMBOL))))
- memcpy(pch,&is,sizeof(IMAGE_SYMBOL));
- else return E_OUTOFMEMORY;
-#ifdef HOST_64BIT
- _ASSERTE(!"this is probably broken!!");
-#endif // HOST_64BIT
- delete (char*)(UINT_PTR)(rcur->offset);
- ToRelocTable = FALSE;
- tk = 0;
- szSymbolName = NULL;
- break;
-
- case 0x7FFB: // compid value
- TokInSymbolTable[NumberOfSymbols++] = 0;
- memset(&is,0,sizeof(IMAGE_SYMBOL));
- memcpy(is.N.ShortName,"@comp.id",8);
- is.Value = VAL32(rcur->offset);
- is.SectionNumber = VAL16(IMAGE_SYM_ABSOLUTE);
- is.Type = VAL16(IMAGE_SYM_DTYPE_NULL);
- is.StorageClass = IMAGE_SYM_CLASS_STATIC;
- is.NumberOfAuxSymbols = 0;
- if((pch = reloc->getBlock(sizeof(IMAGE_SYMBOL))))
- memcpy(pch,&is,sizeof(IMAGE_SYMBOL));
- else return E_OUTOFMEMORY;
- ToRelocTable = FALSE;
- tk = 0;
- szSymbolName = NULL;
- break;
-
- case 0x7FFF: // Token value, def
- tk = rcur->offset;
- ToRelocTable = FALSE;
- break;
-
- case 0x7FFE: //Token value, ref
- tk = rcur->offset;
- ToRelocTable = TRUE;
- break;
-
- case 0x7FFD: //RVA value
- rva = rcur->offset;
- if(tk)
- {
- // Add to SymbolTable
- DWORD i;
- for(i = 0; (i < NumberOfSymbols)&&(tk != TokInSymbolTable[i]); i++);
- if(i == NumberOfSymbols)
- {
- if(szSymbolName && *szSymbolName) // Add "extern" symbol and string table entry
- {
- TokInSymbolTable[NumberOfSymbols++] = 0;
- memset(&is,0,sizeof(IMAGE_SYMBOL));
- i++; // so reloc record (if generated) points to COM token symbol
- is.N.Name.Long = VAL32(StrTableLen);
- is.SectionNumber = VAL16(1); //textSection is the first one
- is.StorageClass = IMAGE_SYM_CLASS_EXTERNAL;
- is.NumberOfAuxSymbols = 0;
- is.Value = VAL32(rva);
- if(TypeFromToken(tk) == mdtMethodDef)
- {
- is.Type = VAL16(0x20); //IMAGE_SYM_DTYPE_FUNCTION;
- }
- if((pch = reloc->getBlock(sizeof(IMAGE_SYMBOL))))
- memcpy(pch,&is,sizeof(IMAGE_SYMBOL));
- else return E_OUTOFMEMORY;
- DWORD l = (DWORD)(strlen(szSymbolName)+1); // don't forget zero terminator!
- if((pch = reloc->getBlock(1)))
- memcpy(pch,szSymbolName,1);
- else return E_OUTOFMEMORY;
- delete szSymbolName;
- StrTableLen += l;
- }
- TokInSymbolTable[NumberOfSymbols++] = tk;
- memset(&is,0,sizeof(IMAGE_SYMBOL));
- sprintf_s((char*)is.N.ShortName,sizeof(is.N.ShortName),"%08X",tk);
- is.SectionNumber = VAL16(1); //textSection is the first one
- is.StorageClass = 0x6B; //IMAGE_SYM_CLASS_COM_TOKEN;
- is.Value = VAL32(rva);
- if(TypeFromToken(tk) == mdtMethodDef)
- {
- is.Type = VAL16(0x20); //IMAGE_SYM_DTYPE_FUNCTION;
- //is.NumberOfAuxSymbols = 1;
- }
- if((pch = reloc->getBlock(sizeof(IMAGE_SYMBOL))))
- memcpy(pch,&is,sizeof(IMAGE_SYMBOL));
- else return E_OUTOFMEMORY;
- if(is.NumberOfAuxSymbols == 1)
- {
- BYTE dummy[sizeof(IMAGE_SYMBOL)];
- memset(dummy,0,sizeof(IMAGE_SYMBOL));
- dummy[0] = dummy[2] = 1;
- if((pch = reloc->getBlock(sizeof(IMAGE_SYMBOL))))
- memcpy(pch,dummy,sizeof(IMAGE_SYMBOL));
- else return E_OUTOFMEMORY;
- TokInSymbolTable[NumberOfSymbols++] = 0;
- }
- }
- if(ToRelocTable)
- {
- IMAGE_SECTION_HEADER* phdr = textSection->m_header;
- // Add to reloc table
- ir.VirtualAddress = VAL32(rva);
- ir.SymbolTableIndex = VAL32(i);
- ir.Type = VAL16(IMAGE_REL_I386_SECREL);
- if(phdr->PointerToRelocations == 0)
- phdr->PointerToRelocations = VAL32(VAL32(phdr->PointerToRawData) + VAL32(phdr->SizeOfRawData));
- phdr->NumberOfRelocations = VAL32(VAL32(phdr->NumberOfRelocations) + 1);
- if((pch = reloc->getBlock(sizeof(IMAGE_RELOCATION))))
- memcpy(pch,&is,sizeof(IMAGE_RELOCATION));
- else return E_OUTOFMEMORY;
- }
- }
- ToRelocTable = FALSE;
- tk = 0;
- szSymbolName = NULL;
- break;
-
- default:
- break;
- } //end switch(cur->type)
- } // end for all relocs
- // Add string table counter:
- if((pch = reloc->getBlock(sizeof(ULONG))))
- memcpy(pch,&StrTableLen,sizeof(ULONG));
- else return E_OUTOFMEMORY;
- reloc->m_header->Misc.VirtualSize = VAL32(reloc->dataLen());
- if(NumberOfSymbols)
- {
- // recompute the actual sizes and positions of all the sections
- filePos = roundUp(VAL16(m_ntHeaders->FileHeader.NumberOfSections) * sizeof(IMAGE_SECTION_HEADER)+
- sizeof(IMAGE_FILE_HEADER), RoundUpVal);
- for(cur = getSectStart(); cur < getSectCur(); cur++)
- {
- IMAGE_SECTION_HEADER* header = (*cur)->m_header;
- header->Misc.VirtualSize = VAL32((*cur)->dataLen());
- header->VirtualAddress = VAL32(0);
- header->SizeOfRawData = VAL32(roundUp(VAL32(header->Misc.VirtualSize), RoundUpVal));
- header->PointerToRawData = VAL32(filePos);
+ if (isPE32())
+ pCurDataDirectory = &(ntHeaders32()->OptionalHeader.DataDirectory[index]);
+ else
+ pCurDataDirectory = &(ntHeaders64()->OptionalHeader.DataDirectory[index]);
- filePos += VAL32(header->SizeOfRawData);
- }
- m_ntHeaders->FileHeader.Machine = VAL16(0xC0EE); //COM+ EE
- m_ntHeaders->FileHeader.PointerToSymbolTable = VAL32(filePos);
- m_ntHeaders->FileHeader.NumberOfSymbols = VAL32(NumberOfSymbols);
- filePos += roundUp(VAL32(reloc->m_header->Misc.VirtualSize)+strtab->dataLen(),RoundUpVal);
+ pCurDataDirectory->VirtualAddress = VAL32(section->m_baseRVA + pEntries[index].offset);
+ pCurDataDirectory->Size = VAL32(pEntries[index].size);
}
- delete[] TokInSymbolTable;
- } //end if OBJ
+ }
+
+ m_ntHeaders->OptionalHeader.SizeOfImage = VAL32(virtualPos);
- const unsigned headerOffset = (unsigned) (ExeOrDll ? sizeof(IMAGE_DOS_HEADER) + sizeof(x86StubPgm) : 0);
+ const unsigned headerOffset = (unsigned)sizeof(IMAGE_DOS_HEADER) + sizeof(x86StubPgm);
memset(&m_dosHeader, 0, sizeof(IMAGE_DOS_HEADER));
m_dosHeader.e_magic = VAL16(IMAGE_DOS_SIGNATURE);
@@ -2096,9 +1828,6 @@ HRESULT PEWriter::fixup(CeeGenTokenMapper *pMapper)
return(S_OK); // SUCCESS
}
-#ifdef _PREFAST_
-#pragma warning(pop)
-#endif
HRESULT PEWriter::Open(__in LPCWSTR fileName)
{
@@ -2188,25 +1917,15 @@ HRESULT PEWriter::write(__in LPCWSTR fileName) {
HRESULT hr;
- bool ExeOrDll;
unsigned RoundUpVal;
- ExeOrDll = isExeOrDll(m_ntHeaders);
RoundUpVal = VAL32(m_ntHeaders->OptionalHeader.FileAlignment);
IfFailGo(Open(fileName));
- if(ExeOrDll)
- {
- // write the PE headers
- IfFailGo(Write(&m_dosHeader, sizeof(IMAGE_DOS_HEADER)));
- IfFailGo(Write(x86StubPgm, sizeof(x86StubPgm)));
- IfFailGo(Write(m_ntHeaders, m_ntHeadersSize));
- }
- else
- {
- // write the object file header
- IfFailGo(Write(&(m_ntHeaders->FileHeader),sizeof(IMAGE_FILE_HEADER)));
- }
+ // write the PE headers
+ IfFailGo(Write(&m_dosHeader, sizeof(IMAGE_DOS_HEADER)));
+ IfFailGo(Write(x86StubPgm, sizeof(x86StubPgm)));
+ IfFailGo(Write(m_ntHeaders, m_ntHeadersSize));
IfFailGo(Write(headers, (int)(sizeof(IMAGE_SECTION_HEADER)*(headersEnd-headers))));
@@ -2221,18 +1940,6 @@ HRESULT PEWriter::write(__in LPCWSTR fileName) {
}
}
- // writes for an object file
- if (!ExeOrDll)
- {
- // write the relocs section (Does nothing if relocs section is empty)
- IfFailGo(reloc->write(m_file));
- //write string table (obj only, empty for exe or dll)
- IfFailGo(strtab->write(m_file));
- int lena = padLen(VAL32(reloc->m_header->Misc.VirtualSize)+strtab->dataLen(), RoundUpVal);
- if (lena > 0)
- IfFailGo(Write(NULL, lena));
- }
-
return Close();
ErrExit:
@@ -2243,19 +1950,11 @@ HRESULT PEWriter::write(__in LPCWSTR fileName) {
HRESULT PEWriter::write(void ** ppImage)
{
- bool ExeOrDll = isExeOrDll(m_ntHeaders);
const unsigned RoundUpVal = VAL32(m_ntHeaders->OptionalHeader.FileAlignment);
char *pad = (char *) _alloca(RoundUpVal);
memset(pad, 0, RoundUpVal);
size_t lSize = filePos;
- if (!ExeOrDll)
- {
- lSize += reloc->dataLen();
- lSize += strtab->dataLen();
- lSize += padLen(VAL32(reloc->m_header->Misc.VirtualSize)+strtab->dataLen(),
- RoundUpVal);
- }
// allocate the block we are handing back to the caller
void * pImage = (void *) ::CoTaskMemAlloc(lSize);
@@ -2269,17 +1968,10 @@ HRESULT PEWriter::write(void ** ppImage)
char *pCur = (char *)pImage;
- if(ExeOrDll)
- {
- // PE Header
- COPY_AND_ADVANCE(pCur, &m_dosHeader, sizeof(IMAGE_DOS_HEADER));
- COPY_AND_ADVANCE(pCur, x86StubPgm, sizeof(x86StubPgm));
- COPY_AND_ADVANCE(pCur, m_ntHeaders, m_ntHeadersSize);
- }
- else
- {
- COPY_AND_ADVANCE(pCur, &(m_ntHeaders->FileHeader), sizeof(IMAGE_FILE_HEADER));
- }
+ // PE Header
+ COPY_AND_ADVANCE(pCur, &m_dosHeader, sizeof(IMAGE_DOS_HEADER));
+ COPY_AND_ADVANCE(pCur, x86StubPgm, sizeof(x86StubPgm));
+ COPY_AND_ADVANCE(pCur, m_ntHeaders, m_ntHeadersSize);
COPY_AND_ADVANCE(pCur, headers, sizeof(*headers)*(headersEnd - headers));
@@ -2295,26 +1987,6 @@ HRESULT PEWriter::write(void ** ppImage)
}
}
- // !!! Need to jump to the right place...
-
- if (!ExeOrDll)
- {
- // now the relocs (exe, dll) or symbol table (obj) (if any)
- // write the relocs section (Does nothing if relocs section is empty)
- reloc->writeMem((void **)&pCur);
-
- //write string table (obj only, empty for exe or dll)
- strtab->writeMem((void **)&pCur);
-
- // final pad
- size_t len = padLen(VAL32(reloc->m_header->Misc.VirtualSize)+strtab->dataLen(), RoundUpVal);
- if (len > 0)
- {
- // WARNING: macro - must enclose in curly braces
- COPY_AND_ADVANCE(pCur, pad, len);
- }
- }
-
// make sure we wrote the exact numbmer of bytes expected
_ASSERTE(lSize == (size_t) (pCur - (char *)pImage));
diff --git a/src/coreclr/dlls/mscorpe/pewriter.h b/src/coreclr/dlls/mscorpe/pewriter.h
index ee56061bede..21817b1d5ef 100644
--- a/src/coreclr/dlls/mscorpe/pewriter.h
+++ b/src/coreclr/dlls/mscorpe/pewriter.h
@@ -85,8 +85,6 @@ public:
size_t getImageBase();
- void setEnCRvaBase(ULONG dataBase, ULONG rdataBase);
-
HRESULT getFileTimeStamp(DWORD *pTimeStamp);
IMAGE_NT_HEADERS32* ntHeaders32() { return (IMAGE_NT_HEADERS32*) m_ntHeaders; }
@@ -113,7 +111,6 @@ public:
private:
DWORD m_ilRVA;
- BOOL m_encMode;
ULONG m_dataRvaBase;
ULONG m_rdataRvaBase;
ULONG m_codeRvaBase;
diff --git a/src/coreclr/ilasm/assem.cpp b/src/coreclr/ilasm/assem.cpp
index 286447b4ec1..aa94f557972 100644
--- a/src/coreclr/ilasm/assem.cpp
+++ b/src/coreclr/ilasm/assem.cpp
@@ -253,16 +253,6 @@ void Assembler::SetDLL(BOOL IsDll)
m_fDLL = IsDll;
}
-void Assembler::SetOBJ(BOOL IsObj)
-{
- HRESULT OK;
- OK = m_pCeeFileGen->SetObjSwitch(m_pCeeFile, IsObj);
- _ASSERTE(SUCCEEDED(OK));
-
- m_fOBJ = IsObj;
-}
-
-
void Assembler::ResetArgNameList()
{
if(m_firstArgName) delArgNameList(m_firstArgName);
diff --git a/src/coreclr/ilasm/assembler.cpp b/src/coreclr/ilasm/assembler.cpp
index f28552f00fe..48f9487656f 100644
--- a/src/coreclr/ilasm/assembler.cpp
+++ b/src/coreclr/ilasm/assembler.cpp
@@ -1799,7 +1799,6 @@ mdToken Assembler::MakeMemberRef(mdToken cr, __in __nullterminated char* pszMemb
mr = 0;
}
}
- //if(m_fOBJ) m_pCurMethod->m_TRDList.PUSH(new TokenRelocDescr(m_CurPC,mr));
delete [] pszMemberName;
delete sig;
}
@@ -2068,7 +2067,6 @@ void Assembler::EmitInstrStringLiteral(Instr* instr, BinStr* literal, BOOL Conve
else
{
EmitOpcode(instr);
- if(m_fOBJ) m_pCurMethod->m_TRDList.PUSH(new TokenRelocDescr(m_CurPC,tk));
EmitBytes((BYTE *)&tk,sizeof(mdToken));
}
@@ -2092,7 +2090,6 @@ void Assembler::EmitInstrSig(Instr* instr, BinStr* sig)
else
{
EmitOpcode(instr);
- if(m_fOBJ) m_pCurMethod->m_TRDList.PUSH(new TokenRelocDescr(m_CurPC,MetadataToken));
EmitBytes((BYTE *)&MetadataToken, sizeof(mdSignature));
}
delete sig;
diff --git a/src/coreclr/ilasm/assembler.h b/src/coreclr/ilasm/assembler.h
index 3edc1b40702..b7ec921f579 100644
--- a/src/coreclr/ilasm/assembler.h
+++ b/src/coreclr/ilasm/assembler.h
@@ -803,7 +803,6 @@ public:
//MethodList m_MethodList;
BOOL m_fDLL;
- BOOL m_fOBJ;
BOOL m_fEntryPointPresent;
BOOL m_fHaveFieldsWithRvas;
BOOL m_fFoldCode;
@@ -870,7 +869,6 @@ public:
state_t CheckLocalTypeConsistancy(int instr, unsigned arg);
state_t AddGlobalLabel(__in __nullterminated char *pszName, HCEESECTION section);
void SetDLL(BOOL);
- void SetOBJ(BOOL);
void ResetForNextMethod();
void ResetLineNumbers();
void SetStdMapping(BOOL val = TRUE) { m_fStdMapping = val; };
diff --git a/src/coreclr/ilasm/main.cpp b/src/coreclr/ilasm/main.cpp
index 230d0df089a..17fa665db3d 100644
--- a/src/coreclr/ilasm/main.cpp
+++ b/src/coreclr/ilasm/main.cpp
@@ -105,7 +105,7 @@ WCHAR wzPdbFilename[MAX_FILENAME_LENGTH];
extern "C" int _cdecl wmain(int argc, __in WCHAR **argv)
{
int i, NumFiles = 0, NumDeltaFiles = 0;
- bool IsDLL = false, IsOBJ = false;
+ bool IsDLL = false;
Assembler *pAsm;
MappedFileStream *pIn;
AsmParse *pParser;
@@ -281,13 +281,7 @@ extern "C" int _cdecl wmain(int argc, __in WCHAR **argv)
}
else if (!_stricmp(szOpt, "DLL"))
{
- IsDLL = true; IsOBJ = false;
- }
- else if (!_stricmp(szOpt, "OBJ"))
- {
- //IsOBJ = true; IsDLL = false;
- printf("Option /OBJECT is not supported.\n");
- goto ErrorExit;
+ IsDLL = true;
}
else if (!_stricmp(szOpt, "ERR"))
{
@@ -608,7 +602,7 @@ extern "C" int _cdecl wmain(int argc, __in WCHAR **argv)
}
}
while(j);
- wcscat_s(wzOutputFilename, MAX_FILENAME_LENGTH,(IsDLL ? W(".dll") : (IsOBJ ? W(".obj") : W(".exe"))));
+ wcscat_s(wzOutputFilename, MAX_FILENAME_LENGTH,(IsDLL ? W(".dll") : W(".exe")));
}
if (pAsm->m_fGeneratePDB)
{
@@ -644,7 +638,6 @@ extern "C" int _cdecl wmain(int argc, __in WCHAR **argv)
}
pAsm->SetDLL(IsDLL);
- pAsm->SetOBJ(IsOBJ);
wcscpy_s(pAsm->m_wzOutputFileName,MAX_FILENAME_LENGTH,wzOutputFilename);
strcpy_s(pAsm->m_szSourceFileName,MAX_FILENAME_LENGTH*3+1,szInputFilename);
@@ -665,7 +658,7 @@ extern "C" int _cdecl wmain(int argc, __in WCHAR **argv)
{
pParser->msg("\nAssembling '%s' ", szInputFilename);
if(!pAsm->m_fAutoInheritFromObject) pParser->msg(" NOAUTOINHERIT");
- pParser->msg(IsDLL ? " to DLL" : (IsOBJ? " to OBJ" : " to EXE"));
+ pParser->msg(IsDLL ? " to DLL" : " to EXE");
//======================================================================
if (pAsm->m_fStdMapping == FALSE)
pParser->msg(", with REFERENCE mapping");
@@ -732,7 +725,7 @@ extern "C" int _cdecl wmain(int argc, __in WCHAR **argv)
if(exitval == 0) // Write the output file
{
if(bClock) cw.cFilegenEnd = GetTickCount();
- if(pAsm->m_fReportProgress) pParser->msg("Writing %s file\n", pAsm->m_fOBJ ? "COFF" : "PE");
+ if(pAsm->m_fReportProgress) pParser->msg("Writing PE file\n");
// Generate the file
if (FAILED(hr = pAsm->m_pCeeFileGen->GenerateCeeFile(pAsm->m_pCeeFile)))
{
diff --git a/src/coreclr/inc/ceefilegenwriter.h b/src/coreclr/inc/ceefilegenwriter.h
index ab55bdc6a91..94391857c97 100644
--- a/src/coreclr/inc/ceefilegenwriter.h
+++ b/src/coreclr/inc/ceefilegenwriter.h
@@ -33,13 +33,9 @@ class CeeFileGenWriter : public CCeeGen
LPWSTR m_outputFileName;
LPWSTR m_resourceFileName;
- LPWSTR m_libraryName;
- GUID m_libraryGuid;
bool m_dllSwitch;
ULONG m_iatOffset;
- DWORD m_dwMacroDefinitionRVA;
- DWORD m_dwMacroDefinitionSize;
DWORD m_dwManifestRVA;
DWORD m_dwManifestSize;
@@ -70,15 +66,6 @@ class CeeFileGenWriter : public CCeeGen
int m_iDataOffsetIAT;
char *m_iDataIAT;
-#ifdef EMIT_FIXUPS
-
- CeeSection * m_sectionFixups;
- IMAGE_DEBUG_DIRECTORY * m_pDebugDir;
- bool m_fFixupsUpdated;
- bool m_fEmitFixups;
-
-#endif
-
HRESULT allocateIAT();
public:
// Create with one of these two methods, not operator new
@@ -116,9 +103,6 @@ public:
HRESULT setResourceFileName(__in LPWSTR resourceFileName);
LPWSTR getResourceFileName();
- HRESULT setLibraryName(__in LPWSTR libraryName);
- LPWSTR getLibraryName();
-
HRESULT setDirectoryEntry(CeeSection &section, ULONG entry, ULONG size, ULONG offset=0);
HRESULT computeSectionOffset(CeeSection &section, __in char *ptr,
unsigned *offset);
@@ -128,21 +112,12 @@ public:
HRESULT getFileTimeStamp(DWORD *pTimeStamp);
-//<TODO>@FUTURE: this entry point is only here so that down level clients of this interface
-// can import the method by name in the exports table using the original name.
-// These things really ought to be exported through a v-table so there is no
-// name mangling issues. It would make the export table much smaller as well.</TODO>
- HRESULT emitLibraryName(IMetaDataEmit *emitter);
HRESULT setLibraryGuid(__in LPWSTR libraryGuid);
HRESULT setDllSwitch(bool dllSwitch);
bool getDllSwitch();
- HRESULT setObjSwitch(bool objSwitch);
- bool getObjSwitch();
- HRESULT EmitMacroDefinitions(void *pData, DWORD cData);
HRESULT setManifestEntry(ULONG size, ULONG offset);
HRESULT setStrongNameEntry(ULONG size, ULONG offset);
- HRESULT setEnCRvaBase(ULONG dataBase, ULONG rdataBase);
HRESULT setVTableEntry(ULONG size, ULONG offset);
HRESULT setVTableEntry64(ULONG size, void* ptr);
@@ -157,20 +132,6 @@ protected:
HRESULT MapTokens(CeeGenTokenMapper *pMapper, IMetaDataImport *pImport);
HRESULT MapTokensForMethod(CeeGenTokenMapper *pMapper,BYTE *pCode, LPCWSTR szMethodName);
-
-#ifdef EMIT_FIXUPS
-
- HRESULT InitFixupSection();
- HRESULT UpdateFixups();
- HRESULT setEmitFixups();
-
-#ifdef TEST_EMIT_FIXUPS
- HRESULT TestEmitFixups();
-#endif
-
-public:
- HRESULT addFixup(CeeSection& secFixups, unsigned offset, CeeSectionRelocType reloc, CeeSection * relativeTo = NULL, CeeSectionRelocExtra *extra = 0);
-#endif
};
@@ -188,9 +149,7 @@ inline LPWSTR CeeFileGenWriter::getResourceFileName() {
}
inline HRESULT CeeFileGenWriter::setDllSwitch(bool dllSwitch) {
- if((m_dllSwitch = dllSwitch))
- m_objSwitch = FALSE;
-
+ m_dllSwitch = dllSwitch;
return S_OK;
}
@@ -198,21 +157,6 @@ inline bool CeeFileGenWriter::getDllSwitch() {
return m_dllSwitch;
}
-inline HRESULT CeeFileGenWriter::setObjSwitch(bool objSwitch) {
- if((m_objSwitch = objSwitch))
- m_dllSwitch = FALSE;
-
- return S_OK;
-}
-
-inline bool CeeFileGenWriter::getObjSwitch() {
- return m_objSwitch;
-}
-
-inline LPWSTR CeeFileGenWriter::getLibraryName() {
- return m_libraryName;
-}
-
inline mdMethodDef CeeFileGenWriter::getEntryPoint() {
return m_entryPoint;
}
diff --git a/src/coreclr/inc/ceegen.h b/src/coreclr/inc/ceegen.h
index f770797d5e5..66dfa6421e6 100644
--- a/src/coreclr/inc/ceegen.h
+++ b/src/coreclr/inc/ceegen.h
@@ -25,7 +25,7 @@ typedef DWORD StringRef;
This is a description of the current implementation of these types for generating
CLR modules.
- ICeeGen - interface to generate in-memory CLR module.
+ ICeeGenInternal - interface to generate in-memory CLR module.
CCeeGen - implementation of ICeeGen. Currently it uses both CeeSections
as well as PESections (inside PESectionMan), and maintains a
@@ -45,7 +45,7 @@ typedef DWORD StringRef;
etc which are not implemented. These are left over from before
+----------------------------+
- | ICeeGen |
+ | ICeeGenInternal |
| |
| COM-style version of |
| ICeeFileGen. HCEEFILE is |
@@ -174,16 +174,14 @@ class CeeSection {
// Only handles in memory stuff
// Base class for CeeFileGenWriter (which actually generates PEFiles)
-class CCeeGen : public ICeeGen, ICeeGenInternal {
+class CCeeGen : public ICeeGenInternal {
LONG m_cRefs;
- BOOL m_encMode;
protected:
short m_textIdx; // m_sections[] index for the .text section
short m_metaIdx; // m_sections[] index for metadata (.text, or .cormeta for obj files)
short m_corHdrIdx; // m_sections[] index for the COM+ header (.text0)
short m_stringIdx; // m_sections[] index for strings (.text, or .rdata for EnC)
short m_ilIdx; // m_sections[] index for IL (.text)
- bool m_objSwitch;
CeeGenTokenMapper *m_pTokenMap;
BOOLEAN m_fTokenMapSupported; // temporary to support both models
@@ -202,8 +200,6 @@ class CCeeGen : public ICeeGen, ICeeGenInternal {
HRESULT addSection(CeeSection *section, short *sectionIdx);
- HRESULT setEnCMode();
-
// Init process: Call static CreateNewInstance() , not operator new
protected:
HRESULT Init();
@@ -217,7 +213,7 @@ class CCeeGen : public ICeeGen, ICeeGenInternal {
virtual HRESULT Cleanup();
- // ICeeGen interfaces
+ // ICeeGenInternal interfaces
ULONG STDMETHODCALLTYPE AddRef();
ULONG STDMETHODCALLTYPE Release();
@@ -274,13 +270,7 @@ class CCeeGen : public ICeeGen, ICeeGenInternal {
ULONG align=1,
void **ppBytes=0);
- STDMETHODIMP TruncateSection (
- HCEESECTION section,
- ULONG len);
-
- STDMETHODIMP GenerateCeeMemoryImage (void **ppImage);
-
- STDMETHODIMP ComputePointer (
+ STDMETHODIMP ComputePointer (
HCEESECTION section,
ULONG RVA, // [IN] RVA for method to return
UCHAR **lpBuffer); // [OUT] Returned buffer
@@ -325,15 +315,6 @@ class CCeeGen : public ICeeGen, ICeeGenInternal {
//Section data will be appended onto any information already in the section.
//This is done to support the DynamicIL -> PersistedIL transform.
virtual HRESULT cloneInstance(CCeeGen *destination);
-
-#ifdef EMIT_FIXUPS
-public:
- virtual HRESULT addFixup(CeeSection& sectionSource, unsigned offset, CeeSectionRelocType reloc, CeeSection * sectionTarget = NULL, CeeSectionRelocExtra *extra = 0) {
- LIMITED_METHOD_CONTRACT;
-
- return(E_NOTIMPL);
- }
-#endif
};
// ***** CeeSection inline methods
diff --git a/src/coreclr/inc/cor.h b/src/coreclr/inc/cor.h
index 413000b920e..a77a9f10777 100644
--- a/src/coreclr/inc/cor.h
+++ b/src/coreclr/inc/cor.h
@@ -122,8 +122,6 @@ interface IMetaDataImport;
interface IMetaDataAssemblyEmit;
interface IMetaDataAssemblyImport;
interface IMetaDataEmit;
-interface ICeeGen;
-
typedef UNALIGNED void const *UVCP_CONSTANT;
@@ -1458,202 +1456,6 @@ DECLARE_INTERFACE_(IMetaDataDispenserEx, IMetaDataDispenser)
};
-//*****************************************************************************
-//*****************************************************************************
-//
-// Registration declarations. Will be replace by Services' Registration
-// implementation.
-//
-//*****************************************************************************
-//*****************************************************************************
-// Various flags for use in installing a module or a composite
-typedef enum
-{
- regNoCopy = 0x00000001, // Don't copy files into destination
- regConfig = 0x00000002, // Is a configuration
- regHasRefs = 0x00000004 // Has class references
-} CorRegFlags;
-
-typedef GUID CVID;
-
-typedef struct {
- short Major;
- short Minor;
- short Sub;
- short Build;
-} CVStruct;
-
-
-//*****************************************************************************
-//*****************************************************************************
-//
-// CeeGen interfaces for generating in-memory Common Language Runtime files
-//
-//*****************************************************************************
-//*****************************************************************************
-
-typedef void *HCEESECTION;
-
-typedef enum {
- sdNone = 0,
- sdReadOnly = IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_INITIALIZED_DATA,
- sdReadWrite = sdReadOnly | IMAGE_SCN_MEM_WRITE,
- sdExecute = IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE
-} CeeSectionAttr;
-
-//
-// Relocation types.
-//
-
-typedef enum {
- // generate only a section-relative reloc, nothing into .reloc section
- srRelocAbsolute,
-
- // generate a .reloc for a pointer sized location,
- // This is transformed into BASED_HIGHLOW or BASED_DIR64 based on the platform
- srRelocHighLow = 3,
-
- // generate a .reloc for the top 16-bits of a 32 bit number, where the
- // bottom 16 bits are included in the next word in the .reloc table
- srRelocHighAdj, // Never Used
-
- // generate a token map relocation, nothing into .reloc section
- srRelocMapToken,
-
- // relative address fixup
- srRelocRelative,
-
- // Generate only a section-relative reloc, nothing into .reloc
- // section. This reloc is relative to the file position of the
- // section, not the section's virtual address.
- srRelocFilePos,
-
- // code relative address fixup
- srRelocCodeRelative,
-
- // generate a .reloc for a 64 bit address in an ia64 movl instruction
- srRelocIA64Imm64,
-
- // generate a .reloc for a 64 bit address
- srRelocDir64,
-
- // generate a .reloc for a 25-bit PC relative address in an ia64 br.call instruction
- srRelocIA64PcRel25,
-
- // generate a .reloc for a 64-bit PC relative address in an ia64 brl.call instruction
- srRelocIA64PcRel64,
-
- // generate a 30-bit section-relative reloc, used for tagged pointer values
- srRelocAbsoluteTagged,
-
-
- // A sentinel value to help ensure any additions to this enum are reflected
- // in PEWriter.cpp's RelocName array.
- srRelocSentinel,
-
- // Flags that can be used with the above reloc types
-
- // do not emit base reloc
- srNoBaseReloc = 0x4000,
-
- // pre-fixup contents of memory are ptr rather than a section offset
- srRelocPtr = 0x8000,
-
- // legal enums which include the Ptr flag
- srRelocAbsolutePtr = srRelocPtr + srRelocAbsolute,
- srRelocHighLowPtr = srRelocPtr + srRelocHighLow,
- srRelocRelativePtr = srRelocPtr + srRelocRelative,
- srRelocIA64Imm64Ptr = srRelocPtr + srRelocIA64Imm64,
- srRelocDir64Ptr = srRelocPtr + srRelocDir64,
-
-} CeeSectionRelocType;
-
-typedef union {
- USHORT highAdj;
-} CeeSectionRelocExtra;
-
-//-------------------------------------
-//--- ICeeGen
-//-------------------------------------
-// {7ED1BDFF-8E36-11d2-9C56-00A0C9B7CC45}
-EXTERN_GUID(IID_ICeeGen, 0x7ed1bdff, 0x8e36, 0x11d2, 0x9c, 0x56, 0x0, 0xa0, 0xc9, 0xb7, 0xcc, 0x45);
-
-DECLARE_INTERFACE_(ICeeGen, IUnknown)
-{
- STDMETHOD (EmitString) (
- _In_
- LPWSTR lpString, // [IN] String to emit
- ULONG *RVA) PURE; // [OUT] RVA for string emitted string
-
- STDMETHOD (GetString) (
- ULONG RVA, // [IN] RVA for string to return
- _Out_opt_
- LPWSTR *lpString) PURE; // [OUT] Returned string
-
- STDMETHOD (AllocateMethodBuffer) (
- ULONG cchBuffer, // [IN] Length of buffer to create
- UCHAR **lpBuffer, // [OUT] Returned buffer
- ULONG *RVA) PURE; // [OUT] RVA for method
-
- STDMETHOD (GetMethodBuffer) (
- ULONG RVA, // [IN] RVA for method to return
- UCHAR **lpBuffer) PURE; // [OUT] Returned buffer
-
- STDMETHOD (GetIMapTokenIface) (
- IUnknown **pIMapToken) PURE;
-
- STDMETHOD (GenerateCeeFile) () PURE;
-
- STDMETHOD (GetIlSection) (
- HCEESECTION *section) PURE;
-
- STDMETHOD (GetStringSection) (
- HCEESECTION *section) PURE;
-
- STDMETHOD (AddSectionReloc) (
- HCEESECTION section,
- ULONG offset,
- HCEESECTION relativeTo,
- CeeSectionRelocType relocType) PURE;
-
- // use these only if you have special section requirements not handled
- // by other APIs
- STDMETHOD (GetSectionCreate) (
- const char *name,
- DWORD flags,
- HCEESECTION *section) PURE;
-
- STDMETHOD (GetSectionDataLen) (
- HCEESECTION section,
- ULONG *dataLen) PURE;
-
- STDMETHOD (GetSectionBlock) (
- HCEESECTION section,
- ULONG len,
- ULONG align=1,
- void **ppBytes=0) PURE;
-
- STDMETHOD (TruncateSection) (
- HCEESECTION section,
- ULONG len) PURE;
-
- STDMETHOD (GenerateCeeMemoryImage) (
- void **ppImage) PURE;
-
- STDMETHOD (ComputePointer) (
- HCEESECTION section,
- ULONG RVA, // [IN] RVA for method to return
- UCHAR **lpBuffer) PURE; // [OUT] Returned buffer
-
-};
-
-//*****************************************************************************
-//*****************************************************************************
-//
-// End of CeeGen declarations.
-//
-//*****************************************************************************
-
//**********************************************************************
//**********************************************************************
//--- IMetaDataTables
diff --git a/src/coreclr/inc/corpriv.h b/src/coreclr/inc/corpriv.h
index 49056335cc7..495440c93fc 100644
--- a/src/coreclr/inc/corpriv.h
+++ b/src/coreclr/inc/corpriv.h
@@ -294,17 +294,162 @@ typedef enum CorOpenFlagsInternal
#define COR_MODULE_CLASS "<Module>"
#define COR_WMODULE_CLASS W("<Module>")
+//*****************************************************************************
+//*****************************************************************************
+//
+// CeeGen interfaces for generating in-memory Common Language Runtime files
+//
+//*****************************************************************************
+//*****************************************************************************
+
+typedef void* HCEESECTION;
+
+typedef enum {
+ sdNone = 0,
+ sdReadOnly = IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_INITIALIZED_DATA,
+ sdReadWrite = sdReadOnly | IMAGE_SCN_MEM_WRITE,
+ sdExecute = IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE
+} CeeSectionAttr;
+
+//
+// Relocation types.
+//
+
+typedef enum {
+ // generate only a section-relative reloc, nothing into .reloc section
+ srRelocAbsolute,
+
+ // generate a .reloc for a pointer sized location,
+ // This is transformed into BASED_HIGHLOW or BASED_DIR64 based on the platform
+ srRelocHighLow = 3,
+
+ // generate a .reloc for the top 16-bits of a 32 bit number, where the
+ // bottom 16 bits are included in the next word in the .reloc table
+ srRelocHighAdj, // Never Used
+
+ // generate a token map relocation, nothing into .reloc section
+ srRelocMapToken,
+
+ // relative address fixup
+ srRelocRelative,
+
+ // Generate only a section-relative reloc, nothing into .reloc
+ // section. This reloc is relative to the file position of the
+ // section, not the section's virtual address.
+ srRelocFilePos,
+
+ // code relative address fixup
+ srRelocCodeRelative,
+
+ // generate a .reloc for a 64 bit address in an ia64 movl instruction
+ srRelocIA64Imm64,
+
+ // generate a .reloc for a 64 bit address
+ srRelocDir64,
+
+ // generate a .reloc for a 25-bit PC relative address in an ia64 br.call instruction
+ srRelocIA64PcRel25,
+
+ // generate a .reloc for a 64-bit PC relative address in an ia64 brl.call instruction
+ srRelocIA64PcRel64,
+
+ // generate a 30-bit section-relative reloc, used for tagged pointer values
+ srRelocAbsoluteTagged,
+
+
+ // A sentinel value to help ensure any additions to this enum are reflected
+ // in PEWriter.cpp's RelocName array.
+ srRelocSentinel,
+
+ // Flags that can be used with the above reloc types
+
+ // do not emit base reloc
+ srNoBaseReloc = 0x4000,
+
+ // pre-fixup contents of memory are ptr rather than a section offset
+ srRelocPtr = 0x8000,
+
+ // legal enums which include the Ptr flag
+ srRelocAbsolutePtr = srRelocPtr + srRelocAbsolute,
+ srRelocHighLowPtr = srRelocPtr + srRelocHighLow,
+ srRelocRelativePtr = srRelocPtr + srRelocRelative,
+ srRelocIA64Imm64Ptr = srRelocPtr + srRelocIA64Imm64,
+ srRelocDir64Ptr = srRelocPtr + srRelocDir64,
+
+} CeeSectionRelocType;
+
+typedef union {
+ USHORT highAdj;
+} CeeSectionRelocExtra;
+
//-------------------------------------
//--- ICeeGenInternal
//-------------------------------------
-// {9fd3c7af-dc4e-4b9b-be22-9cf8cc577489}
-EXTERN_GUID(IID_ICeeGenInternal, 0x9fd3c7af, 0xdc4e, 0x4b9b, 0xbe, 0x22, 0x9c, 0xf8, 0xcc, 0x57, 0x74, 0x89);
-
+// {8C26FC02-BE39-476D-B835-E17EDD120246}
+EXTERN_GUID(IID_ICeeGenInternal, 0x8c26fc02, 0xbe39, 0x476d, 0xb8, 0x35, 0xe1, 0x7e, 0xdd, 0x12, 0x2, 0x46);
#undef INTERFACE
#define INTERFACE ICeeGenInternal
DECLARE_INTERFACE_(ICeeGenInternal, IUnknown)
{
- STDMETHOD (SetInitialGrowth) (DWORD growth) PURE;
+ STDMETHOD(EmitString) (
+ _In_
+ LPWSTR lpString, // [IN] String to emit
+ ULONG * RVA) PURE; // [OUT] RVA for string emitted string
+
+ STDMETHOD(GetString) (
+ ULONG RVA, // [IN] RVA for string to return
+ _Out_opt_
+ LPWSTR * lpString) PURE; // [OUT] Returned string
+
+ STDMETHOD(AllocateMethodBuffer) (
+ ULONG cchBuffer, // [IN] Length of buffer to create
+ UCHAR * *lpBuffer, // [OUT] Returned buffer
+ ULONG * RVA) PURE; // [OUT] RVA for method
+
+ STDMETHOD(GetMethodBuffer) (
+ ULONG RVA, // [IN] RVA for method to return
+ UCHAR * *lpBuffer) PURE; // [OUT] Returned buffer
+
+ STDMETHOD(GetIMapTokenIface) (
+ IUnknown * *pIMapToken) PURE;
+
+ STDMETHOD(GenerateCeeFile) () PURE;
+
+ STDMETHOD(GetIlSection) (
+ HCEESECTION * section) PURE;
+
+ STDMETHOD(GetStringSection) (
+ HCEESECTION * section) PURE;
+
+ STDMETHOD(AddSectionReloc) (
+ HCEESECTION section,
+ ULONG offset,
+ HCEESECTION relativeTo,
+ CeeSectionRelocType relocType) PURE;
+
+ // use these only if you have special section requirements not handled
+ // by other APIs
+ STDMETHOD(GetSectionCreate) (
+ const char* name,
+ DWORD flags,
+ HCEESECTION * section) PURE;
+
+ STDMETHOD(GetSectionDataLen) (
+ HCEESECTION section,
+ ULONG * dataLen) PURE;
+
+ STDMETHOD(GetSectionBlock) (
+ HCEESECTION section,
+ ULONG len,
+ ULONG align = 1,
+ void** ppBytes = 0) PURE;
+
+ STDMETHOD(ComputePointer) (
+ HCEESECTION section,
+ ULONG RVA, // [IN] RVA for method to return
+ UCHAR * *lpBuffer) PURE; // [OUT] Returned buffer
+
+ STDMETHOD(SetInitialGrowth) (DWORD growth) PURE;
};
//
diff --git a/src/coreclr/inc/iceefilegen.h b/src/coreclr/inc/iceefilegen.h
index cb4b5ef868e..f0fb5b091c9 100644
--- a/src/coreclr/inc/iceefilegen.h
+++ b/src/coreclr/inc/iceefilegen.h
@@ -32,7 +32,7 @@
pEmit = IMetaDataEmit object; // Get a metadata emitter
GetSectionBlock(...);, AddSectionReloc(...); ... // Get blocks, write non-metadata information, and add necessary relocation
EmitMetaDataEx(pEmit); // Write out the metadata
- GenerateCeeFile(...); // Write out the file. Implicitly calls LinkCeeFile and FixupCeeFile
+ GenerateCeeFile(...); // Write out the file.
DestroyICeeFileGen(...); // Release the ICeeFileGen object
*/
@@ -42,7 +42,7 @@
#define _ICEEFILEGEN_H_
#include <ole2.h>
-#include "cor.h"
+#include "corpriv.h"
class ICeeFileGen;
@@ -58,7 +58,6 @@ typedef HRESULT (__stdcall * PFN_DestroyICeeFileGen)(ICeeFileGen ** ceeFileGen);
#define ICEE_CREATE_FILE_PE64 0x00000002 // Create a PE+ (64-bit)
#define ICEE_CREATE_FILE_CORMAIN_STUB 0x00000004 // add a mscoree!_Cor___Main call stub
#define ICEE_CREATE_FILE_STRIP_RELOCS 0x00000008 // strip the .reloc section
-#define ICEE_CREATE_FILE_EMIT_FIXUPS 0x00000010 // emit fixups for use by Vulcan
#define ICEE_CREATE_MACHINE_MASK 0x0000FF00 // space for up to 256 machine targets (note: most users just do a bit check, not an equality compare after applying the mask)
#define ICEE_CREATE_MACHINE_ILLEGAL 0x00000000 // An illegal machine name
@@ -79,12 +78,7 @@ class ICeeFileGen {
virtual HRESULT CreateCeeFile(HCEEFILE *ceeFile); // call this to instantiate a file handle
- // <TODO>@FUTURE: remove this function. We no longer support mdScope.</TODO>
- virtual HRESULT EmitMetaData (HCEEFILE ceeFile, IMetaDataEmit *emitter, mdScope scope);
- virtual HRESULT EmitLibraryName (HCEEFILE ceeFile, IMetaDataEmit *emitter, mdScope scope);
- virtual HRESULT EmitMethod (); // <TODO>@FUTURE: remove</TODO>
virtual HRESULT GetMethodRVA (HCEEFILE ceeFile, ULONG codeOffset, ULONG *codeRVA);
- virtual HRESULT EmitSignature (); // <TODO>@FUTURE: remove</TODO>
virtual HRESULT EmitString (HCEEFILE ceeFile,_In_ LPWSTR strValue, ULONG *strRef);
virtual HRESULT GenerateCeeFile (HCEEFILE ceeFile);
@@ -102,24 +96,9 @@ class ICeeFileGen {
virtual HRESULT SetSubsystem(HCEEFILE ceeFile, DWORD subsystem, DWORD major, DWORD minor);
- virtual HRESULT SetEntryClassToken (); //<TODO>@FUTURE: remove</TODO>
- virtual HRESULT GetEntryClassToken (); //<TODO>@FUTURE: remove</TODO>
-
- virtual HRESULT SetEntryPointDescr (); //<TODO>@FUTURE: remove</TODO>
- virtual HRESULT GetEntryPointDescr (); //<TODO>@FUTURE: remove</TODO>
-
- virtual HRESULT SetEntryPointFlags (); //<TODO>@FUTURE: remove</TODO>
- virtual HRESULT GetEntryPointFlags (); //<TODO>@FUTURE: remove</TODO>
-
virtual HRESULT SetDllSwitch (HCEEFILE ceeFile, BOOL dllSwitch);
virtual HRESULT GetDllSwitch (HCEEFILE ceeFile, BOOL *dllSwitch);
- virtual HRESULT SetLibraryName (HCEEFILE ceeFile, _In_ LPWSTR LibraryName);
- _Return_type_success_( return == S_OK )
- virtual HRESULT GetLibraryName (HCEEFILE ceeFile, _Out_ LPWSTR *LibraryName);
-
- virtual HRESULT SetLibraryGuid (HCEEFILE ceeFile, _In_ LPWSTR LibraryGuid);
-
virtual HRESULT DestroyCeeFile(HCEEFILE *ceeFile); // call this to delete a file handle
virtual HRESULT GetSectionCreate (HCEEFILE ceeFile, const char *name, DWORD flags, HCEESECTION *section);
@@ -128,18 +107,8 @@ class ICeeFileGen {
virtual HRESULT GetSectionDataLen (HCEESECTION section, ULONG *dataLen);
virtual HRESULT GetSectionBlock (HCEESECTION section, ULONG len, ULONG align=1, void **ppBytes=0);
- virtual HRESULT TruncateSection (HCEESECTION section, ULONG len);
virtual HRESULT AddSectionReloc (HCEESECTION section, ULONG offset, HCEESECTION relativeTo, CeeSectionRelocType relocType);
- // deprecated: use SetDirectoryEntry instead
- virtual HRESULT SetSectionDirectoryEntry (HCEESECTION section, ULONG num);
-
- virtual HRESULT CreateSig (); //<TODO>@FUTURE: Remove</TODO>
- virtual HRESULT AddSigArg (); //<TODO>@FUTURE: Remove</TODO>
- virtual HRESULT SetSigReturnType (); //<TODO>@FUTURE: Remove</TODO>
- virtual HRESULT SetSigCallingConvention (); //<TODO>@FUTURE: Remove</TODO>
- virtual HRESULT DeleteSig (); //<TODO>@FUTURE: Remove</TODO>
-
virtual HRESULT SetEntryPoint (HCEEFILE ceeFile, mdMethodDef method);
virtual HRESULT GetEntryPoint (HCEEFILE ceeFile, mdMethodDef *method);
@@ -154,18 +123,13 @@ class ICeeFileGen {
// Use EmitMetaDataAt() for more control
virtual HRESULT EmitMetaDataEx (HCEEFILE ceeFile, IMetaDataEmit *emitter);
- virtual HRESULT EmitLibraryNameEx (HCEEFILE ceeFile, IMetaDataEmit *emitter);
virtual HRESULT GetIMapTokenIfaceEx(HCEEFILE ceeFile, IMetaDataEmit *emitter, IUnknown **pIMapToken);
- virtual HRESULT EmitMacroDefinitions(HCEEFILE ceeFile, void *pData, DWORD cData);
virtual HRESULT CreateCeeFileFromICeeGen(
- ICeeGen *pFromICeeGen, HCEEFILE *ceeFile, DWORD createFlags = ICEE_CREATE_FILE_PURE_IL); // call this to instantiate a file handle
+ ICeeGenInternal *pFromICeeGen, HCEEFILE *ceeFile, DWORD createFlags = ICEE_CREATE_FILE_PURE_IL); // call this to instantiate a file handle
virtual HRESULT SetManifestEntry(HCEEFILE ceeFile, ULONG size, ULONG offset);
- virtual HRESULT SetEnCRVABase(HCEEFILE ceeFile, ULONG dataBase, ULONG rdataBase);
- virtual HRESULT GenerateCeeMemoryImage (HCEEFILE ceeFile, void **ppImage);
-
virtual HRESULT ComputeSectionOffset(HCEESECTION section, _In_ char *ptr,
unsigned *offset);
@@ -178,9 +142,6 @@ class ICeeFileGen {
// Layout the sections and assign their starting addresses
virtual HRESULT LinkCeeFile (HCEEFILE ceeFile);
- // Apply relocations to any pointer data. Also generate PE base relocs
- virtual HRESULT FixupCeeFile (HCEEFILE ceeFile);
-
// Base RVA assinged to the section. To be called only after LinkCeeFile()
virtual HRESULT GetSectionRVA (HCEESECTION section, ULONG *rva);
@@ -188,8 +149,6 @@ class ICeeFileGen {
virtual HRESULT ComputeSectionPointer(HCEESECTION section, ULONG offset,
_Out_ char **ptr);
- virtual HRESULT SetObjSwitch (HCEEFILE ceeFile, BOOL objSwitch);
- virtual HRESULT GetObjSwitch (HCEEFILE ceeFile, BOOL *objSwitch);
virtual HRESULT SetVTableEntry(HCEEFILE ceeFile, ULONG size, ULONG offset);
// See the end of interface for another overload of AetVTableEntry
diff --git a/src/coreclr/md/ceefilegen/cceegen.cpp b/src/coreclr/md/ceefilegen/cceegen.cpp
index 707d45ab83f..adddcddb206 100644
--- a/src/coreclr/md/ceefilegen/cceegen.cpp
+++ b/src/coreclr/md/ceefilegen/cceegen.cpp
@@ -18,7 +18,7 @@
HRESULT STDMETHODCALLTYPE CreateICeeGen(REFIID riid, void **pCeeGen)
{
- if (riid != IID_ICeeGen)
+ if (riid != IID_ICeeGenInternal)
return E_NOTIMPL;
if (!pCeeGen)
return E_POINTER;
@@ -67,9 +67,7 @@ STDMETHODIMP CCeeGen::QueryInterface(REFIID riid, void** ppv)
*ppv = NULL;
if (riid == IID_IUnknown)
- *ppv = (IUnknown*)(ICeeGen*)this;
- else if (riid == IID_ICeeGen)
- *ppv = (ICeeGen*)this;
+ *ppv = (IUnknown*)(ICeeGenInternal*)this;
else if (riid == IID_ICeeGenInternal)
*ppv = (ICeeGenInternal*)this;
if (*ppv == NULL)
@@ -226,16 +224,6 @@ STDMETHODIMP CCeeGen::GenerateCeeFile ()
return E_NOTIMPL;
}
-STDMETHODIMP CCeeGen::GenerateCeeMemoryImage (void **)
-{
- BEGIN_ENTRYPOINT_NOTHROW;
-
- _ASSERTE(!"E_NOTIMPL");
- END_ENTRYPOINT_NOTHROW;
-
- return E_NOTIMPL;
-}
-
STDMETHODIMP CCeeGen::GetIlSection (
HCEESECTION *section)
{
@@ -315,18 +303,6 @@ STDMETHODIMP CCeeGen::GetSectionBlock (
return NOERROR;
}
-STDMETHODIMP CCeeGen::TruncateSection (
- HCEESECTION section,
- ULONG len)
-{
- BEGIN_ENTRYPOINT_NOTHROW;
-
- _ASSERTE(!"E_NOTIMPL");
- END_ENTRYPOINT_NOTHROW;
- return E_NOTIMPL;
-}
-
-
CCeeGen::CCeeGen() // protected ctor
{
@@ -386,7 +362,6 @@ HRESULT CCeeGen::Init() // not-virtual, protected
m_metaIdx = m_textIdx; // meta section is actually in .text
m_ilIdx = m_textIdx; // il section is actually in .text
m_corHdrIdx = -1;
- m_encMode = FALSE;
LExit:
if (FAILED(hr)) {
@@ -396,24 +371,6 @@ LExit:
return hr;
}
-// For EnC mode, generate strings into .rdata section rather than .text section
-HRESULT CCeeGen::setEnCMode()
-{
- PESection *section = NULL;
- HRESULT hr = m_peSectionMan->getSectionCreate(".rdata", sdExecute, &section);
- TESTANDRETURNHR(hr);
- CeeSection *ceeSection = new CeeSectionString(*this, *section);
- if (ceeSection == NULL)
- {
- return E_OUTOFMEMORY;
- }
- hr = addSection(ceeSection, &m_stringIdx);
- if (SUCCEEDED(hr))
- m_encMode = TRUE;
- return hr;
-}
-
-
HRESULT CCeeGen::cloneInstance(CCeeGen *destination) { //public, virtual
_ASSERTE(destination);
@@ -493,7 +450,7 @@ HRESULT CCeeGen::getSectionCreate (const char *name, DWORD flags, CeeSection **s
name = ".text";
else if (strcmp(name, ".meta") == 0)
name = ".text";
- else if (strcmp(name, ".rdata") == 0 && !m_encMode)
+ else if (strcmp(name, ".rdata") == 0)
name = ".text";
for (int i=0; i<m_numSections; i++) {
if (strcmp((const char *)m_sections[i]->name(), name) == 0) {
@@ -549,12 +506,6 @@ HRESULT CCeeGen::emitMetaData(IMetaDataEmit *emitter, CeeSection* section, DWORD
IfFailGoto((HRESULT)(metaStream->Stat(&statStg, STATFLAG_NONAME)), Exit);
buffLen = statStg.cbSize.u.LowPart;
- if(m_objSwitch)
- {
- CeeSection* pSect;
- DWORD flags = IMAGE_SCN_LNK_INFO | IMAGE_SCN_LNK_REMOVE | IMAGE_SCN_ALIGN_1BYTES; // 0x00100A00
- IfFailGoto(getSectionCreate(".cormeta",flags,&pSect,&m_metaIdx), Exit);
- }
buffer = (BYTE *)section->getBlock(buffLen, sizeof(DWORD));
IfNullGoto(buffer, Exit);
offset = getMetaSection().dataLen() - buffLen;
diff --git a/src/coreclr/vm/ceeload.cpp b/src/coreclr/vm/ceeload.cpp
index 4a71037c89c..8a5ad542c5a 100644
--- a/src/coreclr/vm/ceeload.cpp
+++ b/src/coreclr/vm/ceeload.cpp
@@ -12520,7 +12520,7 @@ void ReflectionModule::Initialize(AllocMemTracker *pamTracker, LPCWSTR szName)
Module::Initialize(pamTracker);
- IfFailThrow(CreateICeeGen(IID_ICeeGen, (void **)&m_pCeeFileGen));
+ IfFailThrow(CreateICeeGen(IID_ICeeGenInternal, (void **)&m_pCeeFileGen));
// Collectible modules should try to limit the growth of their associate IL section, as common scenarios for collectible
// modules include single type modules
diff --git a/src/coreclr/vm/ceeload.h b/src/coreclr/vm/ceeload.h
index 05bb84dad4a..1f4b9b3b4ac 100644
--- a/src/coreclr/vm/ceeload.h
+++ b/src/coreclr/vm/ceeload.h
@@ -3208,7 +3208,7 @@ class ReflectionModule : public Module
HCEESECTION m_sdataSection;
protected:
- ICeeGen * m_pCeeFileGen;
+ ICeeGenInternal * m_pCeeFileGen;
private:
Assembly *m_pCreatingAssembly;
ISymUnmanagedWriter *m_pISymUnmanagedWriter;
@@ -3284,7 +3284,7 @@ public:
m_pCreatingAssembly = assembly;
}
- ICeeGen *GetCeeGen() {LIMITED_METHOD_CONTRACT; return m_pCeeFileGen; }
+ ICeeGenInternal *GetCeeGen() {LIMITED_METHOD_CONTRACT; return m_pCeeFileGen; }
RefClassWriter *GetClassWriter()
{
diff --git a/src/coreclr/vm/comdynamic.cpp b/src/coreclr/vm/comdynamic.cpp
index 892e7498624..69aae15b15f 100644
--- a/src/coreclr/vm/comdynamic.cpp
+++ b/src/coreclr/vm/comdynamic.cpp
@@ -365,7 +365,7 @@ void QCALLTYPE COMDynamicWrite::SetMethodIL(QCall::ModuleHandle pModule,
if (totalSizeSafe.IsOverflow())
COMPlusThrowOM();
UINT32 totalSize = totalSizeSafe.Value();
- ICeeGen* pGen = pRCW->GetCeeGen();
+ ICeeGenInternal* pGen = pRCW->GetCeeGen();
BYTE* buf = NULL;
ULONG methodRVA;
pGen->AllocateMethodBuffer(totalSize, &buf, &methodRVA);
diff --git a/src/coreclr/vm/commodule.cpp b/src/coreclr/vm/commodule.cpp
index e789270777f..9eb5e8ead77 100644
--- a/src/coreclr/vm/commodule.cpp
+++ b/src/coreclr/vm/commodule.cpp
@@ -622,7 +622,7 @@ void QCALLTYPE COMModule::SetFieldRVAContent(QCall::ModuleHandle pModule, INT32
RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter();
_ASSERTE(pRCW);
- ICeeGen * pGen = pRCW->GetCeeGen();
+ ICeeGenInternal * pGen = pRCW->GetCeeGen();
ReflectionModule * pReflectionModule = pModule->GetReflectionModule();
diff --git a/src/coreclr/vm/reflectclasswriter.cpp b/src/coreclr/vm/reflectclasswriter.cpp
index 40688a9d629..c8c2b94ca74 100644
--- a/src/coreclr/vm/reflectclasswriter.cpp
+++ b/src/coreclr/vm/reflectclasswriter.cpp
@@ -18,7 +18,7 @@ STDAPI GetMetaDataInternalInterfaceFromPublic(
//* constructor for RefClassWriter
//*
//******************************************************
-HRESULT RefClassWriter::Init(ICeeGen *pCeeGen, IUnknown *pUnk, LPCWSTR szName)
+HRESULT RefClassWriter::Init(ICeeGenInternal *pCeeGen, IUnknown *pUnk, LPCWSTR szName)
{
CONTRACT(HRESULT) {
NOTHROW;
diff --git a/src/coreclr/vm/reflectclasswriter.h b/src/coreclr/vm/reflectclasswriter.h
index 574eb78c8fa..98c22ca220c 100644
--- a/src/coreclr/vm/reflectclasswriter.h
+++ b/src/coreclr/vm/reflectclasswriter.h
@@ -17,7 +17,7 @@ protected:
IMetaDataEmit2* m_emitter; // Emit interface.
IMetaDataImport* m_importer; // Import interface.
IMDInternalImport* m_internalimport; // Scopeless internal import interface
- ICeeGen* m_pCeeGen;
+ ICeeGenInternal* m_pCeeGen;
ICeeFileGen* m_pCeeFileGen;
HCEEFILE m_ceeFile;
IMetaDataEmitHelper* m_pEmitHelper;
@@ -29,7 +29,7 @@ public:
LIMITED_METHOD_CONTRACT;
}
- HRESULT Init(ICeeGen *pCeeGen, IUnknown *pUnk, LPCWSTR szName);
+ HRESULT Init(ICeeGenInternal *pCeeGen, IUnknown *pUnk, LPCWSTR szName);
IMetaDataEmit2* GetEmitter() {
LIMITED_METHOD_CONTRACT;
@@ -51,7 +51,7 @@ public:
return m_internalimport;
}
- ICeeGen* GetCeeGen() {
+ ICeeGenInternal* GetCeeGen() {
LIMITED_METHOD_CONTRACT;
return m_pCeeGen;
}