forked from OSchip/llvm-project
Rename CieRecord instance variables.
CieRecord is a struct containing a CIE and FDEs, but oftentimes the struct itself is named `Cie` which caused some confusion. This patch renames them `CieRecords` or `Rec`. llvm-svn: 313681
This commit is contained in:
parent
85908aa84b
commit
74ea1f0938
|
@ -403,38 +403,38 @@ EhFrameSection<ELFT>::EhFrameSection()
|
||||||
// and where their relocations point to.
|
// and where their relocations point to.
|
||||||
template <class ELFT>
|
template <class ELFT>
|
||||||
template <class RelTy>
|
template <class RelTy>
|
||||||
CieRecord *EhFrameSection<ELFT>::addCie(EhSectionPiece &Piece,
|
CieRecord *EhFrameSection<ELFT>::addCie(EhSectionPiece &Cie,
|
||||||
ArrayRef<RelTy> Rels) {
|
ArrayRef<RelTy> Rels) {
|
||||||
auto *Sec = cast<EhInputSection>(Piece.Sec);
|
auto *Sec = cast<EhInputSection>(Cie.Sec);
|
||||||
const endianness E = ELFT::TargetEndianness;
|
const endianness E = ELFT::TargetEndianness;
|
||||||
if (read32<E>(Piece.data().data() + 4) != 0)
|
if (read32<E>(Cie.data().data() + 4) != 0)
|
||||||
fatal(toString(Sec) + ": CIE expected at beginning of .eh_frame");
|
fatal(toString(Sec) + ": CIE expected at beginning of .eh_frame");
|
||||||
|
|
||||||
SymbolBody *Personality = nullptr;
|
SymbolBody *Personality = nullptr;
|
||||||
unsigned FirstRelI = Piece.FirstRelocation;
|
unsigned FirstRelI = Cie.FirstRelocation;
|
||||||
if (FirstRelI != (unsigned)-1)
|
if (FirstRelI != (unsigned)-1)
|
||||||
Personality =
|
Personality =
|
||||||
&Sec->template getFile<ELFT>()->getRelocTargetSym(Rels[FirstRelI]);
|
&Sec->template getFile<ELFT>()->getRelocTargetSym(Rels[FirstRelI]);
|
||||||
|
|
||||||
// Search for an existing CIE by CIE contents/relocation target pair.
|
// Search for an existing CIE by CIE contents/relocation target pair.
|
||||||
CieRecord *Cie = &CieMap[{Piece.data(), Personality}];
|
CieRecord *Rec = &CieMap[{Cie.data(), Personality}];
|
||||||
|
|
||||||
// If not found, create a new one.
|
// If not found, create a new one.
|
||||||
if (Cie->Piece == nullptr) {
|
if (Rec->Cie == nullptr) {
|
||||||
Cie->Piece = &Piece;
|
Rec->Cie = &Cie;
|
||||||
Cies.push_back(Cie);
|
CieRecords.push_back(Rec);
|
||||||
}
|
}
|
||||||
return Cie;
|
return Rec;
|
||||||
}
|
}
|
||||||
|
|
||||||
// There is one FDE per function. Returns true if a given FDE
|
// There is one FDE per function. Returns true if a given FDE
|
||||||
// points to a live function.
|
// points to a live function.
|
||||||
template <class ELFT>
|
template <class ELFT>
|
||||||
template <class RelTy>
|
template <class RelTy>
|
||||||
bool EhFrameSection<ELFT>::isFdeLive(EhSectionPiece &Piece,
|
bool EhFrameSection<ELFT>::isFdeLive(EhSectionPiece &Fde,
|
||||||
ArrayRef<RelTy> Rels) {
|
ArrayRef<RelTy> Rels) {
|
||||||
auto *Sec = cast<EhInputSection>(Piece.Sec);
|
auto *Sec = cast<EhInputSection>(Fde.Sec);
|
||||||
unsigned FirstRelI = Piece.FirstRelocation;
|
unsigned FirstRelI = Fde.FirstRelocation;
|
||||||
|
|
||||||
// An FDE should point to some function because FDEs are to describe
|
// An FDE should point to some function because FDEs are to describe
|
||||||
// functions. That's however not always the case due to an issue of
|
// functions. That's however not always the case due to an issue of
|
||||||
|
@ -476,13 +476,13 @@ void EhFrameSection<ELFT>::addSectionAux(EhInputSection *Sec,
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t CieOffset = Offset + 4 - ID;
|
uint32_t CieOffset = Offset + 4 - ID;
|
||||||
CieRecord *Cie = OffsetToCie[CieOffset];
|
CieRecord *Rec = OffsetToCie[CieOffset];
|
||||||
if (!Cie)
|
if (!Rec)
|
||||||
fatal(toString(Sec) + ": invalid CIE reference");
|
fatal(toString(Sec) + ": invalid CIE reference");
|
||||||
|
|
||||||
if (!isFdeLive(Piece, Rels))
|
if (!isFdeLive(Piece, Rels))
|
||||||
continue;
|
continue;
|
||||||
Cie->FdePieces.push_back(&Piece);
|
Rec->Fdes.push_back(&Piece);
|
||||||
NumFdes++;
|
NumFdes++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -530,11 +530,11 @@ template <class ELFT> void EhFrameSection<ELFT>::finalizeContents() {
|
||||||
return; // Already finalized.
|
return; // Already finalized.
|
||||||
|
|
||||||
size_t Off = 0;
|
size_t Off = 0;
|
||||||
for (CieRecord *Cie : Cies) {
|
for (CieRecord *Rec : CieRecords) {
|
||||||
Cie->Piece->OutputOff = Off;
|
Rec->Cie->OutputOff = Off;
|
||||||
Off += alignTo(Cie->Piece->Size, Config->Wordsize);
|
Off += alignTo(Rec->Cie->Size, Config->Wordsize);
|
||||||
|
|
||||||
for (EhSectionPiece *Fde : Cie->FdePieces) {
|
for (EhSectionPiece *Fde : Rec->Fdes) {
|
||||||
Fde->OutputOff = Off;
|
Fde->OutputOff = Off;
|
||||||
Off += alignTo(Fde->Size, Config->Wordsize);
|
Off += alignTo(Fde->Size, Config->Wordsize);
|
||||||
}
|
}
|
||||||
|
@ -584,11 +584,11 @@ uint64_t EhFrameSection<ELFT>::getFdePc(uint8_t *Buf, size_t FdeOff,
|
||||||
|
|
||||||
template <class ELFT> void EhFrameSection<ELFT>::writeTo(uint8_t *Buf) {
|
template <class ELFT> void EhFrameSection<ELFT>::writeTo(uint8_t *Buf) {
|
||||||
const endianness E = ELFT::TargetEndianness;
|
const endianness E = ELFT::TargetEndianness;
|
||||||
for (CieRecord *Cie : Cies) {
|
for (CieRecord *Rec : CieRecords) {
|
||||||
size_t CieOffset = Cie->Piece->OutputOff;
|
size_t CieOffset = Rec->Cie->OutputOff;
|
||||||
writeCieFde<ELFT>(Buf + CieOffset, Cie->Piece->data());
|
writeCieFde<ELFT>(Buf + CieOffset, Rec->Cie->data());
|
||||||
|
|
||||||
for (EhSectionPiece *Fde : Cie->FdePieces) {
|
for (EhSectionPiece *Fde : Rec->Fdes) {
|
||||||
size_t Off = Fde->OutputOff;
|
size_t Off = Fde->OutputOff;
|
||||||
writeCieFde<ELFT>(Buf + Off, Fde->data());
|
writeCieFde<ELFT>(Buf + Off, Fde->data());
|
||||||
|
|
||||||
|
@ -605,9 +605,9 @@ template <class ELFT> void EhFrameSection<ELFT>::writeTo(uint8_t *Buf) {
|
||||||
// to get a FDE from an address to which FDE is applied. So here
|
// to get a FDE from an address to which FDE is applied. So here
|
||||||
// we obtain two addresses and pass them to EhFrameHdr object.
|
// we obtain two addresses and pass them to EhFrameHdr object.
|
||||||
if (In<ELFT>::EhFrameHdr) {
|
if (In<ELFT>::EhFrameHdr) {
|
||||||
for (CieRecord *Cie : Cies) {
|
for (CieRecord *Rec : CieRecords) {
|
||||||
uint8_t Enc = getFdeEncoding<ELFT>(Cie->Piece);
|
uint8_t Enc = getFdeEncoding<ELFT>(Rec->Cie);
|
||||||
for (EhSectionPiece *Fde : Cie->FdePieces) {
|
for (EhSectionPiece *Fde : Rec->Fdes) {
|
||||||
uint64_t Pc = getFdePc(Buf, Fde->OutputOff, Enc);
|
uint64_t Pc = getFdePc(Buf, Fde->OutputOff, Enc);
|
||||||
uint64_t FdeVA = getParent()->Addr + Fde->OutputOff;
|
uint64_t FdeVA = getParent()->Addr + Fde->OutputOff;
|
||||||
In<ELFT>::EhFrameHdr->addFde(Pc, FdeVA);
|
In<ELFT>::EhFrameHdr->addFde(Pc, FdeVA);
|
||||||
|
|
|
@ -59,8 +59,8 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CieRecord {
|
struct CieRecord {
|
||||||
EhSectionPiece *Piece = nullptr;
|
EhSectionPiece *Cie = nullptr;
|
||||||
std::vector<EhSectionPiece *> FdePieces;
|
std::vector<EhSectionPiece *> Fdes;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Section for .eh_frame.
|
// Section for .eh_frame.
|
||||||
|
@ -100,7 +100,7 @@ private:
|
||||||
|
|
||||||
uint64_t getFdePc(uint8_t *Buf, size_t Off, uint8_t Enc);
|
uint64_t getFdePc(uint8_t *Buf, size_t Off, uint8_t Enc);
|
||||||
|
|
||||||
std::vector<CieRecord *> Cies;
|
std::vector<CieRecord *> CieRecords;
|
||||||
|
|
||||||
// CIE records are uniquified by their contents and personality functions.
|
// CIE records are uniquified by their contents and personality functions.
|
||||||
llvm::DenseMap<std::pair<ArrayRef<uint8_t>, SymbolBody *>, CieRecord> CieMap;
|
llvm::DenseMap<std::pair<ArrayRef<uint8_t>, SymbolBody *>, CieRecord> CieMap;
|
||||||
|
|
Loading…
Reference in New Issue