1 // RUN: llvm-mc -triple x86_64-apple-darwin10 %s -filetype=obj -o - | llvm-readobj -file-headers -s -sd -r -t -macho-segment -macho-dysymtab -macho-indirect-symbols | FileCheck %s
5 // FIXME: llvm-mc doesn't handle this in a way we can make compatible with 'as',
6 // currently, because of how we handle assembler variables.
8 // See <rdar://problem/7763719> improve handling of absolute symbols
20 // FIXME: Darwin 'as' for historical reasons widens this jump, but doesn't emit
21 // a relocation. It seems like 'as' widens any jump that is not to a temporary,
22 // which is inherited from the x86_32 behavior, even though x86_64 could do
29 // FIXME: Darwin 'as' gets this wrong as well, even though it could get it right
30 // given the other things we do on x86_64. It is using a short jump here. This
31 // is probably fallout of the hack that exists for x86_32.
34 // FIXME: We don't support this, and would currently get it wrong, it should be a jump to an absolute address.
38 // FIXME: Darwin 'as' comes up with 'SIGNED' here instead of 'BRANCH'.
40 // FIXME: Darwin 'as' gets this completely wrong. It ends up with a single
41 // branch relocation. Fallout from the other delta hack?
48 // FIXME: Darwin 'as' gets this completely wrong. It ends up with a single
49 // branch relocation. Fallout from the other delta hack?
52 // FIXME: Darwin 'as' comes up with 'SIGNED' here instead of 'BRANCH'.
54 // FIXME: Darwin 'as' gets this completely wrong. It ends up with a single
55 // branch relocation. Fallout from the other delta hack?
59 // movl %eax,_baz(%rip)
65 // FIXME: Darwin 'as' gets most of these wrong, and there is an ambiguity in ATT
66 // syntax in what they should mean in the first place (absolute or
67 // rip-relative address).
68 // movl %eax,L0 - _g0(%rip)
69 // movl %eax,_g1 - _g0(%rip)
70 // movl %eax,_g1 - L1(%rip)
71 // movl %eax,L1 - _g0(%rip)
78 // FIXME: Darwin 'as' gets most of these wrong, and there is an ambiguity in ATT
79 // syntax in what they should mean in the first place (absolute or
80 // rip-relative address).
81 // movl %eax,L2 - _g2(%rip)
82 // movl %eax,_g3 - _g2(%rip)
83 // movl %eax,_g3 - L3(%rip)
84 // movl %eax,L3 - _g2(%rip)
120 // FIXME: Unfortunately, we do not get these relocations in exactly the same
121 // order as Darwin 'as'. It turns out that 'as' *usually* ends up emitting
122 // them in reverse address order, but sometimes it allocates some
123 // additional relocations late so these end up precede the other entries. I
124 // haven't figured out the exact criteria for this yet.
126 // CHECK: File: <stdin>
127 // CHECK: Format: Mach-O 64-bit x86-64
128 // CHECK: Arch: x86_64
129 // CHECK: AddressSize: 64bit
130 // CHECK: MachHeader {
131 // CHECK: Magic: Magic64 (0xFEEDFACF)
132 // CHECK: CpuType: X86-64 (0x1000007)
133 // CHECK: CpuSubType: CPU_SUBTYPE_X86_64_ALL (0x3)
134 // CHECK: FileType: Relocatable (0x1)
135 // CHECK: NumOfLoadCommands: 4
136 // CHECK: SizeOfLoadCommands: 352
137 // CHECK: Flags [ (0x0)
139 // CHECK: Reserved: 0x0
144 // CHECK: Name: __text (5F 5F 74 65 78 74 00 00 00 00 00 00 00 00 00 00)
145 // CHECK: Segment: __TEXT (5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00)
146 // CHECK: Address: 0x0
148 // CHECK: Offset: 384
149 // CHECK: Alignment: 0
150 // CHECK: RelocationOffset: 0x26C
151 // CHECK: RelocationCount: 12
153 // CHECK: Attributes [ (0x800004)
154 // CHECK: PureInstructions (0x800000)
155 // CHECK: SomeInstructions (0x4)
157 // CHECK: Reserved1: 0x0
158 // CHECK: Reserved2: 0x0
159 // CHECK: Reserved3: 0x0
160 // CHECK: SectionData (
161 // CHECK: 0000: 31C031C0 E9040000 00EBF9E9 00000000 |1.1.............|
162 // CHECK: 0010: E9000000 00E90200 0000E900 000000E9 |................|
163 // CHECK: 0020: 02000000 89050400 00008905 D2FFFFFF |................|
164 // CHECK: 0030: 8905CEFF FFFF8905 00000000 89050200 |................|
165 // CHECK: 0040: 00008905 00000000 89050200 00008905 |................|
166 // CHECK: 0050: 00000000 89050200 000031C0 31C0 |..........1.1.|
171 // CHECK: Name: __data (5F 5F 64 61 74 61 00 00 00 00 00 00 00 00 00 00)
172 // CHECK: Segment: __DATA (5F 5F 44 41 54 41 00 00 00 00 00 00 00 00 00 00)
173 // CHECK: Address: 0x5E
175 // CHECK: Offset: 478
176 // CHECK: Alignment: 0
177 // CHECK: RelocationOffset: 0x2CC
178 // CHECK: RelocationCount: 16
180 // CHECK: Attributes [ (0x4)
181 // CHECK: SomeInstructions (0x4)
183 // CHECK: Reserved1: 0x0
184 // CHECK: Reserved2: 0x0
185 // CHECK: Reserved3: 0x0
186 // CHECK: SectionData (
187 // CHECK: 0000: 31C00400 00000000 00000000 00000000 |1...............|
188 // CHECK: 0010: 00000200 00000000 00000000 00000000 |................|
189 // CHECK: 0020: 00000200 00000000 00000200 00000000 |................|
190 // CHECK: 0030: 00000000 00000000 00000200 00000000 |................|
191 // CHECK: 0040: 00000200 00000000 00000000 00000000 |................|
192 // CHECK: 0050: 00000200 00000000 00000000 00000000 |................|
193 // CHECK: 0060: 00000200 00000000 00000200 00000000 |................|
194 // CHECK: 0070: 00000000 00000000 00000200 00000000 |................|
195 // CHECK: 0080: 00000200 00000000 000031C0 31C0 |..........1.1.|
199 // CHECK: Relocations [
200 // CHECK: Section __text {
201 // CHECK: 0x56 1 2 1 X86_64_RELOC_SIGNED 0 _g3
202 // CHECK: 0x50 1 2 1 X86_64_RELOC_SIGNED 0 _g3
203 // CHECK: 0x4A 1 2 1 X86_64_RELOC_SIGNED 0 _g2
204 // CHECK: 0x44 1 2 1 X86_64_RELOC_SIGNED 0 _g2
205 // CHECK: 0x3E 1 2 1 X86_64_RELOC_SIGNED 0 _g1
206 // CHECK: 0x38 1 2 1 X86_64_RELOC_SIGNED 0 _g1
207 // CHECK: 0x20 1 2 1 X86_64_RELOC_BRANCH 0 _g3
208 // CHECK: 0x1B 1 2 1 X86_64_RELOC_BRANCH 0 _g3
209 // CHECK: 0x16 1 2 1 X86_64_RELOC_BRANCH 0 _g2
210 // CHECK: 0x11 1 2 1 X86_64_RELOC_BRANCH 0 _g2
211 // CHECK: 0xC 1 2 1 X86_64_RELOC_BRANCH 0 _g1
212 // CHECK: 0x5 1 2 1 X86_64_RELOC_BRANCH 0 _foo
214 // CHECK: Section __data {
215 // CHECK: 0x7A 0 3 1 X86_64_RELOC_SUBTRACTOR 0 _g0
216 // CHECK: 0x7A 0 3 1 X86_64_RELOC_UNSIGNED 0 _g1
217 // CHECK: 0x72 0 3 1 X86_64_RELOC_SUBTRACTOR 0 _g0
218 // CHECK: 0x72 0 3 1 X86_64_RELOC_UNSIGNED 0 _g1
219 // CHECK: 0x62 0 3 1 X86_64_RELOC_UNSIGNED 0 _g1
220 // CHECK: 0x5A 0 3 1 X86_64_RELOC_UNSIGNED 0 _g1
221 // CHECK: 0x52 0 3 1 X86_64_RELOC_UNSIGNED 0 _g0
222 // CHECK: 0x4A 0 3 1 X86_64_RELOC_UNSIGNED 0 _g0
223 // CHECK: 0x3A 0 3 1 X86_64_RELOC_SUBTRACTOR 0 _g2
224 // CHECK: 0x3A 0 3 1 X86_64_RELOC_UNSIGNED 0 _g3
225 // CHECK: 0x32 0 3 1 X86_64_RELOC_SUBTRACTOR 0 _g2
226 // CHECK: 0x32 0 3 1 X86_64_RELOC_UNSIGNED 0 _g3
227 // CHECK: 0x22 0 3 1 X86_64_RELOC_UNSIGNED 0 _g3
228 // CHECK: 0x1A 0 3 1 X86_64_RELOC_UNSIGNED 0 _g3
229 // CHECK: 0x12 0 3 1 X86_64_RELOC_UNSIGNED 0 _g2
230 // CHECK: 0xA 0 3 1 X86_64_RELOC_UNSIGNED 0 _g2
235 // CHECK: Name: _foo (1)
236 // CHECK: Type: Section (0xE)
237 // CHECK: Section: __text (0x1)
238 // CHECK: RefType: UndefinedNonLazy (0x0)
239 // CHECK: Flags [ (0x0)
244 // CHECK: Name: _g0 (18)
245 // CHECK: Type: Section (0xE)
246 // CHECK: Section: __text (0x1)
247 // CHECK: RefType: UndefinedNonLazy (0x0)
248 // CHECK: Flags [ (0x0)
253 // CHECK: Name: _g1 (14)
254 // CHECK: Type: Section (0xE)
255 // CHECK: Section: __text (0x1)
256 // CHECK: RefType: UndefinedNonLazy (0x0)
257 // CHECK: Flags [ (0x0)
259 // CHECK: Value: 0x5A
262 // CHECK: Name: _g2 (10)
263 // CHECK: Type: Section (0xE)
264 // CHECK: Section: __data (0x2)
265 // CHECK: RefType: UndefinedNonLazy (0x0)
266 // CHECK: Flags [ (0x0)
268 // CHECK: Value: 0x5E
271 // CHECK: Name: _g3 (6)
272 // CHECK: Type: Section (0xE)
273 // CHECK: Section: __data (0x2)
274 // CHECK: RefType: UndefinedNonLazy (0x0)
275 // CHECK: Flags [ (0x0)
277 // CHECK: Value: 0xE8
280 // CHECK: Indirect Symbols {
286 // CHECK: Cmd: LC_SEGMENT_64
289 // CHECK: vmaddr: 0x0
290 // CHECK: vmsize: 0xEC
291 // CHECK: fileoff: 384
292 // CHECK: filesize: 236
293 // CHECK: maxprot: rwx
294 // CHECK: initprot: rwx
299 // CHECK: ilocalsym: 0
300 // CHECK: nlocalsym: 5
301 // CHECK: iextdefsym: 5
302 // CHECK: nextdefsym: 0
303 // CHECK: iundefsym: 5
304 // CHECK: nundefsym: 0
307 // CHECK: modtaboff: 0
309 // CHECK: extrefsymoff: 0
310 // CHECK: nextrefsyms: 0
311 // CHECK: indirectsymoff: 0
312 // CHECK: nindirectsyms: 0
313 // CHECK: extreloff: 0
315 // CHECK: locreloff: 0