File: arm-thumb-thunk-v6m-xo.s

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (57 lines) | stat: -rw-r--r-- 2,149 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// REQUIRES: arm
// RUN: rm -rf %t && split-file %s %t
// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv6m-none-eabi %t/a.s -o %t/a.o
// RUN: ld.lld --no-rosegment --script %t/a.t %t/a.o -o %t/a
// RUN: llvm-objdump --no-print-imm-hex --no-show-raw-insn -d %t/a --triple=armv6m-none-eabi | FileCheck %s
// 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
// RUN: rm -f %t/a %t/a2

// Range extension thunks for Arm Architecture v6m. Only Thumb instructions
// are permitted which limits the access to instructions that can access the
// high registers (r8 - r15), this means that the thunks have to spill
// low registers (r0 - r7) in order to perform the transfer of control.

//--- a.t
SECTIONS {
  .text_low  0x11345670 : { *(.text_low) }
  .text_high 0x12345678 : { *(.text_high) }
}

//--- a.s
// The 'y' on the .section directive  means that this section is eXecute Only code
 .syntax unified
 .section .text_low, "axy", %progbits
 .thumb
 .type _start, %function
 .balign 4
 .globl _start
_start:
 bl far

 .section .text_high, "ax", %progbits
 .globl far
 .type far, %function
far:
 bx lr

// CHECK: Disassembly of section .text_low:
// CHECK-EMPTY:
// CHECK-NEXT: <_start>:
// CHECK-NEXT: 11345670:        bl      0x11345674 <__Thumbv6MABSXOLongThunk_far>
// CHECK: <__Thumbv6MABSXOLongThunk_far>:
// CHECK-NEXT:                  push    {r0, r1}
// CHECK-NEXT:                  movs    r0, #18
// CHECK-NEXT:                  lsls    r0, r0, #8
// CHECK-NEXT:                  adds    r0, #52
// CHECK-NEXT:                  lsls    r0, r0, #8
// CHECK-NEXT:                  adds    r0, #86
// CHECK-NEXT:                  lsls    r0, r0, #8
// CHECK-NEXT:                  adds    r0, #121
// CHECK-NEXT:                  str     r0, [sp, #4]
// CHECK-NEXT:                  pop     {r0, pc}
// CHECK: Disassembly of section .text_high:
// CHECK-EMPTY:
// CHECK-NEXT: <far>:
// CHECK-NEXT: 12345678:        bx      lr

// CHECK-PI:  error: relocation R_ARM_THM_CALL to far not supported for Armv6-M targets for position independant and execute only code