1# RUN: ld64.lld -arch armv7 %s %p/Inputs/arm-shims.yaml \
2# RUN: -dylib %p/Inputs/armv7/libSystem.yaml -o %t
3# RUN: llvm-readobj -S --section-data %t | FileCheck %s
4#
5# Test b from arm to thumb or vice versa has shims added.s
6#
7#
8
9--- !mach-o
10arch:            armv7
11file-type:       MH_OBJECT
12flags:           [ MH_SUBSECTIONS_VIA_SYMBOLS ]
13sections:
14  - segment:         __TEXT
15    section:         __text
16    type:            S_REGULAR
17    attributes:      [ S_ATTR_PURE_INSTRUCTIONS, S_ATTR_SOME_INSTRUCTIONS ]
18    alignment:       2
19    address:         0x0000000000000000
20    content:         [ 0x00, 0xBF, 0xFF, 0xF7, 0xFE, 0xEF, 0xFF, 0xF7,
21                       0xFB, 0xBF, 0x00, 0x00, 0x00, 0xF0, 0x20, 0xE3,
22                       0xFA, 0xFF, 0xFF, 0xFA, 0xF9, 0xFF, 0xFF, 0xEA ]
23    relocations:
24      - offset:          0x00000014
25        type:            ARM_RELOC_BR24
26        length:          2
27        pc-rel:          true
28        extern:          true
29        symbol:          3
30      - offset:          0x00000010
31        type:            ARM_RELOC_BR24
32        length:          2
33        pc-rel:          true
34        extern:          true
35        symbol:          3
36      - offset:          0x00000006
37        type:            ARM_THUMB_RELOC_BR22
38        length:          2
39        pc-rel:          true
40        extern:          true
41        symbol:          2
42      - offset:          0x00000002
43        type:            ARM_THUMB_RELOC_BR22
44        length:          2
45        pc-rel:          true
46        extern:          true
47        symbol:          2
48global-symbols:
49  - name:            _a1
50    type:            N_SECT
51    scope:           [ N_EXT ]
52    sect:            1
53    value:           0x000000000000000C
54  - name:            _t1
55    type:            N_SECT
56    scope:           [ N_EXT ]
57    sect:            1
58    desc:            [ N_ARM_THUMB_DEF ]
59    value:           0x0000000000000000
60undefined-symbols:
61  - name:            _a2
62    type:            N_UNDF
63    scope:           [ N_EXT ]
64    value:           0x0000000000000000
65  - name:            _t2
66    type:            N_UNDF
67    scope:           [ N_EXT ]
68    value:           0x0000000000000000
69
70...
71
72# CHECK:   Section {
73# CHECK:     Name: __text (5F 5F 74 65 78 74 00 00 00 00 00 00 00 00 00 00)
74# CHECK:     Segment: __TEXT (5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00)
75# CHECK:     SectionData (
76# CHECK:       0000: 00BF00F0 10E800F0 19B80000 00F020E3
77# CHECK:       0010: 000000FA 0F0000EA 00BFFFF7 F8EF00F0
78# CHECK:       0020: 07B80000 00F020E3 F4FFFFFA 050000EA
79# CHECK:       0030: DFF804C0 FF446047 D4FFFFFF DFF804C0
80# CHECK:       0040: FF446047 E0FFFFFF 04C09FE5 0CC08FE0
81# CHECK:       0050: 1CFF2FE1 ADFFFFFF 04C09FE5 0CC08FE0
82# CHECK:       0060: 1CFF2FE1 B5FFFFFF
83# CHECK:     )
84
85# When we get a good mach-o disassembler the above __text section content check can be change to be symbolic.
86
87
88# Input file one:
89#
90#	.align	2
91#	.code	16
92#  .globl _t1
93#  .thumb_func	_t1
94#_t1:
95#    nop
96#    blx _a2
97#    b   _a2
98#
99#	.code	32
100#  .align 2
101#  .globl _a1
102#_a1:
103#    nop
104#    blx _t2
105#    b   _t2
106
107
108
109# Input file two:
110#
111#	.align	2
112#	.code	16
113#  .globl _t2
114#  .thumb_func	_t2
115#_t2:
116#    nop
117#    blx _a1
118#    b   _a1
119#
120#	.code	32
121#  .align 2
122#  .globl _a2
123#_a2:
124#    nop
125#    blx _t1
126#    b   _t1
127