summaryrefslogtreecommitdiffstats
path: root/lld/ELF/MapFile.cpp
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2017-01-14 00:37:28 +0000
committerRui Ueyama <ruiu@google.com>2017-01-14 00:37:28 +0000
commitdb540ff057b32ce8f1003f04d8262ed2181a4713 (patch)
tree001160dcfd2ffa7b7388d7c2f260ce6cd25966d0 /lld/ELF/MapFile.cpp
parent5fa43960f3b00a708ff8e69e93c7894441f4ce27 (diff)
downloadbcm5719-llvm-db540ff057b32ce8f1003f04d8262ed2181a4713.tar.gz
bcm5719-llvm-db540ff057b32ce8f1003f04d8262ed2181a4713.zip
Split writeMapFile2 to reduce indentation level.
llvm-svn: 291984
Diffstat (limited to 'lld/ELF/MapFile.cpp')
-rw-r--r--lld/ELF/MapFile.cpp72
1 files changed, 40 insertions, 32 deletions
diff --git a/lld/ELF/MapFile.cpp b/lld/ELF/MapFile.cpp
index 89d7f41f68c..16f4dfd9743 100644
--- a/lld/ELF/MapFile.cpp
+++ b/lld/ELF/MapFile.cpp
@@ -62,49 +62,57 @@ static void writeSymbolLine(raw_fd_ostream &OS, int Width, uint64_t Address,
}
template <class ELFT>
+static void writeInputSection(raw_fd_ostream &OS, const InputSection<ELFT> *IS,
+ StringRef &PrevName) {
+ int Width = ELFT::Is64Bits ? 16 : 8;
+ StringRef Name = IS->Name;
+ if (Name != PrevName) {
+ writeInSecLine(OS, Width, IS->OutSec->Addr + IS->OutSecOff, IS->getSize(),
+ IS->Alignment, Name);
+ OS << '\n';
+ PrevName = Name;
+ }
+
+ elf::ObjectFile<ELFT> *File = IS->getFile();
+ if (!File)
+ return;
+ writeFileLine(OS, Width, IS->OutSec->Addr + IS->OutSecOff, IS->getSize(),
+ IS->Alignment, toString(File));
+ OS << '\n';
+
+ for (SymbolBody *Sym : File->getSymbols()) {
+ auto *DR = dyn_cast<DefinedRegular<ELFT>>(Sym);
+ if (!DR)
+ continue;
+ if (DR->Section != IS)
+ continue;
+ if (DR->isSection())
+ continue;
+ writeSymbolLine(OS, Width, Sym->getVA<ELFT>(), Sym->getSize<ELFT>(),
+ toString(*Sym));
+ OS << '\n';
+ }
+}
+
+template <class ELFT>
static void writeMapFile2(int FD,
ArrayRef<OutputSectionBase *> OutputSections) {
- typedef typename ELFT::uint uintX_t;
raw_fd_ostream OS(FD, true);
int Width = ELFT::Is64Bits ? 16 : 8;
+
OS << left_justify("Address", Width) << ' ' << left_justify("Size", Width)
<< ' ' << left_justify("Align", 5) << ' ' << left_justify("Out", 7) << ' '
<< left_justify("In", 7) << ' ' << left_justify("File", 7) << " Symbol\n";
+
for (OutputSectionBase *Sec : OutputSections) {
- uintX_t VA = Sec->Addr;
- writeOutSecLine(OS, Width, VA, Sec->Size, Sec->Addralign, Sec->getName());
+ writeOutSecLine(OS, Width, Sec->Addr, Sec->Size, Sec->Addralign,
+ Sec->getName());
OS << '\n';
+
StringRef PrevName = "";
Sec->forEachInputSection([&](InputSectionData *S) {
- const auto *IS = dyn_cast<InputSection<ELFT>>(S);
- if (!IS)
- return;
- StringRef Name = IS->Name;
- if (Name != PrevName) {
- writeInSecLine(OS, Width, VA + IS->OutSecOff, IS->getSize(),
- IS->Alignment, Name);
- OS << '\n';
- PrevName = Name;
- }
- elf::ObjectFile<ELFT> *File = IS->getFile();
- if (!File)
- return;
- writeFileLine(OS, Width, VA + IS->OutSecOff, IS->getSize(), IS->Alignment,
- toString(File));
- OS << '\n';
- ArrayRef<SymbolBody *> Syms = File->getSymbols();
- for (SymbolBody *Sym : Syms) {
- auto *DR = dyn_cast<DefinedRegular<ELFT>>(Sym);
- if (!DR)
- continue;
- if (DR->Section != IS)
- continue;
- if (DR->isSection())
- continue;
- writeSymbolLine(OS, Width, Sym->getVA<ELFT>(), Sym->getSize<ELFT>(),
- toString(*Sym));
- OS << '\n';
- }
+ if (const auto *IS = dyn_cast<InputSection<ELFT>>(S))
+ writeInputSection(OS, IS, PrevName);
});
}
}
OpenPOWER on IntegriCloud