summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2019-01-15 09:19:18 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2019-01-15 09:19:18 +0000
commit9e327827d37a9d18d516fe7a027f373b01cac407 (patch)
treee12f2da631d31a58b9425ae907ffa0b583622705
parent2e9fc8dcaa2624192c7537194b4eaa6f53293bbc (diff)
[llvm-objdump] - Cleanup the code. NFCI.
This is a cosmetic cleanup for the llvm-objdump code. This patch: * Renames things to match the official LLVM code style (lower case -> upper case). * Removes few obviously excessive variables. * Moves a few lines closer to the place of use, reorders the code a bit to simplify it, to avoid doing excessive returns and to avoid using 'else` after returns. I focused only on a llvm-objdump.h/llvm-objdump.cpp files. Few changes in the MachODump.cpp and COFFDump.cpp are a result of llvm-objdump.h modification. Differential revision: https://reviews.llvm.org/D56637
-rw-r--r--llvm/tools/llvm-objdump/COFFDump.cpp2
-rw-r--r--llvm/tools/llvm-objdump/MachODump.cpp12
-rw-r--r--llvm/tools/llvm-objdump/llvm-objdump.cpp528
-rw-r--r--llvm/tools/llvm-objdump/llvm-objdump.h56
4 files changed, 285 insertions, 313 deletions
diff --git a/llvm/tools/llvm-objdump/COFFDump.cpp b/llvm/tools/llvm-objdump/COFFDump.cpp
index a7ee49535d6..55607ec299b 100644
--- a/llvm/tools/llvm-objdump/COFFDump.cpp
+++ b/llvm/tools/llvm-objdump/COFFDump.cpp
@@ -455,7 +455,7 @@ static bool getPDataSection(const COFFObjectFile *Obj,
Rels.push_back(Reloc);
// Sort relocations by address.
- llvm::sort(Rels, RelocAddressLess);
+ llvm::sort(Rels, isRelocAddressLess);
ArrayRef<uint8_t> Contents;
error(Obj->getSectionContents(Pdata, Contents));
diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp
index 397573e2a48..c8707ac1183 100644
--- a/llvm/tools/llvm-objdump/MachODump.cpp
+++ b/llvm/tools/llvm-objdump/MachODump.cpp
@@ -1627,9 +1627,9 @@ static void ProcessMachO(StringRef Name, MachOObjectFile *MachOOF,
if (Relocations)
PrintRelocations(MachOOF, !NonVerbose);
if (SectionHeaders)
- PrintSectionHeaders(MachOOF);
+ printSectionHeaders(MachOOF);
if (SectionContents)
- PrintSectionContents(MachOOF);
+ printSectionContents(MachOOF);
if (!FilterSections.empty())
DumpSectionContents(FileName, MachOOF, !NonVerbose);
if (InfoPlist)
@@ -1639,7 +1639,7 @@ static void ProcessMachO(StringRef Name, MachOObjectFile *MachOOF,
if (DylibId)
PrintDylibs(MachOOF, true);
if (SymbolTable)
- PrintSymbolTable(MachOOF, ArchiveName, ArchitectureName);
+ printSymbolTable(MachOOF, ArchiveName, ArchitectureName);
if (UnwindInfo)
printMachOUnwindInfo(MachOOF);
if (PrivateHeaders) {
@@ -1959,7 +1959,7 @@ static bool ValidateArchFlags() {
// -arch flags selecting just those slices as specified by them and also parses
// archive files. Then for each individual Mach-O file ProcessMachO() is
// called to process the file based on the command line options.
-void llvm::ParseInputMachO(StringRef Filename) {
+void llvm::parseInputMachO(StringRef Filename) {
if (!ValidateArchFlags())
return;
@@ -1998,7 +1998,7 @@ void llvm::ParseInputMachO(StringRef Filename) {
return;
}
if (MachOUniversalBinary *UB = dyn_cast<MachOUniversalBinary>(&Bin)) {
- ParseInputMachO(UB);
+ parseInputMachO(UB);
return;
}
if (ObjectFile *O = dyn_cast<ObjectFile>(&Bin)) {
@@ -2015,7 +2015,7 @@ void llvm::ParseInputMachO(StringRef Filename) {
llvm_unreachable("Input object can't be invalid at this point");
}
-void llvm::ParseInputMachO(MachOUniversalBinary *UB) {
+void llvm::parseInputMachO(MachOUniversalBinary *UB) {
if (!ValidateArchFlags())
return;
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 64de29c4e11..5ce67cdf648 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -430,18 +430,16 @@ static const Target *getTarget(const ObjectFile *Obj = nullptr) {
// Figure out the target triple.
llvm::Triple TheTriple("unknown-unknown-unknown");
if (TripleName.empty()) {
- if (Obj) {
+ if (Obj)
TheTriple = Obj->makeTriple();
- }
} else {
TheTriple.setTriple(Triple::normalize(TripleName));
// Use the triple, but also try to combine with ARM build attributes.
if (Obj) {
auto Arch = Obj->getArch();
- if (Arch == Triple::arm || Arch == Triple::armeb) {
+ if (Arch == Triple::arm || Arch == Triple::armeb)
Obj->setARMSubArch(TheTriple);
- }
}
}
@@ -461,8 +459,8 @@ static const Target *getTarget(const ObjectFile *Obj = nullptr) {
return TheTarget;
}
-bool llvm::RelocAddressLess(RelocationRef a, RelocationRef b) {
- return a.getOffset() < b.getOffset();
+bool llvm::isRelocAddressLess(RelocationRef A, RelocationRef B) {
+ return A.getOffset() < B.getOffset();
}
static std::string demangle(StringRef Name) {
@@ -484,14 +482,12 @@ template <class ELFT>
static std::error_code getRelocationValueString(const ELFObjectFile<ELFT> *Obj,
const RelocationRef &RelRef,
SmallVectorImpl<char> &Result) {
- DataRefImpl Rel = RelRef.getRawDataRefImpl();
-
typedef typename ELFObjectFile<ELFT>::Elf_Sym Elf_Sym;
typedef typename ELFObjectFile<ELFT>::Elf_Shdr Elf_Shdr;
typedef typename ELFObjectFile<ELFT>::Elf_Rela Elf_Rela;
const ELFFile<ELFT> &EF = *Obj->getELFFile();
-
+ DataRefImpl Rel = RelRef.getRawDataRefImpl();
auto SecOrErr = EF.getSection(Rel.d.a);
if (!SecOrErr)
return errorToErrorCode(SecOrErr.takeError());
@@ -509,11 +505,11 @@ static std::error_code getRelocationValueString(const ELFObjectFile<ELFT> *Obj,
if (!StrTabOrErr)
return errorToErrorCode(StrTabOrErr.takeError());
StringRef StrTab = *StrTabOrErr;
- int64_t addend = 0;
+ int64_t Addend = 0;
// If there is no Symbol associated with the relocation, we set the undef
// boolean value to 'true'. This will prevent us from calling functions that
// requires the relocation to be associated with a symbol.
- bool undef = false;
+ bool Undef = false;
switch (Sec->sh_type) {
default:
return object_error::parse_failed;
@@ -523,13 +519,13 @@ static std::error_code getRelocationValueString(const ELFObjectFile<ELFT> *Obj,
}
case ELF::SHT_RELA: {
const Elf_Rela *ERela = Obj->getRela(Rel);
- addend = ERela->r_addend;
- undef = ERela->getSymbol(false) == 0;
+ Addend = ERela->r_addend;
+ Undef = ERela->getSymbol(false) == 0;
break;
}
}
std::string Target;
- if (!undef) {
+ if (!Undef) {
symbol_iterator SI = RelRef.getSymbol();
const Elf_Sym *symb = Obj->getSymbol(SI->getRawDataRefImpl());
if (symb->getType() == ELF::STT_SECTION) {
@@ -555,13 +551,13 @@ static std::error_code getRelocationValueString(const ELFObjectFile<ELFT> *Obj,
// Default scheme is to print Target, as well as "+ <addend>" for nonzero
// addend. Should be acceptable for all normal purposes.
- std::string fmtbuf;
- raw_string_ostream fmt(fmtbuf);
- fmt << Target;
- if (addend != 0)
- fmt << (addend < 0 ? "" : "+") << addend;
- fmt.flush();
- Result.append(fmtbuf.begin(), fmtbuf.end());
+ std::string FmtBuf;
+ raw_string_ostream Fmt(FmtBuf);
+ Fmt << Target;
+ if (Addend != 0)
+ Fmt << (Addend < 0 ? "" : "+") << Addend;
+ Fmt.flush();
+ Result.append(FmtBuf.begin(), FmtBuf.end());
return std::error_code();
}
@@ -592,18 +588,15 @@ static std::error_code getRelocationValueString(const COFFObjectFile *Obj,
static void printRelocationTargetName(const MachOObjectFile *O,
const MachO::any_relocation_info &RE,
- raw_string_ostream &fmt) {
- bool IsScattered = O->isRelocationScattered(RE);
-
+ raw_string_ostream &Fmt) {
// Target of a scattered relocation is an address. In the interest of
// generating pretty output, scan through the symbol table looking for a
// symbol that aligns with that address. If we find one, print it.
// Otherwise, we just print the hex address of the target.
- if (IsScattered) {
+ if (O->isRelocationScattered(RE)) {
uint32_t Val = O->getPlainRelocationSymbolNum(RE);
for (const SymbolRef &Symbol : O->symbols()) {
- std::error_code ec;
Expected<uint64_t> Addr = Symbol.getAddress();
if (!Addr)
report_error(O->getFileName(), Addr.takeError());
@@ -612,7 +605,7 @@ static void printRelocationTargetName(const MachOObjectFile *O,
Expected<StringRef> Name = Symbol.getName();
if (!Name)
report_error(O->getFileName(), Name.takeError());
- fmt << *Name;
+ Fmt << *Name;
return;
}
@@ -627,11 +620,11 @@ static void printRelocationTargetName(const MachOObjectFile *O,
continue;
if ((ec = Section.getName(Name)))
report_error(O->getFileName(), ec);
- fmt << Name;
+ Fmt << Name;
return;
}
- fmt << format("0x%x", Val);
+ Fmt << format("0x%x", Val);
return;
}
@@ -640,9 +633,11 @@ static void printRelocationTargetName(const MachOObjectFile *O,
uint64_t Val = O->getPlainRelocationSymbolNum(RE);
if (O->getAnyRelocationType(RE) == MachO::ARM64_RELOC_ADDEND) {
- fmt << format("0x%0" PRIx64, Val);
+ Fmt << format("0x%0" PRIx64, Val);
return;
- } else if (isExtern) {
+ }
+
+ if (isExtern) {
symbol_iterator SI = O->symbol_begin();
advance(SI, Val);
Expected<StringRef> SOrErr = SI->getName();
@@ -653,21 +648,21 @@ static void printRelocationTargetName(const MachOObjectFile *O,
section_iterator SI = O->section_begin();
// Adjust for the fact that sections are 1-indexed.
if (Val == 0) {
- fmt << "0 (?,?)";
+ Fmt << "0 (?,?)";
return;
}
- uint32_t i = Val - 1;
- while (i != 0 && SI != O->section_end()) {
- i--;
+ uint32_t I = Val - 1;
+ while (I != 0 && SI != O->section_end()) {
+ --I;
advance(SI, 1);
}
if (SI == O->section_end())
- fmt << Val << " (?,?)";
+ Fmt << Val << " (?,?)";
else
SI->getName(S);
}
- fmt << S;
+ Fmt << S;
}
static std::error_code getRelocationValueString(const WasmObjectFile *Obj,
@@ -675,12 +670,12 @@ static std::error_code getRelocationValueString(const WasmObjectFile *Obj,
SmallVectorImpl<char> &Result) {
const wasm::WasmRelocation& Rel = Obj->getWasmRelocation(RelRef);
symbol_iterator SI = RelRef.getSymbol();
- std::string fmtbuf;
- raw_string_ostream fmt(fmtbuf);
+ std::string FmtBuf;
+ raw_string_ostream Fmt(FmtBuf);
if (SI == Obj->symbol_end()) {
// Not all wasm relocations have symbols associated with them.
// In particular R_WEBASSEMBLY_TYPE_INDEX_LEB.
- fmt << Rel.Index;
+ Fmt << Rel.Index;
} else {
Expected<StringRef> SymNameOrErr = SI->getName();
if (!SymNameOrErr)
@@ -688,9 +683,9 @@ static std::error_code getRelocationValueString(const WasmObjectFile *Obj,
StringRef SymName = *SymNameOrErr;
Result.append(SymName.begin(), SymName.end());
}
- fmt << (Rel.Addend < 0 ? "" : "+") << Rel.Addend;
- fmt.flush();
- Result.append(fmtbuf.begin(), fmtbuf.end());
+ Fmt << (Rel.Addend < 0 ? "" : "+") << Rel.Addend;
+ Fmt.flush();
+ Result.append(FmtBuf.begin(), FmtBuf.end());
return std::error_code();
}
@@ -702,8 +697,8 @@ static std::error_code getRelocationValueString(const MachOObjectFile *Obj,
unsigned Arch = Obj->getArch();
- std::string fmtbuf;
- raw_string_ostream fmt(fmtbuf);
+ std::string FmtBuf;
+ raw_string_ostream Fmt(FmtBuf);
unsigned Type = Obj->getAnyRelocationType(RE);
bool IsPCRel = Obj->getAnyRelocationPCRel(RE);
@@ -712,15 +707,13 @@ static std::error_code getRelocationValueString(const MachOObjectFile *Obj,
// X86_64 has entirely custom relocation types.
if (Arch == Triple::x86_64) {
- bool isPCRel = Obj->getAnyRelocationPCRel(RE);
-
switch (Type) {
case MachO::X86_64_RELOC_GOT_LOAD:
case MachO::X86_64_RELOC_GOT: {
- printRelocationTargetName(Obj, RE, fmt);
- fmt << "@GOT";
- if (isPCRel)
- fmt << "PCREL";
+ printRelocationTargetName(Obj, RE, Fmt);
+ Fmt << "@GOT";
+ if (IsPCRel)
+ Fmt << "PCREL";
break;
}
case MachO::X86_64_RELOC_SUBTRACTOR: {
@@ -738,31 +731,31 @@ static std::error_code getRelocationValueString(const MachOObjectFile *Obj,
// The X86_64_RELOC_UNSIGNED contains the minuend symbol;
// X86_64_RELOC_SUBTRACTOR contains the subtrahend.
- printRelocationTargetName(Obj, RENext, fmt);
- fmt << "-";
- printRelocationTargetName(Obj, RE, fmt);
+ printRelocationTargetName(Obj, RENext, Fmt);
+ Fmt << "-";
+ printRelocationTargetName(Obj, RE, Fmt);
break;
}
case MachO::X86_64_RELOC_TLV:
- printRelocationTargetName(Obj, RE, fmt);
- fmt << "@TLV";
- if (isPCRel)
- fmt << "P";
+ printRelocationTargetName(Obj, RE, Fmt);
+ Fmt << "@TLV";
+ if (IsPCRel)
+ Fmt << "P";
break;
case MachO::X86_64_RELOC_SIGNED_1:
- printRelocationTargetName(Obj, RE, fmt);
- fmt << "-1";
+ printRelocationTargetName(Obj, RE, Fmt);
+ Fmt << "-1";
break;
case MachO::X86_64_RELOC_SIGNED_2:
- printRelocationTargetName(Obj, RE, fmt);
- fmt << "-2";
+ printRelocationTargetName(Obj, RE, Fmt);
+ Fmt << "-2";
break;
case MachO::X86_64_RELOC_SIGNED_4:
- printRelocationTargetName(Obj, RE, fmt);
- fmt << "-4";
+ printRelocationTargetName(Obj, RE, Fmt);
+ Fmt << "-4";
break;
default:
- printRelocationTargetName(Obj, RE, fmt);
+ printRelocationTargetName(Obj, RE, Fmt);
break;
}
// X86 and ARM share some relocation types in common.
@@ -785,9 +778,9 @@ static std::error_code getRelocationValueString(const MachOObjectFile *Obj,
report_error(Obj->getFileName(), "Expected GENERIC_RELOC_PAIR after "
"GENERIC_RELOC_SECTDIFF.");
- printRelocationTargetName(Obj, RE, fmt);
- fmt << "-";
- printRelocationTargetName(Obj, RENext, fmt);
+ printRelocationTargetName(Obj, RE, Fmt);
+ Fmt << "-";
+ printRelocationTargetName(Obj, RENext, Fmt);
break;
}
}
@@ -806,20 +799,20 @@ static std::error_code getRelocationValueString(const MachOObjectFile *Obj,
report_error(Obj->getFileName(), "Expected GENERIC_RELOC_PAIR after "
"GENERIC_RELOC_LOCAL_SECTDIFF.");
- printRelocationTargetName(Obj, RE, fmt);
- fmt << "-";
- printRelocationTargetName(Obj, RENext, fmt);
+ printRelocationTargetName(Obj, RE, Fmt);
+ Fmt << "-";
+ printRelocationTargetName(Obj, RENext, Fmt);
break;
}
case MachO::GENERIC_RELOC_TLV: {
- printRelocationTargetName(Obj, RE, fmt);
- fmt << "@TLV";
+ printRelocationTargetName(Obj, RE, Fmt);
+ Fmt << "@TLV";
if (IsPCRel)
- fmt << "P";
+ Fmt << "P";
break;
}
default:
- printRelocationTargetName(Obj, RE, fmt);
+ printRelocationTargetName(Obj, RE, Fmt);
}
} else { // ARM-specific relocations
switch (Type) {
@@ -830,10 +823,10 @@ static std::error_code getRelocationValueString(const MachOObjectFile *Obj,
bool isUpper = (Obj->getAnyRelocationLength(RE) & 0x1) == 1;
if (isUpper)
- fmt << ":upper16:(";
+ Fmt << ":upper16:(";
else
- fmt << ":lower16:(";
- printRelocationTargetName(Obj, RE, fmt);
+ Fmt << ":lower16:(";
+ printRelocationTargetName(Obj, RE, Fmt);
DataRefImpl RelNext = Rel;
Obj->moveRelocationNext(RelNext);
@@ -854,21 +847,21 @@ static std::error_code getRelocationValueString(const MachOObjectFile *Obj,
// ARM_RELOC_HALF_SECTDIFF encodes the second section in the
// symbol/section pointer of the follow-on relocation.
if (Type == MachO::ARM_RELOC_HALF_SECTDIFF) {
- fmt << "-";
- printRelocationTargetName(Obj, RENext, fmt);
+ Fmt << "-";
+ printRelocationTargetName(Obj, RENext, Fmt);
}
- fmt << ")";
+ Fmt << ")";
break;
}
- default: { printRelocationTargetName(Obj, RE, fmt); }
+ default: { printRelocationTargetName(Obj, RE, Fmt); }
}
}
} else
- printRelocationTargetName(Obj, RE, fmt);
+ printRelocationTargetName(Obj, RE, Fmt);
- fmt.flush();
- Result.append(fmtbuf.begin(), fmtbuf.end());
+ Fmt.flush();
+ Result.append(FmtBuf.begin(), FmtBuf.end());
return std::error_code();
}
@@ -890,8 +883,7 @@ static std::error_code getRelocationValueString(const RelocationRef &Rel,
/// relocations, usually because it is the trailing part of a multipart
/// relocation that will be printed as part of the leading relocation.
static bool getHidden(RelocationRef RelRef) {
- const ObjectFile *Obj = RelRef.getObject();
- auto *MachO = dyn_cast<MachOObjectFile>(Obj);
+ auto *MachO = dyn_cast<MachOObjectFile>(RelRef.getObject());
if (!MachO)
return false;
@@ -901,10 +893,10 @@ static bool getHidden(RelocationRef RelRef) {
// On arches that use the generic relocations, GENERIC_RELOC_PAIR
// is always hidden.
- if (Arch == Triple::x86 || Arch == Triple::arm || Arch == Triple::ppc) {
- if (Type == MachO::GENERIC_RELOC_PAIR)
- return true;
- } else if (Arch == Triple::x86_64) {
+ if (Arch == Triple::x86 || Arch == Triple::arm || Arch == Triple::ppc)
+ return Type == MachO::GENERIC_RELOC_PAIR;
+
+ if (Arch == Triple::x86_64) {
// On x86_64, X86_64_RELOC_UNSIGNED is hidden only when it follows
// an X86_64_RELOC_SUBTRACTOR.
if (Type == MachO::X86_64_RELOC_UNSIGNED && Rel.d.a > 0) {
@@ -1079,27 +1071,27 @@ public:
auto Preamble = " { ";
auto Separator = "";
StringRef Fmt = "\t\t\t%08" PRIx64 ": ";
- std::vector<RelocationRef>::const_iterator rel_cur = Rels->begin();
- std::vector<RelocationRef>::const_iterator rel_end = Rels->end();
+ std::vector<RelocationRef>::const_iterator RelCur = Rels->begin();
+ std::vector<RelocationRef>::const_iterator RelEnd = Rels->end();
// Hexagon's packets require relocations to be inline rather than
// clustered at the end of the packet.
auto PrintReloc = [&]() -> void {
- while ((rel_cur != rel_end) && (rel_cur->getOffset() <= Address)) {
- if (rel_cur->getOffset() == Address) {
- SmallString<16> name;
- SmallString<32> val;
- rel_cur->getTypeName(name);
- error(getRelocationValueString(*rel_cur, val));
- OS << Separator << format(Fmt.data(), Address) << name << "\t" << val
+ while ((RelCur != RelEnd) && (RelCur->getOffset() <= Address)) {
+ if (RelCur->getOffset() == Address) {
+ SmallString<16> Name;
+ SmallString<32> Val;
+ RelCur->getTypeName(Name);
+ error(getRelocationValueString(*RelCur, Val));
+ OS << Separator << format(Fmt.data(), Address) << Name << "\t" << Val
<< "\n";
return;
}
- rel_cur++;
+ ++RelCur;
}
};
- while(!HeadTail.first.empty()) {
+ while (!HeadTail.first.empty()) {
OS << Separator;
Separator = "\n";
if (SP && (PrintSource || PrintLines))
@@ -1109,7 +1101,7 @@ public:
Preamble = " ";
StringRef Inst;
auto Duplex = HeadTail.first.split('\v');
- if(!Duplex.second.empty()){
+ if (!Duplex.second.empty()) {
OS << Duplex.first;
OS << "; ";
Inst = Duplex.second;
@@ -1241,7 +1233,6 @@ addDynamicElfSymbols(const ELFObjectFile<ELFT> *Obj,
Expected<uint64_t> AddressOrErr = Symbol.getAddress();
if (!AddressOrErr)
report_error(Obj->getFileName(), AddressOrErr.takeError());
- uint64_t Address = *AddressOrErr;
Expected<StringRef> Name = Symbol.getName();
if (!Name)
@@ -1256,7 +1247,7 @@ addDynamicElfSymbols(const ELFObjectFile<ELFT> *Obj,
if (SecI == Obj->section_end())
continue;
- AllSymbols[*SecI].emplace_back(Address, *Name, SymbolType);
+ AllSymbols[*SecI].emplace_back(*AddressOrErr, *Name, SymbolType);
}
}
@@ -1292,7 +1283,6 @@ static void addPltEntries(const ObjectFile *Obj,
if (auto *ElfObj = dyn_cast<ELFObjectFileBase>(Obj)) {
for (auto PltEntry : ElfObj->getPltAddresses()) {
SymbolRef Symbol(PltEntry.first, ElfObj);
-
uint8_t SymbolType = getElfSymbolType(Obj, Symbol);
Expected<StringRef> NameOrErr = Symbol.getName();
@@ -1330,7 +1320,7 @@ static size_t countSkippableZeroBytes(ArrayRef<uint8_t> Buf) {
return N & ~0x3;
}
-static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
+static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
if (StartAddress > StopAddress)
error("Start address should be less than stop address");
@@ -1338,10 +1328,9 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
// Package up features to be passed to target/subtarget
SubtargetFeatures Features = Obj->getFeatures();
- if (!MAttrs.empty()) {
- for (unsigned i = 0; i != MAttrs.size(); ++i)
- Features.AddFeature(MAttrs[i]);
- }
+ if (!MAttrs.empty())
+ for (unsigned I = 0; I != MAttrs.size(); ++I)
+ Features.AddFeature(MAttrs[I]);
std::unique_ptr<const MCRegisterInfo> MRI(
TheTarget->createMCRegInfo(TripleName));
@@ -1536,7 +1525,7 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
}
// Sort relocations by address.
- llvm::sort(Rels, RelocAddressLess);
+ llvm::sort(Rels, isRelocAddressLess);
StringRef SegmentName = "";
if (const MachOObjectFile *MachO = dyn_cast<const MachOObjectFile>(Obj)) {
@@ -1566,15 +1555,16 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
uint64_t Index;
bool PrintedSection = false;
- std::vector<RelocationRef>::const_iterator rel_cur = Rels.begin();
- std::vector<RelocationRef>::const_iterator rel_end = Rels.end();
+ std::vector<RelocationRef>::const_iterator RelCur = Rels.begin();
+ std::vector<RelocationRef>::const_iterator RelEnd = Rels.end();
// Disassemble symbol by symbol.
- for (unsigned si = 0, se = Symbols.size(); si != se; ++si) {
- uint64_t Start = std::get<0>(Symbols[si]) - SectionAddr;
+ for (unsigned SI = 0, SE = Symbols.size(); SI != SE; ++SI) {
+ uint64_t Start = std::get<0>(Symbols[SI]) - SectionAddr;
// The end is either the section end or the beginning of the next
// symbol.
- uint64_t End =
- (si == se - 1) ? SectSize : std::get<0>(Symbols[si + 1]) - SectionAddr;
+ uint64_t End = (SI == SE - 1)
+ ? SectSize
+ : std::get<0>(Symbols[SI + 1]) - SectionAddr;
// Don't try to disassemble beyond the end of section contents.
if (End > SectSize)
End = SectSize;
@@ -1591,7 +1581,7 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
/// Skip if user requested specific symbols and this is not in the list
if (!DisasmFuncsSet.empty() &&
- !DisasmFuncsSet.count(std::get<1>(Symbols[si])))
+ !DisasmFuncsSet.count(std::get<1>(Symbols[SI])))
continue;
if (!PrintedSection) {
@@ -1607,12 +1597,12 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
End = StopAddress - SectionAddr;
if (Obj->isELF() && Obj->getArch() == Triple::amdgcn) {
- if (std::get<2>(Symbols[si]) == ELF::STT_AMDGPU_HSA_KERNEL) {
+ if (std::get<2>(Symbols[SI]) == ELF::STT_AMDGPU_HSA_KERNEL) {
// skip amd_kernel_code_t at the begining of kernel symbol (256 bytes)
Start += 256;
}
- if (si == se - 1 ||
- std::get<2>(Symbols[si + 1]) == ELF::STT_AMDGPU_HSA_KERNEL) {
+ if (SI == SE - 1 ||
+ std::get<2>(Symbols[SI + 1]) == ELF::STT_AMDGPU_HSA_KERNEL) {
// cut trailing zeroes at the end of kernel
// cut up to 256 bytes
const uint64_t EndAlign = 256;
@@ -1627,7 +1617,7 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
if (!NoLeadingAddr)
outs() << format("%016" PRIx64 " ", SectionAddr + Start);
- StringRef SymbolName = std::get<1>(Symbols[si]);
+ StringRef SymbolName = std::get<1>(Symbols[SI]);
if (Demangle)
outs() << demangle(SymbolName) << ":\n";
else
@@ -1659,7 +1649,7 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
// same section. We rely on the markers introduced to
// understand what we need to dump. If the data marker is within a
// function, it is denoted as a word/short etc
- if (isArmElf(Obj) && std::get<2>(Symbols[si]) != ELF::STT_OBJECT &&
+ if (isArmElf(Obj) && std::get<2>(Symbols[SI]) != ELF::STT_OBJECT &&
!DisassembleAll) {
uint64_t Stride = 0;
@@ -1723,7 +1713,7 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
// disassembling text (applicable all architectures),
// we are in a situation where we must print the data and not
// disassemble it.
- if (Obj->isELF() && std::get<2>(Symbols[si]) == ELF::STT_OBJECT &&
+ if (Obj->isELF() && std::get<2>(Symbols[SI]) == ELF::STT_OBJECT &&
!DisassembleAll && Section.isText()) {
// print out data up to 8 bytes at a time in hex and ascii
uint8_t AsciiData[9] = {'\0'};
@@ -1850,32 +1840,32 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
// Hexagon does this in pretty printer
if (Obj->getArch() != Triple::hexagon)
// Print relocation for instruction.
- while (rel_cur != rel_end) {
- bool hidden = getHidden(*rel_cur);
- uint64_t addr = rel_cur->getOffset();
- SmallString<16> name;
- SmallString<32> val;
+ while (RelCur != RelEnd) {
+ uint64_t Addr = RelCur->getOffset();
+ SmallString<16> Name;
+ SmallString<32> Val;
// If this relocation is hidden, skip it.
- if (hidden || ((SectionAddr + addr) < StartAddress)) {
- ++rel_cur;
+ if (getHidden(*RelCur) || ((SectionAddr + Addr) < StartAddress)) {
+ ++RelCur;
continue;
}
// Stop when rel_cur's address is past the current instruction.
- if (addr >= Index + Size) break;
- rel_cur->getTypeName(name);
- error(getRelocationValueString(*rel_cur, val));
- outs() << format(Fmt.data(), SectionAddr + addr) << name
- << "\t" << val << "\n";
- ++rel_cur;
+ if (Addr >= Index + Size)
+ break;
+ RelCur->getTypeName(Name);
+ error(getRelocationValueString(*RelCur, Val));
+ outs() << format(Fmt.data(), SectionAddr + Addr) << Name << "\t"
+ << Val << "\n";
+ ++RelCur;
}
}
}
}
}
-void llvm::PrintRelocations(const ObjectFile *Obj) {
+void llvm::printRelocations(const ObjectFile *Obj) {
StringRef Fmt = Obj->getBytesInAddress() > 4 ? "%016" PRIx64 :
"%08" PRIx64;
// Regular objdump doesn't print relocations in non-relocatable object
@@ -1886,61 +1876,57 @@ void llvm::PrintRelocations(const ObjectFile *Obj) {
for (const SectionRef &Section : ToolSectionFilter(*Obj)) {
if (Section.relocation_begin() == Section.relocation_end())
continue;
- StringRef secname;
- error(Section.getName(secname));
- outs() << "RELOCATION RECORDS FOR [" << secname << "]:\n";
+ StringRef SecName;
+ error(Section.getName(SecName));
+ outs() << "RELOCATION RECORDS FOR [" << SecName << "]:\n";
for (const RelocationRef &Reloc : Section.relocations()) {
- bool hidden = getHidden(Reloc);
- uint64_t address = Reloc.getOffset();
- SmallString<32> relocname;
- SmallString<32> valuestr;
- if (address < StartAddress || address > StopAddress || hidden)
+ uint64_t Address = Reloc.getOffset();
+ SmallString<32> RelocName;
+ SmallString<32> ValueStr;
+ if (Address < StartAddress || Address > StopAddress || getHidden(Reloc))
continue;
- Reloc.getTypeName(relocname);
- error(getRelocationValueString(Reloc, valuestr));
- outs() << format(Fmt.data(), address) << " " << relocname << " "
- << valuestr << "\n";
+ Reloc.getTypeName(RelocName);
+ error(getRelocationValueString(Reloc, ValueStr));
+ outs() << format(Fmt.data(), Address) << " " << RelocName << " "
+ << ValueStr << "\n";
}
outs() << "\n";
}
}
-void llvm::PrintDynamicRelocations(const ObjectFile *Obj) {
-
+void llvm::printDynamicRelocations(const ObjectFile *Obj) {
// For the moment, this option is for ELF only
if (!Obj->isELF())
return;
const auto *Elf = dyn_cast<ELFObjectFileBase>(Obj);
-
if (!Elf || Elf->getEType() != ELF::ET_DYN) {
error("not a dynamic object");
return;
}
- StringRef Fmt = Obj->getBytesInAddress() > 4 ? "%016" PRIx64 : "%08" PRIx64;
-
std::vector<SectionRef> DynRelSec = Obj->dynamic_relocation_sections();
if (DynRelSec.empty())
return;
outs() << "DYNAMIC RELOCATION RECORDS\n";
+ StringRef Fmt = Obj->getBytesInAddress() > 4 ? "%016" PRIx64 : "%08" PRIx64;
for (const SectionRef &Section : DynRelSec) {
if (Section.relocation_begin() == Section.relocation_end())
continue;
for (const RelocationRef &Reloc : Section.relocations()) {
- uint64_t address = Reloc.getOffset();
- SmallString<32> relocname;
- SmallString<32> valuestr;
- Reloc.getTypeName(relocname);
- error(getRelocationValueString(Reloc, valuestr));
- outs() << format(Fmt.data(), address) << " " << relocname << " "
- << valuestr << "\n";
+ uint64_t Address = Reloc.getOffset();
+ SmallString<32> RelocName;
+ SmallString<32> ValueStr;
+ Reloc.getTypeName(RelocName);
+ error(getRelocationValueString(Reloc, ValueStr));
+ outs() << format(Fmt.data(), Address) << " " << RelocName << " "
+ << ValueStr << "\n";
}
}
}
-void llvm::PrintSectionHeaders(const ObjectFile *Obj) {
+void llvm::printSectionHeaders(const ObjectFile *Obj) {
outs() << "Sections:\n"
"Idx Name Size Address Type\n";
for (const SectionRef &Section : ToolSectionFilter(*Obj)) {
@@ -1960,7 +1946,7 @@ void llvm::PrintSectionHeaders(const ObjectFile *Obj) {
outs() << "\n";
}
-void llvm::PrintSectionContents(const ObjectFile *Obj) {
+void llvm::printSectionContents(const ObjectFile *Obj) {
std::error_code EC;
for (const SectionRef &Section : ToolSectionFilter(*Obj)) {
StringRef Name;
@@ -1982,23 +1968,23 @@ void llvm::PrintSectionContents(const ObjectFile *Obj) {
error(Section.getContents(Contents));
// Dump out the content as hex and printable ascii characters.
- for (std::size_t addr = 0, end = Contents.size(); addr < end; addr += 16) {
- outs() << format(" %04" PRIx64 " ", BaseAddr + addr);
+ for (std::size_t Addr = 0, End = Contents.size(); Addr < End; Addr += 16) {
+ outs() << format(" %04" PRIx64 " ", BaseAddr + Addr);
// Dump line of hex.
- for (std::size_t i = 0; i < 16; ++i) {
- if (i != 0 && i % 4 == 0)
+ for (std::size_t I = 0; I < 16; ++I) {
+ if (I != 0 && I % 4 == 0)
outs() << ' ';
- if (addr + i < end)
- outs() << hexdigit((Contents[addr + i] >> 4) & 0xF, true)
- << hexdigit(Contents[addr + i] & 0xF, true);
+ if (Addr + I < End)
+ outs() << hexdigit((Contents[Addr + I] >> 4) & 0xF, true)
+ << hexdigit(Contents[Addr + I] & 0xF, true);
else
outs() << " ";
}
// Print ascii.
outs() << " ";
- for (std::size_t i = 0; i < 16 && addr + i < end; ++i) {
- if (isPrint(static_cast<unsigned char>(Contents[addr + i]) & 0xFF))
- outs() << Contents[addr + i];
+ for (std::size_t I = 0; I < 16 && Addr + I < End; ++I) {
+ if (isPrint(static_cast<unsigned char>(Contents[Addr + I]) & 0xFF))
+ outs() << Contents[Addr + I];
else
outs() << ".";
}
@@ -2007,47 +1993,47 @@ void llvm::PrintSectionContents(const ObjectFile *Obj) {
}
}
-void llvm::PrintSymbolTable(const ObjectFile *o, StringRef ArchiveName,
+void llvm::printSymbolTable(const ObjectFile *O, StringRef ArchiveName,
StringRef ArchitectureName) {
outs() << "SYMBOL TABLE:\n";
- if (const COFFObjectFile *coff = dyn_cast<const COFFObjectFile>(o)) {
- printCOFFSymbolTable(coff);
+ if (const COFFObjectFile *Coff = dyn_cast<const COFFObjectFile>(O)) {
+ printCOFFSymbolTable(Coff);
return;
}
- for (auto I = o->symbol_begin(), E = o->symbol_end(); I != E; ++I) {
+ for (auto I = O->symbol_begin(), E = O->symbol_end(); I != E; ++I) {
// Skip printing the special zero symbol when dumping an ELF file.
// This makes the output consistent with the GNU objdump.
- if (I == o->symbol_begin() && isa<ELFObjectFileBase>(o))
+ if (I == O->symbol_begin() && isa<ELFObjectFileBase>(O))
continue;
const SymbolRef &Symbol = *I;
Expected<uint64_t> AddressOrError = Symbol.getAddress();
if (!AddressOrError)
- report_error(ArchiveName, o->getFileName(), AddressOrError.takeError(),
+ report_error(ArchiveName, O->getFileName(), AddressOrError.takeError(),
ArchitectureName);
uint64_t Address = *AddressOrError;
if ((Address < StartAddress) || (Address > StopAddress))
continue;
Expected<SymbolRef::Type> TypeOrError = Symbol.getType();
if (!TypeOrError)
- report_error(ArchiveName, o->getFileName(), TypeOrError.takeError(),
+ report_error(ArchiveName, O->getFileName(), TypeOrError.takeError(),
ArchitectureName);
SymbolRef::Type Type = *TypeOrError;
uint32_t Flags = Symbol.getFlags();
Expected<section_iterator> SectionOrErr = Symbol.getSection();
if (!SectionOrErr)
- report_error(ArchiveName, o->getFileName(), SectionOrErr.takeError(),
+ report_error(ArchiveName, O->getFileName(), SectionOrErr.takeError(),
ArchitectureName);
section_iterator Section = *SectionOrErr;
StringRef Name;
- if (Type == SymbolRef::ST_Debug && Section != o->section_end()) {
+ if (Type == SymbolRef::ST_Debug && Section != O->section_end()) {
Section->getName(Name);
} else {
Expected<StringRef> NameOrErr = Symbol.getName();
if (!NameOrErr)
- report_error(ArchiveName, o->getFileName(), NameOrErr.takeError(),
+ report_error(ArchiveName, O->getFileName(), NameOrErr.takeError(),
ArchitectureName);
Name = *NameOrErr;
}
@@ -2071,7 +2057,7 @@ void llvm::PrintSymbolTable(const ObjectFile *o, StringRef ArchiveName,
else if (Type == SymbolRef::ST_Data)
FileFunc = 'O';
- const char *Fmt = o->getBytesInAddress() > 4 ? "%016" PRIx64 :
+ const char *Fmt = O->getBytesInAddress() > 4 ? "%016" PRIx64 :
"%08" PRIx64;
outs() << format(Fmt, Address) << " "
@@ -2087,11 +2073,11 @@ void llvm::PrintSymbolTable(const ObjectFile *o, StringRef ArchiveName,
outs() << "*ABS*";
} else if (Common) {
outs() << "*COM*";
- } else if (Section == o->section_end()) {
+ } else if (Section == O->section_end()) {
outs() << "*UND*";
} else {
if (const MachOObjectFile *MachO =
- dyn_cast<const MachOObjectFile>(o)) {
+ dyn_cast<const MachOObjectFile>(O)) {
DataRefImpl DR = Section->getRawDataRefImpl();
StringRef SegmentName = MachO->getSectionFinalSegmentName(DR);
outs() << SegmentName << ",";
@@ -2102,15 +2088,14 @@ void llvm::PrintSymbolTable(const ObjectFile *o, StringRef ArchiveName,
}
outs() << '\t';
- if (Common || isa<ELFObjectFileBase>(o)) {
+ if (Common || isa<ELFObjectFileBase>(O)) {
uint64_t Val =
Common ? Symbol.getAlignment() : ELFSymbolRef(Symbol).getSize();
outs() << format("\t %08" PRIx64 " ", Val);
}
- if (Hidden) {
+ if (Hidden)
outs() << ".hidden ";
- }
if (Demangle)
outs() << demangle(Name) << '\n';
@@ -2119,80 +2104,68 @@ void llvm::PrintSymbolTable(const ObjectFile *o, StringRef ArchiveName,
}
}
-static void PrintUnwindInfo(const ObjectFile *o) {
+static void printUnwindInfo(const ObjectFile *O) {
outs() << "Unwind info:\n\n";
- if (const COFFObjectFile *coff = dyn_cast<COFFObjectFile>(o)) {
- printCOFFUnwindInfo(coff);
- } else if (const MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o))
+ if (const COFFObjectFile *Coff = dyn_cast<COFFObjectFile>(O))
+ printCOFFUnwindInfo(Coff);
+ else if (const MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(O))
printMachOUnwindInfo(MachO);
- else {
+ else
// TODO: Extract DWARF dump tool to objdump.
WithColor::error(errs(), ToolName)
<< "This operation is only currently supported "
"for COFF and MachO object files.\n";
- return;
- }
}
void llvm::printExportsTrie(const ObjectFile *o) {
outs() << "Exports trie:\n";
if (const MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o))
printMachOExportsTrie(MachO);
- else {
+ else
WithColor::error(errs(), ToolName)
<< "This operation is only currently supported "
"for Mach-O executable files.\n";
- return;
- }
}
void llvm::printRebaseTable(ObjectFile *o) {
outs() << "Rebase table:\n";
if (MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o))
printMachORebaseTable(MachO);
- else {
+ else
WithColor::error(errs(), ToolName)
<< "This operation is only currently supported "
"for Mach-O executable files.\n";
- return;
- }
}
void llvm::printBindTable(ObjectFile *o) {
outs() << "Bind table:\n";
if (MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o))
printMachOBindTable(MachO);
- else {
+ else
WithColor::error(errs(), ToolName)
<< "This operation is only currently supported "
"for Mach-O executable files.\n";
- return;
- }
}
void llvm::printLazyBindTable(ObjectFile *o) {
outs() << "Lazy bind table:\n";
if (MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o))
printMachOLazyBindTable(MachO);
- else {
+ else
WithColor::error(errs(), ToolName)
<< "This operation is only currently supported "
"for Mach-O executable files.\n";
- return;
- }
}
void llvm::printWeakBindTable(ObjectFile *o) {
outs() << "Weak bind table:\n";
if (MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o))
printMachOWeakBindTable(MachO);
- else {
+ else
WithColor::error(errs(), ToolName)
<< "This operation is only currently supported "
"for Mach-O executable files.\n";
- return;
- }
}
/// Dump the raw contents of the __clangast section so the output can be piped
@@ -2230,7 +2203,7 @@ void llvm::printRawClangAST(const ObjectFile *Obj) {
}
static void printFaultMaps(const ObjectFile *Obj) {
- const char *FaultMapSectionName = nullptr;
+ StringRef FaultMapSectionName;
if (isa<ELFObjectFileBase>(Obj)) {
FaultMapSectionName = ".llvm_faultmaps";
@@ -2270,35 +2243,35 @@ static void printFaultMaps(const ObjectFile *Obj) {
outs() << FMP;
}
-static void printPrivateFileHeaders(const ObjectFile *o, bool onlyFirst) {
- if (o->isELF()) {
- printELFFileHeader(o);
- return printELFDynamicSection(o);
+static void printPrivateFileHeaders(const ObjectFile *O, bool OnlyFirst) {
+ if (O->isELF()) {
+ printELFFileHeader(O);
+ return printELFDynamicSection(O);
}
- if (o->isCOFF())
- return printCOFFFileHeader(o);
- if (o->isWasm())
- return printWasmFileHeader(o);
- if (o->isMachO()) {
- printMachOFileHeader(o);
- if (!onlyFirst)
- printMachOLoadCommands(o);
+ if (O->isCOFF())
+ return printCOFFFileHeader(O);
+ if (O->isWasm())
+ return printWasmFileHeader(O);
+ if (O->isMachO()) {
+ printMachOFileHeader(O);
+ if (!OnlyFirst)
+ printMachOLoadCommands(O);
return;
}
- report_error(o->getFileName(), "Invalid/Unsupported object file format");
+ report_error(O->getFileName(), "Invalid/Unsupported object file format");
}
-static void printFileHeaders(const ObjectFile *o) {
- if (!o->isELF() && !o->isCOFF())
- report_error(o->getFileName(), "Invalid/Unsupported object file format");
+static void printFileHeaders(const ObjectFile *O) {
+ if (!O->isELF() && !O->isCOFF())
+ report_error(O->getFileName(), "Invalid/Unsupported object file format");
- Triple::ArchType AT = o->getArch();
+ Triple::ArchType AT = O->getArch();
outs() << "architecture: " << Triple::getArchTypeName(AT) << "\n";
- Expected<uint64_t> StartAddrOrErr = o->getStartAddress();
+ Expected<uint64_t> StartAddrOrErr = O->getStartAddress();
if (!StartAddrOrErr)
- report_error(o->getFileName(), StartAddrOrErr.takeError());
+ report_error(O->getFileName(), StartAddrOrErr.takeError());
- StringRef Fmt = o->getBytesInAddress() > 4 ? "%016" PRIx64 : "%08" PRIx64;
+ StringRef Fmt = O->getBytesInAddress() > 4 ? "%016" PRIx64 : "%08" PRIx64;
uint64_t Address = StartAddrOrErr.get();
outs() << "start address: "
<< "0x" << format(Fmt.data(), Address) << "\n\n";
@@ -2368,55 +2341,55 @@ static void printArchiveChild(StringRef Filename, const Archive::Child &C) {
outs() << Name << "\n";
}
-static void DumpObject(ObjectFile *o, const Archive *a = nullptr,
- const Archive::Child *c = nullptr) {
- StringRef ArchiveName = a != nullptr ? a->getFileName() : "";
+static void dumpObject(ObjectFile *O, const Archive *A = nullptr,
+ const Archive::Child *C = nullptr) {
// Avoid other output when using a raw option.
if (!RawClangAST) {
outs() << '\n';
- if (a)
- outs() << a->getFileName() << "(" << o->getFileName() << ")";
+ if (A)
+ outs() << A->getFileName() << "(" << O->getFileName() << ")";
else
- outs() << o->getFileName();
- outs() << ":\tfile format " << o->getFileFormatName() << "\n\n";
+ outs() << O->getFileName();
+ outs() << ":\tfile format " << O->getFileFormatName() << "\n\n";
}
+ StringRef ArchiveName = A ? A->getFileName() : "";
if (FileHeaders)
- printFileHeaders(o);
- if (ArchiveHeaders && !MachOOpt && c)
- printArchiveChild(ArchiveName, *c);
+ printFileHeaders(O);
+ if (ArchiveHeaders && !MachOOpt && C)
+ printArchiveChild(ArchiveName, *C);
if (Disassemble)
- DisassembleObject(o, Relocations);
+ disassembleObject(O, Relocations);
if (Relocations && !Disassemble)
- PrintRelocations(o);
+ printRelocations(O);
if (DynamicRelocations)
- PrintDynamicRelocations(o);
+ printDynamicRelocations(O);
if (SectionHeaders)
- PrintSectionHeaders(o);
+ printSectionHeaders(O);
if (SectionContents)
- PrintSectionContents(o);
+ printSectionContents(O);
if (SymbolTable)
- PrintSymbolTable(o, ArchiveName);
+ printSymbolTable(O, ArchiveName);
if (UnwindInfo)
- PrintUnwindInfo(o);
+ printUnwindInfo(O);
if (PrivateHeaders || FirstPrivateHeader)
- printPrivateFileHeaders(o, FirstPrivateHeader);
+ printPrivateFileHeaders(O, FirstPrivateHeader);
if (ExportsTrie)
- printExportsTrie(o);
+ printExportsTrie(O);
if (Rebase)
- printRebaseTable(o);
+ printRebaseTable(O);
if (Bind)
- printBindTable(o);
+ printBindTable(O);
if (LazyBind)
- printLazyBindTable(o);
+ printLazyBindTable(O);
if (WeakBind)
- printWeakBindTable(o);
+ printWeakBindTable(O);
if (RawClangAST)
- printRawClangAST(o);
+ printRawClangAST(O);
if (PrintFaultMaps)
- printFaultMaps(o);
+ printFaultMaps(O);
if (DwarfDumpType != DIDT_Null) {
- std::unique_ptr<DIContext> DICtx = DWARFContext::create(*o);
+ std::unique_ptr<DIContext> DICtx = DWARFContext::create(*O);
// Dump the complete DWARF structure.
DIDumpOptions DumpOpts;
DumpOpts.DumpType = DwarfDumpType;
@@ -2424,7 +2397,7 @@ static void DumpObject(ObjectFile *o, const Archive *a = nullptr,
}
}
-static void DumpObject(const COFFImportFile *I, const Archive *A,
+static void dumpObject(const COFFImportFile *I, const Archive *A,
const Archive::Child *C = nullptr) {
StringRef ArchiveName = A ? A->getFileName() : "";
@@ -2442,34 +2415,33 @@ static void DumpObject(const COFFImportFile *I, const Archive *A,
}
/// Dump each object file in \a a;
-static void DumpArchive(const Archive *a) {
+static void dumpArchive(const Archive *A) {
Error Err = Error::success();
- for (auto &C : a->children(Err)) {
+ for (auto &C : A->children(Err)) {
Expected<std::unique_ptr<Binary>> ChildOrErr = C.getAsBinary();
if (!ChildOrErr) {
if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError()))
- report_error(a->getFileName(), C, std::move(E));
+ report_error(A->getFileName(), C, std::move(E));
continue;
}
- if (ObjectFile *o = dyn_cast<ObjectFile>(&*ChildOrErr.get()))
- DumpObject(o, a, &C);
+ if (ObjectFile *O = dyn_cast<ObjectFile>(&*ChildOrErr.get()))
+ dumpObject(O, A, &C);
else if (COFFImportFile *I = dyn_cast<COFFImportFile>(&*ChildOrErr.get()))
- DumpObject(I, a, &C);
+ dumpObject(I, A, &C);
else
- report_error(a->getFileName(), object_error::invalid_file_type);
+ report_error(A->getFileName(), object_error::invalid_file_type);
}
if (Err)
- report_error(a->getFileName(), std::move(Err));
+ report_error(A->getFileName(), std::move(Err));
}
/// Open file and figure out how to dump it.
-static void DumpInput(StringRef file) {
-
+static void dumpInput(StringRef file) {
// If we are using the Mach-O specific object file parser, then let it parse
// the file and process the command line options. So the -arch flags can
// be used to select specific slices, etc.
if (MachOOpt) {
- ParseInputMachO(file);
+ parseInputMachO(file);
return;
}
@@ -2479,12 +2451,12 @@ static void DumpInput(StringRef file) {
report_error(file, BinaryOrErr.takeError());
Binary &Binary = *BinaryOrErr.get().getBinary();
- if (Archive *a = dyn_cast<Archive>(&Binary))
- DumpArchive(a);
- else if (ObjectFile *o = dyn_cast<ObjectFile>(&Binary))
- DumpObject(o);
+ if (Archive *A = dyn_cast<Archive>(&Binary))
+ dumpArchive(A);
+ else if (ObjectFile *O = dyn_cast<ObjectFile>(&Binary))
+ dumpObject(O);
else if (MachOUniversalBinary *UB = dyn_cast<MachOUniversalBinary>(&Binary))
- ParseInputMachO(UB);
+ parseInputMachO(UB);
else
report_error(file, object_error::invalid_file_type);
}
@@ -2550,7 +2522,7 @@ int main(int argc, char **argv) {
DisasmFuncsSet.insert(DisassembleFunctions.begin(),
DisassembleFunctions.end());
- llvm::for_each(InputFilenames, DumpInput);
+ llvm::for_each(InputFilenames, dumpInput);
return EXIT_SUCCESS;
}
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.h b/llvm/tools/llvm-objdump/llvm-objdump.h
index 44ef14d7f69..fe2cb05fe22 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.h
+++ b/llvm/tools/llvm-objdump/llvm-objdump.h
@@ -70,35 +70,35 @@ extern cl::opt<DIDumpType> DwarfDumpType;
// Various helper functions.
void error(std::error_code ec);
-bool RelocAddressLess(object::RelocationRef a, object::RelocationRef b);
-void ParseInputMachO(StringRef Filename);
-void ParseInputMachO(object::MachOUniversalBinary *UB);
-void printCOFFUnwindInfo(const object::COFFObjectFile* o);
-void printMachOUnwindInfo(const object::MachOObjectFile* o);
-void printMachOExportsTrie(const object::MachOObjectFile* o);
-void printMachORebaseTable(object::MachOObjectFile* o);
-void printMachOBindTable(object::MachOObjectFile* o);
-void printMachOLazyBindTable(object::MachOObjectFile* o);
-void printMachOWeakBindTable(object::MachOObjectFile* o);
-void printELFFileHeader(const object::ObjectFile *o);
+bool isRelocAddressLess(object::RelocationRef A, object::RelocationRef B);
+void parseInputMachO(StringRef Filename);
+void parseInputMachO(object::MachOUniversalBinary *UB);
+void printCOFFUnwindInfo(const object::COFFObjectFile *O);
+void printMachOUnwindInfo(const object::MachOObjectFile *O);
+void printMachOExportsTrie(const object::MachOObjectFile *O);
+void printMachORebaseTable(object::MachOObjectFile *O);
+void printMachOBindTable(object::MachOObjectFile *O);
+void printMachOLazyBindTable(object::MachOObjectFile *O);
+void printMachOWeakBindTable(object::MachOObjectFile *O);
+void printELFFileHeader(const object::ObjectFile *O);
void printELFDynamicSection(const object::ObjectFile *Obj);
-void printCOFFFileHeader(const object::ObjectFile *o);
-void printCOFFSymbolTable(const object::COFFImportFile *i);
-void printCOFFSymbolTable(const object::COFFObjectFile *o);
-void printMachOFileHeader(const object::ObjectFile *o);
-void printMachOLoadCommands(const object::ObjectFile *o);
-void printWasmFileHeader(const object::ObjectFile *o);
-void printExportsTrie(const object::ObjectFile *o);
-void printRebaseTable(object::ObjectFile *o);
-void printBindTable(object::ObjectFile *o);
-void printLazyBindTable(object::ObjectFile *o);
-void printWeakBindTable(object::ObjectFile *o);
-void printRawClangAST(const object::ObjectFile *o);
-void PrintRelocations(const object::ObjectFile *o);
-void PrintDynamicRelocations(const object::ObjectFile *o);
-void PrintSectionHeaders(const object::ObjectFile *o);
-void PrintSectionContents(const object::ObjectFile *o);
-void PrintSymbolTable(const object::ObjectFile *o, StringRef ArchiveName,
+void printCOFFFileHeader(const object::ObjectFile *O);
+void printCOFFSymbolTable(const object::COFFImportFile *I);
+void printCOFFSymbolTable(const object::COFFObjectFile *O);
+void printMachOFileHeader(const object::ObjectFile *O);
+void printMachOLoadCommands(const object::ObjectFile *O);
+void printWasmFileHeader(const object::ObjectFile *O);
+void printExportsTrie(const object::ObjectFile *O);
+void printRebaseTable(object::ObjectFile *O);
+void printBindTable(object::ObjectFile *O);
+void printLazyBindTable(object::ObjectFile *O);
+void printWeakBindTable(object::ObjectFile *O);
+void printRawClangAST(const object::ObjectFile *O);
+void printRelocations(const object::ObjectFile *O);
+void printDynamicRelocations(const object::ObjectFile *O);
+void printSectionHeaders(const object::ObjectFile *O);
+void printSectionContents(const object::ObjectFile *O);
+void printSymbolTable(const object::ObjectFile *O, StringRef ArchiveName,
StringRef ArchitectureName = StringRef());
void warn(StringRef Message);
LLVM_ATTRIBUTE_NORETURN void error(Twine Message);