Changeset View
Changeset View
Standalone View
Standalone View
llvm/tools/llvm-objdump/llvm-objdump.cpp
Show First 20 Lines • Show All 2,020 Lines • ▼ Show 20 Lines | static size_t getMaxSectionNameWidth(const ObjectFile &Obj) { | ||||
for (const SectionRef &Section : ToolSectionFilter(Obj)) { | for (const SectionRef &Section : ToolSectionFilter(Obj)) { | ||||
StringRef Name = unwrapOrError(Section.getName(), Obj.getFileName()); | StringRef Name = unwrapOrError(Section.getName(), Obj.getFileName()); | ||||
MaxWidth = std::max(MaxWidth, Name.size()); | MaxWidth = std::max(MaxWidth, Name.size()); | ||||
} | } | ||||
return MaxWidth; | return MaxWidth; | ||||
} | } | ||||
void objdump::printSectionHeaders(ObjectFile &Obj) { | void objdump::printSectionHeaders(ObjectFile &Obj) { | ||||
if (Obj.isELF() && Obj.sections().empty()) | |||||
createFakeELFSections(Obj); | |||||
size_t NameWidth = getMaxSectionNameWidth(Obj); | size_t NameWidth = getMaxSectionNameWidth(Obj); | ||||
size_t AddressWidth = 2 * Obj.getBytesInAddress(); | size_t AddressWidth = 2 * Obj.getBytesInAddress(); | ||||
bool HasLMAColumn = shouldDisplayLMA(Obj); | bool HasLMAColumn = shouldDisplayLMA(Obj); | ||||
outs() << "\nSections:\n"; | outs() << "\nSections:\n"; | ||||
if (HasLMAColumn) | if (HasLMAColumn) | ||||
outs() << "Idx " << left_justify("Name", NameWidth) << " Size " | outs() << "Idx " << left_justify("Name", NameWidth) << " Size " | ||||
<< left_justify("VMA", AddressWidth) << " " | << left_justify("VMA", AddressWidth) << " " | ||||
<< left_justify("LMA", AddressWidth) << " Type\n"; | << left_justify("LMA", AddressWidth) << " Type\n"; | ||||
else | else | ||||
outs() << "Idx " << left_justify("Name", NameWidth) << " Size " | outs() << "Idx " << left_justify("Name", NameWidth) << " Size " | ||||
<< left_justify("VMA", AddressWidth) << " Type\n"; | << left_justify("VMA", AddressWidth) << " Type\n"; | ||||
if (Obj.isELF() && Obj.sections().empty()) | |||||
createFakeELFSections(Obj); | |||||
uint64_t Idx; | uint64_t Idx; | ||||
for (const SectionRef &Section : ToolSectionFilter(Obj, &Idx)) { | for (const SectionRef &Section : ToolSectionFilter(Obj, &Idx)) { | ||||
StringRef Name = unwrapOrError(Section.getName(), Obj.getFileName()); | StringRef Name = unwrapOrError(Section.getName(), Obj.getFileName()); | ||||
uint64_t VMA = Section.getAddress(); | uint64_t VMA = Section.getAddress(); | ||||
if (shouldAdjustVA(Section)) | if (shouldAdjustVA(Section)) | ||||
VMA += AdjustVMA; | VMA += AdjustVMA; | ||||
uint64_t Size = Section.getSize(); | uint64_t Size = Section.getSize(); | ||||
▲ Show 20 Lines • Show All 928 Lines • Show Last 20 Lines |