@@ -384,10 +384,13 @@ class SectionBase {
384
384
std::string Name;
385
385
Segment *ParentSegment = nullptr ;
386
386
uint64_t HeaderOffset;
387
- uint64_t OriginalOffset = std::numeric_limits<uint64_t >::max();
388
387
uint32_t Index;
389
388
bool HasSymbol = false ;
390
389
390
+ uint64_t OriginalFlags = 0 ;
391
+ uint64_t OriginalType = ELF::SHT_NULL;
392
+ uint64_t OriginalOffset = std::numeric_limits<uint64_t >::max();
393
+
391
394
uint64_t Addr = 0 ;
392
395
uint64_t Align = 1 ;
393
396
uint32_t EntrySize = 0 ;
@@ -490,17 +493,17 @@ class OwnedDataSection : public SectionBase {
490
493
OwnedDataSection (StringRef SecName, ArrayRef<uint8_t > Data)
491
494
: Data(std::begin(Data), std::end(Data)) {
492
495
Name = SecName.str ();
493
- Type = ELF::SHT_PROGBITS;
496
+ Type = OriginalType = ELF::SHT_PROGBITS;
494
497
Size = Data.size ();
495
498
OriginalOffset = std::numeric_limits<uint64_t >::max ();
496
499
}
497
500
498
501
OwnedDataSection (const Twine &SecName, uint64_t SecAddr, uint64_t SecFlags,
499
502
uint64_t SecOff) {
500
503
Name = SecName.str ();
501
- Type = ELF::SHT_PROGBITS;
504
+ Type = OriginalType = ELF::SHT_PROGBITS;
502
505
Addr = SecAddr;
503
- Flags = SecFlags;
506
+ Flags = OriginalFlags = SecFlags;
504
507
OriginalOffset = SecOff;
505
508
}
506
509
@@ -530,7 +533,7 @@ class CompressedSection : public SectionBase {
530
533
void accept (MutableSectionVisitor &Visitor) override ;
531
534
532
535
static bool classof (const SectionBase *S) {
533
- return (S->Flags & ELF::SHF_COMPRESSED) ||
536
+ return (S->OriginalFlags & ELF::SHF_COMPRESSED) ||
534
537
(StringRef (S->Name ).startswith (" .zdebug" ));
535
538
}
536
539
};
@@ -543,7 +546,7 @@ class DecompressedSection : public SectionBase {
543
546
: SectionBase(Sec) {
544
547
Size = Sec.getDecompressedSize ();
545
548
Align = Sec.getDecompressedAlign ();
546
- Flags = (Flags & ~ELF::SHF_COMPRESSED);
549
+ Flags = OriginalFlags = (Flags & ~ELF::SHF_COMPRESSED);
547
550
if (StringRef (Name).startswith (" .zdebug" ))
548
551
Name = " ." + Name.substr (2 );
549
552
}
@@ -567,7 +570,7 @@ class StringTableSection : public SectionBase {
567
570
568
571
public:
569
572
StringTableSection () : StrTabBuilder(StringTableBuilder::ELF) {
570
- Type = ELF::SHT_STRTAB;
573
+ Type = OriginalType = ELF::SHT_STRTAB;
571
574
}
572
575
573
576
void addString (StringRef Name);
@@ -577,9 +580,9 @@ class StringTableSection : public SectionBase {
577
580
void accept (MutableSectionVisitor &Visitor) override ;
578
581
579
582
static bool classof (const SectionBase *S) {
580
- if (S->Flags & ELF::SHF_ALLOC)
583
+ if (S->OriginalFlags & ELF::SHF_ALLOC)
581
584
return false ;
582
- return S->Type == ELF::SHT_STRTAB;
585
+ return S->OriginalType == ELF::SHT_STRTAB;
583
586
}
584
587
};
585
588
@@ -648,7 +651,7 @@ class SectionIndexSection : public SectionBase {
648
651
Name = " .symtab_shndx" ;
649
652
Align = 4 ;
650
653
EntrySize = 4 ;
651
- Type = ELF::SHT_SYMTAB_SHNDX;
654
+ Type = OriginalType = ELF::SHT_SYMTAB_SHNDX;
652
655
}
653
656
};
654
657
@@ -666,7 +669,7 @@ class SymbolTableSection : public SectionBase {
666
669
using SymPtr = std::unique_ptr<Symbol>;
667
670
668
671
public:
669
- SymbolTableSection () { Type = ELF::SHT_SYMTAB; }
672
+ SymbolTableSection () { Type = OriginalType = ELF::SHT_SYMTAB; }
670
673
671
674
void addSymbol (Twine Name, uint8_t Bind, uint8_t Type, SectionBase *DefinedIn,
672
675
uint64_t Value, uint8_t Visibility, uint16_t Shndx,
@@ -695,7 +698,7 @@ class SymbolTableSection : public SectionBase {
695
698
const DenseMap<SectionBase *, SectionBase *> &FromTo) override ;
696
699
697
700
static bool classof (const SectionBase *S) {
698
- return S->Type == ELF::SHT_SYMTAB;
701
+ return S->OriginalType == ELF::SHT_SYMTAB;
699
702
}
700
703
};
701
704
@@ -724,7 +727,7 @@ class RelocationSectionBase : public SectionBase {
724
727
void setSection (SectionBase *Sec) { SecToApplyRel = Sec; }
725
728
726
729
static bool classof (const SectionBase *S) {
727
- return S->Type == ELF::SHT_REL || S->Type == ELF::SHT_RELA;
730
+ return S->OriginalType == ELF::SHT_REL || S->OriginalType == ELF::SHT_RELA;
728
731
}
729
732
};
730
733
@@ -762,9 +765,9 @@ class RelocationSection
762
765
const DenseMap<SectionBase *, SectionBase *> &FromTo) override ;
763
766
764
767
static bool classof (const SectionBase *S) {
765
- if (S->Flags & ELF::SHF_ALLOC)
768
+ if (S->OriginalFlags & ELF::SHF_ALLOC)
766
769
return false ;
767
- return S->Type == ELF::SHT_REL || S->Type == ELF::SHT_RELA;
770
+ return S->OriginalType == ELF::SHT_REL || S->OriginalType == ELF::SHT_RELA;
768
771
}
769
772
};
770
773
@@ -799,7 +802,7 @@ class GroupSection : public SectionBase {
799
802
const DenseMap<SectionBase *, SectionBase *> &FromTo) override ;
800
803
801
804
static bool classof (const SectionBase *S) {
802
- return S->Type == ELF::SHT_GROUP;
805
+ return S->OriginalType == ELF::SHT_GROUP;
803
806
}
804
807
};
805
808
@@ -808,7 +811,7 @@ class DynamicSymbolTableSection : public Section {
808
811
explicit DynamicSymbolTableSection (ArrayRef<uint8_t > Data) : Section(Data) {}
809
812
810
813
static bool classof (const SectionBase *S) {
811
- return S->Type == ELF::SHT_DYNSYM;
814
+ return S->OriginalType == ELF::SHT_DYNSYM;
812
815
}
813
816
};
814
817
@@ -817,7 +820,7 @@ class DynamicSection : public Section {
817
820
explicit DynamicSection (ArrayRef<uint8_t > Data) : Section(Data) {}
818
821
819
822
static bool classof (const SectionBase *S) {
820
- return S->Type == ELF::SHT_DYNAMIC;
823
+ return S->OriginalType == ELF::SHT_DYNAMIC;
821
824
}
822
825
};
823
826
@@ -838,9 +841,9 @@ class DynamicRelocationSection
838
841
function_ref<bool (const SectionBase *)> ToRemove) override ;
839
842
840
843
static bool classof (const SectionBase *S) {
841
- if (!(S->Flags & ELF::SHF_ALLOC))
844
+ if (!(S->OriginalFlags & ELF::SHF_ALLOC))
842
845
return false ;
843
- return S->Type == ELF::SHT_REL || S->Type == ELF::SHT_RELA;
846
+ return S->OriginalType == ELF::SHT_REL || S->OriginalType == ELF::SHT_RELA;
844
847
}
845
848
};
846
849
0 commit comments