[llvm] r260487 - [readobj] Move dynamic table parsing to a new function. NFC.

Michael J. Spencer via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 10 20:59:37 PST 2016


Author: mspencer
Date: Wed Feb 10 22:59:37 2016
New Revision: 260487

URL: http://llvm.org/viewvc/llvm-project?rev=260487&view=rev
Log:
[readobj] Move dynamic table parsing to a new function. NFC.

Modified:
    llvm/trunk/tools/llvm-readobj/ELFDumper.cpp

Modified: llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ELFDumper.cpp?rev=260487&r1=260486&r2=260487&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/ELFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/ELFDumper.cpp Wed Feb 10 22:59:37 2016
@@ -112,6 +112,8 @@ private:
     uintX_t EntSize;
   };
 
+  void parseDynamicTable(ArrayRef<const Elf_Phdr *> LoadSegments);
+
   void printSymbolsHelper(bool IsDynamic);
   void printSymbol(const Elf_Sym *Symbol, const Elf_Shdr *SymTab,
                    StringRef StrTable, bool IsDynamic);
@@ -1032,8 +1034,19 @@ ELFDumper<ELFT>::ELFDumper(const ELFFile
     }
   }
 
+  parseDynamicTable(LoadSegments);
+
+  if (opts::Output == opts::GNU)
+    ELFDumperStyle.reset(new GNUStyle<ELFT>(Writer));
+  else
+    ELFDumperStyle.reset(new LLVMStyle<ELFT>(Writer));
+}
+
+template <typename ELFT>
+void ELFDumper<ELFT>::parseDynamicTable(
+    ArrayRef<const Elf_Phdr *> LoadSegments) {
   auto toMappedAddr = [&](uint64_t VAddr) -> const uint8_t * {
-    const Elf_Phdr **I = std::upper_bound(
+    const Elf_Phdr *const *I = std::upper_bound(
         LoadSegments.begin(), LoadSegments.end(), VAddr, compareAddr<ELFT>);
     if (I == LoadSegments.begin())
       report_fatal_error("Virtual address is not in any segment");
@@ -1095,10 +1108,6 @@ ELFDumper<ELFT>::ELFDumper(const ELFFile
     DynamicStringTable = StringRef(StringTableBegin, StringTableSize);
   if (SONameOffset)
     SOName = getDynamicString(SONameOffset);
-  if (opts::Output == opts::GNU)
-    ELFDumperStyle.reset(new GNUStyle<ELFT>(Writer));
-  else
-    ELFDumperStyle.reset(new LLVMStyle<ELFT>(Writer));
 }
 
 template <typename ELFT>




More information about the llvm-commits mailing list