parse-data-relocs-arm64.yaml
8.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# RUN: ld64.lld -arch arm64 -r -print_atoms %s -o %t | FileCheck %s
# RUN: ld64.lld -arch arm64 -r -print_atoms %t -o %t2 | FileCheck %s
#
# Test parsing and writing of arm64 data relocations.
#
# The first step tests if the supplied mach-o file is parsed into the correct
# set of references. The second step verifies relocations can be round-tripped
# by writing to a new .o file, then parsing that file which should result in
# the same references.
#
#_test:
--- !mach-o
arch: arm64
file-type: MH_OBJECT
flags: [ MH_SUBSECTIONS_VIA_SYMBOLS ]
sections:
- segment: __TEXT
section: __text
type: S_REGULAR
attributes: [ S_ATTR_PURE_INSTRUCTIONS, S_ATTR_SOME_INSTRUCTIONS ]
alignment: 4
address: 0x0000000000000000
content: [ 0xC0, 0x03, 0x5F, 0xD6 ]
- segment: __DATA
section: __data
type: S_REGULAR
attributes: [ ]
address: 0x0000000000000004
content: [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xDC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xC0, 0xFF, 0xFF, 0xFF, 0xBE, 0xFF, 0xFF, 0xFF,
0xB0, 0xFF, 0xFF, 0xFF ]
relocations:
- offset: 0x00000050
type: ARM64_RELOC_POINTER_TO_GOT
length: 2
pc-rel: true
extern: true
symbol: 2
- offset: 0x0000004C
type: ARM64_RELOC_SUBTRACTOR
length: 2
pc-rel: false
extern: true
symbol: 2
- offset: 0x0000004C
type: ARM64_RELOC_UNSIGNED
length: 2
pc-rel: false
extern: true
symbol: 2
- offset: 0x00000048
type: ARM64_RELOC_SUBTRACTOR
length: 2
pc-rel: false
extern: true
symbol: 2
- offset: 0x00000048
type: ARM64_RELOC_UNSIGNED
length: 2
pc-rel: false
extern: true
symbol: 2
- offset: 0x00000040
type: ARM64_RELOC_UNSIGNED
length: 3
pc-rel: false
extern: true
symbol: 2
- offset: 0x00000038
type: ARM64_RELOC_UNSIGNED
length: 3
pc-rel: false
extern: false
symbol: 2
- offset: 0x00000030
type: ARM64_RELOC_SUBTRACTOR
length: 3
pc-rel: false
extern: true
symbol: 2
- offset: 0x00000030
type: ARM64_RELOC_UNSIGNED
length: 3
pc-rel: false
extern: true
symbol: 2
- offset: 0x00000028
type: ARM64_RELOC_SUBTRACTOR
length: 3
pc-rel: false
extern: true
symbol: 2
- offset: 0x00000028
type: ARM64_RELOC_UNSIGNED
length: 3
pc-rel: false
extern: true
symbol: 2
- offset: 0x00000020
type: ARM64_RELOC_SUBTRACTOR
length: 3
pc-rel: false
extern: true
symbol: 2
- offset: 0x00000020
type: ARM64_RELOC_UNSIGNED
length: 3
pc-rel: false
extern: true
symbol: 2
- offset: 0x00000018
type: ARM64_RELOC_POINTER_TO_GOT
length: 3
pc-rel: false
extern: true
symbol: 2
- offset: 0x00000010
type: ARM64_RELOC_UNSIGNED
length: 3
pc-rel: false
extern: true
symbol: 2
- offset: 0x00000008
type: ARM64_RELOC_UNSIGNED
length: 3
pc-rel: false
extern: true
symbol: 2
local-symbols:
- name: _v1
type: N_SECT
sect: 2
value: 0x000000000000000C
global-symbols:
- name: _bar
type: N_SECT
scope: [ N_EXT ]
sect: 1
value: 0x0000000000000000
undefined-symbols:
- name: _foo
type: N_UNDF
scope: [ N_EXT ]
value: 0x0000000000000000
page-size: 0x00000000
...
# CHECK: defined-atoms:
# CHECK: - ref-name: L000
# CHECK: type: data
# CHECK: content: [ 00, 00, 00, 00, 00, 00, 00, 00 ]
# CHECK: - name: _v1
# CHECK: type: data
# CHECK: content: [ 00, 00, 00, 00, 00, 00, 00, 00, 08, 00, 00, 00,
# CHECK: 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00,
# CHECK: 00, 00, 00, 00, 00, 00, 00, 00, E0, FF, FF, FF,
# CHECK: FF, FF, FF, FF, DC, FF, FF, FF, FF, FF, FF, FF,
# CHECK: {{..}}, {{..}}, 00, 00, 00, 00, 00, 00, 04, 00, 00, 00,
# CHECK: 00, 00, 00, 00, C0, FF, FF, FF, BE, FF, FF, FF,
# CHECK: {{B0|B8}}, {{..}}, FF, FF ]
# CHECK: references:
# CHECK: - kind: pointer64
# CHECK: offset: 0
# CHECK: target: _foo
# CHECK-NOT: addend:
# CHECK: - kind: pointer64
# CHECK: offset: 8
# CHECK: target: _foo
# CHECK: addend: 8
# CHECK: - kind: pointer64ToGOT
# CHECK: offset: 16
# CHECK: target: _foo
# CHECK-NOT: addend:
# CHECK: - kind: delta64
# CHECK: offset: 24
# CHECK: target: _foo
# CHECK: addend: 24
# CHECK: - kind: delta64
# CHECK: offset: 32
# CHECK: target: _foo
# CHECK-NOT: addend:
# CHECK: - kind: delta64
# CHECK: offset: 40
# CHECK: target: _foo
# CHECK: addend: 4
# CHECK: - kind: pointer64
# CHECK: offset: 48
# CHECK: target: L000
# CHECK-NOT: addend:
# CHECK: - kind: pointer64
# CHECK: offset: 56
# CHECK: target: _foo
# CHECK: addend: 4
# CHECK: - kind: delta32
# CHECK: offset: 64
# CHECK: target: _foo
# CHECK-NOT: addend:
# CHECK: - kind: delta32
# CHECK: offset: 68
# CHECK: target: _foo
# CHECK: addend: 2
# CHECK: - kind: delta32ToGOT
# CHECK: offset: 72
# CHECK: target: _foo
# CHECK-NOT: addend:
# CHECK: - name: _bar
# CHECK: scope: global
# CHECK: content: [ C0, 03, 5F, D6 ]
# CHECK: alignment: 4
# CHECK: undefined-atoms:
# CHECK: - name: _foo
# .subsections_via_symbols
# .text
# .globl_foo
# .align2
# _foo:
# ret
# .data
#Lanon:
# .quad 0
#_v1:
# .quad _foo
# .quad _foo + 8
# .quad _foo@GOT
# .quad _foo + 24 - .
# .quad _foo - .
# .quad _foo + 4 - .
# .quad Lanon
# .quad Lanon + 4
# .long _foo - .
# .long _foo +2 - .
# .long _foo@GOT - .