Do not use inheritance for EhSectionPiece.

EhSectionPiece inherited from SectionPiece, but we did not actually use
EhSectionPiece objects as SectionPiece ojbects. They were handled as
distinct types. So it didn't make much sense to use inheritance.

llvm-svn: 313587
This commit is contained in:
Rui Ueyama 2017-09-18 23:07:21 +00:00
parent a6ff617967
commit e084aac123
2 changed files with 8 additions and 5 deletions

View File

@ -261,15 +261,18 @@ private:
llvm::DenseSet<uint64_t> LiveOffsets;
};
struct EhSectionPiece : public SectionPiece {
struct EhSectionPiece {
EhSectionPiece(size_t Off, InputSectionBase *ID, uint32_t Size,
unsigned FirstRelocation)
: SectionPiece(Off, false), ID(ID), Size(Size),
: InputOff(Off), ID(ID), Size(Size),
FirstRelocation(FirstRelocation) {}
InputSectionBase *ID;
uint32_t Size;
ArrayRef<uint8_t> data() { return {ID->Data.data() + this->InputOff, Size}; }
size_t InputOff;
ssize_t OutputOff = -1;
InputSectionBase *ID;
uint32_t Size;
unsigned FirstRelocation;
};

View File

@ -609,7 +609,7 @@ template <class ELFT> void EhFrameSection<ELFT>::writeTo(uint8_t *Buf) {
if (In<ELFT>::EhFrameHdr) {
for (CieRecord *Cie : Cies) {
uint8_t Enc = getFdeEncoding<ELFT>(Cie->Piece);
for (SectionPiece *Fde : Cie->FdePieces) {
for (EhSectionPiece *Fde : Cie->FdePieces) {
uint64_t Pc = getFdePc(Buf, Fde->OutputOff, Enc);
uint64_t FdeVA = getParent()->Addr + Fde->OutputOff;
In<ELFT>::EhFrameHdr->addFde(Pc, FdeVA);