Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete unreachable code for emitting PE fixups and obj files #50259

Merged
merged 2 commits into from
Mar 27, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
207 changes: 0 additions & 207 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 @@ -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