xref: /aosp_15_r20/external/llvm/test/MC/MachO/ARM/long-call-branch-island-relocation.s (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker@ RUN: llvm-mc -n -triple armv7-apple-darwin10 %s -filetype=obj -o %t.o
2*9880d681SAndroid Build Coastguard Worker@ RUN: llvm-readobj -relocations -expand-relocs < %t.o | FileCheck %s
3*9880d681SAndroid Build Coastguard Worker
4*9880d681SAndroid Build Coastguard Worker@ rdar://12359919
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Worker	.syntax unified
7*9880d681SAndroid Build Coastguard Worker	.text
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Worker	.globl	_bar
10*9880d681SAndroid Build Coastguard Worker	.align	2
11*9880d681SAndroid Build Coastguard Worker	.code	16
12*9880d681SAndroid Build Coastguard Worker	.thumb_func	_bar
13*9880d681SAndroid Build Coastguard Worker_bar:
14*9880d681SAndroid Build Coastguard Worker	push	{r7, lr}
15*9880d681SAndroid Build Coastguard Worker	mov	r7, sp
16*9880d681SAndroid Build Coastguard Worker	bl	_foo
17*9880d681SAndroid Build Coastguard Worker	pop	{r7, pc}
18*9880d681SAndroid Build Coastguard Worker
19*9880d681SAndroid Build Coastguard Worker
20*9880d681SAndroid Build Coastguard Worker_junk:
21*9880d681SAndroid Build Coastguard Worker@ Make the _foo symbol sufficiently far away to force the 'bl' relocation
22*9880d681SAndroid Build Coastguard Worker@ above to be out of range. On Darwin, the assembler deals with this by
23*9880d681SAndroid Build Coastguard Worker@ generating an external relocation so the linker can create a branch
24*9880d681SAndroid Build Coastguard Worker@ island.
25*9880d681SAndroid Build Coastguard Worker
26*9880d681SAndroid Build Coastguard Worker  .space 20000000
27*9880d681SAndroid Build Coastguard Worker
28*9880d681SAndroid Build Coastguard Worker  .section	__TEXT,initcode,regular,pure_instructions
29*9880d681SAndroid Build Coastguard Worker
30*9880d681SAndroid Build Coastguard Worker	.globl	_foo
31*9880d681SAndroid Build Coastguard Worker	.align	2
32*9880d681SAndroid Build Coastguard Worker	.code	16
33*9880d681SAndroid Build Coastguard Worker_foo:
34*9880d681SAndroid Build Coastguard Worker	push	{r7, lr}
35*9880d681SAndroid Build Coastguard Worker	mov	r7, sp
36*9880d681SAndroid Build Coastguard Worker	pop	{r7, pc}
37*9880d681SAndroid Build Coastguard Worker
38*9880d681SAndroid Build Coastguard Worker
39*9880d681SAndroid Build Coastguard Worker@ CHECK: File: <stdin>
40*9880d681SAndroid Build Coastguard Worker@ CHECK: Format: Mach-O arm
41*9880d681SAndroid Build Coastguard Worker@ CHECK: Arch: arm
42*9880d681SAndroid Build Coastguard Worker@ CHECK: AddressSize: 32bit
43*9880d681SAndroid Build Coastguard Worker@ CHECK: Relocations [
44*9880d681SAndroid Build Coastguard Worker@ CHECK:   Section __text {
45*9880d681SAndroid Build Coastguard Worker@ CHECK:     Relocation {
46*9880d681SAndroid Build Coastguard Worker@ CHECK:       Offset: 0x4
47*9880d681SAndroid Build Coastguard Worker@ CHECK:       PCRel: 1
48*9880d681SAndroid Build Coastguard Worker@ CHECK:       Length: 2
49*9880d681SAndroid Build Coastguard Worker@ CHECK:       Type: ARM_THUMB_RELOC_BR22 (6)
50*9880d681SAndroid Build Coastguard Worker@ CHECK:       Symbol: _foo (2)
51*9880d681SAndroid Build Coastguard Worker@ CHECK:     }
52*9880d681SAndroid Build Coastguard Worker@ CHECK:   }
53*9880d681SAndroid Build Coastguard Worker@ CHECK: ]
54