File: arm-bl-v4.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 (119 lines) | stat: -rw-r--r-- 4,817 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
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// REQUIRES: arm
// RUN: rm -rf %t && split-file %s %t
// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv4-none-linux-gnueabi %t/a.s -o %t/a.o
// RUN: ld.lld %t/a.o --script %t/far.lds -o %t/a-far
// RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn --triple=armv4-none-linux-gnueabi %t/a-far | FileCheck %s --check-prefixes=FAR
// RUN: ld.lld %t/a.o --script %t/near.lds -o %t/a-near
// RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn --triple=armv4-none-linux-gnueabi %t/a-near | FileCheck %s --check-prefixes=NEAR
// RUN: ld.lld %t/a.o -pie --script %t/far.lds -o %t/a-far-pie
// RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn --triple=armv4-none-linux-gnueabi %t/a-far-pie | FileCheck %s --check-prefixes=FAR-PIE
// RUN: ld.lld %t/a.o -pie --script %t/near.lds -o %t/a-near-pie
// RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn --triple=armv4-none-linux-gnueabi %t/a-near-pie | FileCheck %s --check-prefixes=NEAR

// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv4eb-none-linux-gnueabi %t/a.s -o %t/a.o
// RUN: ld.lld %t/a.o --script %t/far.lds -o %t/a-far
// RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn --triple=armv4eb-none-linux-gnueabi %t/a-far | FileCheck %s --check-prefixes=FAR-EB
// RUN: ld.lld %t/a.o --script %t/near.lds -o %t/a-near
// RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn --triple=armv4eb-none-linux-gnueabi %t/a-near | FileCheck %s --check-prefixes=NEAR
// RUN: ld.lld %t/a.o -pie --script %t/far.lds -o %t/a-far-pie
// RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn --triple=armv4eb-none-linux-gnueabi %t/a-far-pie | FileCheck %s --check-prefixes=FAR-EB-PIE
// RUN: ld.lld %t/a.o -pie --script %t/near.lds -o %t/a-near-pie
// RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn --triple=armv4eb-none-linux-gnueabi %t/a-near-pie | FileCheck %s --check-prefixes=NEAR

/// On Armv4 there is no blx instruction so long branch/exchange looks slightly
/// different.

//--- a.s
 .text
 .syntax unified
 .cpu    arm7tdmi

 .section .low, "ax", %progbits
 .arm
 .globl _start
 .type   _start,%function
 .p2align       2
_start:
  bl target
  mov pc, lr

// FAR-LABEL: <_start>:
// FAR-NEXT:   1000000:      	bl	0x1000008 <__ARMv5LongLdrPcThunk_target> @ imm = #0
// FAR-NEXT:                	mov pc, lr
// FAR-EMPTY:
// FAR-NEXT:  <__ARMv5LongLdrPcThunk_target>:
// FAR-NEXT:   1000008:      	ldr	pc, [pc, #-4]           @ 0x100000c <__ARMv5LongLdrPcThunk_target+0x4>
// FAR-EMPTY:
// FAR-NEXT:  <$d>:
// FAR-NEXT:   100000c: 00 00 00 06  	.word	0x06000000

// FAR-EB-LABEL: <_start>:
// FAR-EB-NEXT:   1000000:      	bl	0x1000008 <__ARMv5LongLdrPcThunk_target> @ imm = #0
// FAR-EB-NEXT:                	mov pc, lr
// FAR-EB-EMPTY:
// FAR-EB-NEXT:  <__ARMv5LongLdrPcThunk_target>:
// FAR-EB-NEXT:   1000008:      	ldr	pc, [pc, #-4]           @ 0x100000c <__ARMv5LongLdrPcThunk_target+0x4>
// FAR-EB-EMPTY:
// FAR-EB-NEXT:  <$d>:
// FAR-EB-NEXT:   100000c: 06 00 00 00  	.word	0x06000000

// FAR-PIE-LABEL: <_start>:
// FAR-PIE-NEXT:   1000000:      	bl	0x1000008 <__ARMv4PILongThunk_target> @ imm = #0
// FAR-PIE-NEXT:                	mov pc, lr
// FAR-PIE-EMPTY:
// FAR-PIE-NEXT:  <__ARMv4PILongThunk_target>:
// FAR-PIE-NEXT:   1000008:      	ldr	r12, [pc]               @ 0x1000010 <__ARMv4PILongThunk_target+0x8>
// FAR-PIE-NEXT:                	add	pc, pc, r12
// FAR-PIE-EMPTY:
// FAR-PIE-NEXT:  <$d>:
// FAR-PIE-NEXT:   1000010: ec ff ff 04  	.word	0x04ffffec

// FAR-EB-PIE-LABEL: <_start>:
// FAR-EB-PIE-NEXT:   1000000:      	bl	0x1000008 <__ARMv4PILongThunk_target> @ imm = #0
// FAR-EB-PIE-NEXT:                	mov pc, lr
// FAR-EB-PIE-EMPTY:
// FAR-EB-PIE-NEXT:  <__ARMv4PILongThunk_target>:
// FAR-EB-PIE-NEXT:   1000008:      	ldr	r12, [pc]               @ 0x1000010 <__ARMv4PILongThunk_target+0x8>
// FAR-EB-PIE-NEXT:                	add	pc, pc, r12
// FAR-EB-PIE-EMPTY:
// FAR-EB-PIE-NEXT:  <$d>:
// FAR-EB-PIE-NEXT:   1000010: 04 ff ff ec  	.word	0x04ffffec

// NEAR-LABEL: <_start>:
// NEAR-NEXT:  1000000:      	bl 0x1000008 <target> @ imm = #0
// NEAR-NEXT:               	mov pc, lr

.section .high, "ax", %progbits
 .arm
 .globl target
 .type target,%function
target:
  mov pc, lr

// FAR-LABEL: <target>:
// FAR-NEXT:   6000000:      	mov pc, lr

// FAR-EB-LABEL: <target>:
// FAR-EB-NEXT:   6000000:      	mov pc, lr

// FAR-PIE-LABEL: <target>:
// FAR-PIE-NEXT:   6000000:     mov pc, lr

// FAR-EB-PIE-LABEL: <target>:
// FAR-EB-PIE-NEXT:   6000000:     mov pc, lr

// NEAR-LABEL: <target>:
// NEAR-LABEL:  1000008:      	mov pc, lr

//--- far.lds
SECTIONS {
  . = SIZEOF_HEADERS;
  .low 0x01000000 : { *(.low) }
  .high 0x06000000 : { *(.high) }
}

//--- near.lds
SECTIONS {
  . = SIZEOF_HEADERS;
  .all 0x01000000 : { *(.low) *(.high) }
}