File: arm-thunk-arm-thumb-reuse.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 (67 lines) | stat: -rw-r--r-- 2,040 bytes parent folder | download | duplicates (2)
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
58
59
60
61
62
63
64
65
66
67
// REQUIRES: arm
// RUN: split-file %s %t
// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv7a-none-linux-gnueabi %t/test.s -o %t.o
// RUN: ld.lld --script %t/script %t.o -o %t2
// RUN: llvm-objdump --no-print-imm-hex --no-show-raw-insn -d %t2 | FileCheck %s

// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv7aeb-none-linux-gnueabi -mcpu=cortex-a8 %t/test.s -o %t.o
// RUN: ld.lld --script %t/script %t.o -o %t2
// RUN: llvm-objdump --no-print-imm-hex --no-show-raw-insn -d %t2 | FileCheck %s
// RUN: ld.lld --be8 --script %t/script %t.o -o %t2
// RUN: llvm-objdump --no-print-imm-hex --no-show-raw-insn -d %t2 | FileCheck %s

/// Test that we can reuse thunks between Arm and Thumb callers
/// using a BL. Expect two thunks, one for far, one for far2.

//--- script
SECTIONS {
        .text 0x10000 : { *(.text) }
        .text.far 0x10000000 : AT (0x10000000) { *(.far) }
}

//--- test.s

.syntax unified
.text
.globl _start
.type _start, %function
 .arm
_start:
 bl far
 .thumb
 bl far
 bl far2
 .arm
 bl far2

// CHECK:   00010000 <_start>:
// CHECK-NEXT: 10000: bl      0x10010 <__ARMv7ABSLongThunk_far>
// CHECK:   00010004 <$t.1>:
// CHECK-NEXT: 10004: blx     0x10010 <__ARMv7ABSLongThunk_far>
// CHECK-NEXT: 10008: bl      0x1001c <__Thumbv7ABSLongThunk_far2>
// CHECK:   0001000c <$a.2>:
// CHECK-NEXT: 1000c: blx     0x1001c <__Thumbv7ABSLongThunk_far2>
// CHECK:   00010010 <__ARMv7ABSLongThunk_far>:
// CHECK-NEXT: 10010: movw    r12, #0
// CHECK-NEXT: 10014: movt    r12, #4096
// CHECK-NEXT: 10018: bx      r12
// CHECK:   0001001c <__Thumbv7ABSLongThunk_far2>:
// CHECK-NEXT: 1001c: movw    r12, #4
// CHECK-NEXT: 10020: movt    r12, #4096
// CHECK-NEXT: 10024: bx      r12

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

// CHECK: Disassembly of section .text.far:
// CHECK:      10000000 <far>:
// CHECK-NEXT: 10000000: bx      lr
// CHECK:      10000004 <far2>:
// CHECK-NEXT: 10000004: bx      lr