xref: /llvm-project/llvm/test/ExecutionEngine/JITLink/AArch32/ELF_stubs_thumb.s (revision 55929cd679375d6ee5111edcb881103f57588d0e)
1# RUN: rm -rf %t && mkdir -p %t/thumbv7m && mkdir -p %t/thumbv7
2#
3# RUN: llvm-mc -triple=thumbv7m-linux-gnueabi -arm-add-build-attributes \
4# RUN:         -filetype=obj -o %t/thumbv7m/out.o %s
5# RUN: llvm-jitlink -noexec -slab-address 0x76ff0000 \
6# RUN:              -slab-allocate 10Kb -slab-page-size 4096 \
7# RUN:              -abs ext=0x76bbe880 -check %s %t/thumbv7m/out.o
8#
9# RUN: llvm-mc -triple=thumbv7-linux-gnueabi -arm-add-build-attributes \
10# RUN:         -filetype=obj -o %t/thumbv7/out.o %s
11# RUN: llvm-jitlink -noexec -slab-address 0x76ff0000 \
12# RUN:              -slab-allocate 10Kb -slab-page-size 4096 \
13# RUN:              -abs ext=0x76bbe880 -check %s %t/thumbv7/out.o
14
15
16	.text
17	.syntax unified
18
19# Check that calls/jumps to external functions trigger the generation of
20# branch-range extension stubs. These stubs don't follow the default PLT model
21# where the branch-target address is loaded from a GOT entry. Instead, they
22# hard-code it in the immediate field.
23#
24# jitlink-check: decode_operand(test_external_call, 2) = stub_addr(out.o, ext) - next_pc(test_external_call)
25# jitlink-check: decode_operand(test_external_jump, 0) = stub_addr(out.o, ext) - next_pc(test_external_jump)
26	.globl  test_external_call
27	.type	test_external_call,%function
28	.p2align	1
29	.code	16
30	.thumb_func
31test_external_call:
32	bl	ext
33	.size test_external_call, .-test_external_call
34
35	.globl  test_external_jump
36	.type	test_external_jump,%function
37	.p2align	1
38	.code	16
39	.thumb_func
40test_external_jump:
41	b	ext
42	.size test_external_jump, .-test_external_jump
43
44# Empty main function for jitlink to be happy
45	.globl	main
46	.type	main,%function
47	.p2align	1
48	.code	16
49	.thumb_func
50main:
51	bx	lr
52	.size	main,	.-main
53