// an offset to the CIE (provided by parsing the FDE header). The CIE itself
// is obtained lazily once it's actually required.
FDE(uint64_t Offset, uint64_t Length, int64_t LinkedCIEOffset,
- uint64_t InitialLocation, uint64_t AddressRange)
+ uint64_t InitialLocation, uint64_t AddressRange,
+ CIE *Cie)
: FrameEntry(FK_FDE, Offset, Length), LinkedCIEOffset(LinkedCIEOffset),
InitialLocation(InitialLocation), AddressRange(AddressRange),
- LinkedCIE(nullptr) {}
+ LinkedCIE(Cie) {}
~FDE() {
}
void DWARFDebugFrame::parse(DataExtractor Data) {
uint32_t Offset = 0;
+ DenseMap<uint32_t, CIE *> CIEs;
while (Data.isValidOffset(Offset)) {
uint32_t StartOffset = Offset;
int64_t DataAlignmentFactor = Data.getSLEB128(&Offset);
uint64_t ReturnAddressRegister = Data.getULEB128(&Offset);
- Entries.emplace_back(new CIE(StartOffset, Length, Version,
- StringRef(Augmentation), CodeAlignmentFactor,
- DataAlignmentFactor, ReturnAddressRegister));
+ auto Cie = make_unique<CIE>(StartOffset, Length, Version,
+ StringRef(Augmentation), CodeAlignmentFactor,
+ DataAlignmentFactor, ReturnAddressRegister);
+ CIEs[StartOffset] = Cie.get();
+ Entries.emplace_back(std::move(Cie));
} else {
// FDE
uint64_t CIEPointer = Id;
uint64_t AddressRange = Data.getAddress(&Offset);
Entries.emplace_back(new FDE(StartOffset, Length, CIEPointer,
- InitialLocation, AddressRange));
+ InitialLocation, AddressRange,
+ CIEs[CIEPointer]));
}
Entries.back()->parseInstructions(Data, &Offset, EndStructureOffset);