Skip to content

Commit c2c48d2

Browse files
authored
Delete support for IA64 relocs (dotnet#90752)
Dead code
1 parent 374b111 commit c2c48d2

File tree

5 files changed

+3
-488
lines changed

5 files changed

+3
-488
lines changed

src/coreclr/dlls/mscorpe/pewriter.cpp

Lines changed: 2 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,9 @@
1414

1515
static const char* const RelocName[] = {
1616
"Absolute", "Unk1", "Unk2", "HighLow", "Unk4", "MapToken",
17-
"Relative", "FilePos", "CodeRel", "Movl64", "Dir64", "PcRel25", "PcRel64",
18-
"AbsTag" };
17+
"Relative", "FilePos", "CodeRel", "Dir64", "AbsTag" };
1918
static const char RelocSpaces[] = " ";
2019

21-
static INT64 s_minPcRel25;
22-
static INT64 s_maxPcRel25;
2320
#endif
2421

2522
/* This is the stub program that says it can't be run in DOS mode */
@@ -312,14 +309,6 @@ HRESULT PEWriterSection::applyRelocs(IMAGE_NT_HEADERS * pNtHeaders,
312309
if (!isPE32 && (curType == srRelocHighLow))
313310
curType = srRelocDir64;
314311

315-
/* If we have an IA64 instruction fixup then extract the slot number and adjust curOffset */
316-
if ((curType == srRelocIA64PcRel25) || (curType == srRelocIA64Imm64) || (curType == srRelocIA64PcRel64))
317-
{
318-
_ASSERTE((curOffset & 0x3) == 0);
319-
slotNum = (curOffset & 0xf) >> 2;
320-
curOffset &= ~0xf;
321-
}
322-
323312
DWORD curRVA = m_baseRVA; // RVA in the PE image of the reloc site
324313
IfFailRet(AddOvf_RVA(curRVA, curOffset));
325314
DWORD UNALIGNED * pos = (DWORD *) m_blobFetcher.ComputePointer(curOffset);
@@ -363,26 +352,7 @@ HRESULT PEWriterSection::applyRelocs(IMAGE_NT_HEADERS * pNtHeaders,
363352
IfFailRet(UnsignedFitsIn32Bits(targetOffset)); // Check for overflow
364353
SET_UNALIGNED_VAL32(pos, targetOffset);
365354
}
366-
else if (curType == srRelocIA64Imm64) {
367-
_ASSERTE(slotNum == 1);
368-
ptr = (char *) ((intptr_t) GetIA64Imm64((UINT64 *) ptr));
369-
oldStarPos = (SSIZE_T) ptr;
370-
targetOffset = externalAddress ? (size_t) ptr
371-
: cur->section->computeOffset(ptr);
372-
_ASSERTE(!isPE32);
373-
PutIA64Imm64((UINT64 *)pos, targetOffset);
374-
}
375-
else if (curType == srRelocIA64PcRel64) {
376-
_ASSERTE(slotNum == 1);
377-
ptr = (char *) ((intptr_t) GetIA64Rel64((UINT64 *) ptr));
378-
oldStarPos = (SSIZE_T) ptr;
379-
targetOffset = externalAddress ? (size_t) ptr
380-
: cur->section->computeOffset(ptr);
381-
_ASSERTE(!isPE32);
382-
PutIA64Rel64((UINT64 *)pos, targetOffset);
383-
}
384355
else {
385-
_ASSERTE(curType != srRelocIA64PcRel25);
386356
ptr = (char *) GET_UNALIGNED_VALPTR(ptr);
387357
oldStarPos = (SSIZE_T) ptr;
388358
targetOffset = externalAddress ? (size_t) ptr
@@ -397,26 +367,7 @@ HRESULT PEWriterSection::applyRelocs(IMAGE_NT_HEADERS * pNtHeaders,
397367
#ifdef LOGGING
398368
else
399369
{
400-
if (curType == srRelocIA64PcRel25)
401-
{
402-
oldStarPos = GetIA64Rel25((UINT64 *) pos, slotNum);
403-
}
404-
else
405-
{
406-
if (curType == srRelocIA64PcRel64)
407-
{
408-
_ASSERTE(slotNum == 1);
409-
oldStarPos = GetIA64Rel64((UINT64 *) pos);
410-
}
411-
else if (curType == srRelocIA64Imm64)
412-
{
413-
oldStarPos = GetIA64Imm64((UINT64 *)pos);
414-
}
415-
else
416-
{
417-
oldStarPos = GET_UNALIGNED_VAL32(pos);
418-
}
419-
}
370+
oldStarPos = GET_UNALIGNED_VAL32(pos);
420371
}
421372
#endif
422373

@@ -495,100 +446,6 @@ HRESULT PEWriterSection::applyRelocs(IMAGE_NT_HEADERS * pNtHeaders,
495446
SET_UNALIGNED_VAL32(pos, newStarPos);
496447

497448
}
498-
else if (curType == srRelocIA64PcRel25)
499-
{
500-
_ASSERTE((m_baseRVA & 15) == 0);
501-
_ASSERTE((cur->section->m_baseRVA & 15) == 0);
502-
503-
newStarPos = GetIA64Rel25((UINT64 *) pos, slotNum);
504-
IfFailRet(SubOvf_S_U32(newStarPos, curRVA));
505-
if (externalAddress)
506-
IfFailRet(SubOvf_S_U(newStarPos, imageBase));
507-
else
508-
IfFailRet(AddOvf_S_U32(newStarPos, cur->section->m_baseRVA));
509-
510-
INT64 hiBits = newStarPos >> 24;
511-
512-
_ASSERTE((hiBits==0) || (hiBits==-1));
513-
514-
IfFailRet(AddOvf_S_U32(newStarPos, GetIA64Rel25((UINT64 *) pos, slotNum)));
515-
516-
hiBits = newStarPos >> 24;
517-
518-
_ASSERTE((hiBits==0) || (hiBits==-1));
519-
520-
INT32 delta32 = (INT32) newStarPos;
521-
522-
PutIA64Rel25((UINT64 *) pos, slotNum, delta32);
523-
524-
_ASSERTE(GetIA64Rel25((UINT64 *) pos, slotNum) == delta32);
525-
526-
#ifdef LOGGING
527-
if (newStarPos < s_minPcRel25)
528-
s_minPcRel25 = newStarPos;
529-
if (newStarPos > s_maxPcRel25)
530-
s_maxPcRel25 = newStarPos;
531-
#endif
532-
}
533-
else if (curType == srRelocIA64PcRel64)
534-
{
535-
_ASSERTE((m_baseRVA & 15) == 0);
536-
_ASSERTE(slotNum == 1);
537-
538-
newStarPos = GetIA64Rel64((UINT64 *) pos);
539-
IfFailRet(SubOvf_S_U32(newStarPos, m_baseRVA));
540-
541-
if (externalAddress)
542-
IfFailRet(SubOvf_S_U(newStarPos, imageBase));
543-
else
544-
{
545-
_ASSERTE((cur->section->m_baseRVA & 15) == 0);
546-
IfFailRet(AddOvf_S_U32(newStarPos, cur->section->m_baseRVA));
547-
}
548-
549-
INT64 hiBits = newStarPos >> 24;
550-
551-
fNeedBrl = (hiBits != 0) && (hiBits != -1);
552-
553-
/* Can we convert the brl.call into a br.call? */
554-
if (!fNeedBrl)
555-
{
556-
INT32 delta32 = (INT32) newStarPos;
557-
558-
UINT64 temp0 = ((UINT64 *) pos)[0];
559-
UINT64 temp1 = ((UINT64 *) pos)[1];
560-
#ifdef _DEBUG
561-
//
562-
// make certain we're decoding a brl opcode, with template 4 or 5
563-
//
564-
UINT64 templa = (temp0 >> 0) & 0x1f;
565-
UINT64 opcode = (temp1 >> 60) & 0xf;
566-
567-
_ASSERTE(((opcode == 0xC) || (opcode == 0xD)) &&
568-
((templa == 0x4) || (templa == 0x5)));
569-
#endif
570-
const UINT64 mask0 = UI64(0x00003FFFFFFFFFE1);
571-
const UINT64 mask1 = UI64(0x7700000FFF800000);
572-
573-
/* Clear all bits used as part of the slot1 and slot2 */
574-
temp0 &= mask0; // opcode becomes 4 or 5
575-
temp1 &= mask1;
576-
577-
temp0 |= 0x10; // template becomes 0x10 or 0x11
578-
temp1 |= 0x200; // slot 1 becomes nop.i
579-
580-
((UINT64 *) pos)[0] = temp0;
581-
((UINT64 *) pos)[1] = temp1;
582-
583-
PutIA64Rel25((UINT64 *) pos, 2, delta32);
584-
_ASSERTE(GetIA64Rel25((UINT64 *) pos, 2) == delta32);
585-
}
586-
else
587-
{
588-
PutIA64Rel64((UINT64 *) pos, newStarPos);
589-
_ASSERTE(GetIA64Rel64((UINT64 *) pos) == newStarPos);
590-
}
591-
}
592449
else if (curType == srRelocHighLow)
593450
{
594451
_ASSERTE(isPE32);
@@ -630,27 +487,6 @@ HRESULT PEWriterSection::applyRelocs(IMAGE_NT_HEADERS * pNtHeaders,
630487
newStarPos = targetOffset;
631488
fBaseReloc = true;
632489
}
633-
else if (curType == srRelocIA64Imm64)
634-
{
635-
_ASSERTE(!isPE32);
636-
_ASSERTE((curRVA & 15) == 0); // This reloc should be 16-byte aligned
637-
638-
// we have a 64-bit value encoded in the instruction at pos
639-
targetOffset = GetIA64Imm64((UINT64 *)pos);
640-
641-
if (!externalAddress)
642-
{
643-
// The upper bits of targetOffset must be zero
644-
IfFailRet(UnsignedFitsIn32Bits(targetOffset));
645-
646-
IfFailRet(AddOvf_U_U32(targetOffset, cur->section->m_baseRVA));
647-
IfFailRet(AddOvf_U_U(targetOffset, imageBase));
648-
}
649-
650-
PutIA64Imm64((UINT64 *)pos, targetOffset);
651-
newStarPos = targetOffset;
652-
fBaseReloc = true;
653-
}
654490
else
655491
{
656492
_ASSERTE(!"Unknown Relocation type");

src/coreclr/ildasm/ceeload.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ BOOL PELoader::open(HMODULE hMod)
149149
}
150150
fileAlignment = VAL32(m_pNT32->OptionalHeader.FileAlignment)-1;
151151
}
152-
else //For now assume not i386 is IA64
152+
else
153153
{
154154
if ((m_pNT64->Signature != VAL32(IMAGE_NT_SIGNATURE)) ||
155155
(m_pNT64->FileHeader.SizeOfOptionalHeader != VAL16(sizeof(IMAGE_OPTIONAL_HEADER64))))

src/coreclr/inc/corpriv.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -334,18 +334,9 @@ typedef enum {
334334
// code relative address fixup
335335
srRelocCodeRelative,
336336

337-
// generate a .reloc for a 64 bit address in an ia64 movl instruction
338-
srRelocIA64Imm64,
339-
340337
// generate a .reloc for a 64 bit address
341338
srRelocDir64,
342339

343-
// generate a .reloc for a 25-bit PC relative address in an ia64 br.call instruction
344-
srRelocIA64PcRel25,
345-
346-
// generate a .reloc for a 64-bit PC relative address in an ia64 brl.call instruction
347-
srRelocIA64PcRel64,
348-
349340
// generate a 30-bit section-relative reloc, used for tagged pointer values
350341
srRelocAbsoluteTagged,
351342

@@ -366,7 +357,6 @@ typedef enum {
366357
srRelocAbsolutePtr = srRelocPtr + srRelocAbsolute,
367358
srRelocHighLowPtr = srRelocPtr + srRelocHighLow,
368359
srRelocRelativePtr = srRelocPtr + srRelocRelative,
369-
srRelocIA64Imm64Ptr = srRelocPtr + srRelocIA64Imm64,
370360
srRelocDir64Ptr = srRelocPtr + srRelocDir64,
371361

372362
} CeeSectionRelocType;

src/coreclr/inc/utilcode.h

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3279,49 +3279,6 @@ HRESULT Utf2Quick(
32793279
CQuickArray<WCHAR> &rStr, // The QuickArray<WCHAR> to convert it into.
32803280
int iCurLen = 0); // Initial characters in the array to leave (default 0).
32813281

3282-
//*****************************************************************************
3283-
// Extract the movl 64-bit unsigned immediate from an IA64 bundle
3284-
// (Format X2)
3285-
//*****************************************************************************
3286-
UINT64 GetIA64Imm64(UINT64 * pBundle);
3287-
UINT64 GetIA64Imm64(UINT64 qword0, UINT64 qword1);
3288-
3289-
//*****************************************************************************
3290-
// Deposit the movl 64-bit unsigned immediate into an IA64 bundle
3291-
// (Format X2)
3292-
//*****************************************************************************
3293-
void PutIA64Imm64(UINT64 * pBundle, UINT64 imm64);
3294-
3295-
//*****************************************************************************
3296-
// Extract the IP-Relative signed 25-bit immediate from an IA64 bundle
3297-
// (Formats B1, B2 or B3)
3298-
// Note that due to branch target alignment requirements
3299-
// the lowest four bits in the result will always be zero.
3300-
//*****************************************************************************
3301-
INT32 GetIA64Rel25(UINT64 * pBundle, UINT32 slot);
3302-
INT32 GetIA64Rel25(UINT64 qword0, UINT64 qword1, UINT32 slot);
3303-
3304-
//*****************************************************************************
3305-
// Deposit the IP-Relative signed 25-bit immediate into an IA64 bundle
3306-
// (Formats B1, B2 or B3)
3307-
// Note that due to branch target alignment requirements
3308-
// the lowest four bits are required to be zero.
3309-
//*****************************************************************************
3310-
void PutIA64Rel25(UINT64 * pBundle, UINT32 slot, INT32 imm25);
3311-
3312-
//*****************************************************************************
3313-
// Extract the IP-Relative signed 64-bit immediate from an IA64 bundle
3314-
// (Formats X3 or X4)
3315-
//*****************************************************************************
3316-
INT64 GetIA64Rel64(UINT64 * pBundle);
3317-
INT64 GetIA64Rel64(UINT64 qword0, UINT64 qword1);
3318-
3319-
//*****************************************************************************
3320-
// Deposit the IP-Relative signed 64-bit immediate into a IA64 bundle
3321-
// (Formats X3 or X4)
3322-
//*****************************************************************************
3323-
void PutIA64Rel64(UINT64 * pBundle, INT64 imm64);
3324-
33253282
//*****************************************************************************
33263283
// Extract the 32-bit immediate from movw/movt Thumb2 sequence
33273284
//*****************************************************************************

0 commit comments

Comments
 (0)