diff options
| author | Rui Ueyama <ruiu@google.com> | 2017-04-28 20:38:27 +0000 |
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2017-04-28 20:38:27 +0000 |
| commit | 3012b371fd1163ef6d269209bfd8e8dfbae59379 (patch) | |
| tree | eb47b59591ac8139eb8a704fc62f5c8f79244c97 /lld/ELF/MapFile.cpp | |
| parent | 859f8b544a784798614cf9e0f0cdd99397b046fe (diff) | |
| download | bcm5719-llvm-3012b371fd1163ef6d269209bfd8e8dfbae59379.tar.gz bcm5719-llvm-3012b371fd1163ef6d269209bfd8e8dfbae59379.zip | |
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
Diffstat (limited to 'lld/ELF/MapFile.cpp')
| -rw-r--r-- | lld/ELF/MapFile.cpp | 49 |
1 files changed, 11 insertions, 38 deletions
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<OutputSection *> 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<const SectionBase *, SmallVector<DefinedRegular *, 4>> Symbols; @@ -98,7 +95,7 @@ template <class ELFT> PrettyPrinter<ELFT>::PrettyPrinter() { raw_string_ostream OS(Str[I]); writeHeader<ELFT>(OS, Syms[I]->getVA(), Syms[I]->template getSize<ELFT>(), 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 <class ELFT> PrettyPrinter<ELFT>::PrettyPrinter() { template <class ELFT> void PrettyPrinter<ELFT>::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<ELFT>(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<ELFT> *File = IS->template getFile<ELFT>(); - if (!File) - return; - writeHeader<ELFT>(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<ELFT>::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<ELFT>(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); } } |

