summaryrefslogtreecommitdiffstats
path: root/lld/test/mach-o/parse-relocs-x86.yaml
blob: b93b43645714b8bcfbb30e287d568b46d24e041e (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
289
290
291
292
293
294
295
296
# RUN: ld64.lld -arch i386 -r -print_atoms %s -o %t  | FileCheck %s \
# RUN: && ld64.lld -arch i386 -r -print_atoms %t -o %t2  | FileCheck %s
#
# Test parsing and writing of x86 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.
#
#  .text
#_test:
#  	call _undef
#  	call _undef+2
#  	call _foo
#  	call _foo+2
#   callw _undef
#  	callw _foo
#  	callw _foo+2
#L1:
#  	movl	_undef, %eax
#   movl	_x, %eax
#   movl	_x+4, %eax
#  	movl	_x-L1(%eax), %eax
#  	movl	_x+4-L1(%eax), %eax
#
#_foo:
#    ret
#
#  .data
#_x:
#  .long _undef
#  .long _undef+7
#  .long _foo
#  .long _foo+3
#  .long _test - .
#  .long _test+3 - .
#

--- !mach-o
arch:            x86
file-type:       MH_OBJECT
flags:           [ MH_SUBSECTIONS_VIA_SYMBOLS ]
OS:              unknown
sections:
  - segment:         __TEXT
    section:         __text
    type:            S_REGULAR
    attributes:      [ S_ATTR_PURE_INSTRUCTIONS, S_ATTR_SOME_INSTRUCTIONS ]
    address:         0x0000000000000000
    content:         [ 0xE8, 0xFB, 0xFF, 0xFF, 0xFF, 0xE8, 0xF8, 0xFF,
                       0xFF, 0xFF, 0xE8, 0x2C, 0x00, 0x00, 0x00, 0xE8,
                       0x29, 0x00, 0x00, 0x00, 0x66, 0xE8, 0xE8, 0xFF,
                       0x66, 0xE8, 0x1F, 0x00, 0x66, 0xE8, 0x1D, 0x00,
                       0xA1, 0x00, 0x00, 0x00, 0x00, 0xA1, 0x3C, 0x00,
                       0x00, 0x00, 0xA1, 0x40, 0x00, 0x00, 0x00, 0x8B,
                       0x80, 0x1C, 0x00, 0x00, 0x00, 0x8B, 0x80, 0x20,
                       0x00, 0x00, 0x00, 0xC3 ]
    relocations:
      - offset:          0x00000037
        scattered:       true
        type:            GENERIC_RELOC_LOCAL_SECTDIFF
        length:          2
        pc-rel:          false
        value:           0x0000003C
      - offset:          0x00000000
        scattered:       true
        type:            GENERIC_RELOC_PAIR
        length:          2
        pc-rel:          false
        value:           0x00000020
      - offset:          0x00000031
        scattered:       true
        type:            GENERIC_RELOC_LOCAL_SECTDIFF
        length:          2
        pc-rel:          false
        value:           0x0000003C
      - offset:          0x00000000
        scattered:       true
        type:            GENERIC_RELOC_PAIR
        length:          2
        pc-rel:          false
        value:           0x00000020
      - offset:          0x0000002B
        scattered:       true
        type:            GENERIC_RELOC_VANILLA
        length:          2
        pc-rel:          false
        value:           0x0000003C
      - offset:          0x00000026
        type:            GENERIC_RELOC_VANILLA
        length:          2
        pc-rel:          false
        extern:          false
        symbol:          2
      - offset:          0x00000021
        type:            GENERIC_RELOC_VANILLA
        length:          2
        pc-rel:          false
        extern:          true
        symbol:          3
      - offset:          0x0000001E
        scattered:       true
        type:            GENERIC_RELOC_VANILLA
        length:          1
        pc-rel:          true
        value:           0x0000003B
      - offset:          0x0000001A
        type:            GENERIC_RELOC_VANILLA
        length:          1
        pc-rel:          true
        extern:          false
        symbol:          1
      - offset:          0x00000016
        type:            GENERIC_RELOC_VANILLA
        length:          1
        pc-rel:          true
        extern:          true
        symbol:          3
      - offset:          0x00000010
        scattered:       true
        type:            GENERIC_RELOC_VANILLA
        length:          2
        pc-rel:          true
        value:           0x0000003B
      - offset:          0x0000000B
        type:            GENERIC_RELOC_VANILLA
        length:          2
        pc-rel:          true
        extern:          false
        symbol:          1
      - offset:          0x00000006
        type:            GENERIC_RELOC_VANILLA
        length:          2
        pc-rel:          true
        extern:          true
        symbol:          3
      - offset:          0x00000001
        type:            GENERIC_RELOC_VANILLA
        length:          2
        pc-rel:          true
        extern:          true
        symbol:          3
  - segment:         __DATA
    section:         __data
    type:            S_REGULAR
    attributes:      [  ]
    address:         0x000000000000003C
    content:         [ 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
                       0x3B, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00,
                       0xB4, 0xFF, 0xFF, 0xFF, 0xB3, 0xFF, 0xFF, 0xFF ]
    relocations:
      - offset:          0x00000014
        scattered:       true
        type:            GENERIC_RELOC_LOCAL_SECTDIFF
        length:          2
        pc-rel:          false
        value:           0x00000000
      - offset:          0x00000000
        scattered:       true
        type:            GENERIC_RELOC_PAIR
        length:          2
        pc-rel:          false
        value:           0x00000050
      - offset:          0x00000010
        scattered:       true
        type:            GENERIC_RELOC_LOCAL_SECTDIFF
        length:          2
        pc-rel:          false
        value:           0x00000000
      - offset:          0x00000000
        scattered:       true
        type:            GENERIC_RELOC_PAIR
        length:          2
        pc-rel:          false
        value:           0x0000004C
      - offset:          0x0000000C
        scattered:       true
        type:            GENERIC_RELOC_VANILLA
        length:          2
        pc-rel:          false
        value:           0x0000003B
      - offset:          0x00000008
        type:            GENERIC_RELOC_VANILLA
        length:          2
        pc-rel:          false
        extern:          false
        symbol:          1
      - offset:          0x00000004
        type:            GENERIC_RELOC_VANILLA
        length:          2
        pc-rel:          false
        extern:          true
        symbol:          3
      - offset:          0x00000000
        type:            GENERIC_RELOC_VANILLA
        length:          2
        pc-rel:          false
        extern:          true
        symbol:          3
local-symbols:
  - name:            _test
    type:            N_SECT
    sect:            1
    value:           0x0000000000000000
  - name:            _foo
    type:            N_SECT
    sect:            1
    value:           0x000000000000003B
  - name:            _x
    type:            N_SECT
    sect:            2
    value:           0x000000000000003C
undefined-symbols:
  - name:            _undef
    type:            N_UNDF
    scope:           [ N_EXT ]
    value:           0x0000000000000000
...

# CHECK: defined-atoms:
# CHECK:   - name:            _x
# CHECK:     type:            data
# CHECK:     references:
# CHECK:       - kind:            pointer32
# CHECK:         offset:          0
# CHECK:         target:          _undef
# CHECK-NOT:     addend:
# CHECK:       - kind:            pointer32
# CHECK:         offset:          4
# CHECK:         target:          _undef
# CHECK:         addend:          7
# CHECK:       - kind:            pointer32
# CHECK:         offset:          8
# CHECK:         target:          _foo
# CHECK-NOT:     addend:
# CHECK:       - kind:            pointer32
# CHECK:         offset:          12
# CHECK:         target:          _foo
# CHECK:         addend:          3
# CHECK:       - kind:            delta32
# CHECK:         offset:          16
# CHECK:         target:          _test
# CHECK:       - kind:            delta32
# CHECK:         offset:          20
# CHECK:         target:          _test
# CHECK:         addend:          3
# CHECK:  - name:            _test
# CHECK:    references:
# CHECK:      - kind:            branch32
# CHECK:        offset:          1
# CHECK:        target:          _undef
# CHECK-NOT:    addend:
# CHECK:      - kind:            branch32
# CHECK:        offset:          6
# CHECK:        target:          _undef
# CHECK:        addend:          2
# CHECK:      - kind:            branch32
# CHECK:        offset:          11
# CHECK:        target:          _foo
# CHECK-NOT:    addend:
# CHECK:      - kind:            branch32
# CHECK:        offset:          16
# CHECK:        target:          _foo
# CHECK:        addend:          2
# CHECK:      - kind:            branch16
# CHECK:        offset:          22
# CHECK:        target:          _undef
# CHECK-NOT:    addend:
# CHECK:      - kind:            branch16
# CHECK:        offset:          26
# CHECK:        target:          _foo
# CHECK-NOT:    addend:
# CHECK:      - kind:            branch16
# CHECK:        offset:          30
# CHECK:        target:          _foo
# CHECK:        addend:          2
# CHECK:      - kind:            abs32
# CHECK:        offset:          33
# CHECK:        target:          _undef
# CHECK:      - kind:            abs32
# CHECK:        offset:          38
# CHECK:        target:          _x
# CHECK:      - kind:            abs32
# CHECK:        offset:          43
# CHECK:        target:          _x
# CHECK:        addend:          4
# CHECK:      - kind:            funcRel32
# CHECK:        offset:          49
# CHECK:        target:          _x
# CHECK:        addend:          -32
# CHECK:      - kind:            funcRel32
# CHECK:        offset:          55
# CHECK:        target:          _x
# CHECK:        addend:          -28

OpenPOWER on IntegriCloud