[PATCH] D64674: [NFC][llvm-readobj] Refactor dynamic string table indexing into a function.
Yuanfang Chen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 12 15:41:47 PDT 2019
ychen created this revision.
ychen added reviewers: jhenderson, MaskRay, grimar.
Herald added subscribers: llvm-commits, rupprecht, arphaman.
Herald added a project: LLVM.
Restore printDynamicString removed in rL363868 <https://reviews.llvm.org/rL363868>. It provides better
error handling whenever indexing dynamic string table is needed.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D64674
Files:
llvm/tools/llvm-readobj/ELFDumper.cpp
Index: llvm/tools/llvm-readobj/ELFDumper.cpp
===================================================================
--- llvm/tools/llvm-readobj/ELFDumper.cpp
+++ llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -296,6 +296,8 @@
void printSymbolsHelper(bool IsDynamic) const;
void printDynamicEntry(raw_ostream &OS, uint64_t Type, uint64_t Value) const;
+ void printDynamicString(uint64_t Value, raw_ostream &OS,
+ bool WithBracket = true) const;
const Elf_Shdr *getDotSymtabSec() const { return DotSymtabSec; }
const Elf_Shdr *getDotCGProfileSec() const { return DotCGProfileSec; }
@@ -1952,12 +1954,7 @@
{DT_RUNPATH, "Library runpath"},
};
OS << TagNames.at(Type) << ": ";
- if (DynamicStringTable.empty())
- OS << "<String table is empty or was not found> ";
- else if (Value < DynamicStringTable.size())
- OS << "[" << StringRef(DynamicStringTable.data() + Value) << "]";
- else
- OS << "<Invalid offset 0x" << utohexstr(Value) << ">";
+ printDynamicString(Value, OS, true);
break;
}
case DT_FLAGS:
@@ -1972,6 +1969,21 @@
}
}
+template <class ELFT>
+void ELFDumper<ELFT>::printDynamicString(uint64_t Value, raw_ostream &OS,
+ bool WithBracket) const {
+ if (DynamicStringTable.empty())
+ OS << "<String table is empty or was not found> ";
+ else if (Value < DynamicStringTable.size()) {
+ if (WithBracket)
+ OS << "[";
+ OS << StringRef(DynamicStringTable.data() + Value);
+ if (WithBracket)
+ OS << "]";
+ } else
+ OS << "<Invalid offset 0x" << utohexstr(Value) << ">";
+}
+
template <class ELFT> void ELFDumper<ELFT>::printUnwindInfo() {
DwarfCFIEH::PrinterContext<ELFT> Ctx(W, ObjF);
Ctx.printUnwindInformation();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64674.209624.patch
Type: text/x-patch
Size: 1789 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190712/6229c91f/attachment.bin>
More information about the llvm-commits
mailing list