Remove duplicated code.
authorRafael Espindola <rafael.espindola@gmail.com>
Mon, 20 Jul 2015 22:41:44 +0000 (22:41 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Mon, 20 Jul 2015 22:41:44 +0000 (22:41 +0000)
Both ELFObjectFile and ELFFile had an implementation of getLoadName.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242725 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Object/ELFObjectFile.h
tools/llvm-readobj/llvm-readobj.cpp

index cd334d5e06f527459aca6498210ede3bde523b48..2a870bdbca94522b96412fd9475c8e11a3ed443a 100644 (file)
@@ -318,7 +318,6 @@ public:
   uint8_t getBytesInAddress() const override;
   StringRef getFileFormatName() const override;
   unsigned getArch() const override;
-  StringRef getLoadName() const;
 
   std::error_code getPlatformFlags(unsigned &Result) const override {
     Result = EF.getHeader()->e_flags;
@@ -779,19 +778,6 @@ section_iterator ELFObjectFile<ELFT>::section_end() const {
   return section_iterator(SectionRef(toDRI(EF.section_end()), this));
 }
 
-template <class ELFT>
-StringRef ELFObjectFile<ELFT>::getLoadName() const {
-  const Elf_Dyn *DI = EF.dynamic_table_begin();
-  const Elf_Dyn *DE = EF.dynamic_table_end();
-
-  while (DI != DE && DI->getTag() != ELF::DT_SONAME)
-    ++DI;
-
-  if (DI != DE)
-    return EF.getDynamicString(DI->getVal());
-  return "";
-}
-
 template <class ELFT>
 uint8_t ELFObjectFile<ELFT>::getBytesInAddress() const {
   return ELFT::Is64Bits ? 8 : 4;
index 3f03618bb224ce634d1e95ecfaf68f6b1b3611d8..28532d993f85b25bced0e30fed327602a5c17315 100644 (file)
@@ -253,13 +253,13 @@ static std::error_code createDumper(const ObjectFile *Obj, StreamWriter &Writer,
 
 static StringRef getLoadName(const ObjectFile *Obj) {
   if (auto *ELF = dyn_cast<ELF32LEObjectFile>(Obj))
-    return ELF->getLoadName();
+    return ELF->getELFFile()->getLoadName();
   if (auto *ELF = dyn_cast<ELF64LEObjectFile>(Obj))
-    return ELF->getLoadName();
+    return ELF->getELFFile()->getLoadName();
   if (auto *ELF = dyn_cast<ELF32BEObjectFile>(Obj))
-    return ELF->getLoadName();
+    return ELF->getELFFile()->getLoadName();
   if (auto *ELF = dyn_cast<ELF64BEObjectFile>(Obj))
-    return ELF->getLoadName();
+    return ELF->getELFFile()->getLoadName();
   llvm_unreachable("Not ELF");
 }