2 // RUN
: llvm-mc
-filetype
=obj
-triple
=thumbv7a-none-linux-gnueabi
%s
-o
%t
3 // RUN
: llvm-mc
-filetype
=obj
-triple
=thumbv7a-none-linux-gnueabi
%S
/Inputs
/arm-thumb-blx-targets.s
-o
%ttarget
4 // RUN
: echo
"SECTIONS { \
5 // RUN: .R_ARM_CALL24_callee1 : { *(.R_ARM_CALL24_callee_low) } \
6 // RUN: .R_ARM_CALL24_callee2 : { *(.R_ARM_CALL24_callee_thumb_low) } \
7 // RUN: .caller : { *(.text) } \
8 // RUN: .R_ARM_CALL24_callee3 : { *(.R_ARM_CALL24_callee_high) } \
9 // RUN: .R_ARM_CALL24_callee4 : { *(.R_ARM_CALL24_callee_thumb_high) } } " > %t.script
10 // RUN
: ld.lld
--script
%t.script
%t %ttarget
-o
%t2
11 // RUN
: llvm-objdump
-d
%t2 | FileCheck
%s
12 // Test BLX instruction is chosen for Thumb
BL/BLX instruction
and ARM callee
13 // 2 byte nops are used to test the pc-rounding behaviour. As
a BLX from
a
14 // 2 byte aligned destination is defined as Align
(PC
,4) + immediate
:00
15 // FIXME
: llvm-mc has problems assembling BLX unless the destination is
16 // external. The targets of the
BL and BLX instructions are in arm-thumb-blx-target.s
18 .section .text, "ax",%progbits
22 .type _start,%function
36 // Expect BLX to thumb target to
be written out as
a BL
42 // CHECK
: Disassembly of section
.R_ARM_CALL24_callee1:
44 // CHECK-NEXT-ARM
: callee_low
:
45 // CHECK-NEXT-ARM
: b4
: 1e ff
2f e1 bx
lr
47 // CHECK
: Disassembly of section
.R_ARM_CALL24_callee2:
49 // CHECK-NEXT-THUMB
: callee_thumb_low
:
50 // CHECK-NEXT-THUMB
: 100: 70 47 bx
lr
52 // CHECK
: Disassembly of section
.caller:
55 // Align
(0x10000,4) - 0xff50 (65360) + 4 = 0xb4 = callee_low
56 // CHECK-NEXT-THUMB
: 10000: f0 f7 58 e8 blx
#-65360
57 // CHECK-NEXT-THUMB
: 10004: 00 bf nop
58 // Align
(0x10006,4) - 0xff54 (65364) + 4 = 0xb4 = callee_low
59 // CHECK-NEXT-THUMB
: 10006: f0 f7 56 e8 blx
#-65364
60 // CHECK-NEXT-THUMB
: 1000a: 00 bf nop
61 // Align
(0x1000c,4) + 0xf0 (240) + 4 = 0x10100 = callee_high
62 // CHECK-NEXT-THUMB
: 1000c
: 00 f0 78 e8 blx
#240
63 // CHECK-NEXT-THUMB
: 10010: 00 bf nop
64 // Align
(0x10012,4) + 0xec (236) + 4 = 0x10100 = callee_high
65 // CHECK-NEXT-THUMB
: 10012: 00 f0 76 e8 blx
#236
66 // CHECK-NEXT-THUMB
: 10016: 00 bf nop
67 // Align
(0x10018,4) + 0xfffffc (16777212) = 0x1010018 = blx_far
68 // CHECK-NEXT-THUMB
: 10018: ff
f3 fe c7 blx
#16777212
69 // CHECK-NEXT-THUMB
: 1001c
: 00 bf nop
70 // Align
(0x1001e,4) + 0xfffff8 (16777208) = 0x1010018 = blx_far
71 // CHECK-NEXT-THUMB
: 1001e
: ff
f3 fc c7 blx
#16777208
72 // CHECK-NEXT-THUMB
: 10022: 00 bf nop
73 // 10024 - 0xff28 (65320) + 4 = 0x100 = callee_thumb_low
74 // CHECK-NEXT-THUMB
: 10024: f0 f7 6c
f8 bl #-65320
75 // CHECK-NEXT-THUMB
: 10028: 00 bf nop
76 // 1002a + 0x1d2 (466) + 4 = 0x10200 = callee_thumb_high
77 // CHECK-NEXT-THUMB
: 1002a: 00 f0 e9
f8 bl #466
78 // CHECK-NEXT-THUMB
: 1002e
: 70 47 bx
lr
81 // CHECK
: Disassembly of section
.R_ARM_CALL24_callee3:
83 // CHECK-NEXT-ARM
: callee_high
:
84 // CHECK-NEXT-ARM
: 10100: 1e ff
2f e1 bx
lr
86 // CHECK
: Disassembly of section
.R_ARM_CALL24_callee4:
88 // CHECK-NEXT-THUMB
:callee_thumb_high
:
89 // CHECK-NEXT-THUMB
: 10200: 70 47 bx
lr