[ELF] Refine isExported/isPreemptible condition
[llvm-project.git] / lld / test / ELF / arm-thumb-thunk-v6m-xo.s
blobcaee025ef52b2cdd1a5f9e0c7039f9041776d6a4
1 // REQUIRES: arm
2 // This test intentionally checks for fatal errors, and fatal errors aren't supported for testing when main is run twice.
3 // XFAIL: main-run-twice
4 // RUN: rm -rf %t && split-file %s %t
5 // RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv6m-none-eabi %t/a.s -o %t/a.o
6 // RUN: ld.lld --no-rosegment --script %t/a.t %t/a.o -o %t/a
7 // RUN: llvm-objdump --no-print-imm-hex --no-show-raw-insn -d %t/a --triple=armv6m-none-eabi | FileCheck %s
8 // RUN: not ld.lld --no-rosegment --script %t/a.t %t/a.o -o %t/a2 --pie 2>&1 | FileCheck --check-prefix=CHECK-PI %s
9 // RUN: rm -f %t/a %t/a2
11 // Range extension thunks for Arm Architecture v6m. Only Thumb instructions
12 // are permitted which limits the access to instructions that can access the
13 // high registers (r8 - r15), this means that the thunks have to spill
14 // low registers (r0 - r7) in order to perform the transfer of control.
16 //--- a.t
17 SECTIONS {
18 .text_low 0x11345670 : { *(.text_low) }
19 .text_high 0x12345678 : { *(.text_high) }
22 //--- a.s
23 // The 'y' on the .section directive means that this section is eXecute Only code
24 .syntax unified
25 .section .text_low, "axy", %progbits
26 .thumb
27 .type _start, %function
28 .balign 4
29 .globl _start
30 _start:
31 bl far
33 .section .text_high, "ax", %progbits
34 .globl far
35 .type far, %function
36 far:
37 bx lr
39 // CHECK: Disassembly of section .text_low:
40 // CHECK-EMPTY:
41 // CHECK-NEXT: <_start>:
42 // CHECK-NEXT: 11345670: bl 0x11345674 <__Thumbv6MABSXOLongThunk_far>
43 // CHECK: <__Thumbv6MABSXOLongThunk_far>:
44 // CHECK-NEXT: push {r0, r1}
45 // CHECK-NEXT: movs r0, #18
46 // CHECK-NEXT: lsls r0, r0, #8
47 // CHECK-NEXT: adds r0, #52
48 // CHECK-NEXT: lsls r0, r0, #8
49 // CHECK-NEXT: adds r0, #86
50 // CHECK-NEXT: lsls r0, r0, #8
51 // CHECK-NEXT: adds r0, #121
52 // CHECK-NEXT: str r0, [sp, #4]
53 // CHECK-NEXT: pop {r0, pc}
54 // CHECK: Disassembly of section .text_high:
55 // CHECK-EMPTY:
56 // CHECK-NEXT: <far>:
57 // CHECK-NEXT: 12345678: bx lr
59 // CHECK-PI: error: relocation R_ARM_THM_CALL to far not supported for Armv6-M targets for position independent and execute only code