diff --git a/lld/test/ELF/new-dtags.test b/lld/test/ELF/new-dtags.test --- a/lld/test/ELF/new-dtags.test +++ b/lld/test/ELF/new-dtags.test @@ -10,11 +10,11 @@ // RUN: llvm-readobj --dynamic-table %t2 | FileCheck --check-prefix=ENABLE %s // DISABLE: DynamicSection [ -// DISABLE: 0x000000000000000F RPATH /somepath +// DISABLE: 0x000000000000000F RPATH Library rpath: [/somepath] // DISABLE-NOT: RUNPATH // DISABLE: ] // ENABLE: DynamicSection [ -// ENABLE: 0x000000000000001D RUNPATH /somepath +// ENABLE: 0x000000000000001D RUNPATH Library runpath: [/somepath] // ENABLE-NOT: RPATH // ENABLE: ] diff --git a/lld/test/ELF/shared-ppc64.s b/lld/test/ELF/shared-ppc64.s --- a/lld/test/ELF/shared-ppc64.s +++ b/lld/test/ELF/shared-ppc64.s @@ -27,7 +27,7 @@ // CHECK: DynamicSection [ // CHECK-NEXT: Tag Type Name/Value -// CHECK-NEXT: 0x000000000000001D RUNPATH foo:bar +// CHECK-NEXT: 0x000000000000001D RUNPATH Library runpath: [foo:bar] // CHECK-NEXT: 0x0000000000000001 NEEDED Shared library: [{{.*}}2.so] // CHECK-NEXT: 0x0000000000000015 DEBUG 0x0 // CHECK-NEXT: 0x0000000000000007 RELA [[RELADDR]] diff --git a/lld/test/ELF/shared.s b/lld/test/ELF/shared.s --- a/lld/test/ELF/shared.s +++ b/lld/test/ELF/shared.s @@ -250,7 +250,7 @@ // CHECK: DynamicSection [ // CHECK-NEXT: Tag Type Name/Value -// CHECK-NEXT: 0x0000001D RUNPATH foo:bar +// CHECK-NEXT: 0x0000001D RUNPATH Library runpath: [foo:bar] // CHECK-NEXT: 0x00000001 NEEDED Shared library: [{{.*}}2.so] // CHECK-NEXT: 0x00000015 DEBUG 0x0 // CHECK-NEXT: 0x00000011 REL [[RELADDR]] diff --git a/llvm/test/tools/llvm-readobj/elf-dynamic-malformed.test b/llvm/test/tools/llvm-readobj/elf-dynamic-malformed.test --- a/llvm/test/tools/llvm-readobj/elf-dynamic-malformed.test +++ b/llvm/test/tools/llvm-readobj/elf-dynamic-malformed.test @@ -79,8 +79,8 @@ # BAD-STRING-LLVM: 0x000000007FFFFFFD AUXILIARY Auxiliary library: # BAD-STRING-LLVM: 0x000000007FFFFFFE USED Not needed object: # BAD-STRING-LLVM: 0x000000000000000E SONAME Library soname: -# BAD-STRING-LLVM: 0x000000000000000F RPATH -# BAD-STRING-LLVM: 0x000000000000001D RUNPATH +# BAD-STRING-LLVM: 0x000000000000000F RPATH Library rpath: +# BAD-STRING-LLVM: 0x000000000000001D RUNPATH Library runpath: # BAD-STRING-GNU: 0x000000000000000a (STRSZ) 1 (bytes) # BAD-STRING-GNU: 0x0000000000000001 (NEEDED) Shared library: @@ -88,8 +88,8 @@ # BAD-STRING-GNU: 0x000000007ffffffd (AUXILIARY) Auxiliary library: # BAD-STRING-GNU: 0x000000007ffffffe (USED) Not needed object: # BAD-STRING-GNU: 0x000000000000000e (SONAME) Library soname: -# BAD-STRING-GNU: 0x000000000000000f (RPATH) -# BAD-STRING-GNU: 0x000000000000001d (RUNPATH) +# BAD-STRING-GNU: 0x000000000000000f (RPATH) Library rpath: +# BAD-STRING-GNU: 0x000000000000001d (RUNPATH) Library runpath: --- !ELF FileHeader: diff --git a/llvm/test/tools/llvm-readobj/elf-dynamic-tags.test b/llvm/test/tools/llvm-readobj/elf-dynamic-tags.test --- a/llvm/test/tools/llvm-readobj/elf-dynamic-tags.test +++ b/llvm/test/tools/llvm-readobj/elf-dynamic-tags.test @@ -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) diff --git a/llvm/test/tools/llvm-readobj/rpath.test b/llvm/test/tools/llvm-readobj/rpath.test --- a/llvm/test/tools/llvm-readobj/rpath.test +++ b/llvm/test/tools/llvm-readobj/rpath.test @@ -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] diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp --- a/llvm/tools/llvm-readobj/ELFDumper.cpp +++ b/llvm/tools/llvm-readobj/ELFDumper.cpp @@ -206,8 +206,6 @@ void loadDynamicTable(const ELFFile *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; @@ -1790,22 +1788,6 @@ } } -template -void ELFDumper::printDynamicString(uint64_t Value, - raw_ostream &OS, - bool WithBracket) const { - if (DynamicStringTable.empty()) - OS << " "; - else if (Value < DynamicStringTable.size()) { - if (WithBracket) - OS << "["; - OS << StringRef(DynamicStringTable.data() + Value); - if (WithBracket) - OS << "]"; - } else - OS << ""; -} - template void ELFDumper::printDynamicEntry(raw_ostream &OS, uint64_t Type, uint64_t Value) const { @@ -1952,22 +1934,27 @@ case DT_SONAME: case DT_AUXILIARY: case DT_USED: - case DT_FILTER: { + case DT_FILTER: + case DT_RPATH: + case DT_RUNPATH: { const std::map 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 << " "; + else if (Value < DynamicStringTable.size()) + OS << "[" << StringRef(DynamicStringTable.data() + Value) << "]"; + else + OS << ""; break; } - case DT_RPATH: - case DT_RUNPATH: - printDynamicString(Value, OS, false); - break; case DT_FLAGS: printFlags(Value, makeArrayRef(ElfDynamicDTFlags), OS); break;