14
14
15
15
static const char * const RelocName[] = {
16
16
" Absolute" , " Unk1" , " Unk2" , " HighLow" , " Unk4" , " MapToken" ,
17
- " Relative" , " FilePos" , " CodeRel" , " Movl64" , " Dir64" , " PcRel25" , " PcRel64" ,
18
- " AbsTag" };
17
+ " Relative" , " FilePos" , " CodeRel" , " Dir64" , " AbsTag" };
19
18
static const char RelocSpaces[] = " " ;
20
19
21
- static INT64 s_minPcRel25;
22
- static INT64 s_maxPcRel25;
23
20
#endif
24
21
25
22
/* 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,
312
309
if (!isPE32 && (curType == srRelocHighLow))
313
310
curType = srRelocDir64;
314
311
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
-
323
312
DWORD curRVA = m_baseRVA; // RVA in the PE image of the reloc site
324
313
IfFailRet (AddOvf_RVA (curRVA, curOffset));
325
314
DWORD UNALIGNED * pos = (DWORD *) m_blobFetcher.ComputePointer (curOffset);
@@ -363,26 +352,7 @@ HRESULT PEWriterSection::applyRelocs(IMAGE_NT_HEADERS * pNtHeaders,
363
352
IfFailRet (UnsignedFitsIn32Bits (targetOffset)); // Check for overflow
364
353
SET_UNALIGNED_VAL32 (pos, targetOffset);
365
354
}
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
- }
384
355
else {
385
- _ASSERTE (curType != srRelocIA64PcRel25);
386
356
ptr = (char *) GET_UNALIGNED_VALPTR (ptr);
387
357
oldStarPos = (SSIZE_T) ptr;
388
358
targetOffset = externalAddress ? (size_t ) ptr
@@ -397,26 +367,7 @@ HRESULT PEWriterSection::applyRelocs(IMAGE_NT_HEADERS * pNtHeaders,
397
367
#ifdef LOGGING
398
368
else
399
369
{
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);
420
371
}
421
372
#endif
422
373
@@ -495,100 +446,6 @@ HRESULT PEWriterSection::applyRelocs(IMAGE_NT_HEADERS * pNtHeaders,
495
446
SET_UNALIGNED_VAL32 (pos, newStarPos);
496
447
497
448
}
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
- }
592
449
else if (curType == srRelocHighLow)
593
450
{
594
451
_ASSERTE (isPE32);
@@ -630,27 +487,6 @@ HRESULT PEWriterSection::applyRelocs(IMAGE_NT_HEADERS * pNtHeaders,
630
487
newStarPos = targetOffset;
631
488
fBaseReloc = true ;
632
489
}
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
- }
654
490
else
655
491
{
656
492
_ASSERTE (!" Unknown Relocation type" );
0 commit comments