66 lines · plain
1# RUN: rm -rf %t && mkdir -p %t/armv4t && mkdir -p %t/armv6 && mkdir -p %t/armv72#3# RUN: llvm-mc -triple=armv4t-linux-gnueabi -arm-add-build-attributes \4# RUN: -filetype=obj -o %t/armv4t/out.o %s5# RUN: llvm-jitlink -noexec -slab-address 0x76ff0000 \6# RUN: -slab-allocate 10Kb -slab-page-size 4096 \7# RUN: -abs ext=0x76bbe880 -check %s %t/armv4t/out.o8#9# RUN: llvm-mc -triple=armv6-linux-gnueabi -arm-add-build-attributes \10# RUN: -filetype=obj -o %t/armv6/out.o %s11# RUN: llvm-jitlink -noexec -slab-address 0x76ff0000 \12# RUN: -slab-allocate 10Kb -slab-page-size 4096 \13# RUN: -abs ext=0x76bbe880 -check %s %t/armv6/out.o14#15# RUN: llvm-mc -triple=armv7-linux-gnueabi -arm-add-build-attributes \16# RUN: -filetype=obj -o %t/armv7/out.o %s17# RUN: llvm-jitlink -noexec -slab-address 0x76ff0000 \18# RUN: -slab-allocate 10Kb -slab-page-size 4096 \19# RUN: -abs ext=0x76bbe880 -check %s %t/armv7/out.o20 21 .text22 .syntax unified23 24# Check that calls/jumps to external functions trigger the generation of25# branch-range extension stubs. These stubs don't follow the default PLT model26# where the branch-target address is loaded from a GOT entry. Instead, they27# hard-code it in the immediate field.28 29# The external function ext will return to the caller directly.30# jitlink-check: decode_operand(test_arm_jump, 0) = stub_addr(out.o, ext) - next_pc(test_arm_jump)31 .globl test_arm_jump32 .type test_arm_jump,%function33 .p2align 234test_arm_jump:35 b ext36 .size test_arm_jump, .-test_arm_jump37 38# The branch-with-link sets the LR register so that the external function ext39# returns to us. We have to save the register (push) and return to main manually40# (pop). This adds the +4 offset for the bl instruction we decode:41# jitlink-check: decode_operand(test_arm_call + 4, 0) = stub_addr(out.o, ext) - next_pc(test_arm_call) - 442 .globl test_arm_call43 .type test_arm_call,%function44 .p2align 245test_arm_call:46 push {lr}47 bl ext48 pop {pc}49 .size test_arm_call, .-test_arm_call50 51# This test is executable with any Arm (and for v7+ also Thumb) `ext` functions.52# It only has to return with `bx lr`. For example:53# > echo "void ext() {}" | clang -target armv7-linux-gnueabihf -o ext.o -c -xc -54# > llvm-jitlink ext.o out.o55#56 .globl main57 .type main,%function58 .p2align 259main:60 push {lr}61 bl test_arm_call62 bl test_arm_jump63 mov r0, #064 pop {pc}65 .size main, .-main66