Skip to content

Commit

Permalink
Remove support for emitting and loading Itanium-64 assemblies (dotnet…
Browse files Browse the repository at this point in the history
  • Loading branch information
jkoritzinsky authored and mikelle-rogers committed Dec 4, 2024
1 parent 8a356aa commit 0001147
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 156 deletions.
9 changes: 0 additions & 9 deletions src/coreclr/debug/daccess/datatargetadapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,6 @@ DataTargetAdapter::GetPlatform(
platform = CORDB_PLATFORM_POSIX_LOONGARCH64;
break;

case IMAGE_FILE_MACHINE_IA64:
_ASSERTE_MSG(false, "Not supported platform.");
return E_NOTIMPL;

case IMAGE_FILE_MACHINE_RISCV64:
ulExpectedPointerSize = 8;
platform = CORDB_PLATFORM_POSIX_RISCV64;
Expand All @@ -151,11 +147,6 @@ DataTargetAdapter::GetPlatform(
platform = CORDB_PLATFORM_WINDOWS_AMD64;
break;

case IMAGE_FILE_MACHINE_IA64:
ulExpectedPointerSize = 8;
platform = CORDB_PLATFORM_WINDOWS_IA64;
break;

case IMAGE_FILE_MACHINE_ARMNT:
ulExpectedPointerSize = 4;
platform = CORDB_PLATFORM_WINDOWS_ARM;
Expand Down
105 changes: 0 additions & 105 deletions src/coreclr/dlls/mscorpe/ceefilegenwriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,62 +117,6 @@ const BYTE DllMainAMD64Template[] =
#define DllMainAMD64TemplateSize sizeof(DllMainAMD64Template)
#define CorDllMainAMD64IATOffset 2

//*****************************************************************************
// This stub is designed for an ia64 Windows application. It will call the
// _CorExeMain function in mscoree.dll. This entry point will in turn load
// and run the IL program.
//
// jump _CorExeMain();
//
// The code jumps to the imported function _CorExeMain using the iat.
// We set the value of gp to point at the iat table entry for _CorExeMain
//*****************************************************************************

const BYTE ExeMainIA64Template[] =
{
// ld8 r9 = [gp] ;;
// ld8 r10 = [r9],8
// nop.i ;;
// ld8 gp = [r9]
// mov b6 = r10
// br.cond.sptk.few b6
//
0x0B, 0x48, 0x00, 0x02, 0x18, 0x10, 0xA0, 0x40,
0x24, 0x30, 0x28, 0x00, 0x00, 0x00, 0x04, 0x00,
0x10, 0x08, 0x00, 0x12, 0x18, 0x10, 0x60, 0x50,
0x04, 0x80, 0x03, 0x00, 0x60, 0x00, 0x80, 0x00
};

#define ExeMainIA64TemplateSize sizeof(ExeMainIA64Template)

//*****************************************************************************
// This stub is designed for an ia64 Windows application. It will call the
// _CorDllMain function in mscoree.dll with with the base entry point for
// the loaded DLL. This entry point will in turn load and run the IL program.
//
// jump _CorDllMain
//
// The code jumps to the imported function _CorExeMain using the iat.
// We set the value of gp to point at the iat table entry for _CorExeMain
//*****************************************************************************

const BYTE DllMainIA64Template[] =
{
// ld8 r9 = [gp] ;;
// ld8 r10 = [r9],8
// nop.i ;;
// ld8 gp = [r9]
// mov b6 = r10
// br.cond.sptk.few b6
//
0x0B, 0x48, 0x00, 0x02, 0x18, 0x10, 0xA0, 0x40,
0x24, 0x30, 0x28, 0x00, 0x00, 0x00, 0x04, 0x00,
0x10, 0x08, 0x00, 0x12, 0x18, 0x10, 0x60, 0x50,
0x04, 0x80, 0x03, 0x00, 0x60, 0x00, 0x80, 0x00
};

#define DllMainIA64TemplateSize sizeof(DllMainIA64Template)

// Get the Symbol entry given the head and a 0-based index
inline IMAGE_SYMBOL* GetSymbolEntry(IMAGE_SYMBOL* pHead, SIZE_T idx)
{
Expand Down Expand Up @@ -836,55 +780,6 @@ HRESULT CeeFileGenWriter::emitExeMain()
addAddrReloc(getTextSection(), exeMainBuf, entryPointOffset+CorExeMainAMD64IATOffset, m_iDataSectionIAT);
}
}
else if (getPEWriter().isIA64())
{
// Must have a PE+ PE64 file
//_ASSERTE(!getPEWriter().isPE32());

// Put the entry point code into the PE+ file
curOffset = getTextSection().dataLen();
align = 16; // instructions on ia64 must be 16-byte aligned

// The entry point address be aligned
diff = ((curOffset + align -1) & ~(align-1)) - curOffset;
if (diff)
{
char* pDiff = getTextSection().getBlock(diff);
if(NULL==pDiff) return E_OUTOFMEMORY;
memset(pDiff,0,diff);
}

unsigned entryPointOffset = getTextSection().dataLen();

if (m_dllSwitch)
{
UCHAR *dllMainBuf = (UCHAR*)getTextSection().getBlock(sizeof(DllMainIA64Template));
if (dllMainBuf==NULL) return E_OUTOFMEMORY;
memcpy(dllMainBuf, DllMainIA64Template, sizeof(DllMainIA64Template));
}
else
{
UCHAR *exeMainBuf = (UCHAR*)getTextSection().getBlock(sizeof(ExeMainIA64Template));
if (exeMainBuf==NULL) return E_OUTOFMEMORY;
memcpy(exeMainBuf, ExeMainIA64Template, sizeof(ExeMainIA64Template));
}

// Put the entry point function pointer into the PE file
unsigned entryPlabelOffset = getTextSection().dataLen();
getPEWriter().setEntryPointTextOffset(entryPlabelOffset);

UCHAR * entryPtr = (UCHAR*)getTextSection().getBlock(sizeof(ULONGLONG));
UCHAR * gpPtr = (UCHAR*)getTextSection().getBlock(sizeof(ULONGLONG));

memset(entryPtr,0,sizeof(ULONGLONG));
memset(gpPtr,0,sizeof(ULONGLONG));

setAddrReloc(entryPtr, entryPointOffset);
addAddrReloc(getTextSection(), entryPtr, entryPlabelOffset, &getTextSection());

setAddrReloc(gpPtr, m_iDataDlls[0].m_iatOffset + m_iDataOffsetIAT);
addAddrReloc(getTextSection(), gpPtr, entryPlabelOffset+8, m_iDataSectionIAT);
}
else
{
_ASSERTE(!"Unknown target machine");
Expand Down
4 changes: 0 additions & 4 deletions src/coreclr/dlls/mscorpe/pewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,10 +575,6 @@ HRESULT PEWriter::Init(PESectionMan *pFrom, DWORD createFlags)
{
m_ntHeaders->FileHeader.Machine = VAL16(IMAGE_FILE_MACHINE_I386);
}
else if ((createFlags & ICEE_CREATE_MACHINE_MASK) == ICEE_CREATE_MACHINE_IA64)
{
m_ntHeaders->FileHeader.Machine = VAL16(IMAGE_FILE_MACHINE_IA64);
}
else if ((createFlags & ICEE_CREATE_MACHINE_MASK) == ICEE_CREATE_MACHINE_AMD64)
{
m_ntHeaders->FileHeader.Machine = VAL16(IMAGE_FILE_MACHINE_AMD64);
Expand Down
3 changes: 0 additions & 3 deletions src/coreclr/dlls/mscorpe/pewriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@ class PEWriter : public PESectionMan
bool isI386() // true -> target machine is i386
{ return (m_ntHeaders->FileHeader.Machine == VAL16(IMAGE_FILE_MACHINE_I386)); }

bool isIA64() // true -> target machine is ia64
{ return (m_ntHeaders->FileHeader.Machine == VAL16(IMAGE_FILE_MACHINE_IA64)); }

bool isAMD64() // true -> target machine is ia64
{ return (m_ntHeaders->FileHeader.Machine == VAL16(IMAGE_FILE_MACHINE_AMD64)); }

Expand Down
8 changes: 2 additions & 6 deletions src/coreclr/ildasm/dasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5700,7 +5700,7 @@ void DumpHeader(IMAGE_COR20_HEADER *CORHeader, void* GUICookie)
sprintf_s(szString,SZSTRING_SIZE,"// Addr. of entry point: 0x%08x", VAL32(pOptHeader->AddressOfEntryPoint));
printLine(GUICookie,szStr);
dwAddrOfEntryPoint = VAL32(pOptHeader->AddressOfEntryPoint);
dwEntryPointSize = (VAL16(pCOFF->Machine)==IMAGE_FILE_MACHINE_IA64) ? 48 : 12;
dwEntryPointSize = 12;
sprintf_s(szString,SZSTRING_SIZE,"// Base of code: 0x%08x", VAL32(pOptHeader->BaseOfCode));
printLine(GUICookie,szStr);
sprintf_s(szString,SZSTRING_SIZE,"// Image base: 0x%016I64x", VAL64(pOptHeader->ImageBase));
Expand Down Expand Up @@ -6689,11 +6689,7 @@ void DumpEATEntries(void* GUICookie,
}
else
{
ULONGLONG ullTokRVA;
if(pNTHeader64->FileHeader.Machine == IMAGE_FILE_MACHINE_IA64)
ullTokRVA = VAL64(*((ULONGLONG*)(pCont+8)));
else
ullTokRVA = VAL64(*((ULONGLONG*)(pCont+2)));
ULONGLONG ullTokRVA = VAL64(*((ULONGLONG*)(pCont+2)));

dwTokRVA =(DWORD)(ullTokRVA - VAL64((DWORD)pOptHeader64->ImageBase));
}
Expand Down
7 changes: 3 additions & 4 deletions src/coreclr/inc/iceefilegen.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,9 @@ typedef HRESULT (__stdcall * PFN_DestroyICeeFileGen)(ICeeFileGen ** ceeFileGen);
#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
#define ICEE_CREATE_MACHINE_I386 0x00000100 // Create a IMAGE_FILE_MACHINE_I386
#define ICEE_CREATE_MACHINE_IA64 0x00000200 // Create a IMAGE_FILE_MACHINE_IA64
#define ICEE_CREATE_MACHINE_AMD64 0x00000400 // Create a IMAGE_FILE_MACHINE_AMD64
#define ICEE_CREATE_MACHINE_ARM 0x00000800 // Create a IMAGE_FILE_MACHINE_ARMNT
#define ICEE_CREATE_MACHINE_ARM64 0x00001000 // Create a IMAGE_FILE_MACHINE_ARM64
#define ICEE_CREATE_MACHINE_AMD64 0x00000200 // Create a IMAGE_FILE_MACHINE_AMD64
#define ICEE_CREATE_MACHINE_ARM 0x00000400 // Create a IMAGE_FILE_MACHINE_ARMNT
#define ICEE_CREATE_MACHINE_ARM64 0x00000800 // Create a IMAGE_FILE_MACHINE_ARM64

// Pass this to CreateCeeFileEx to create a pure IL Exe or DLL
#define ICEE_CREATE_FILE_PURE_IL ICEE_CREATE_FILE_PE32 | \
Expand Down
20 changes: 5 additions & 15 deletions src/coreclr/utilcode/pedecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1587,23 +1587,13 @@ CHECK PEDecoder::CheckILOnlyBaseRelocations() const

UINT16 *pRelocEntry = (UINT16 *) (pReloc + 1);
UINT16 *pRelocEntryEnd = (UINT16 *) ((BYTE *) pReloc + VAL32(pReloc->SizeOfBlock));
if(FindNTHeaders()->FileHeader.Machine == VAL16(IMAGE_FILE_MACHINE_IA64))
{
// Exactly 2 Reloc records, both IMAGE_REL_BASED_DIR64
CHECK(VAL32(pReloc->SizeOfBlock) >= (sizeof(IMAGE_BASE_RELOCATION)+2*sizeof(UINT16)));
CHECK((VAL16(pRelocEntry[0]) & 0xF000) == (IMAGE_REL_BASED_DIR64 << 12));
pRelocEntry++;

// Only one Reloc record is expected
CHECK(VAL32(pReloc->SizeOfBlock) >= (sizeof(IMAGE_BASE_RELOCATION)+sizeof(UINT16)));
if(FindNTHeaders()->FileHeader.Machine == VAL16(IMAGE_FILE_MACHINE_AMD64))
CHECK((VAL16(pRelocEntry[0]) & 0xF000) == (IMAGE_REL_BASED_DIR64 << 12));
}
else
{
// Only one Reloc record is expected
CHECK(VAL32(pReloc->SizeOfBlock) >= (sizeof(IMAGE_BASE_RELOCATION)+sizeof(UINT16)));
if(FindNTHeaders()->FileHeader.Machine == VAL16(IMAGE_FILE_MACHINE_AMD64))
CHECK((VAL16(pRelocEntry[0]) & 0xF000) == (IMAGE_REL_BASED_DIR64 << 12));
else
CHECK((VAL16(pRelocEntry[0]) & 0xF000) == (IMAGE_REL_BASED_HIGHLOW << 12));
}
CHECK((VAL16(pRelocEntry[0]) & 0xF000) == (IMAGE_REL_BASED_HIGHLOW << 12));

while (++pRelocEntry < pRelocEntryEnd)
{
Expand Down
10 changes: 0 additions & 10 deletions src/coreclr/vm/peassembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,6 @@ static void ValidatePEFileMachineType(PEAssembly *pPEAssembly)

if (actualMachineType != IMAGE_FILE_MACHINE_NATIVE && actualMachineType != IMAGE_FILE_MACHINE_NATIVE_NI)
{
#ifdef TARGET_AMD64
// v4.0 64-bit compatibility workaround. The 64-bit v4.0 CLR's Reflection.Load(byte[]) api does not detect cpu-matches. We should consider fixing that in
// the next SxS release. In the meantime, this bypass will retain compat for 64-bit v4.0 CLR for target platforms that existed at the time.
//
// Though this bypass kicks in for all Load() flavors, the other Load() flavors did detect cpu-matches through various other code paths that still exist.
// Or to put it another way, this #ifdef makes the (4.5 only) ValidatePEFileMachineType() a NOP for x64, hence preserving 4.0 compatibility.
if (actualMachineType == IMAGE_FILE_MACHINE_I386 || actualMachineType == IMAGE_FILE_MACHINE_IA64)
return;
#endif // BIT64_

// Image has required machine that doesn't match the CLR.
StackSString name;
pPEAssembly->GetDisplayName(name);
Expand Down

0 comments on commit 0001147

Please sign in to comment.