From 3012b371fd1163ef6d269209bfd8e8dfbae59379 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Fri, 28 Apr 2017 20:38:27 +0000 Subject: Change the format of the map file. Previously, we printed out input sections and input files in separate columns as shown below. Address Size Align Out In File Symbol 0000000000201000 0000000000000015 4 .text 0000000000201000 000000000000000e 4 .text 0000000000201000 000000000000000e 4 foo.o 0000000000201000 0000000000000000 0 _start 0000000000201005 0000000000000000 0 f(int) 000000000020100e 0000000000000000 0 local 0000000000201010 0000000000000002 4 bar.o 0000000000201010 0000000000000000 0 foo 0000000000201011 0000000000000000 0 bar This format doesn't make much sense because for each input section, there's always exactly one input file. This patch changes the format to this. Address Size Align Out In Symbol 0000000000201000 0000000000000015 4 .text 0000000000201000 000000000000000e 4 foo.o:(.text) 0000000000201000 0000000000000000 0 _start 0000000000201005 0000000000000000 0 f(int) 000000000020100e 0000000000000000 0 local 0000000000201010 0000000000000002 4 bar.o:(.text) 0000000000201010 0000000000000000 0 foo 0000000000201011 0000000000000000 0 bar Differential Revision: https://reviews.llvm.org/D32657 llvm-svn: 301683 --- lld/ELF/MapFile.cpp | 49 +++++++++++-------------------------------------- 1 file changed, 11 insertions(+), 38 deletions(-) (limited to 'lld/ELF/MapFile.cpp') diff --git a/lld/ELF/MapFile.cpp b/lld/ELF/MapFile.cpp index 9a346a18de3..30178633ef0 100644 --- a/lld/ELF/MapFile.cpp +++ b/lld/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 @@ public: 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 @@ template PrettyPrinter::PrettyPrinter() { 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 PrettyPrinter::PrettyPrinter() { 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 @@ void PrettyPrinter::print(raw_ostream &OS, // 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); } } -- cgit v1.2.3