mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-14 14:56:47 +00:00
Split writeMapFile2 to reduce indentation level.
llvm-svn: 291984
This commit is contained in:
parent
5fa43960f3
commit
db540ff057
@ -61,50 +61,58 @@ static void writeSymbolLine(raw_fd_ostream &OS, int Width, uint64_t Address,
|
|||||||
OS << ' ' << left_justify(Name, 7);
|
OS << ' ' << left_justify(Name, 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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>
|
template <class ELFT>
|
||||||
static void writeMapFile2(int FD,
|
static void writeMapFile2(int FD,
|
||||||
ArrayRef<OutputSectionBase *> OutputSections) {
|
ArrayRef<OutputSectionBase *> OutputSections) {
|
||||||
typedef typename ELFT::uint uintX_t;
|
|
||||||
raw_fd_ostream OS(FD, true);
|
raw_fd_ostream OS(FD, true);
|
||||||
int Width = ELFT::Is64Bits ? 16 : 8;
|
int Width = ELFT::Is64Bits ? 16 : 8;
|
||||||
|
|
||||||
OS << left_justify("Address", Width) << ' ' << left_justify("Size", Width)
|
OS << left_justify("Address", Width) << ' ' << left_justify("Size", Width)
|
||||||
<< ' ' << left_justify("Align", 5) << ' ' << left_justify("Out", 7) << ' '
|
<< ' ' << left_justify("Align", 5) << ' ' << left_justify("Out", 7) << ' '
|
||||||
<< left_justify("In", 7) << ' ' << left_justify("File", 7) << " Symbol\n";
|
<< left_justify("In", 7) << ' ' << left_justify("File", 7) << " Symbol\n";
|
||||||
|
|
||||||
for (OutputSectionBase *Sec : OutputSections) {
|
for (OutputSectionBase *Sec : OutputSections) {
|
||||||
uintX_t VA = Sec->Addr;
|
writeOutSecLine(OS, Width, Sec->Addr, Sec->Size, Sec->Addralign,
|
||||||
writeOutSecLine(OS, Width, VA, Sec->Size, Sec->Addralign, Sec->getName());
|
Sec->getName());
|
||||||
OS << '\n';
|
OS << '\n';
|
||||||
|
|
||||||
StringRef PrevName = "";
|
StringRef PrevName = "";
|
||||||
Sec->forEachInputSection([&](InputSectionData *S) {
|
Sec->forEachInputSection([&](InputSectionData *S) {
|
||||||
const auto *IS = dyn_cast<InputSection<ELFT>>(S);
|
if (const auto *IS = dyn_cast<InputSection<ELFT>>(S))
|
||||||
if (!IS)
|
writeInputSection(OS, IS, PrevName);
|
||||||
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';
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user