# BAD-STRING-LLVM: 0x000000007FFFFFFD AUXILIARY Auxiliary library: <Invalid offset 0x1>
# BAD-STRING-LLVM: 0x000000007FFFFFFE USED Not needed object: <Invalid offset 0x1>
# BAD-STRING-LLVM: 0x000000000000000E SONAME Library soname: <Invalid offset 0x1>
-# BAD-STRING-LLVM: 0x000000000000000F RPATH <Invalid offset 0x1>
-# BAD-STRING-LLVM: 0x000000000000001D RUNPATH <Invalid offset 0x1>
+# BAD-STRING-LLVM: 0x000000000000000F RPATH Library rpath: <Invalid offset 0x1>
+# BAD-STRING-LLVM: 0x000000000000001D RUNPATH Library runpath: <Invalid offset 0x1>
# BAD-STRING-GNU: 0x000000000000000a (STRSZ) 1 (bytes)
# BAD-STRING-GNU: 0x0000000000000001 (NEEDED) Shared library: <Invalid offset 0x1>
# BAD-STRING-GNU: 0x000000007ffffffd (AUXILIARY) Auxiliary library: <Invalid offset 0x1>
# BAD-STRING-GNU: 0x000000007ffffffe (USED) Not needed object: <Invalid offset 0x1>
# BAD-STRING-GNU: 0x000000000000000e (SONAME) Library soname: <Invalid offset 0x1>
-# BAD-STRING-GNU: 0x000000000000000f (RPATH) <Invalid offset 0x1>
-# BAD-STRING-GNU: 0x000000000000001d (RUNPATH) <Invalid offset 0x1>
+# BAD-STRING-GNU: 0x000000000000000f (RPATH) Library rpath: <Invalid offset 0x1>
+# BAD-STRING-GNU: 0x000000000000001d (RUNPATH) Library runpath: <Invalid offset 0x1>
--- !ELF
FileHeader:
# LLVM-NEXT: 0x000000000000000C INIT 0x1000
# LLVM-NEXT: 0x000000000000000D FINI 0x1000
# LLVM-NEXT: 0x000000000000000E SONAME Library soname: [U]
-# LLVM-NEXT: 0x000000000000000F RPATH f
+# LLVM-NEXT: 0x000000000000000F RPATH Library rpath: [f]
# LLVM-NEXT: 0x0000000000000010 SYMBOLIC 0x1234567890ABCDEF
# LLVM-NEXT: 0x0000000000000011 REL 0x1000
# LLVM-NEXT: 0x0000000000000012 RELSZ 16 (bytes)
# LLVM-NEXT: 0x000000000000001A FINI_ARRAY 0x1000
# LLVM-NEXT: 0x000000000000001B INIT_ARRAYSZ 16 (bytes)
# LLVM-NEXT: 0x000000000000001C FINI_ARRAYSZ 16 (bytes)
-# LLVM-NEXT: 0x000000000000001D RUNPATH w
+# LLVM-NEXT: 0x000000000000001D RUNPATH Library runpath: [w]
# LLVM-NEXT: 0x000000000000001E FLAGS ORIGIN SYMBOLIC TEXTREL BIND_NOW STATIC_TLS {{$}}
# LLVM-NEXT: 0x0000000000000020 PREINIT_ARRAY 0x1000
# LLVM-NEXT: 0x0000000000000021 PREINIT_ARRAYSZ 16 (bytes)
# GNU-NEXT: 0x000000000000000c (INIT) 0x1000
# GNU-NEXT: 0x000000000000000d (FINI) 0x1000
# GNU-NEXT: 0x000000000000000e (SONAME) Library soname: [U]
-# GNU-NEXT: 0x000000000000000f (RPATH) f
+# GNU-NEXT: 0x000000000000000f (RPATH) Library rpath: [f]
# GNU-NEXT: 0x0000000000000010 (SYMBOLIC) 0x1234567890abcdef
# GNU-NEXT: 0x0000000000000011 (REL) 0x1000
# GNU-NEXT: 0x0000000000000012 (RELSZ) 16 (bytes)
# GNU-NEXT: 0x000000000000001a (FINI_ARRAY) 0x1000
# GNU-NEXT: 0x000000000000001b (INIT_ARRAYSZ) 16 (bytes)
# GNU-NEXT: 0x000000000000001c (FINI_ARRAYSZ) 16 (bytes)
-# GNU-NEXT: 0x000000000000001d (RUNPATH) w
+# GNU-NEXT: 0x000000000000001d (RUNPATH) Library runpath: [w]
# GNU-NEXT: 0x000000000000001e (FLAGS) ORIGIN SYMBOLIC TEXTREL BIND_NOW STATIC_TLS {{$}}
# GNU-NEXT: 0x0000000000000020 (PREINIT_ARRAY) 0x1000
# GNU-NEXT: 0x0000000000000021 (PREINIT_ARRAYSZ) 16 (bytes)
RUN: llvm-readobj --dynamic-table %p/Inputs/rpath.exe.elf-x86_64 \
RUN: | FileCheck %s
-CHECK: 0x000000000000000F RPATH /usr/local/lib
+CHECK: 0x000000000000000F RPATH Library rpath: [/usr/local/lib]
void loadDynamicTable(const ELFFile<ELFT> *Obj);
void parseDynamicTable();
- void printDynamicString(uint64_t Offset, raw_ostream &OS,
- bool WithBracket = true) const;
StringRef getSymbolVersion(StringRef StrTab, const Elf_Sym *symb,
bool &IsDefault) const;
void LoadVersionMap() const;
}
}
-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>::printDynamicEntry(raw_ostream &OS, uint64_t Type,
uint64_t Value) const {
case DT_SONAME:
case DT_AUXILIARY:
case DT_USED:
- case DT_FILTER: {
+ case DT_FILTER:
+ case DT_RPATH:
+ case DT_RUNPATH: {
const std::map<uint64_t, const char*> TagNames = {
{DT_NEEDED, "Shared library"},
{DT_SONAME, "Library soname"},
{DT_AUXILIARY, "Auxiliary library"},
{DT_USED, "Not needed object"},
{DT_FILTER, "Filter library"},
+ {DT_RPATH, "Library rpath"},
+ {DT_RUNPATH, "Library runpath"},
};
OS << TagNames.at(Type) << ": ";
- printDynamicString(Value, OS);
+ 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) << ">";
break;
}
- case DT_RPATH:
- case DT_RUNPATH:
- printDynamicString(Value, OS, false);
- break;
case DT_FLAGS:
printFlags(Value, makeArrayRef(ElfDynamicDTFlags), OS);
break;