summaryrefslogtreecommitdiff
path: root/test/MC/MachO/reloc.s
blob: 800dd6de4f361ffa929a7963b9dab2ffdbdf08f8 (plain)
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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
// RUN: llvm-mc -triple i386-apple-darwin9 %s -filetype=obj -o - | macho-dump --dump-section-data | FileCheck %s

        .data
        .long undef
        .long (undef + 4)

        .globl local_a_ext
local_a_ext:
        .long local_a_ext

local_a:
        .long 0
local_a_elt:
        .long 0
local_b:
        .long local_b - local_c + 245
        .long 0
local_c:
        .long 0


        .long local_a_elt + 1
        .long local_a_elt + 10
        .short local_a_elt + 20
        .byte local_a_elt + 89

        .const

        .long
bar:
        .long local_a_elt - bar + 33

L0:
        .long L0
        .long L1

        .text
_f0:
L1:
        jmp L0
        jmp L1
        ret

        .objc_class_name_A=0
	.globl .objc_class_name_A

        .text
        .globl _f1
        .weak_definition _f1
_f1:
        .data
        .long _f1
        .long _f1 + 4

// CHECK: ('cputype', 7)
// CHECK: ('cpusubtype', 3)
// CHECK: ('filetype', 1)
// CHECK: ('num_load_commands', 1)
// CHECK: ('load_commands_size', 364)
// CHECK: ('flag', 0)
// CHECK: ('load_commands', [
// CHECK:   # Load Command 0
// CHECK:  (('command', 1)
// CHECK:   ('size', 260)
// CHECK:   ('segment_name', '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
// CHECK:   ('vm_addr', 0)
// CHECK:   ('vm_size', 71)
// CHECK:   ('file_offset', 392)
// CHECK:   ('file_size', 71)
// CHECK:   ('maxprot', 7)
// CHECK:   ('initprot', 7)
// CHECK:   ('num_sections', 3)
// CHECK:   ('flags', 0)
// CHECK:   ('sections', [
// CHECK:     # Section 0
// CHECK:    (('section_name', '__text\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
// CHECK:     ('segment_name', '__TEXT\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
// CHECK:     ('address', 0)
// CHECK:     ('size', 8)
// CHECK:     ('offset', 392)
// CHECK:     ('alignment', 0)
// CHECK:     ('reloc_offset', 464)
// CHECK:     ('num_reloc', 1)
// CHECK:     ('flags', 0x80000400)
// CHECK:     ('reserved1', 0)
// CHECK:     ('reserved2', 0)
// CHECK:    ),
// CHECK:   ('_relocations', [
// CHECK:     # Relocation 0
// CHECK:     (('word-0', 0x1),
// CHECK:      ('word-1', 0x5000003)),
// CHECK:   ])
// CHECK:   ('_section_data', 'e93a0000 00ebf9c3')
// CHECK:     # Section 1
// CHECK:    (('section_name', '__data\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
// CHECK:     ('segment_name', '__DATA\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
// CHECK:     ('address', 8)
// CHECK:     ('size', 51)
// CHECK:     ('offset', 400)
// CHECK:     ('alignment', 0)
// CHECK:     ('reloc_offset', 472)
// CHECK:     ('num_reloc', 11)
// CHECK:     ('flags', 0x0)
// CHECK:     ('reserved1', 0)
// CHECK:     ('reserved2', 0)
// CHECK:    ),
// CHECK:   ('_relocations', [
// CHECK:     # Relocation 0
// CHECK:     (('word-0', 0x2f),
// CHECK:      ('word-1', 0xc000007)),
// CHECK:     # Relocation 1
// CHECK:     (('word-0', 0x2b),
// CHECK:      ('word-1', 0xc000007)),
// CHECK:     # Relocation 2
// CHECK:     (('word-0', 0x8000002a),
// CHECK:      ('word-1', 0x18)),
// CHECK:     # Relocation 3
// CHECK:     (('word-0', 0x90000028),
// CHECK:      ('word-1', 0x18)),
// CHECK:     # Relocation 4
// CHECK:     (('word-0', 0xa0000024),
// CHECK:      ('word-1', 0x18)),
// CHECK:     # Relocation 5
// CHECK:     (('word-0', 0xa0000020),
// CHECK:      ('word-1', 0x18)),
// CHECK:     # Relocation 6
// CHECK:     (('word-0', 0xa4000014),
// CHECK:      ('word-1', 0x1c)),
// CHECK:     # Relocation 7
// CHECK:     (('word-0', 0xa1000000),
// CHECK:      ('word-1', 0x24)),
// CHECK:     # Relocation 8
// CHECK:     (('word-0', 0x8),
// CHECK:      ('word-1', 0x4000002)),
// CHECK:     # Relocation 9
// CHECK:     (('word-0', 0x4),
// CHECK:      ('word-1', 0xc000009)),
// CHECK:     # Relocation 10
// CHECK:     (('word-0', 0x0),
// CHECK:      ('word-1', 0xc000009)),
// CHECK:   ])
// CHECK:   ('_section_data', '00000000 04000000 10000000 00000000 00000000 ed000000 00000000 00000000 19000000 22000000 2c007100 00000004 000000')
// CHECK:     # Section 2
// CHECK:    (('section_name', '__const\x00\x00\x00\x00\x00\x00\x00\x00\x00')
// CHECK:     ('segment_name', '__TEXT\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
// CHECK:     ('address', 59)
// CHECK:     ('size', 12)
// CHECK:     ('offset', 451)
// CHECK:     ('alignment', 0)
// CHECK:     ('reloc_offset', 560)
// CHECK:     ('num_reloc', 4)
// CHECK:     ('flags', 0x0)
// CHECK:     ('reserved1', 0)
// CHECK:     ('reserved2', 0)
// CHECK:    ),
// CHECK:   ('_relocations', [
// CHECK:     # Relocation 0
// CHECK:     (('word-0', 0x8),
// CHECK:      ('word-1', 0x4000001)),
// CHECK:     # Relocation 1
// CHECK:     (('word-0', 0x4),
// CHECK:      ('word-1', 0x4000003)),
// CHECK:     # Relocation 2
// CHECK:     (('word-0', 0xa4000000),
// CHECK:      ('word-1', 0x18)),
// CHECK:     # Relocation 3
// CHECK:     (('word-0', 0xa1000000),
// CHECK:      ('word-1', 0x3b)),
// CHECK:   ])
// CHECK:   ('_section_data', 'feffffff 3f000000 00000000')
// CHECK:   ])
// CHECK:  ),
// CHECK:   # Load Command 1
// CHECK:  (('command', 2)
// CHECK:   ('size', 24)
// CHECK:   ('symoff', 592)
// CHECK:   ('nsyms', 10)
// CHECK:   ('stroff', 712)
// CHECK:   ('strsize', 88)
// CHECK:   ('_string_data', '\x00undef\x00local_a_ext\x00.objc_class_name_A\x00_f1\x00local_a\x00local_a_elt\x00local_b\x00local_c\x00bar\x00_f0\x00\x00\x00')
// CHECK:   ('_symbols', [
// CHECK:     # Symbol 0
// CHECK:    (('n_strx', 42)
// CHECK:     ('n_type', 0xe)
// CHECK:     ('n_sect', 2)
// CHECK:     ('n_desc', 0)
// CHECK:     ('n_value', 20)
// CHECK:     ('_string', 'local_a')
// CHECK:    ),
// CHECK:     # Symbol 1
// CHECK:    (('n_strx', 50)
// CHECK:     ('n_type', 0xe)
// CHECK:     ('n_sect', 2)
// CHECK:     ('n_desc', 0)
// CHECK:     ('n_value', 24)
// CHECK:     ('_string', 'local_a_elt')
// CHECK:    ),
// CHECK:     # Symbol 2
// CHECK:    (('n_strx', 62)
// CHECK:     ('n_type', 0xe)
// CHECK:     ('n_sect', 2)
// CHECK:     ('n_desc', 0)
// CHECK:     ('n_value', 28)
// CHECK:     ('_string', 'local_b')
// CHECK:    ),
// CHECK:     # Symbol 3
// CHECK:    (('n_strx', 70)
// CHECK:     ('n_type', 0xe)
// CHECK:     ('n_sect', 2)
// CHECK:     ('n_desc', 0)
// CHECK:     ('n_value', 36)
// CHECK:     ('_string', 'local_c')
// CHECK:    ),
// CHECK:     # Symbol 4
// CHECK:    (('n_strx', 78)
// CHECK:     ('n_type', 0xe)
// CHECK:     ('n_sect', 3)
// CHECK:     ('n_desc', 0)
// CHECK:     ('n_value', 59)
// CHECK:     ('_string', 'bar')
// CHECK:    ),
// CHECK:     # Symbol 5
// CHECK:    (('n_strx', 82)
// CHECK:     ('n_type', 0xe)
// CHECK:     ('n_sect', 1)
// CHECK:     ('n_desc', 0)
// CHECK:     ('n_value', 0)
// CHECK:     ('_string', '_f0')
// CHECK:    ),
// CHECK:     # Symbol 6
// CHECK:    (('n_strx', 19)
// CHECK:     ('n_type', 0x3)
// CHECK:     ('n_sect', 0)
// CHECK:     ('n_desc', 0)
// CHECK:     ('n_value', 0)
// CHECK:     ('_string', '.objc_class_name_A')
// CHECK:    ),
// CHECK:     # Symbol 7
// CHECK:    (('n_strx', 38)
// CHECK:     ('n_type', 0xf)
// CHECK:     ('n_sect', 1)
// CHECK:     ('n_desc', 128)
// CHECK:     ('n_value', 8)
// CHECK:     ('_string', '_f1')
// CHECK:    ),
// CHECK:     # Symbol 8
// CHECK:    (('n_strx', 7)
// CHECK:     ('n_type', 0xf)
// CHECK:     ('n_sect', 2)
// CHECK:     ('n_desc', 0)
// CHECK:     ('n_value', 16)
// CHECK:     ('_string', 'local_a_ext')
// CHECK:    ),
// CHECK:     # Symbol 9
// CHECK:    (('n_strx', 1)
// CHECK:     ('n_type', 0x1)
// CHECK:     ('n_sect', 0)
// CHECK:     ('n_desc', 0)
// CHECK:     ('n_value', 0)
// CHECK:     ('_string', 'undef')
// CHECK:    ),
// CHECK:   ])
// CHECK:  ),
// CHECK:   # Load Command 2
// CHECK:  (('command', 11)
// CHECK:   ('size', 80)
// CHECK:   ('ilocalsym', 0)
// CHECK:   ('nlocalsym', 6)
// CHECK:   ('iextdefsym', 6)
// CHECK:   ('nextdefsym', 3)
// CHECK:   ('iundefsym', 9)
// CHECK:   ('nundefsym', 1)
// CHECK:   ('tocoff', 0)
// CHECK:   ('ntoc', 0)
// CHECK:   ('modtaboff', 0)
// CHECK:   ('nmodtab', 0)
// CHECK:   ('extrefsymoff', 0)
// CHECK:   ('nextrefsyms', 0)
// CHECK:   ('indirectsymoff', 0)
// CHECK:   ('nindirectsyms', 0)
// CHECK:   ('extreloff', 0)
// CHECK:   ('nextrel', 0)
// CHECK:   ('locreloff', 0)
// CHECK:   ('nlocrel', 0)
// CHECK:   ('_indirect_symbols', [
// CHECK:   ])
// CHECK:  ),
// CHECK: ])