llvm.org GIT mirror llvm / edd7694
[WebAssembly] llvm-readobj: display symbols names in relocations Differential Revision: https://reviews.llvm.org/D46296 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331279 91177308-0d34-0410-b5e6-96231b3b80d8 Sam Clegg 2 years ago
6 changed file(s) with 70 addition(s) and 55 deletion(s). Raw diff Collapse all Expand all
132132 ; CHECK-NEXT:]
133133 ; CHECK-NEXT:Relocations [
134134 ; CHECK-NEXT: Section (6) DATA {
135 ; CHECK-NEXT: 0x6 R_WEBASSEMBLY_MEMORY_ADDR_I32[10] 0
136 ; CHECK-NEXT: 0xF R_WEBASSEMBLY_TABLE_INDEX_I32[8]
135 ; CHECK-NEXT: 0x6 R_WEBASSEMBLY_MEMORY_ADDR_I32 myextern 0
136 ; CHECK-NEXT: 0xF R_WEBASSEMBLY_TABLE_INDEX_I32 f2
137137 ; CHECK-NEXT: }
138138 ; CHECK-NEXT: Section (9) .debug_info {
139 ; CHECK-NEXT: 0x6 R_WEBASSEMBLY_SECTION_OFFSET_I32[1] 0
140 ; CHECK-NEXT: 0xC R_WEBASSEMBLY_SECTION_OFFSET_I32[0] 0
141 ; CHECK-NEXT: 0x12 R_WEBASSEMBLY_SECTION_OFFSET_I32[0] 55
142 ; CHECK-NEXT: 0x16 R_WEBASSEMBLY_SECTION_OFFSET_I32[7] 0
143 ; CHECK-NEXT: 0x1A R_WEBASSEMBLY_SECTION_OFFSET_I32[0] 62
144 ; CHECK-NEXT: 0x1E R_WEBASSEMBLY_FUNCTION_OFFSET_I32[8] 0
145 ; CHECK-NEXT: 0x27 R_WEBASSEMBLY_SECTION_OFFSET_I32[0] 105
146 ; CHECK-NEXT: 0x33 R_WEBASSEMBLY_MEMORY_ADDR_I32[9] 0
147 ; CHECK-NEXT: 0x3D R_WEBASSEMBLY_SECTION_OFFSET_I32[0] 109
148 ; CHECK-NEXT: 0x44 R_WEBASSEMBLY_SECTION_OFFSET_I32[0] 113
149 ; CHECK-NEXT: 0x50 R_WEBASSEMBLY_MEMORY_ADDR_I32[11] 0
150 ; CHECK-NEXT: 0x5B R_WEBASSEMBLY_FUNCTION_OFFSET_I32[8] 0
151 ; CHECK-NEXT: 0x63 R_WEBASSEMBLY_SECTION_OFFSET_I32[0] 118
139 ; CHECK-NEXT: 0x6 R_WEBASSEMBLY_SECTION_OFFSET_I32 .debug_abbrev 0
140 ; CHECK-NEXT: 0xC R_WEBASSEMBLY_SECTION_OFFSET_I32 .debug_str 0
141 ; CHECK-NEXT: 0x12 R_WEBASSEMBLY_SECTION_OFFSET_I32 .debug_str 55
142 ; CHECK-NEXT: 0x16 R_WEBASSEMBLY_SECTION_OFFSET_I32 .debug_line 0
143 ; CHECK-NEXT: 0x1A R_WEBASSEMBLY_SECTION_OFFSET_I32 .debug_str 62
144 ; CHECK-NEXT: 0x1E R_WEBASSEMBLY_FUNCTION_OFFSET_I32 f2 0
145 ; CHECK-NEXT: 0x27 R_WEBASSEMBLY_SECTION_OFFSET_I32 .debug_str 105
146 ; CHECK-NEXT: 0x33 R_WEBASSEMBLY_MEMORY_ADDR_I32 foo 0
147 ; CHECK-NEXT: 0x3D R_WEBASSEMBLY_SECTION_OFFSET_I32 .debug_str 109
148 ; CHECK-NEXT: 0x44 R_WEBASSEMBLY_SECTION_OFFSET_I32 .debug_str 113
149 ; CHECK-NEXT: 0x50 R_WEBASSEMBLY_MEMORY_ADDR_I32 ptr2 0
150 ; CHECK-NEXT: 0x5B R_WEBASSEMBLY_FUNCTION_OFFSET_I32 f2 0
151 ; CHECK-NEXT: 0x63 R_WEBASSEMBLY_SECTION_OFFSET_I32 .debug_str 118
152152 ; CHECK-NEXT: }
153153 ; CHECK-NEXT: Section (12) .debug_pubnames {
154 ; CHECK-NEXT: 0x6 R_WEBASSEMBLY_SECTION_OFFSET_I32[2] 0
154 ; CHECK-NEXT: 0x6 R_WEBASSEMBLY_SECTION_OFFSET_I32 .debug_info 0
155155 ; CHECK-NEXT: }
156156 ; CHECK-NEXT: Section (13) .debug_pubtypes {
157 ; CHECK-NEXT: 0x6 R_WEBASSEMBLY_SECTION_OFFSET_I32[2] 0
157 ; CHECK-NEXT: 0x6 R_WEBASSEMBLY_SECTION_OFFSET_I32 .debug_info 0
158158 ; CHECK-NEXT: }
159159 ; CHECK-NEXT: Section (14) .debug_line {
160 ; CHECK-NEXT: 0x2B R_WEBASSEMBLY_FUNCTION_OFFSET_I32[8] 0
160 ; CHECK-NEXT: 0x2B R_WEBASSEMBLY_FUNCTION_OFFSET_I32 f2 0
161161 ; CHECK-NEXT: }
162162 ; CHECK-NEXT:]
163163 ; CHECK-NEXT:Symbols [
2323 ret void
2424 }
2525
26 ; CHECK: Section {
27 ; CHECK: Type: ELEM (0x9)
28 ; CHECK: Size: 7
29 ; CHECK: }
26 ; CHECK: Type: ELEM (0x9)
27 ; CHECK-NEXT: Size: 7
3028
31 ; CHECK: Relocations [
32 ; CHECK: Section (5) CODE {
33 ; CHECK: Relocation {
34 ; CHECK: Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB (0)
35 ; CHECK: Offset: 0x4
36 ; CHECK: Index: 0x1
37 ; CHECK: }
38 ; CHECK: Relocation {
39 ; CHECK: Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB (0)
40 ; CHECK: Offset: 0xB
41 ; CHECK: Index: 0x2
42 ; CHECK: }
43 ; CHECK: Relocation {
44 ; CHECK: Type: R_WEBASSEMBLY_TABLE_INDEX_SLEB (1)
45 ; CHECK: Offset: 0x1E
46 ; CHECK: Index: 0x5
47 ; CHECK: }
48 ; CHECK: }
29 ; CHECK: Relocations [
30 ; CHECK-NEXT: Section (5) CODE {
31 ; CHECK-NEXT: Relocation {
32 ; CHECK-NEXT: Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB (0)
33 ; CHECK-NEXT: Offset: 0x4
34 ; CHECK-NEXT: Symbol: import1
35 ; CHECK-NEXT: }
36 ; CHECK-NEXT: Relocation {
37 ; CHECK-NEXT: Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB (0)
38 ; CHECK-NEXT: Offset: 0xB
39 ; CHECK-NEXT: Symbol: import2
40 ; CHECK-NEXT: }
41 ; CHECK-NEXT: Relocation {
42 ; CHECK-NEXT: Type: R_WEBASSEMBLY_GLOBAL_INDEX_LEB (7)
43 ; CHECK-NEXT: Offset: 0x15
44 ; CHECK-NEXT: Symbol: __stack_pointer
45 ; CHECK-NEXT: }
46 ; CHECK-NEXT: Relocation {
47 ; CHECK-NEXT: Type: R_WEBASSEMBLY_TABLE_INDEX_SLEB (1)
48 ; CHECK-NEXT: Offset: 0x1E
49 ; CHECK-NEXT: Symbol: import3
50 ; CHECK-NEXT: }
51 ; CHECK-NEXT: }
52 ; CHECK-NEXT: ]
2727 ; CHECK-NEXT: Relocation {
2828 ; CHECK-NEXT: Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB (3)
2929 ; CHECK-NEXT: Offset: 0x9
30 ; CHECK-NEXT: Index: 0x1
30 ; CHECK-NEXT: Symbol: b
3131 ; CHECK-NEXT: Addend: 0
3232 ; CHECK-NEXT: }
3333 ; CHECK-NEXT: Relocation {
3434 ; CHECK-NEXT: Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB (3)
3535 ; CHECK-NEXT: Offset: 0x14
36 ; CHECK-NEXT: Index: 0x2
36 ; CHECK-NEXT: Symbol: a
3737 ; CHECK-NEXT: Addend: 0
3838 ; CHECK-NEXT: }
3939 ; CHECK-NEXT: Relocation {
4949 ; CHECK-NEXT: Relocation {
5050 ; CHECK-NEXT: Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB (0)
5151 ; CHECK-NEXT: Offset: 0x2D
52 ; CHECK-NEXT: Index: 0x3
52 ; CHECK-NEXT: Symbol: c
5353 ; CHECK-NEXT: }
5454 ; CHECK-NEXT: Relocation {
5555 ; CHECK-NEXT: Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB (0)
5656 ; CHECK-NEXT: Offset: 0x34
57 ; CHECK-NEXT: Index: 0x4
57 ; CHECK-NEXT: Symbol: d
5858 ; CHECK-NEXT: }
5959 ; CHECK-NEXT: }
6060 ; CHECK-NEXT: ]
1616 ; CHECK-NEXT: Relocation {
1717 ; CHECK-NEXT: Type: R_WEBASSEMBLY_MEMORY_ADDR_I32 (5)
1818 ; CHECK-NEXT: Offset: 0x13
19 ; CHECK-NEXT: Index: 0x2
19 ; CHECK-NEXT: Symbol: foo
2020 ; CHECK-NEXT: Addend: 8
2121 ; CHECK-NEXT: }
2222 ; CHECK-NEXT: Relocation {
2323 ; CHECK-NEXT: Type: R_WEBASSEMBLY_MEMORY_ADDR_I32 (5)
2424 ; CHECK-NEXT: Offset: 0x1C
25 ; CHECK-NEXT: Index: 0x0
25 ; CHECK-NEXT: Symbol: bar
2626 ; CHECK-NEXT: Addend: -16
2727 ; CHECK-NEXT: }
2828 ; CHECK-NEXT: Relocation {
2929 ; CHECK-NEXT: Type: R_WEBASSEMBLY_MEMORY_ADDR_I32 (5)
3030 ; CHECK-NEXT: Offset: 0x25
31 ; CHECK-NEXT: Index: 0x2
31 ; CHECK-NEXT: Symbol: foo
3232 ; CHECK-NEXT: Addend: 0
3333 ; CHECK-NEXT: }
3434 ; CHECK-NEXT: Relocation {
3535 ; CHECK-NEXT: Type: R_WEBASSEMBLY_MEMORY_ADDR_I32 (5)
3636 ; CHECK-NEXT: Offset: 0x29
37 ; CHECK-NEXT: Index: 0x2
37 ; CHECK-NEXT: Symbol: foo
3838 ; CHECK-NEXT: Addend: 0
3939 ; CHECK-NEXT: }
4040 ; CHECK-NEXT: Relocation {
4141 ; CHECK-NEXT: Type: R_WEBASSEMBLY_MEMORY_ADDR_I32 (5)
4242 ; CHECK-NEXT: Offset: 0x2D
43 ; CHECK-NEXT: Index: 0x2
43 ; CHECK-NEXT: Symbol: foo
4444 ; CHECK-NEXT: Addend: 0
4545 ; CHECK-NEXT: }
4646 ; CHECK-NEXT: }
290290 WASM-NEXT: Relocation {
291291 WASM-NEXT: Type: R_WEBASSEMBLY_MEMORY_ADDR_SLEB (4)
292292 WASM-NEXT: Offset: 0x4
293 WASM-NEXT: Index: 0x1
293 WASM-NEXT: Symbol: .L.str
294294 WASM-NEXT: Addend: 0
295295 WASM-NEXT: }
296296 WASM-NEXT: Relocation {
297297 WASM-NEXT: Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB (0)
298298 WASM-NEXT: Offset: 0xA
299 WASM-NEXT: Index: 0x2
299 WASM-NEXT: Symbol: puts
300300 WASM-NEXT: }
301301 WASM-NEXT: Relocation {
302302 WASM-NEXT: Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB (0)
303303 WASM-NEXT: Offset: 0x11
304 WASM-NEXT: Index: 0x3
304 WASM-NEXT: Symbol: SomeOtherFunction
305305 WASM-NEXT: }
306306 WASM-NEXT: }
307307 WASM-NEXT: ]
7979 Reloc.getTypeName(RelocTypeName);
8080 const wasm::WasmRelocation &WasmReloc = Obj->getWasmRelocation(Reloc);
8181
82 StringRef SymName;
83 symbol_iterator SI = Reloc.getSymbol();
84 if (SI != Obj->symbol_end())
85 SymName = error(SI->getName());
86
8287 bool HasAddend = false;
8388 switch (RelocType) {
8489 case wasm::R_WEBASSEMBLY_MEMORY_ADDR_LEB:
95100 DictScope Group(W, "Relocation");
96101 W.printNumber("Type", RelocTypeName, RelocType);
97102 W.printHex("Offset", Reloc.getOffset());
98 W.printHex("Index", WasmReloc.Index);
103 if (!SymName.empty())
104 W.printString("Symbol", SymName);
105 else
106 W.printHex("Index", WasmReloc.Index);
99107 if (HasAddend)
100108 W.printNumber("Addend", WasmReloc.Addend);
101109 } else {
102110 raw_ostream& OS = W.startLine();
103 OS << W.hex(Reloc.getOffset()) << " " << RelocTypeName << "["
104 << WasmReloc.Index << "]";
111 OS << W.hex(Reloc.getOffset()) << " " << RelocTypeName << " ";
112 if (!SymName.empty())
113 OS << SymName;
114 else
115 OS << WasmReloc.Index;
105116 if (HasAddend)
106117 OS << " " << WasmReloc.Addend;
107118 OS << "\n";