Index: ELF/MapFile.cpp =================================================================== --- ELF/MapFile.cpp +++ ELF/MapFile.cpp @@ -142,6 +142,58 @@ if (!ISD) continue; for (InputSection *IS : ISD->Sections) { + if (IS == InX::EhFrame) { + uint64_t InputStart = 0, InputEnd = 0, OutputStart = 0, OutputEnd = 0; + + auto AddEntry = [&](InputSectionBase *IS) { + writeHeader(OS, (OSec->Addr + OutputStart), + (OutputEnd - OutputStart), IS->Alignment); + + std::string InputName = toString(IS); + if (InputStart) { + auto Pos = InputName.size(); + if (Pos && (InputName.back() == ')')) + --Pos; + InputName.insert(Pos, "+" + std::to_string(InputStart)); + } + + OS << indent(1) << InputName << '\n'; + }; + + InputSectionBase *IS = nullptr; + + auto ProcessPiece = [&](const EhSectionPiece *P) { + uint64_t InputOff = P->InputOff; + uint64_t OutputOff = P->OutputOff; + if (P->Sec != IS || (OutputOff != OutputEnd) || + (InputOff != InputEnd)) { + if (IS) + AddEntry(IS); + InputStart = InputOff; + OutputStart = OutputOff; + IS = P->Sec; + } + + auto Size = P->Size; + OutputEnd = OutputOff + Size; + InputEnd = InputOff + Size; + }; + + auto CieRecords = InX::EhFrame->getCieRecords(); + for (const auto *Rec : CieRecords) { + ProcessPiece(Rec->Cie); + + const auto &Fdes = Rec->Fdes; + for (const auto *Fde : Fdes) + ProcessPiece(Fde); + } + + if (IS) + AddEntry(IS); + + continue; + } + writeHeader(OS, OSec->Addr + IS->OutSecOff, IS->getSize(), IS->Alignment); OS << indent(1) << toString(IS) << '\n'; Index: ELF/SyntheticSections.h =================================================================== --- ELF/SyntheticSections.h +++ ELF/SyntheticSections.h @@ -83,6 +83,7 @@ }; std::vector getFdeData() const; + std::vector const &getCieRecords() const { return CieRecords; } private: uint64_t Size = 0;