Skip to content

Commit

Permalink
Delete unreachable code for emitting PE fixups and obj files (#50259)
Browse files Browse the repository at this point in the history
* Delete unrechable code for emitting PE fixups and obj files

* Fold ICeeGen into ICeeGenInternal and change IID
  • Loading branch information
jkotas authored Mar 27, 2021
1 parent 01d724c commit 67983f7
Show file tree
Hide file tree
Showing 21 changed files with 321 additions and 1,698 deletions.
600 changes: 3 additions & 597 deletions src/coreclr/dlls/mscorpe/ceefilegenwriter.cpp

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions src/coreclr/dlls/mscorpe/ceefilegenwritertokens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
209 changes: 1 addition & 208 deletions src/coreclr/dlls/mscorpe/iceefilegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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)
{
Expand Down
Loading

0 comments on commit 67983f7

Please sign in to comment.