summaryrefslogtreecommitdiffstats
path: root/lld/test/mach-o/arm-interworking.yaml
blob: 59c46050fab5c497393a36ce6d7198280cf14ca1 (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: lld -flavor darwin -arch armv7 -r -print_atoms %s \
# RUN: %p/Inputs/arm-interworking.yaml -o %t  | FileCheck %s \
# RUN: && lld -flavor darwin -arch armv7 -dylib -print_atoms \
# RUN:         %p/Inputs/libSystem.yaml %t -o %t2  | FileCheck %s \
# RUN: && llvm-readobj -s -sd %t2 | FileCheck -check-prefix=CODE %s
#
# Test thumb and arm branches round trip through -r.
# Test bl/blx instructions are fixed up properly.
#
#

--- !mach-o
arch:            armv7
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:       2
    address:         0x0000000000000000
    content:         [ 0xFF, 0xF7, 0xFE, 0xFF, 0xC0, 0x46, 0xFF, 0xF7,
                       0xFC, 0xEF, 0xC0, 0x46, 0xFF, 0xF7, 0xF8, 0xEF,
                       0xFF, 0xF7, 0xF6, 0xFF, 0xC0, 0x46, 0xFF, 0xF7,
                       0xF3, 0xFF, 0xC0, 0x46, 0x00, 0xF0, 0x06, 0xE8,
                       0xC0, 0x46, 0x00, 0xF0, 0x03, 0xF8, 0x00, 0xF0,
                       0x02, 0xF8, 0x70, 0x47, 0x70, 0x47, 0x70, 0x47 ]
    relocations:
      - offset:          0x00000026
        type:            ARM_THUMB_RELOC_BR22
        length:          2
        pc-rel:          true
        extern:          false
        symbol:          1
      - offset:          0x00000022
        type:            ARM_THUMB_RELOC_BR22
        length:          2
        pc-rel:          true
        extern:          false
        symbol:          1
      - offset:          0x0000001C
        type:            ARM_THUMB_RELOC_BR22
        length:          2
        pc-rel:          true
        extern:          false
        symbol:          1
      - offset:          0x00000016
        type:            ARM_THUMB_RELOC_BR22
        length:          2
        pc-rel:          true
        extern:          false
        symbol:          1
      - offset:          0x00000010
        type:            ARM_THUMB_RELOC_BR22
        length:          2
        pc-rel:          true
        extern:          false
        symbol:          1
      - offset:          0x0000000C
        type:            ARM_THUMB_RELOC_BR22
        length:          2
        pc-rel:          true
        extern:          true
        symbol:          5
      - offset:          0x00000006
        type:            ARM_THUMB_RELOC_BR22
        length:          2
        pc-rel:          true
        extern:          true
        symbol:          5
      - offset:          0x00000000
        type:            ARM_THUMB_RELOC_BR22
        length:          2
        pc-rel:          true
        extern:          true
        symbol:          4
  - segment:         __DATA
    section:         __data
    type:            S_REGULAR
    attributes:      [  ]
    address:         0x0000000000000030
    content:         [ 0x2D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ]
    relocations:
      - offset:          0x00000004
        type:            ARM_RELOC_VANILLA
        length:          2
        pc-rel:          false
        extern:          true
        symbol:          4
      - offset:          0x00000000
        type:            ARM_RELOC_VANILLA
        length:          2
        pc-rel:          false
        extern:          false
        symbol:          1
local-symbols:
  - name:            _t3
    type:            N_SECT
    sect:            1
    desc:            [ N_ARM_THUMB_DEF ]
    value:           0x000000000000002E
  - name:            _d1
    type:            N_SECT
    sect:            2
    value:           0x0000000000000030
global-symbols:
  - name:            _t1
    type:            N_SECT
    scope:           [ N_EXT ]
    sect:            1
    desc:            [ N_ARM_THUMB_DEF ]
    value:           0x0000000000000000
  - name:            _t2
    type:            N_SECT
    scope:           [ N_EXT ]
    sect:            1
    desc:            [ N_ARM_THUMB_DEF ]
    value:           0x000000000000002C
undefined-symbols:
  - name:            _a1
    type:            N_UNDF
    scope:           [ N_EXT ]
    value:           0x0000000000000000
  - name:            _a2
    type:            N_UNDF
    scope:           [ N_EXT ]
    value:           0x0000000000000000

...


# CHECK: defined-atoms:
# CHECK:   - name:            _d1
# CHECK:     type:            data
# CHECK:     references:
# CHECK:       - kind:            pointer32
# CHECK:         offset:          0
# CHECK:         target:          _t2
# CHECK:       - kind:            pointer32
# CHECK:         offset:          4
# CHECK:         target:          _a1
# CHECK:   - name:            _d2
# CHECK:     type:            data
# CHECK:     references:
# CHECK:       - kind:            pointer32
# CHECK:         offset:          0
# CHECK:         target:          _t1
# CHECK:       - kind:            pointer32
# CHECK:         offset:          4
# CHECK:         target:          _a1
# CHECK:   - name:            _t1
# CHECK:     scope:           global
# CHECK:     references:
# CHECK:       - kind:            modeThumbCode
# CHECK:         offset:          0
# CHECK:         target:          _t1
# CHECK:       - kind:            thumb_bl22
# CHECK:         offset:          0
# CHECK:         target:          _a1
# CHECK:       - kind:            thumb_bl22
# CHECK:         offset:          6
# CHECK:         target:          _a2
# CHECK:       - kind:            thumb_bl22
# CHECK:         offset:          12
# CHECK:         target:          _a2
# CHECK:       - kind:            thumb_bl22
# CHECK:         offset:          16
# CHECK:         target:          _t1
# CHECK:       - kind:            thumb_bl22
# CHECK:         offset:          22
# CHECK:         target:          _t1
# CHECK:       - kind:            thumb_bl22
# CHECK:         offset:          28
# CHECK:         target:          _t2
# CHECK:       - kind:            thumb_bl22
# CHECK:         offset:          34
# CHECK:         target:          _t2
# CHECK:       - kind:            thumb_bl22
# CHECK:         offset:          38
# CHECK:         target:          _t3
# CHECK:   - name:            _t2
# CHECK:     scope:           global
# CHECK:     content:         [ 70, 47 ]
# CHECK:     references:
# CHECK:       - kind:            modeThumbCode
# CHECK:         offset:          0
# CHECK:         target:          _t2
# CHECK:   - name:            _t3
# CHECK:     content:         [ 70, 47 ]
# CHECK:     references:
# CHECK:       - kind:            modeThumbCode
# CHECK:         offset:          0
# CHECK:         target:          _t3
# CHECK:   - name:            _a1
# CHECK:     scope:           global
# CHECK:     references:
# CHECK:       - kind:            arm_bl24
# CHECK:         offset:          0
# CHECK:         target:          _a1
# CHECK:       - kind:            arm_bl24
# CHECK:         offset:          4
# CHECK:         target:          _a2
# CHECK:       - kind:            arm_bl24
# CHECK:         offset:          8
# CHECK:         target:          _t1
# CHECK:       - kind:            arm_bl24
# CHECK:         offset:          12
# CHECK:         target:          _t2
# CHECK:   - name:            _a2
# CHECK:     scope:           global

# CODE:     Name: __text (5F 5F 74 65 78 74 00 00 00 00 00 00 00 00 00 00)
# CODE:     Segment: __TEXT (5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00)
# CODE:     SectionData (
# CODE:       0000: 00F016E8 C04600F0 1EE8C046 00F01AE8
# CODE:       0010: FFF7F6FF C046FFF7 F3FFC046 00F006F8
# CODE:       0020: C04600F0 03F800F0 02F87047 70477047
# CODE:       0030: FEFFFFEB 020000EB F0FFFFFA FAFFFFFA
# CODE:       0040: 1EFF2FE1 1EFF2FE1
# CODE:     )

# CODE:     Name: __data (5F 5F 64 61 74 61 00 00 00 00 00 00 00 00 00 00)
# CODE:     Segment: __DATA (5F 5F 44 41 54 41 00 00 00 00 00 00 00 00 00 00)
# CODE:     SectionData (
# CODE:       0000: E50F0000 E80F0000 B90F0000 E80F0000
# CODE:     )

# When we get a good mach-o disassembler the above __text section content check can be change to be symbolic.
# Verify the low (thumb) bit is set on the first and third pointers but not the second and fourth.



# Input file one:
#
#	.align	2
#	.code	16
#  .globl _t1
#  .thumb_func	_t1
#_t1:
#    bl  _a1
#    nop
#    blx _a2
#    nop
#    blx _a2
#    bl  _t1
#    nop
#    bl  _t1
#    nop
#    blx _t2
#    nop
#    blx  _t2
#    bx   lr
#
#  .globl _t2
#  .thumb_func	_t2
#_t2:
#    bx   lr
#
#    .data
#_d1:  .long _t2
#      .long _a1



# Input file two:
#
#	.align	2
#	.code	32
#  .globl _a1
#_a1:
#    bl  _a1
#    blx _a2
#    bl  _t1
#    blx _t2
#    bx   lr
#
#  .globl _a2
#_a2:
#    bx   lr
#
#    .data
#_d2:  .long _t1
#      .long _a1




OpenPOWER on IntegriCloud