1RUN: llvm-readobj -r %p/Inputs/trivial.obj.coff-i386 \
2RUN:   | FileCheck %s -check-prefix COFF
3RUN: llvm-readobj -r %p/Inputs/bad-relocs.obj.coff-i386 \
4RUN:   | FileCheck %s -check-prefix BAD-COFF-RELOCS
5RUN: llvm-readobj -r %p/Inputs/relocs-no-symtab.obj.coff-i386 \
6RUN:   | FileCheck %s -check-prefix BAD-COFF-RELOCS
7RUN: llvm-readobj -r %p/Inputs/trivial.obj.elf-i386 \
8RUN:   | FileCheck %s -check-prefix ELF
9RUN: llvm-readobj -r %p/Inputs/trivial.obj.macho-i386 \
10RUN:   | FileCheck %s -check-prefix MACHO-I386
11RUN: llvm-readobj -r %p/Inputs/trivial.obj.macho-x86-64 \
12RUN:   | FileCheck %s -check-prefix MACHO-X86-64
13RUN: llvm-readobj -r --expand-relocs %p/Inputs/trivial.obj.macho-ppc \
14RUN:   | FileCheck %s -check-prefix MACHO-PPC
15RUN: llvm-readobj -r --expand-relocs %p/Inputs/trivial.obj.macho-ppc64 \
16RUN:   | FileCheck %s -check-prefix MACHO-PPC64
17RUN: llvm-readobj -r -expand-relocs %p/Inputs/trivial.obj.macho-arm \
18RUN:   | FileCheck %s -check-prefix MACHO-ARM
19RUN: llvm-readobj -r --expand-relocs %p/Inputs/trivial.obj.wasm \
20RUN:   | FileCheck %s -check-prefix WASM
21
22COFF:      Relocations [
23COFF-NEXT:   Section (1) .text {
24COFF-NEXT:     0x4 IMAGE_REL_I386_DIR32 .data
25COFF-NEXT:     0x9 IMAGE_REL_I386_REL32 _puts
26COFF-NEXT:     0xE IMAGE_REL_I386_REL32 _SomeOtherFunction
27COFF-NEXT:   }
28COFF-NEXT: ]
29
30BAD-COFF-RELOCS:      Relocations [
31BAD-COFF-RELOCS-NEXT:   Section (1) sec {
32BAD-COFF-RELOCS-NEXT:     0xDEADBEEF IMAGE_REL_I386_ABSOLUTE -
33BAD-COFF-RELOCS-NEXT:   }
34BAD-COFF-RELOCS-NEXT: ]
35
36ELF:      Relocations [
37ELF-NEXT:   Section (2) .rel.text {
38ELF-NEXT:     0xC R_386_GOTPC _GLOBAL_OFFSET_TABLE_ 0x0
39ELF-NEXT:     0x12 R_386_GOTOFF .L.str 0x0
40ELF-NEXT:     0x1A R_386_PLT32 puts 0x0
41ELF-NEXT:     0x1F R_386_PLT32 SomeOtherFunction 0x0
42ELF-NEXT:   }
43ELF-NEXT: ]
44
45MACHO-I386:      Relocations [
46MACHO-I386-NEXT:   Section __text {
47MACHO-I386-NEXT:     0x18 1 2 1 GENERIC_RELOC_VANILLA 0 _SomeOtherFunction
48MACHO-I386-NEXT:     0x13 1 2 1 GENERIC_RELOC_VANILLA 0 _puts
49MACHO-I386-NEXT:     0xB 0 2 n/a GENERIC_RELOC_LOCAL_SECTDIFF 1 0x22
50MACHO-I386-NEXT:     0x0 0 2 n/a GENERIC_RELOC_PAIR 1 0x8
51MACHO-I386-NEXT:   }
52MACHO-I386-NEXT: ]
53
54MACHO-X86-64: Relocations [
55MACHO-X86-64-NEXT:  Section __text {
56MACHO-X86-64-NEXT:    0xE 1 2 1 X86_64_RELOC_BRANCH 0 _SomeOtherFunction
57MACHO-X86-64-NEXT:    0x9 1 2 1 X86_64_RELOC_BRANCH 0 _puts
58MACHO-X86-64-NEXT:    0x4 1 2 1 X86_64_RELOC_SIGNED 0 L_.str
59MACHO-X86-64-NEXT:  }
60MACHO-X86-64-NEXT:]
61
62MACHO-PPC: Relocations [
63MACHO-PPC-NEXT:   Section __text {
64MACHO-PPC-NEXT:     Relocation {
65MACHO-PPC-NEXT:       Offset: 0x24
66MACHO-PPC-NEXT:       PCRel: 0
67MACHO-PPC-NEXT:       Length: 2
68MACHO-PPC-NEXT:       Type: PPC_RELOC_LO16_SECTDIFF (11)
69MACHO-PPC-NEXT:       Value: 0x64
70MACHO-PPC-NEXT:     }
71MACHO-PPC-NEXT:     Relocation {
72MACHO-PPC-NEXT:       Offset: 0x0
73MACHO-PPC-NEXT:       PCRel: 0
74MACHO-PPC-NEXT:       Length: 2
75MACHO-PPC-NEXT:       Type: PPC_RELOC_PAIR (1)
76MACHO-PPC-NEXT:       Value: 0xC
77MACHO-PPC-NEXT:     }
78MACHO-PPC-NEXT:     Relocation {
79MACHO-PPC-NEXT:       Offset: 0x1C
80MACHO-PPC-NEXT:       PCRel: 0
81MACHO-PPC-NEXT:       Length: 2
82MACHO-PPC-NEXT:       Type: PPC_RELOC_HA16_SECTDIFF (12)
83MACHO-PPC-NEXT:       Value: 0x64
84MACHO-PPC-NEXT:     }
85MACHO-PPC-NEXT:     Relocation {
86MACHO-PPC-NEXT:       Offset: 0x58
87MACHO-PPC-NEXT:       PCRel: 0
88MACHO-PPC-NEXT:       Length: 2
89MACHO-PPC-NEXT:       Type: PPC_RELOC_PAIR (1)
90MACHO-PPC-NEXT:       Value: 0xC
91MACHO-PPC-NEXT:     }
92MACHO-PPC-NEXT:     Relocation {
93MACHO-PPC-NEXT:       Offset: 0x18
94MACHO-PPC-NEXT:       PCRel: 1
95MACHO-PPC-NEXT:       Length: 2
96MACHO-PPC-NEXT:       Type: PPC_RELOC_BR24 (3)
97MACHO-PPC-NEXT:       Section: __picsymbolstub1 (2)
98MACHO-PPC-NEXT:     }
99MACHO-PPC-NEXT:   }
100MACHO-PPC-NEXT:   Section __picsymbolstub1 {
101MACHO-PPC-NEXT:     Relocation {
102MACHO-PPC-NEXT:       Offset: 0x14
103MACHO-PPC-NEXT:       PCRel: 0
104MACHO-PPC-NEXT:       Length: 2
105MACHO-PPC-NEXT:       Type: PPC_RELOC_LO16_SECTDIFF (11)
106MACHO-PPC-NEXT:       Value: 0x68
107MACHO-PPC-NEXT:     }
108MACHO-PPC-NEXT:     Relocation {
109MACHO-PPC-NEXT:       Offset: 0x0
110MACHO-PPC-NEXT:       PCRel: 0
111MACHO-PPC-NEXT:       Length: 2
112MACHO-PPC-NEXT:       Type: PPC_RELOC_PAIR (1)
113MACHO-PPC-NEXT:       Value: 0x48
114MACHO-PPC-NEXT:     }
115MACHO-PPC-NEXT:     Relocation {
116MACHO-PPC-NEXT:       Offset: 0xC
117MACHO-PPC-NEXT:       PCRel: 0
118MACHO-PPC-NEXT:       Length: 2
119MACHO-PPC-NEXT:       Type: PPC_RELOC_HA16_SECTDIFF (12)
120MACHO-PPC-NEXT:       Value: 0x68
121MACHO-PPC-NEXT:     }
122MACHO-PPC-NEXT:     Relocation {
123MACHO-PPC-NEXT:       Offset: 0x20
124MACHO-PPC-NEXT:       PCRel: 0
125MACHO-PPC-NEXT:       Length: 2
126MACHO-PPC-NEXT:       Type: PPC_RELOC_PAIR (1)
127MACHO-PPC-NEXT:       Value: 0x48
128MACHO-PPC-NEXT:     }
129MACHO-PPC-NEXT:   }
130MACHO-PPC-NEXT:   Section __la_symbol_ptr {
131MACHO-PPC-NEXT:     Relocation {
132MACHO-PPC-NEXT:       Offset: 0x0
133MACHO-PPC-NEXT:       PCRel: 0
134MACHO-PPC-NEXT:       Length: 2
135MACHO-PPC-NEXT:       Type: PPC_RELOC_VANILLA (0)
136MACHO-PPC-NEXT:       Symbol: dyld_stub_binding_helper (5)
137MACHO-PPC-NEXT:     }
138MACHO-PPC-NEXT:   }
139MACHO-PPC-NEXT: ]
140
141MACHO-PPC64: Relocations [
142MACHO-PPC64-NEXT:   Section __text {
143MACHO-PPC64-NEXT:     Relocation {
144MACHO-PPC64-NEXT:       Offset: 0x24
145MACHO-PPC64-NEXT:       PCRel: 0
146MACHO-PPC64-NEXT:       Length: 2
147MACHO-PPC64-NEXT:       Type:  (14)
148MACHO-PPC64-NEXT:       Value: 0x64
149MACHO-PPC64-NEXT:     }
150MACHO-PPC64-NEXT:     Relocation {
151MACHO-PPC64-NEXT:       Offset: 0x0
152MACHO-PPC64-NEXT:       PCRel: 0
153MACHO-PPC64-NEXT:       Length: 2
154MACHO-PPC64-NEXT:       Type:  (1)
155MACHO-PPC64-NEXT:       Value: 0xC
156MACHO-PPC64-NEXT:     }
157MACHO-PPC64-NEXT:     Relocation {
158MACHO-PPC64-NEXT:       Offset: 0x1C
159MACHO-PPC64-NEXT:       PCRel: 0
160MACHO-PPC64-NEXT:       Length: 2
161MACHO-PPC64-NEXT:       Type:  (12)
162MACHO-PPC64-NEXT:       Value: 0x64
163MACHO-PPC64-NEXT:     }
164MACHO-PPC64-NEXT:     Relocation {
165MACHO-PPC64-NEXT:       Offset: 0x58
166MACHO-PPC64-NEXT:       PCRel: 0
167MACHO-PPC64-NEXT:       Length: 2
168MACHO-PPC64-NEXT:       Type:  (1)
169MACHO-PPC64-NEXT:       Value: 0xC
170MACHO-PPC64-NEXT:     }
171MACHO-PPC64-NEXT:     Relocation {
172MACHO-PPC64-NEXT:       Offset: 0x18
173MACHO-PPC64-NEXT:       PCRel: 1
174MACHO-PPC64-NEXT:       Length: 2
175MACHO-PPC64-NEXT:       Type:  (3)
176MACHO-PPC64-NEXT:       Section: __picsymbolstub1 (2)
177MACHO-PPC64-NEXT:     }
178MACHO-PPC64-NEXT:   }
179MACHO-PPC64-NEXT:   Section __picsymbolstub1 {
180MACHO-PPC64-NEXT:     Relocation {
181MACHO-PPC64-NEXT:       Offset: 0x14
182MACHO-PPC64-NEXT:       PCRel: 0
183MACHO-PPC64-NEXT:       Length: 2
184MACHO-PPC64-NEXT:       Type:  (14)
185MACHO-PPC64-NEXT:       Value: 0x6C
186MACHO-PPC64-NEXT:     }
187MACHO-PPC64-NEXT:     Relocation {
188MACHO-PPC64-NEXT:       Offset: 0x0
189MACHO-PPC64-NEXT:       PCRel: 0
190MACHO-PPC64-NEXT:       Length: 2
191MACHO-PPC64-NEXT:       Type:  (1)
192MACHO-PPC64-NEXT:       Value: 0x48
193MACHO-PPC64-NEXT:     }
194MACHO-PPC64-NEXT:     Relocation {
195MACHO-PPC64-NEXT:       Offset: 0xC
196MACHO-PPC64-NEXT:       PCRel: 0
197MACHO-PPC64-NEXT:       Length: 2
198MACHO-PPC64-NEXT:       Type:  (12)
199MACHO-PPC64-NEXT:       Value: 0x6C
200MACHO-PPC64-NEXT:     }
201MACHO-PPC64-NEXT:     Relocation {
202MACHO-PPC64-NEXT:       Offset: 0x24
203MACHO-PPC64-NEXT:       PCRel: 0
204MACHO-PPC64-NEXT:       Length: 2
205MACHO-PPC64-NEXT:       Type:  (1)
206MACHO-PPC64-NEXT:       Value: 0x48
207MACHO-PPC64-NEXT:     }
208MACHO-PPC64-NEXT:   }
209MACHO-PPC64-NEXT:   Section __la_symbol_ptr {
210MACHO-PPC64-NEXT:     Relocation {
211MACHO-PPC64-NEXT:       Offset: 0x0
212MACHO-PPC64-NEXT:       PCRel: 0
213MACHO-PPC64-NEXT:       Length: 3
214MACHO-PPC64-NEXT:       Type:  (0)
215MACHO-PPC64-NEXT:       Symbol: dyld_stub_binding_helper (5)
216MACHO-PPC64-NEXT:     }
217MACHO-PPC64-NEXT:   }
218MACHO-PPC64-NEXT: ]
219
220
221MACHO-ARM:       Relocations [
222MACHO-ARM-NEXT:    Section __text {
223MACHO-ARM-NEXT:      Relocation {
224MACHO-ARM-NEXT:        Offset: 0x38
225MACHO-ARM-NEXT:        PCRel: 0
226MACHO-ARM-NEXT:        Length: 2
227MACHO-ARM-NEXT:        Type: ARM_RELOC_SECTDIFF (2)
228MACHO-ARM-NEXT:        Value: 0x40
229MACHO-ARM-NEXT:      }
230MACHO-ARM-NEXT:      Relocation {
231MACHO-ARM-NEXT:        Offset: 0x0
232MACHO-ARM-NEXT:        PCRel: 0
233MACHO-ARM-NEXT:        Length: 2
234MACHO-ARM-NEXT:        Type: ARM_RELOC_PAIR (1)
235MACHO-ARM-NEXT:        Value: 0x28
236MACHO-ARM-NEXT:      }
237MACHO-ARM-NEXT:      Relocation {
238MACHO-ARM-NEXT:        Offset: 0x20
239MACHO-ARM-NEXT:        PCRel: 1
240MACHO-ARM-NEXT:        Length: 2
241MACHO-ARM-NEXT:        Type: ARM_RELOC_BR24 (5)
242MACHO-ARM-NEXT:        Symbol: _g
243MACHO-ARM-NEXT:      }
244MACHO-ARM-NEXT:      Relocation {
245MACHO-ARM-NEXT:        Offset: 0x1C
246MACHO-ARM-NEXT:        PCRel: 0
247MACHO-ARM-NEXT:        Length: 1
248MACHO-ARM-NEXT:        Type: ARM_RELOC_HALF (8)
249MACHO-ARM-NEXT:        Symbol: _g
250MACHO-ARM-NEXT:      }
251MACHO-ARM-NEXT:      Relocation {
252MACHO-ARM-NEXT:        Offset: 0x0
253MACHO-ARM-NEXT:        PCRel: 0
254MACHO-ARM-NEXT:        Length: 1
255MACHO-ARM-NEXT:        Type: ARM_RELOC_PAIR (1)
256MACHO-ARM-NEXT:        Section: -
257MACHO-ARM-NEXT:      }
258MACHO-ARM-NEXT:      Relocation {
259MACHO-ARM-NEXT:        Offset: 0x18
260MACHO-ARM-NEXT:        PCRel: 0
261MACHO-ARM-NEXT:        Length: 0
262MACHO-ARM-NEXT:        Type: ARM_RELOC_HALF (8)
263MACHO-ARM-NEXT:        Symbol: _g
264MACHO-ARM-NEXT:      }
265MACHO-ARM-NEXT:      Relocation {
266MACHO-ARM-NEXT:        Offset: 0x0
267MACHO-ARM-NEXT:        PCRel: 0
268MACHO-ARM-NEXT:        Length: 0
269MACHO-ARM-NEXT:        Type: ARM_RELOC_PAIR (1)
270MACHO-ARM-NEXT:        Section: -
271MACHO-ARM-NEXT:      }
272MACHO-ARM-NEXT:      Relocation {
273MACHO-ARM-NEXT:        Offset: 0xC
274MACHO-ARM-NEXT:        PCRel: 0
275MACHO-ARM-NEXT:        Length: 2
276MACHO-ARM-NEXT:        Type: ARM_RELOC_SECTDIFF (2)
277MACHO-ARM-NEXT:        Value: 0x44
278MACHO-ARM-NEXT:      }
279MACHO-ARM-NEXT:      Relocation {
280MACHO-ARM-NEXT:        Offset: 0x0
281MACHO-ARM-NEXT:        PCRel: 0
282MACHO-ARM-NEXT:        Length: 2
283MACHO-ARM-NEXT:        Type: ARM_RELOC_PAIR (1)
284MACHO-ARM-NEXT:        Value: 0x4
285MACHO-ARM-NEXT:      }
286MACHO-ARM-NEXT:    }
287MACHO-ARM-NEXT:  ]
288
289WASM:      Relocations [
290WASM-NEXT:   Section (4) CODE {
291WASM-NEXT:     Relocation {
292WASM-NEXT:       Type: R_WEBASSEMBLY_MEMORY_ADDR_SLEB (4)
293WASM-NEXT:       Offset: 0x4
294WASM-NEXT:       Symbol: .L.str
295WASM-NEXT:       Addend: 0
296WASM-NEXT:     }
297WASM-NEXT:     Relocation {
298WASM-NEXT:       Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB (0)
299WASM-NEXT:       Offset: 0xA
300WASM-NEXT:       Symbol: puts
301WASM-NEXT:     }
302WASM-NEXT:     Relocation {
303WASM-NEXT:       Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB (0)
304WASM-NEXT:       Offset: 0x11
305WASM-NEXT:       Symbol: SomeOtherFunction
306WASM-NEXT:     }
307WASM-NEXT:   }
308WASM-NEXT: ]
309