File: arm-branch.s

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (57 lines) | stat: -rw-r--r-- 1,876 bytes parent folder | download | duplicates (22)
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
/// Test the Arm state R_ARM_CALL and R_ARM_JUMP24 relocation to Arm state destinations.
/// R_ARM_CALL is used for branch and link (BL)
/// R_ARM_JUMP24 is used for unconditional and conditional branches (B and B<cc>)
/// Relocations defined in https://github.com/ARM-software/abi-aa/blob/main/aaelf32/aaelf32.rst
/// Addend A is always -8 to cancel out Arm state PC-bias of 8 bytes

// REQUIRES: arm
// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t
// RUN: echo "SECTIONS { \
// RUN:          . = 0xb4; \
// RUN:          .callee1 : { *(.callee_low) } \
// RUN:          .caller : { *(.text) } \
// RUN:          .callee2 : { *(.callee_high) } } " > %t.script
// RUN: ld.lld --defsym=far=0x201001c --script %t.script %t -o %t2
// RUN: llvm-objdump -d --no-show-raw-insn --triple=armv7a-none-linux-gnueabi %t2 | FileCheck  %s

 .syntax unified
 .section .callee_low, "ax",%progbits
 .align 2
 .type callee_low,%function
callee_low:
 bx lr

 .section .text, "ax",%progbits
 .globl _start
 .balign 0x10000
 .type _start,%function
_start:
 bl  callee_low
 b   callee_low
 beq callee_low
 bl  callee_high
 b   callee_high
 bne callee_high
 bl  far
 b   far
 bgt far
 bx lr

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

// CHECK: 00010000 <_start>:
// CHECK-NEXT:   10000:       bl      0xb4 <callee_low>
// CHECK-NEXT:   10004:       b       0xb4 <callee_low>
// CHECK-NEXT:   10008:       beq     0xb4 <callee_low>
// CHECK-NEXT:   1000c:       bl      0x10028 <callee_high>
// CHECK-NEXT:   10010:       b       0x10028 <callee_high>
// CHECK-NEXT:   10014:       bne     0x10028 <callee_high>
/// 0x201001c = far
// CHECK-NEXT:   10018:       bl      0x201001c
// CHECK-NEXT:   1001c:       b       0x201001c
// CHECK-NEXT:   10020:       bgt     0x201001c
// CHECK-NEXT:   10024:       bx      lr