llvm.org GIT mirror llvm / 4368c16
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363868 91177308-0d34-0410-b5e6-96231b3b80d8 Yuanfang Chen 27 days ago
4 changed file(s) with 20 addition(s) and 33 deletion(s). Raw diff Collapse all Expand all
7878 # BAD-STRING-LLVM: 0x000000007FFFFFFD AUXILIARY Auxiliary library:
7979 # BAD-STRING-LLVM: 0x000000007FFFFFFE USED Not needed object:
8080 # BAD-STRING-LLVM: 0x000000000000000E SONAME Library soname:
81 # BAD-STRING-LLVM: 0x000000000000000F RPATH
82 # BAD-STRING-LLVM: 0x000000000000001D RUNPATH
81 # BAD-STRING-LLVM: 0x000000000000000F RPATH Library rpath:
82 # BAD-STRING-LLVM: 0x000000000000001D RUNPATH Library runpath:
8383
8484 # BAD-STRING-GNU: 0x000000000000000a (STRSZ) 1 (bytes)
8585 # BAD-STRING-GNU: 0x0000000000000001 (NEEDED) Shared library:
8787 # BAD-STRING-GNU: 0x000000007ffffffd (AUXILIARY) Auxiliary library:
8888 # BAD-STRING-GNU: 0x000000007ffffffe (USED) Not needed object:
8989 # BAD-STRING-GNU: 0x000000000000000e (SONAME) Library soname:
90 # BAD-STRING-GNU: 0x000000000000000f (RPATH)
91 # BAD-STRING-GNU: 0x000000000000001d (RUNPATH)
90 # BAD-STRING-GNU: 0x000000000000000f (RPATH) Library rpath:
91 # BAD-STRING-GNU: 0x000000000000001d (RUNPATH) Library runpath:
9292
9393 --- !ELF
9494 FileHeader:
1818 # LLVM-NEXT: 0x000000000000000C INIT 0x1000
1919 # LLVM-NEXT: 0x000000000000000D FINI 0x1000
2020 # LLVM-NEXT: 0x000000000000000E SONAME Library soname: [U]
21 # LLVM-NEXT: 0x000000000000000F RPATH f
21 # LLVM-NEXT: 0x000000000000000F RPATH Library rpath: [f]
2222 # LLVM-NEXT: 0x0000000000000010 SYMBOLIC 0x1234567890ABCDEF
2323 # LLVM-NEXT: 0x0000000000000011 REL 0x1000
2424 # LLVM-NEXT: 0x0000000000000012 RELSZ 16 (bytes)
3232 # LLVM-NEXT: 0x000000000000001A FINI_ARRAY 0x1000
3333 # LLVM-NEXT: 0x000000000000001B INIT_ARRAYSZ 16 (bytes)
3434 # LLVM-NEXT: 0x000000000000001C FINI_ARRAYSZ 16 (bytes)
35 # LLVM-NEXT: 0x000000000000001D RUNPATH w
35 # LLVM-NEXT: 0x000000000000001D RUNPATH Library runpath: [w]
3636 # LLVM-NEXT: 0x000000000000001E FLAGS ORIGIN SYMBOLIC TEXTREL BIND_NOW STATIC_TLS {{$}}
3737 # LLVM-NEXT: 0x0000000000000020 PREINIT_ARRAY 0x1000
3838 # LLVM-NEXT: 0x0000000000000021 PREINIT_ARRAYSZ 16 (bytes)
8383 # GNU-NEXT: 0x000000000000000c (INIT) 0x1000
8484 # GNU-NEXT: 0x000000000000000d (FINI) 0x1000
8585 # GNU-NEXT: 0x000000000000000e (SONAME) Library soname: [U]
86 # GNU-NEXT: 0x000000000000000f (RPATH) f
86 # GNU-NEXT: 0x000000000000000f (RPATH) Library rpath: [f]
8787 # GNU-NEXT: 0x0000000000000010 (SYMBOLIC) 0x1234567890abcdef
8888 # GNU-NEXT: 0x0000000000000011 (REL) 0x1000
8989 # GNU-NEXT: 0x0000000000000012 (RELSZ) 16 (bytes)
9797 # GNU-NEXT: 0x000000000000001a (FINI_ARRAY) 0x1000
9898 # GNU-NEXT: 0x000000000000001b (INIT_ARRAYSZ) 16 (bytes)
9999 # GNU-NEXT: 0x000000000000001c (FINI_ARRAYSZ) 16 (bytes)
100 # GNU-NEXT: 0x000000000000001d (RUNPATH) w
100 # GNU-NEXT: 0x000000000000001d (RUNPATH) Library runpath: [w]
101101 # GNU-NEXT: 0x000000000000001e (FLAGS) ORIGIN SYMBOLIC TEXTREL BIND_NOW STATIC_TLS {{$}}
102102 # GNU-NEXT: 0x0000000000000020 (PREINIT_ARRAY) 0x1000
103103 # GNU-NEXT: 0x0000000000000021 (PREINIT_ARRAYSZ) 16 (bytes)
0 RUN: llvm-readobj --dynamic-table %p/Inputs/rpath.exe.elf-x86_64 \
11 RUN: | FileCheck %s
22
3 CHECK: 0x000000000000000F RPATH /usr/local/lib
3 CHECK: 0x000000000000000F RPATH Library rpath: [/usr/local/lib]
205205 void loadDynamicTable(const ELFFile *Obj);
206206 void parseDynamicTable();
207207
208 void printDynamicString(uint64_t Offset, raw_ostream &OS,
209 bool WithBracket = true) const;
210208 StringRef getSymbolVersion(StringRef StrTab, const Elf_Sym *symb,
211209 bool &IsDefault) const;
212210 void LoadVersionMap() const;
17901788 }
17911789
17921790 template
1793 void ELFDumper::printDynamicString(uint64_t Value,
1794 raw_ostream &OS,
1795 bool WithBracket) const {
1796 if (DynamicStringTable.empty())
1797 OS << " ";
1798 else if (Value < DynamicStringTable.size()) {
1799 if (WithBracket)
1800 OS << "[";
1801 OS << StringRef(DynamicStringTable.data() + Value);
1802 if (WithBracket)
1803 OS << "]";
1804 } else
1805 OS << "";
1806 }
1807
1808 template
18091791 void ELFDumper::printDynamicEntry(raw_ostream &OS, uint64_t Type,
18101792 uint64_t Value) const {
18111793 const char *ConvChar =
19511933 case DT_SONAME:
19521934 case DT_AUXILIARY:
19531935 case DT_USED:
1954 case DT_FILTER: {
1936 case DT_FILTER:
1937 case DT_RPATH:
1938 case DT_RUNPATH: {
19551939 const std::map TagNames = {
19561940 {DT_NEEDED, "Shared library"},
19571941 {DT_SONAME, "Library soname"},
19581942 {DT_AUXILIARY, "Auxiliary library"},
19591943 {DT_USED, "Not needed object"},
19601944 {DT_FILTER, "Filter library"},
1945 {DT_RPATH, "Library rpath"},
1946 {DT_RUNPATH, "Library runpath"},
19611947 };
19621948 OS << TagNames.at(Type) << ": ";
1963 printDynamicString(Value, OS);
1949 if (DynamicStringTable.empty())
1950 OS << " ";
1951 else if (Value < DynamicStringTable.size())
1952 OS << "[" << StringRef(DynamicStringTable.data() + Value) << "]";
1953 else
1954 OS << "";
19641955 break;
19651956 }
1966 case DT_RPATH:
1967 case DT_RUNPATH:
1968 printDynamicString(Value, OS, false);
1969 break;
19701957 case DT_FLAGS:
19711958 printFlags(Value, makeArrayRef(ElfDynamicDTFlags), OS);
19721959 break;