summaryrefslogtreecommitdiff
path: root/tools/llvm-readobj
diff options
context:
space:
mode:
authorSimon Atanasyan <simon@atanasyan.com>2014-05-11 08:48:09 +0000
committerSimon Atanasyan <simon@atanasyan.com>2014-05-11 08:48:09 +0000
commitf5e04c38cd1eb48ea1cd68bbc7aa59e0d5ad141f (patch)
tree54216690a5bb02f866df32c7d09fdca893931e0d /tools/llvm-readobj
parent86118b4532f0790fe7168fcf00e61a09fa2e5362 (diff)
[llvm-readobj] Print values of FLAGS and MIPS_FLAGS dynamic table tags
in a human readable form. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208489 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-readobj')
-rw-r--r--tools/llvm-readobj/ELFDumper.cpp62
1 files changed, 61 insertions, 1 deletions
diff --git a/tools/llvm-readobj/ELFDumper.cpp b/tools/llvm-readobj/ELFDumper.cpp
index 856de7ce958..5b3302c4302 100644
--- a/tools/llvm-readobj/ELFDumper.cpp
+++ b/tools/llvm-readobj/ELFDumper.cpp
@@ -738,6 +738,8 @@ static const char *getTypeString(uint64_t Type) {
LLVM_READOBJ_TYPE_CASE(VERNEED);
LLVM_READOBJ_TYPE_CASE(VERNEEDNUM);
LLVM_READOBJ_TYPE_CASE(VERSYM);
+ LLVM_READOBJ_TYPE_CASE(RELCOUNT);
+ LLVM_READOBJ_TYPE_CASE(GNU_HASH);
LLVM_READOBJ_TYPE_CASE(MIPS_RLD_VERSION);
LLVM_READOBJ_TYPE_CASE(MIPS_FLAGS);
LLVM_READOBJ_TYPE_CASE(MIPS_BASE_ADDRESS);
@@ -753,6 +755,57 @@ static const char *getTypeString(uint64_t Type) {
#undef LLVM_READOBJ_TYPE_CASE
+#define LLVM_READOBJ_DT_FLAG_ENT(prefix, enum) \
+ { #enum, prefix##_##enum }
+
+static const EnumEntry<unsigned> ElfDynamicDTFlags[] = {
+ LLVM_READOBJ_DT_FLAG_ENT(DF, ORIGIN),
+ LLVM_READOBJ_DT_FLAG_ENT(DF, SYMBOLIC),
+ LLVM_READOBJ_DT_FLAG_ENT(DF, TEXTREL),
+ LLVM_READOBJ_DT_FLAG_ENT(DF, BIND_NOW),
+ LLVM_READOBJ_DT_FLAG_ENT(DF, STATIC_TLS)
+};
+
+static const EnumEntry<unsigned> ElfDynamicDTMipsFlags[] = {
+ LLVM_READOBJ_DT_FLAG_ENT(RHF, NONE),
+ LLVM_READOBJ_DT_FLAG_ENT(RHF, QUICKSTART),
+ LLVM_READOBJ_DT_FLAG_ENT(RHF, NOTPOT),
+ LLVM_READOBJ_DT_FLAG_ENT(RHS, NO_LIBRARY_REPLACEMENT),
+ LLVM_READOBJ_DT_FLAG_ENT(RHF, NO_MOVE),
+ LLVM_READOBJ_DT_FLAG_ENT(RHF, SGI_ONLY),
+ LLVM_READOBJ_DT_FLAG_ENT(RHF, GUARANTEE_INIT),
+ LLVM_READOBJ_DT_FLAG_ENT(RHF, DELTA_C_PLUS_PLUS),
+ LLVM_READOBJ_DT_FLAG_ENT(RHF, GUARANTEE_START_INIT),
+ LLVM_READOBJ_DT_FLAG_ENT(RHF, PIXIE),
+ LLVM_READOBJ_DT_FLAG_ENT(RHF, DEFAULT_DELAY_LOAD),
+ LLVM_READOBJ_DT_FLAG_ENT(RHF, REQUICKSTART),
+ LLVM_READOBJ_DT_FLAG_ENT(RHF, REQUICKSTARTED),
+ LLVM_READOBJ_DT_FLAG_ENT(RHF, CORD),
+ LLVM_READOBJ_DT_FLAG_ENT(RHF, NO_UNRES_UNDEF),
+ LLVM_READOBJ_DT_FLAG_ENT(RHF, RLD_ORDER_SAFE)
+};
+
+#undef LLVM_READOBJ_DT_FLAG_ENT
+
+template <typename T, typename TFlag>
+void printFlags(T Value, ArrayRef<EnumEntry<TFlag>> Flags, raw_ostream &OS) {
+ typedef EnumEntry<TFlag> FlagEntry;
+ typedef SmallVector<FlagEntry, 10> FlagVector;
+ FlagVector SetFlags;
+
+ for (const auto &Flag : Flags) {
+ if (Flag.Value == 0)
+ continue;
+
+ if ((Value & Flag.Value) == Flag.Value)
+ SetFlags.push_back(Flag);
+ }
+
+ for (const auto &Flag : SetFlags) {
+ OS << Flag.Name << " ";
+ }
+}
+
template <class ELFT>
static void printValue(const ELFFile<ELFT> *O, uint64_t Type, uint64_t Value,
bool Is64, raw_ostream &OS) {
@@ -781,14 +834,15 @@ static void printValue(const ELFFile<ELFT> *O, uint64_t Type, uint64_t Value,
case DT_DEBUG:
case DT_VERNEED:
case DT_VERSYM:
+ case DT_GNU_HASH:
case DT_NULL:
- case DT_MIPS_FLAGS:
case DT_MIPS_BASE_ADDRESS:
case DT_MIPS_GOTSYM:
case DT_MIPS_RLD_MAP:
case DT_MIPS_PLTGOT:
OS << format("0x%" PRIX64, Value);
break;
+ case DT_RELCOUNT:
case DT_VERNEEDNUM:
case DT_MIPS_RLD_VERSION:
case DT_MIPS_LOCAL_GOTNO:
@@ -818,6 +872,12 @@ static void printValue(const ELFFile<ELFT> *O, uint64_t Type, uint64_t Value,
case DT_RUNPATH:
OS << O->getDynamicString(Value);
break;
+ case DT_MIPS_FLAGS:
+ printFlags(Value, makeArrayRef(ElfDynamicDTMipsFlags), OS);
+ break;
+ case DT_FLAGS:
+ printFlags(Value, makeArrayRef(ElfDynamicDTFlags), OS);
+ break;
}
}