Simplify printing the soname. NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242786 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2015-07-21 13:48:41 +00:00
parent ed3c543ddb
commit 71e35258cb
3 changed files with 7 additions and 14 deletions

View File

@ -57,6 +57,7 @@ public:
void printNeededLibraries() override;
void printProgramHeaders() override;
void printHashTable() override;
void printLoadName() override;
void printAttributes() override;
void printMipsPLTGOT() override;
@ -1140,6 +1141,10 @@ void ELFDumper<ELFT>::printHashTable() {
W.printList("Chains", HT->chains());
}
template <typename ELFT> void ELFDumper<ELFT>::printLoadName() {
outs() << "LoadName: " << Obj->getLoadName() << '\n';
}
template <class ELFT>
void ELFDumper<ELFT>::printAttributes() {
W.startLine() << "Attributes not implemented.\n";

View File

@ -38,6 +38,7 @@ public:
virtual void printNeededLibraries() { }
virtual void printProgramHeaders() { }
virtual void printHashTable() { }
virtual void printLoadName() {}
// Only implemented for ARM ELF at this time.
virtual void printAttributes() { }

View File

@ -251,18 +251,6 @@ static std::error_code createDumper(const ObjectFile *Obj, StreamWriter &Writer,
return readobj_error::unsupported_obj_file_format;
}
static StringRef getLoadName(const ObjectFile *Obj) {
if (auto *ELF = dyn_cast<ELF32LEObjectFile>(Obj))
return ELF->getELFFile()->getLoadName();
if (auto *ELF = dyn_cast<ELF64LEObjectFile>(Obj))
return ELF->getELFFile()->getLoadName();
if (auto *ELF = dyn_cast<ELF32BEObjectFile>(Obj))
return ELF->getELFFile()->getLoadName();
if (auto *ELF = dyn_cast<ELF64BEObjectFile>(Obj))
return ELF->getELFFile()->getLoadName();
llvm_unreachable("Not ELF");
}
/// @brief Dumps the specified object file.
static void dumpObject(const ObjectFile *Obj) {
StreamWriter Writer(outs());
@ -279,8 +267,7 @@ static void dumpObject(const ObjectFile *Obj) {
<< Triple::getArchTypeName((llvm::Triple::ArchType)Obj->getArch())
<< "\n";
outs() << "AddressSize: " << (8*Obj->getBytesInAddress()) << "bit\n";
if (Obj->isELF())
outs() << "LoadName: " << getLoadName(Obj) << "\n";
Dumper->printLoadName();
if (opts::FileHeaders)
Dumper->printFileHeaders();