120 lines · plain
1# RUN: rm -rf %t && mkdir -p %t/armv6 && mkdir -p %t/armv7 && mkdir -p %t/thumbv72# RUN: llvm-mc -triple=armv6-none-linux-gnueabi -arm-add-build-attributes -filetype=obj -o %t/armv6/out.o %s3# RUN: llvm-objdump -r %t/armv6/out.o | FileCheck --check-prefix=CHECK-TYPE %s4# RUN: llvm-jitlink -noexec -slab-address 0x76ff0000 -slab-allocate 10Kb -slab-page-size 4096 \5# RUN: -abs target=0x76bbe88f -check %s %t/armv6/out.o6 7# RUN: llvm-mc -triple=armv7-none-linux-gnueabi -arm-add-build-attributes -filetype=obj -o %t/armv7/out.o %s8# RUN: llvm-objdump -r %t/armv7/out.o | FileCheck --check-prefix=CHECK-TYPE %s9# RUN: llvm-jitlink -noexec -slab-address 0x76ff0000 -slab-allocate 10Kb -slab-page-size 4096 \10# RUN: -abs target=0x76bbe88f -check %s %t/armv7/out.o11 12# RUN: llvm-mc -triple=thumbv7-none-linux-gnueabi -arm-add-build-attributes -filetype=obj -o %t/thumbv7/out.o %s13# RUN: llvm-objdump -r %t/thumbv7/out.o | FileCheck --check-prefix=CHECK-TYPE %s14# RUN: llvm-jitlink -noexec -slab-address 0x76ff0000 -slab-allocate 10Kb -slab-page-size 4096 \15# RUN: -abs target=0x76bbe88f -check %s %t/thumbv7/out.o16 17 .data18 .global target19 20 .text21 .syntax unified22 23# CHECK-TYPE: {{[0-9a-f]+}} R_ARM_ABS32 target24# jitlink-check: *{4}(abs32) = target25 .global abs3226abs32:27 .word target28 .size abs32, .-abs3229 30# CHECK-TYPE: {{[0-9a-f]+}} R_ARM_REL32 target31# jitlink-check: (rel32 + *{4}(rel32))[31:0] = target32 .global rel3233rel32:34 .word target - .35 .size rel32, .-rel3236 37# CHECK-TYPE: {{[0-9a-f]+}} R_ARM_TARGET1 target38# jitlink-check: *{4}(target1_abs32) = target39 .global target1_abs3240target1_abs32:41 .word target(target1)42 .size target1_abs32, .-target1_abs3243 44# CHECK-TYPE: {{[0-9a-f]+}} R_ARM_GOT_PREL target45#46# The GOT entry contains the absolute address of the external:47# jitlink-check: *{4}(got_addr(out.o, target)) = target48#49# The embedded offset value contains the offset to the GOT entry relative to pc.50# The +12 accounts for the ARM branch offset (8) and the .LPC offset (4), which51# is stored as initial addend inline.52# FIXME: We shouldn't need to substract the 64-bit sign-extension manually.53# jitlink-check: *{4}got_prel_offset = got_addr(out.o, target) - (next_pc(got_prel) + 4) - 0xffffffff0000000054 .globl got_prel55 .type got_prel,%function56 .p2align 257 .code 3258got_prel:59 ldr r0, .LCPI60.LPC:61 ldr r0, [pc, r0]62 ldr r0, [r0]63 bx lr64# Actual relocation site is on the embedded offset value:65 .globl got_prel_offset66got_prel_offset:67.LCPI:68 .long target(GOT_PREL)-((.LPC+8)-.LCPI)69 .size got_prel_offset, .-got_prel_offset70 .size got_prel, .-got_prel71 72# EH personality routine in .ARM.exidx73# CHECK-TYPE: {{[0-9a-f]+}} R_ARM_NONE __aeabi_unwind_cpp_pr074 .globl __aeabi_unwind_cpp_pr075 .type __aeabi_unwind_cpp_pr0,%function76 .align 277__aeabi_unwind_cpp_pr0:78 bx lr79 80# CHECK-TYPE: {{[0-9a-f]+}} R_ARM_PREL31 .text81#82# An .ARM.exidx table entry is 8-bytes in size, made up of 2 4-byte entries.83# First word contains offset to function for this entry:84# jitlink-check: (*{4}section_addr(out.o, .ARM.exidx))[31:0] = prel31 - section_addr(out.o, .ARM.exidx)85#86# Most-significant bit in second word denotes inline entry when set (and87# relocation to .ARM.extab otherwise). Inline entry with compact model index 0:88# 0x9b vsp = r1189# 0x84 0x80 pop {r11, r14}90#91# jitlink-check: *{4}(section_addr(out.o, .ARM.exidx) + 4) = 0x809b848092#93 .globl prel3194 .type prel31,%function95 .align 296prel31:97 .fnstart98 .save {r11, lr}99 push {r11, lr}100 .setfp r11, sp101 mov r11, sp102 pop {r11, lr}103 mov pc, lr104 .fnend105 .size prel31,.-prel31106 107# This test is executable with any 4-byte external target:108# > echo "unsigned target = 42;" | clang -target armv7-linux-gnueabihf -o target.o -c -xc -109# > llvm-jitlink target.o armv7/out.o110#111 .globl main112 .type main, %function113 .p2align 2114main:115 push {lr}116 bl got_prel117 bl prel31118 pop {pc}119 .size main, .-main120