Index: ELF/MapFile.cpp =================================================================== --- ELF/MapFile.cpp +++ ELF/MapFile.cpp @@ -138,6 +138,58 @@ // Dump symbols for each input section. for (InputSection *IS : getInputSections(OSec)) { + 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, "+0x" + utohexstr(InputStart, true)); + } + + 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'; for (Symbol *Sym : SectionSyms[IS]) 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; Index: test/ELF/Inputs/map-file2.s =================================================================== --- test/ELF/Inputs/map-file2.s +++ test/ELF/Inputs/map-file2.s @@ -1,5 +1,7 @@ foo: +.cfi_startproc nop +.cfi_endproc .global bar bar: nop Index: test/ELF/map-file.s =================================================================== --- test/ELF/map-file.s +++ test/ELF/map-file.s @@ -15,6 +15,8 @@ .global _start _start: +.cfi_startproc +.cfi_endproc .quad sharedFoo .quad sharedBar .byte 0xe8 @@ -26,8 +28,8 @@ .global _Z1fi _Z1fi: .cfi_startproc -.cfi_endproc nop +.cfi_endproc .weak bar bar: .long bar - . @@ -51,8 +53,10 @@ // CHECK-NEXT: 00000000002002d0 0000000000000030 8 :(.rela.dyn) // CHECK-NEXT: 0000000000200300 0000000000000030 8 .rela.plt // CHECK-NEXT: 0000000000200300 0000000000000030 8 :(.rela.plt) -// CHECK-NEXT: 0000000000200330 0000000000000030 8 .eh_frame -// CHECK-NEXT: 0000000000200330 0000000000000030 8 :(.eh_frame) +// CHECK-NEXT: 0000000000200330 0000000000000060 8 .eh_frame +// CHECK-NEXT: 0000000000200330 000000000000002c 8 {{.*}}{{/|\\}}map-file.s.tmp1.o:(.eh_frame) +// CHECK-NEXT: 0000000000200360 0000000000000014 8 {{.*}}{{/|\\}}map-file.s.tmp1.o:(.eh_frame+0x2c) +// CHECK-NEXT: 0000000000200378 0000000000000018 8 {{.*}}{{/|\\}}map-file.s.tmp2.o:(.eh_frame+0x18) // CHECK-NEXT: 0000000000201000 000000000000002d 4 .text // CHECK-NEXT: 0000000000201000 0000000000000028 4 {{.*}}{{/|\\}}map-file.s.tmp1.o:(.text) // CHECK-NEXT: 0000000000201000 0000000000000000 0 _start