Fangrui Song | b6772b8 | 2018-06-26 22:20:04 | [diff] [blame] | 1 | // REQUIRES: arm |
Peter Smith | d1be026 | 2018-08-20 09:19:30 | [diff] [blame] | 2 | // RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv6-none-linux-gnueabi %s -o %t |
Fangrui Song | 5d4bc12 | 2019-07-22 11:37:03 | [diff] [blame] | 3 | // RUN: ld.lld %t -o %t2 |
Fangrui Song | 024bf27d | 2019-08-27 11:52:36 | [diff] [blame] | 4 | // 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 Smith | 57eb046 | 2017-11-28 13:51:48 | [diff] [blame] | 8 | |
| 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 Smith | a8656c62 | 2018-08-20 09:37:50 | [diff] [blame] | 13 | // use these instructions either. |
Peter Smith | 57eb046 | 2017-11-28 13:51:48 | [diff] [blame] | 14 | |
Peter Smith | a8656c62 | 2018-08-20 09:37:50 | [diff] [blame] | 15 | |
Peter Smith | 57eb046 | 2017-11-28 13:51:48 | [diff] [blame] | 16 | // 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 Smith | 57eb046 | 2017-11-28 13:51:48 | [diff] [blame] | 21 | .globl _start |
| 22 | .type _start,%function |
| 23 | .balign 0x1000 |
| 24 | _start: |
| 25 | bl thumbfunc |
| 26 | bx lr |
| 27 | |
Peter Smith | a8656c62 | 2018-08-20 09:37:50 | [diff] [blame] | 28 | // CHECK-ARM1: Disassembly of section .text: |
Fangrui Song | 5387c2c | 2019-05-01 10:40:48 | [diff] [blame] | 29 | // CHECK-ARM1-EMPTY: |
Peter Smith | a8656c62 | 2018-08-20 09:37:50 | [diff] [blame] | 30 | // CHECK-ARM1-NEXT: _start: |
Fangrui Song | 024bf27d | 2019-08-27 11:52:36 | [diff] [blame] | 31 | // CHECK-ARM1-NEXT: 12000: 00 00 00 fa blx #0 <thumbfunc> |
| 32 | // CHECK-ARM1-NEXT: 12004: 1e ff 2f e1 bx lr |
Peter Smith | 57eb046 | 2017-11-28 13:51:48 | [diff] [blame] | 33 | .thumb |
| 34 | .section .text.2, "ax", %progbits |
| 35 | .globl thumbfunc |
| 36 | .type thumbfunc,%function |
| 37 | thumbfunc: |
| 38 | bl farthumbfunc |
| 39 | |
Peter Smith | a8656c62 | 2018-08-20 09:37:50 | [diff] [blame] | 40 | // CHECK-THUMB1: thumbfunc: |
Fangrui Song | 024bf27d | 2019-08-27 11:52:36 | [diff] [blame] | 41 | // CHECK-THUMB1-NEXT: 12008: 00 f2 00 e8 blx #2097152 |
Peter Smith | a8656c62 | 2018-08-20 09:37:50 | [diff] [blame] | 42 | // 6 Megabytes, enough to make farthumbfunc out of range of caller |
| 43 | // on a v6 Arm, but not on a v7 Arm. |
| 44 | |
Peter Smith | 57eb046 | 2017-11-28 13:51:48 | [diff] [blame] | 45 | .section .text.3, "ax", %progbits |
| 46 | .space 0x200000 |
Peter Smith | a8656c62 | 2018-08-20 09:37:50 | [diff] [blame] | 47 | // CHECK-ARM2: __ARMv5ABSLongThunk_farthumbfunc: |
Fangrui Song | 024bf27d | 2019-08-27 11:52:36 | [diff] [blame] | 48 | // CHECK-ARM2-NEXT: 21200c: 04 f0 1f e5 ldr pc, [pc, #-4] |
Peter Smith | a8656c62 | 2018-08-20 09:37:50 | [diff] [blame] | 49 | // CHECK-ARM2: $d: |
Fangrui Song | 024bf27d | 2019-08-27 11:52:36 | [diff] [blame] | 50 | // CHECK-ARM2-NEXT: 212010: 01 30 61 00 .word 0x00613001 |
Peter Smith | 57eb046 | 2017-11-28 13:51:48 | [diff] [blame] | 51 | .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 |
| 62 | farthumbfunc: |
| 63 | bx lr |
Peter Smith | a8656c62 | 2018-08-20 09:37:50 | [diff] [blame] | 64 | // CHECK-THUMB2: farthumbfunc: |
Fangrui Song | 024bf27d | 2019-08-27 11:52:36 | [diff] [blame] | 65 | // CHECK-THUMB2-NEXT: 613000: 70 47 bx lr |