Index: lld/trunk/ELF/MapFile.cpp =================================================================== --- lld/trunk/ELF/MapFile.cpp +++ lld/trunk/ELF/MapFile.cpp @@ -11,13 +11,11 @@ // hierarchically the output sections, input sections, input files and // symbol: // -// Address Size Align Out In File Symbol -// ================================================================= -// 00201000 00000015 4 .text -// 00201000 0000000e 4 .text -// 00201000 0000000e 4 test.o -// 0020100e 00000000 0 local -// 00201005 00000000 0 f(int) +// Address Size Align Out In Symbol +// 00201000 00000015 4 .text +// 00201000 0000000e 4 test.o:.text +// 0020100e 00000000 0 local +// 00201005 00000000 0 f(int) // //===----------------------------------------------------------------------===// @@ -42,8 +40,7 @@ void print(raw_ostream &OS, ArrayRef OutputSections); private: - void writeInputSection(raw_ostream &OS, const InputSection *IS, - StringRef &CurSection); + void writeInputSection(raw_ostream &OS, const InputSection *IS); // Maps sections to their symbols. DenseMap> Symbols; @@ -98,7 +95,7 @@ raw_string_ostream OS(Str[I]); writeHeader(OS, Syms[I]->getVA(), Syms[I]->template getSize(), 0); - OS << indent(3) << toString(*Syms[I]) << '\n'; + OS << indent(2) << toString(*Syms[I]) << '\n'; }); for (size_t I = 0, E = Syms.size(); I < E; ++I) SymStr[Syms[I]] = std::move(Str[I]); @@ -106,33 +103,11 @@ template void PrettyPrinter::writeInputSection(raw_ostream &OS, - const InputSection *IS, - StringRef &CurSection) { - // We want to print out a line like - // - // Address Size Align Out In File Symbol - // ================================================================= - // 00201000 00000015 4 .text - // 00201000 0000000e 4 .text <----- THIS - // 00201000 0000000e 4 test.o - // - // once for each new input section. - if (IS->Name != CurSection) { - writeHeader(OS, IS->OutSec->Addr + IS->OutSecOff, IS->getSize(), - IS->Alignment); - OS << indent(1) << IS->Name << '\n'; - CurSection = IS->Name; - } - + const InputSection *IS) { // Write a line for each symbol defined in the given section. - elf::ObjectFile *File = IS->template getFile(); - if (!File) - return; - writeHeader(OS, IS->OutSec->Addr + IS->OutSecOff, IS->getSize(), IS->Alignment); - OS << indent(2) << toString(File) << '\n'; - + OS << indent(1) << toString(IS) << '\n'; for (DefinedRegular *Sym : Symbols[IS]) OS << SymStr[Sym]; } @@ -143,16 +118,14 @@ // Print out the header line. int W = ELFT::Is64Bits ? 16 : 8; OS << left_justify("Address", W) << ' ' << left_justify("Size", W) - << " Align Out In File Symbol\n"; + << " Align Out In Symbol\n"; // Print out a mapfile. for (OutputSection *Sec : OutputSections) { writeHeader(OS, Sec->Addr, Sec->Size, Sec->Alignment); OS << Sec->Name << '\n'; - - StringRef CurSection; for (InputSection *IS : Sec->Sections) - writeInputSection(OS, IS, CurSection); + writeInputSection(OS, IS); } } Index: lld/trunk/test/ELF/map-file.s =================================================================== --- lld/trunk/test/ELF/map-file.s +++ lld/trunk/test/ELF/map-file.s @@ -26,36 +26,33 @@ local: .comm common,4,16 -// CHECK: Address Size Align Out In File Symbol +// CHECK: Address Size Align Out In Symbol // CHECK-NEXT: 0000000000200158 0000000000000030 8 .eh_frame -// CHECK-NEXT: 0000000000200158 0000000000000030 8 .eh_frame +// CHECK-NEXT: 0000000000200158 0000000000000030 8 :(.eh_frame) // CHECK-NEXT: 0000000000201000 0000000000000015 4 .text -// CHECK-NEXT: 0000000000201000 000000000000000e 4 .text -// CHECK-NEXT: 0000000000201000 000000000000000e 4 {{.*}}{{/|\\}}map-file.s.tmp1.o -// CHECK-NEXT: 0000000000201000 0000000000000000 0 _start -// CHECK-NEXT: 0000000000201005 0000000000000000 0 f(int) -// CHECK-NEXT: 000000000020100e 0000000000000000 0 local -// CHECK-NEXT: 0000000000201010 0000000000000002 4 {{.*}}{{/|\\}}map-file.s.tmp2.o -// CHECK-NEXT: 0000000000201010 0000000000000000 0 foo -// CHECK-NEXT: 0000000000201011 0000000000000000 0 bar -// CHECK-NEXT: 0000000000201012 0000000000000000 1 .text.zed -// CHECK-NEXT: 0000000000201012 0000000000000000 1 {{.*}}{{/|\\}}map-file.s.tmp2.o -// CHECK-NEXT: 0000000000201012 0000000000000000 0 zed -// CHECK-NEXT: 0000000000201014 0000000000000000 4 .text -// CHECK-NEXT: 0000000000201014 0000000000000000 4 {{.*}}{{/|\\}}map-file.s.tmp3.o -// CHECK-NEXT: 0000000000201014 0000000000000000 0 bah -// CHECK-NEXT: 0000000000201014 0000000000000001 4 {{.*}}{{/|\\}}map-file.s.tmp4.a(map-file.s.tmp4.o) -// CHECK-NEXT: 0000000000201014 0000000000000000 0 baz +// CHECK-NEXT: 0000000000201000 000000000000000e 4 {{.*}}{{/|\\}}map-file.s.tmp1.o:(.text) +// CHECK-NEXT: 0000000000201000 0000000000000000 0 _start +// CHECK-NEXT: 0000000000201005 0000000000000000 0 f(int) +// CHECK-NEXT: 000000000020100e 0000000000000000 0 local +// CHECK-NEXT: 0000000000201010 0000000000000002 4 {{.*}}{{/|\\}}map-file.s.tmp2.o:(.text) +// CHECK-NEXT: 0000000000201010 0000000000000000 0 foo +// CHECK-NEXT: 0000000000201011 0000000000000000 0 bar +// CHECK-NEXT: 0000000000201012 0000000000000000 1 {{.*}}{{/|\\}}map-file.s.tmp2.o:(.text.zed) +// CHECK-NEXT: 0000000000201012 0000000000000000 0 zed +// CHECK-NEXT: 0000000000201014 0000000000000000 4 {{.*}}{{/|\\}}map-file.s.tmp3.o:(.text) +// CHECK-NEXT: 0000000000201014 0000000000000000 0 bah +// CHECK-NEXT: 0000000000201014 0000000000000001 4 {{.*}}{{/|\\}}map-file.s.tmp4.a(map-file.s.tmp4.o):(.text) +// CHECK-NEXT: 0000000000201014 0000000000000000 0 baz // CHECK-NEXT: 0000000000202000 0000000000000004 16 .bss -// CHECK-NEXT: 0000000000202000 0000000000000004 16 COMMON +// CHECK-NEXT: 0000000000202000 0000000000000004 16 :(COMMON) // CHECK-NEXT: 0000000000000000 0000000000000008 1 .comment -// CHECK-NEXT: 0000000000000000 0000000000000008 1 .comment +// CHECK-NEXT: 0000000000000000 0000000000000008 1 :(.comment) // CHECK-NEXT: 0000000000000000 00000000000000f0 8 .symtab -// CHECK-NEXT: 0000000000000000 00000000000000f0 8 .symtab +// CHECK-NEXT: 0000000000000000 00000000000000f0 8 :(.symtab) // CHECK-NEXT: 0000000000000000 0000000000000039 1 .shstrtab -// CHECK-NEXT: 0000000000000000 0000000000000039 1 .shstrtab +// CHECK-NEXT: 0000000000000000 0000000000000039 1 :(.shstrtab) // CHECK-NEXT: 0000000000000000 000000000000002f 1 .strtab -// CHECK-NEXT: 0000000000000000 000000000000002f 1 .strtab +// CHECK-NEXT: 0000000000000000 000000000000002f 1 :(.strtab) // RUN: not ld.lld %t1.o %t2.o %t3.o %t4.a -o %t -Map=/ 2>&1 \ // RUN: | FileCheck -check-prefix=FAIL %s