1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00

[llvm-readobj] Print values of FLAGS and MIPS_FLAGS dynamic table tags

in a human readable form.

llvm-svn: 208489
This commit is contained in:
Simon Atanasyan 2014-05-11 08:48:09 +00:00
parent d043cc92e5
commit 026ba36cfb
4 changed files with 105 additions and 3 deletions

View File

@ -1666,6 +1666,7 @@ enum {
DT_LOPROC = 0x70000000, // Start of processor specific tags.
DT_HIPROC = 0x7FFFFFFF, // End of processor specific tags.
DT_GNU_HASH = 0x6FFFFEF5, // Reference to the GNU hash table.
DT_RELACOUNT = 0x6FFFFFF9, // ELF32_Rela count.
DT_RELCOUNT = 0x6FFFFFFA, // ELF32_Rel count.

Binary file not shown.

View File

@ -21,7 +21,7 @@ ELF-MIPS: 0x00000011 REL 0x518
ELF-MIPS: 0x00000012 RELSZ 16 (bytes)
ELF-MIPS: 0x00000013 RELENT 8 (bytes)
ELF-MIPS: 0x70000001 MIPS_RLD_VERSION 1
ELF-MIPS: 0x70000005 MIPS_FLAGS 0x2
ELF-MIPS: 0x70000005 MIPS_FLAGS NOTPOT
ELF-MIPS: 0x70000006 MIPS_BASE_ADDRESS 0x0
ELF-MIPS: 0x7000000A MIPS_LOCAL_GOTNO 10
ELF-MIPS: 0x70000011 MIPS_SYMTABNO 19
@ -55,7 +55,7 @@ ELF-MIPS-EXE: 0x70000016 MIPS_RLD_MAP 0x410880
ELF-MIPS-EXE: 0x00000015 DEBUG 0x0
ELF-MIPS-EXE: 0x00000003 PLTGOT 0x410890
ELF-MIPS-EXE: 0x70000001 MIPS_RLD_VERSION 1
ELF-MIPS-EXE: 0x70000005 MIPS_FLAGS 0x2
ELF-MIPS-EXE: 0x70000005 MIPS_FLAGS NOTPOT
ELF-MIPS-EXE: 0x70000006 MIPS_BASE_ADDRESS 0x400000
ELF-MIPS-EXE: 0x7000000A MIPS_LOCAL_GOTNO 5
ELF-MIPS-EXE: 0x70000011 MIPS_SYMTABNO 8
@ -70,3 +70,44 @@ ELF-MIPS-EXE: 0x6FFFFFFF VERNEEDNUM 1
ELF-MIPS-EXE: 0x6FFFFFF0 VERSYM 0x4003D8
ELF-MIPS-EXE: 0x00000000 NULL 0x0
ELF-MIPS-EXE: ]
RUN: llvm-readobj -dynamic-table %p/Inputs/dynamic-table-exe.x86 \
RUN: | FileCheck %s -check-prefix ELF-X86-EXE
ELF-X86-EXE: Format: ELF32-i386
ELF-X86-EXE: Arch: i386
ELF-X86-EXE: AddressSize: 32bit
ELF-X86-EXE: LoadName:
ELF-X86-EXE: DynamicSection [ (30 entries)
ELF-X86-EXE: Tag Type Name/Value
ELF-X86-EXE: 0x00000001 NEEDED SharedLibrary (libstdc++.so.6)
ELF-X86-EXE: 0x00000001 NEEDED SharedLibrary (libgcc_s.so.1)
ELF-X86-EXE: 0x00000001 NEEDED SharedLibrary (libc.so.6)
ELF-X86-EXE: 0x0000000C INIT 0x62C
ELF-X86-EXE: 0x0000000D FINI 0x920
ELF-X86-EXE: 0x00000019 INIT_ARRAY 0x19FC
ELF-X86-EXE: 0x0000001B INIT_ARRAYSZ 4 (bytes)
ELF-X86-EXE: 0x0000001A FINI_ARRAY 0x1A00
ELF-X86-EXE: 0x0000001C FINI_ARRAYSZ 4 (bytes)
ELF-X86-EXE: 0x00000004 HASH 0x18C
ELF-X86-EXE: 0x6FFFFEF5 GNU_HASH 0x1E4
ELF-X86-EXE: 0x00000005 STRTAB 0x328
ELF-X86-EXE: 0x00000006 SYMTAB 0x218
ELF-X86-EXE: 0x0000000A STRSZ 408 (bytes)
ELF-X86-EXE: 0x0000000B SYMENT 16 (bytes)
ELF-X86-EXE: 0x00000015 DEBUG 0x0
ELF-X86-EXE: 0x00000003 PLTGOT 0x1B30
ELF-X86-EXE: 0x00000002 PLTRELSZ 64 (bytes)
ELF-X86-EXE: 0x00000014 PLTREL REL
ELF-X86-EXE: 0x00000017 JMPREL 0x5EC
ELF-X86-EXE: 0x00000011 REL 0x564
ELF-X86-EXE: 0x00000012 RELSZ 136 (bytes)
ELF-X86-EXE: 0x00000013 RELENT 8 (bytes)
ELF-X86-EXE: 0x00000016 TEXTREL
ELF-X86-EXE: 0x0000001E FLAGS TEXTREL
ELF-X86-EXE: 0x6FFFFFFE VERNEED 0x4E4
ELF-X86-EXE: 0x6FFFFFFF VERNEEDNUM 3
ELF-X86-EXE: 0x6FFFFFF0 VERSYM 0x4C0
ELF-X86-EXE: 0x6FFFFFFA RELCOUNT 6
ELF-X86-EXE: 0x00000000 NULL 0x0
ELF-X86-EXE: ]

View File

@ -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;
}
}