File: arm-thumb-narrow-branch-check.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 (94 lines) | stat: -rw-r--r-- 2,882 bytes parent folder | download | duplicates (15)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// REQUIRES: arm
// RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t
// RUN: echo "SECTIONS { \
// RUN:          . = SIZEOF_HEADERS; \
// RUN:          .callee_low : { *(.callee_low) } \
// RUN:          .caller : { *(.caller) } \
// RUN:          .callee_high : { *(.callee_high) } \
// RUN:          .text : { *(.text) } } " > %t.script
// RUN: ld.lld --script %t.script %t %S/Inputs/arm-thumb-narrow-branch.o -o %t2
// RUN: llvm-objdump -d %t2 | FileCheck %s

// Test the R_ARM_THM_JUMP11 and R_ARM_THM_JUMP8 relocations which are used
// with the narrow encoding of B.N and BEQ.N.
//
// The source of these relocations is a binary file arm-thumb-narrow-branch.o
// which has been assembled with the GNU assembler as llvm-mc doesn't emit it
// as the range of +-2048 bytes is too small to be practically useful for out
// of section branches.
 .syntax unified

.global callee_low_far
.type callee_low_far,%function
callee_low_far = 0x809

.global callee_low_near
.type callee_low_near,%function
callee_low_near = 0xfff

 .section .callee_low,"ax",%progbits
 .thumb
 .balign 0x1000
 .type callee_low,%function
 .globl callee_low
callee_low:
 bx lr

 .text
 .align 2
 .thumb
 .globl _start
 .type _start, %function
_start:
 bl callers
 bx lr

 .section .callee_high,"ax",%progbits
 .thumb
 .align 2
 .type callee_high,%function
 .globl callee_high
callee_high:
 bx lr

.global callee_high_near
.type callee_high_near,%function
callee_high_near = 0x10ff

.global callee_high_far
.type callee_high_far,%function
callee_high_far = 0x180d

// CHECK: Disassembly of section .callee_low:
// CHECK-EMPTY:
// CHECK-NEXT: <callee_low>:
// CHECK-NEXT:    1000:       4770    bx      lr
// CHECK-EMPTY:
// CHECK-NEXT: Disassembly of section .caller:
// CHECK-EMPTY:
// CHECK-NEXT: <callers>:
/// callee_low_far = 0x809
// CHECK-NEXT:    1004:       e400    b       0x808
// CHECK-NEXT:    1006:       e7fb    b       0x1000 <callee_low>
// CHECK-NEXT:    1008:       e006    b       0x1018 <callee_high>
/// callee_high_far = 0x180d
// CHECK-NEXT:    100a:       e3ff    b       0x180c
/// callee_low_near = 0xfff
// CHECK-NEXT:    100c:       d0f7    beq     0xffe
// CHECK-NEXT:    100e:       d0f7    beq     0x1000 <callee_low>
// CHECK-NEXT:    1010:       d002    beq     0x1018 <callee_high>
/// callee_high_near = 0x10ff
// CHECK-NEXT:    1012:       d074    beq     0x10fe
// CHECK-NEXT:    1014:       4770    bx      lr
// CHECK-NEXT:    1016:       46c0    mov     r8, r8
// CHECK-EMPTY:
// CHECK-NEXT: Disassembly of section .callee_high:
// CHECK-EMPTY:
// CHECK-NEXT: <callee_high>:
// CHECK-NEXT:    1018:       4770    bx      lr
// CHECK-EMPTY:
// CHECK-NEXT: Disassembly of section .text:
// CHECK-EMPTY:
// CHECK-NEXT: <_start>:
// CHECK-NEXT:    101c:       f7ff fff2       bl      0x1004 <callers>
// CHECK-NEXT:    1020:       4770    bx      lr