1 # RUN: ld64.lld -arch x86_64 -r -print_atoms %s -o %t | FileCheck %s \
2 # RUN: && ld64.lld -arch x86_64 -r -print_atoms %t -o %t2 | FileCheck %s
4 # Test parsing and writing of x86_64 text relocations.
6 # The first step tests if the supplied mach-o file is parsed into the correct
7 # set of references. The second step verifies relocations can be round-tripped
8 # by writing to a new .o file, then parsing that file which should result in
14 # movq _foo@GOTPCREL(%rip), %rax
15 # pushq _foo@GOTPCREL(%rip)
16 # movl _foo(%rip), %eax
17 # movl _foo+4(%rip), %eax
18 # movb $0x12, _foo(%rip)
19 # movw $0x1234, _foo(%rip)
20 # movl $0x12345678, _foo(%rip)
22 # movb $0x12, L2(%rip)
23 # movw $0x1234, L2(%rip)
24 # movl $0x12345678, L2(%rip)
38 attributes: [ S_ATTR_PURE_INSTRUCTIONS, S_ATTR_SOME_INSTRUCTIONS ]
39 address: 0x0000000000000000
40 content: [ 0xE8, 0x00, 0x00, 0x00, 0x00, 0xE8, 0x04, 0x00,
41 0x00, 0x00, 0x48, 0x8B, 0x05, 0x04, 0x00, 0x00,
42 0x00, 0xFF, 0x35, 0x04, 0x00, 0x00, 0x00, 0x8B,
43 0x05, 0x00, 0x00, 0x00, 0x00, 0x8B, 0x05, 0x04,
44 0x00, 0x00, 0x00, 0xC6, 0x05, 0xFF, 0xFF, 0xFF,
45 0xFF, 0x12, 0x66, 0xC7, 0x05, 0xFE, 0xFF, 0xFF,
46 0xFF, 0x34, 0x12, 0xC7, 0x05, 0xFC, 0xFF, 0xFF,
47 0xFF, 0x78, 0x56, 0x34, 0x12, 0x8B, 0x05, 0x1A,
48 0x00, 0x00, 0x00, 0xc6, 0x05, 0x13, 0x00, 0x00,
49 0x00, 0x12, 0x66, 0xc7, 0x05, 0x0a, 0x00, 0x00,
50 0x00, 0x34, 0x12, 0xc7, 0x05, 0x00, 0x00, 0x00,
51 0x00, 0x78, 0x56, 0x34, 0x12 ]
54 type: X86_64_RELOC_SIGNED_4
60 type: X86_64_RELOC_SIGNED_2
66 type: X86_64_RELOC_SIGNED_1
72 type: X86_64_RELOC_SIGNED
78 type: X86_64_RELOC_SIGNED_4
84 type: X86_64_RELOC_SIGNED_2
90 type: X86_64_RELOC_SIGNED_1
96 type: X86_64_RELOC_SIGNED
102 type: X86_64_RELOC_SIGNED
108 type: X86_64_RELOC_GOT
114 type: X86_64_RELOC_GOT_LOAD
120 type: X86_64_RELOC_BRANCH
126 type: X86_64_RELOC_BRANCH
135 address: 0x000000000000005D
136 content: [ 0x00, 0x00, 0x00, 0x00 ]
141 value: 0x0000000000000000
146 value: 0x0000000000000000
149 # CHECK: defined-atoms:
150 # CHECK: - ref-name: [[LABEL:L[0-9]+]]
152 # CHECK: content: [ 00, 00, 00, 00 ]
153 # CHECK: - name: _test
155 # CHECK: - kind: branch32
157 # CHECK: target: _foo
158 # CHECK: - kind: branch32
160 # CHECK: target: _foo
162 # CHECK: - kind: ripRel32GotLoad
164 # CHECK: target: _foo
166 # CHECK: - kind: ripRel32Got
168 # CHECK: target: _foo
170 # CHECK: - kind: ripRel32
172 # CHECK: target: _foo
173 # CHECK: - kind: ripRel32
175 # CHECK: target: _foo
177 # CHECK: - kind: ripRel32Minus1
179 # CHECK: target: _foo
181 # CHECK: - kind: ripRel32Minus2
183 # CHECK: target: _foo
185 # CHECK: - kind: ripRel32Minus4
187 # CHECK: target: _foo
189 # CHECK: - kind: ripRel32Anon
191 # CHECK: target: [[LABEL]]
193 # CHECK: - kind: ripRel32Minus1Anon
195 # CHECK: target: [[LABEL]]
197 # CHECK: - kind: ripRel32Minus2Anon
199 # CHECK: target: [[LABEL]]
201 # CHECK: - kind: ripRel32Minus4Anon
203 # CHECK: target: [[LABEL]]