From: Rafael Espindola Date: Tue, 21 Jul 2015 13:48:41 +0000 (+0000) Subject: Simplify printing the soname. NFC. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=71e35258cb84d7f8f85d038d83de6763317594fe;p=oota-llvm.git Simplify printing the soname. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242786 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/llvm-readobj/ELFDumper.cpp b/tools/llvm-readobj/ELFDumper.cpp index a03b6174a14..a710ea9524a 100644 --- a/tools/llvm-readobj/ELFDumper.cpp +++ b/tools/llvm-readobj/ELFDumper.cpp @@ -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::printHashTable() { W.printList("Chains", HT->chains()); } +template void ELFDumper::printLoadName() { + outs() << "LoadName: " << Obj->getLoadName() << '\n'; +} + template void ELFDumper::printAttributes() { W.startLine() << "Attributes not implemented.\n"; diff --git a/tools/llvm-readobj/ObjDumper.h b/tools/llvm-readobj/ObjDumper.h index ad1b70fea98..206082fa5e2 100644 --- a/tools/llvm-readobj/ObjDumper.h +++ b/tools/llvm-readobj/ObjDumper.h @@ -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() { } diff --git a/tools/llvm-readobj/llvm-readobj.cpp b/tools/llvm-readobj/llvm-readobj.cpp index 28532d993f8..f0956f8c63e 100644 --- a/tools/llvm-readobj/llvm-readobj.cpp +++ b/tools/llvm-readobj/llvm-readobj.cpp @@ -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(Obj)) - return ELF->getELFFile()->getLoadName(); - if (auto *ELF = dyn_cast(Obj)) - return ELF->getELFFile()->getLoadName(); - if (auto *ELF = dyn_cast(Obj)) - return ELF->getELFFile()->getLoadName(); - if (auto *ELF = dyn_cast(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();