diff options
author | Jan Kotas <jkotas@microsoft.com> | 2021-03-27 06:02:35 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-27 06:02:35 +0300 |
commit | 67983f7bd8e415e343ce4e5148208302a7049d4b (patch) | |
tree | 092635939aac82c2b05445ded7ac01067d0883c4 /src/coreclr/dlls | |
parent | 01d724c1bd1ba9a21a307ee10f881be26f443dd8 (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/coreclr/dlls')
-rw-r--r-- | src/coreclr/dlls/mscorpe/ceefilegenwriter.cpp | 600 | ||||
-rw-r--r-- | src/coreclr/dlls/mscorpe/ceefilegenwritertokens.cpp | 5 | ||||
-rw-r--r-- | src/coreclr/dlls/mscorpe/iceefilegen.cpp | 209 | ||||
-rw-r--r-- | src/coreclr/dlls/mscorpe/pewriter.cpp | 612 | ||||
-rw-r--r-- | src/coreclr/dlls/mscorpe/pewriter.h | 3 |
5 files changed, 146 insertions, 1283 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 §ion, __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 = §ionSource; - - 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; |