[llvm] r363868 - [llvm-readobj] Match GNU output for DT_RPATH and DT_RUNPATH when dumping dynamic symbol table.
Yuanfang Chen via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 19 12:31:08 PDT 2019
Author: yuanfang
Date: Wed Jun 19 12:31:07 2019
New Revision: 363868
URL: http://llvm.org/viewvc/llvm-project?rev=363868&view=rev
Log:
[llvm-readobj] Match GNU output for DT_RPATH and DT_RUNPATH when dumping dynamic symbol table.
Reviewers: jhenderson, grimar, MaskRay, rupprecht, espindola
Subscribers: emaste, nemanjai, arichardson, kbarton, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D63347
Modified:
llvm/trunk/test/tools/llvm-readobj/elf-dynamic-malformed.test
llvm/trunk/test/tools/llvm-readobj/elf-dynamic-tags.test
llvm/trunk/test/tools/llvm-readobj/rpath.test
llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
Modified: llvm/trunk/test/tools/llvm-readobj/elf-dynamic-malformed.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/elf-dynamic-malformed.test?rev=363868&r1=363867&r2=363868&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-readobj/elf-dynamic-malformed.test (original)
+++ llvm/trunk/test/tools/llvm-readobj/elf-dynamic-malformed.test Wed Jun 19 12:31:07 2019
@@ -79,8 +79,8 @@ ProgramHeaders:
# 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>
@@ -88,8 +88,8 @@ ProgramHeaders:
# 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:
Modified: llvm/trunk/test/tools/llvm-readobj/elf-dynamic-tags.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/elf-dynamic-tags.test?rev=363868&r1=363867&r2=363868&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-readobj/elf-dynamic-tags.test (original)
+++ llvm/trunk/test/tools/llvm-readobj/elf-dynamic-tags.test Wed Jun 19 12:31:07 2019
@@ -19,7 +19,7 @@
# 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)
@@ -33,7 +33,7 @@
# 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)
@@ -84,7 +84,7 @@
# 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)
@@ -98,7 +98,7 @@
# 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)
Modified: llvm/trunk/test/tools/llvm-readobj/rpath.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/rpath.test?rev=363868&r1=363867&r2=363868&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-readobj/rpath.test (original)
+++ llvm/trunk/test/tools/llvm-readobj/rpath.test Wed Jun 19 12:31:07 2019
@@ -1,4 +1,4 @@
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]
Modified: llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ELFDumper.cpp?rev=363868&r1=363867&r2=363868&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/ELFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/ELFDumper.cpp Wed Jun 19 12:31:07 2019
@@ -206,8 +206,6 @@ private:
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;
@@ -1791,22 +1789,6 @@ void printFlags(T Value, ArrayRef<EnumEn
}
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 {
const char *ConvChar =
@@ -1952,22 +1934,27 @@ void ELFDumper<ELFT>::printDynamicEntry(
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;
More information about the llvm-commits
mailing list