blob: 24af92469dcdb49f44b3b1e19b837cab22aea32b [file] [log] [blame]
Fangrui Songb6772b82018-06-26 22:20:041// REQUIRES: arm
Peter Smithd1be0262018-08-20 09:19:302// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv6-none-linux-gnueabi %s -o %t
Fangrui Song5d4bc122019-07-22 11:37:033// RUN: ld.lld %t -o %t2
Fangrui Song024bf27d2019-08-27 11:52:364// RUN: llvm-objdump -d -triple=armv6-none-linux-gnueabi -start-address=0x12000 -stop-address=0x12008 %t2 | FileCheck -check-prefix=CHECK-ARM1 %s
5// RUN: llvm-objdump -d -triple=thumbv6-none-linux-gnueabi %t2 -start-address=0x12008 -stop-address=0x1200c | FileCheck -check-prefix=CHECK-THUMB1 %s
6// RUN: llvm-objdump -d -triple=armv6-none-linux-gnueabi -start-address=0x21200c -stop-address=0x212014 %t2 | FileCheck -check-prefix=CHECK-ARM2 %s
7// RUN: llvm-objdump -d -triple=thumbv6-none-linux-gnueabi %t2 -start-address=0x613000 -stop-address=0x613002 | FileCheck -check-prefix=CHECK-THUMB2 %s
Peter Smith57eb0462017-11-28 13:51:488
9// On Arm v6 the range of a Thumb BL instruction is only 4 megabytes as the
10// extended range encoding is not supported. The following example has a Thumb
11// BL that is out of range on ARM v6 and requires a range extension thunk.
12// As v6 does not support MOVT or MOVW instructions the Thunk must not
Peter Smitha8656c622018-08-20 09:37:5013// use these instructions either.
Peter Smith57eb0462017-11-28 13:51:4814
Peter Smitha8656c622018-08-20 09:37:5015
Peter Smith57eb0462017-11-28 13:51:4816// ARM v6 supports blx so we shouldn't see the blx not supported warning.
17// CHECK-NOT: warning: lld uses blx instruction, no object with architecture supporting feature detected.
18 .text
19 .syntax unified
20 .cpu arm1176jzf-s
Peter Smith57eb0462017-11-28 13:51:4821 .globl _start
22 .type _start,%function
23 .balign 0x1000
24_start:
25 bl thumbfunc
26 bx lr
27
Peter Smitha8656c622018-08-20 09:37:5028// CHECK-ARM1: Disassembly of section .text:
Fangrui Song5387c2c2019-05-01 10:40:4829// CHECK-ARM1-EMPTY:
Peter Smitha8656c622018-08-20 09:37:5030// CHECK-ARM1-NEXT: _start:
Fangrui Song024bf27d2019-08-27 11:52:3631// CHECK-ARM1-NEXT: 12000: 00 00 00 fa blx #0 <thumbfunc>
32// CHECK-ARM1-NEXT: 12004: 1e ff 2f e1 bx lr
Peter Smith57eb0462017-11-28 13:51:4833 .thumb
34 .section .text.2, "ax", %progbits
35 .globl thumbfunc
36 .type thumbfunc,%function
37thumbfunc:
38 bl farthumbfunc
39
Peter Smitha8656c622018-08-20 09:37:5040// CHECK-THUMB1: thumbfunc:
Fangrui Song024bf27d2019-08-27 11:52:3641// CHECK-THUMB1-NEXT: 12008: 00 f2 00 e8 blx #2097152
Peter Smitha8656c622018-08-20 09:37:5042// 6 Megabytes, enough to make farthumbfunc out of range of caller
43// on a v6 Arm, but not on a v7 Arm.
44
Peter Smith57eb0462017-11-28 13:51:4845 .section .text.3, "ax", %progbits
46 .space 0x200000
Peter Smitha8656c622018-08-20 09:37:5047// CHECK-ARM2: __ARMv5ABSLongThunk_farthumbfunc:
Fangrui Song024bf27d2019-08-27 11:52:3648// CHECK-ARM2-NEXT: 21200c: 04 f0 1f e5 ldr pc, [pc, #-4]
Peter Smitha8656c622018-08-20 09:37:5049// CHECK-ARM2: $d:
Fangrui Song024bf27d2019-08-27 11:52:3650// CHECK-ARM2-NEXT: 212010: 01 30 61 00 .word 0x00613001
Peter Smith57eb0462017-11-28 13:51:4851 .section .text.4, "ax", %progbits
52 .space 0x200000
53
54 .section .text.5, "ax", %progbits
55 .space 0x200000
56
57 .thumb
58 .section .text.6, "ax", %progbits
59 .balign 0x1000
60 .globl farthumbfunc
61 .type farthumbfunc,%function
62farthumbfunc:
63 bx lr
Peter Smitha8656c622018-08-20 09:37:5064// CHECK-THUMB2: farthumbfunc:
Fangrui Song024bf27d2019-08-27 11:52:3665// CHECK-THUMB2-NEXT: 613000: 70 47 bx lr