1# RUN: rm -rf %t && mkdir -p %t
2# RUN: llvm-mc -triple=thumbv7s-apple-ios7.0.0 -filetype=obj -o %t/MachO_Thumb.o %s
3# RUN: llvm-rtdyld -triple=thumbv7s-apple-ios7.0.0 -verify -check=%s %t/MachO_Thumb.o
4
5        .section        __TEXT,__text,regular,pure_instructions
6        .syntax unified
7
8        .globl  thumb_caller_thumb_callee
9        .p2align        1
10        .code   16
11        .thumb_func     thumb_caller_thumb_callee
12thumb_caller_thumb_callee:
13        nop
14
15        .globl  arm_caller_thumb_callee
16        .p2align        1
17        .code   16
18        .thumb_func     arm_caller_thumb_callee
19arm_caller_thumb_callee:
20        nop
21
22        .globl  thumb_caller_arm_callee
23        .p2align        1
24        .code   32
25thumb_caller_arm_callee:
26        nop
27
28        .globl  thumb_caller
29        .p2align        1
30        .code   16
31        .thumb_func     thumb_caller
32thumb_caller:
33        nop
34
35# Check that stubs for thumb callers use thumb code (not arm), and that thumb
36# callees have the low bit set on their addresses.
37#
38# rtdyld-check: *{4}(stub_addr(MachO_Thumb.o/__text, thumb_caller_thumb_callee)) = 0xf000f8df
39# rtdyld-check: *{4}(stub_addr(MachO_Thumb.o/__text, thumb_caller_thumb_callee) + 4) = (thumb_caller_thumb_callee | 0x1)
40        bl thumb_caller_thumb_callee
41
42# Check that arm callees do not have the low bit set on their addresses.
43#
44# rtdyld-check: *{4}(stub_addr(MachO_Thumb.o/__text, thumb_caller_arm_callee)) = 0xf000f8df
45# rtdyld-check: *{4}(stub_addr(MachO_Thumb.o/__text, thumb_caller_arm_callee) + 4) = thumb_caller_arm_callee
46        bl thumb_caller_arm_callee
47
48        .globl  arm_caller
49        .p2align        2
50        .code   32
51arm_caller:
52        nop
53
54# Check that stubs for arm callers use arm code (not thumb), and that thumb
55# callees have the low bit set on their addresses.
56# rtdyld-check: *{4}(stub_addr(MachO_Thumb.o/__text, arm_caller_thumb_callee)) = 0xe51ff004
57# rtdyld-check: *{4}(stub_addr(MachO_Thumb.o/__text, arm_caller_thumb_callee) + 4) = (arm_caller_thumb_callee | 0x1)
58        bl      arm_caller_thumb_callee
59        nop
60
61.subsections_via_symbols
62