forked from OSchip/llvm-project
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
This commit is contained in:
parent
859f8b544a
commit
3012b371fd
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,36 +26,33 @@ bar:
|
|||
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 <internal>:(.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 <internal>:(COMMON)
|
||||
// CHECK-NEXT: 0000000000000000 0000000000000008 1 .comment
|
||||
// CHECK-NEXT: 0000000000000000 0000000000000008 1 .comment
|
||||
// CHECK-NEXT: 0000000000000000 0000000000000008 1 <internal>:(.comment)
|
||||
// CHECK-NEXT: 0000000000000000 00000000000000f0 8 .symtab
|
||||
// CHECK-NEXT: 0000000000000000 00000000000000f0 8 .symtab
|
||||
// CHECK-NEXT: 0000000000000000 00000000000000f0 8 <internal>:(.symtab)
|
||||
// CHECK-NEXT: 0000000000000000 0000000000000039 1 .shstrtab
|
||||
// CHECK-NEXT: 0000000000000000 0000000000000039 1 .shstrtab
|
||||
// CHECK-NEXT: 0000000000000000 0000000000000039 1 <internal>:(.shstrtab)
|
||||
// CHECK-NEXT: 0000000000000000 000000000000002f 1 .strtab
|
||||
// CHECK-NEXT: 0000000000000000 000000000000002f 1 .strtab
|
||||
// CHECK-NEXT: 0000000000000000 000000000000002f 1 <internal>:(.strtab)
|
||||
|
||||
// RUN: not ld.lld %t1.o %t2.o %t3.o %t4.a -o %t -Map=/ 2>&1 \
|
||||
// RUN: | FileCheck -check-prefix=FAIL %s
|
||||
|
|
Loading…
Reference in New Issue