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