brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · fee78f9 Raw
114 lines · plain
1// REQUIRES: arm2// RUN: llvm-mc --triple=armv7a-none-eabi --arm-add-build-attributes -filetype=obj -o %t.o %s3// RUN: ld.lld %t.o -o %t4/// R_ARM_ALU_PC_G0 referencing a non-preemptible symbol can be used in PIC links.5// RUN: ld.lld %t.o --shared -o /dev/null6// RUN: llvm-objdump -d --no-show-raw-insn --triple=armv7a-none-eabi %t | FileCheck %s7 8/// Test the short range cases of R_ARM_ALU_PC_G0. The range of the instruction9/// depends on the number of trailing zeros of the displacement. In practice10/// the maximum effective range will be 1024 bytes, which is a 4-byte aligned11/// instruction to a 4-byte aligned word.12 13 .arm14 .section .os1, "ax", %progbits15 .balign 102416 .word 017 .word 018 .word 019 .word 020dat1:21 .word 022dat2:23 .word 024 25 .section .os2, "ax", %progbits26 .balign 102427 .global _start28 .type _start, %function29_start:30/// adr r0, dat131 .inst 0xe24f000832 .reloc 0, R_ARM_ALU_PC_G0, dat133/// adr r0, dat234 .inst 0xe24f000835 .reloc 4, R_ARM_ALU_PC_G0, dat236/// adr r0, dat337 .inst 0xe24f000838 .reloc 8, R_ARM_ALU_PC_G0, dat339/// adr r0, dat440 .inst 0xe24f000841 .reloc 0xc, R_ARM_ALU_PC_G0, dat442 43 .section .os3, "ax", %progbits44 .balign 102445 .word 046 .word 047 .word 048 .word 049dat3:50 .word 051dat4:52 .word 053 54 .section .os4, "ax", %progbits55 .thumb56 .type tfunc, %function57tfunc:58  bx lr59 60 .section .os5, "ax", %progbits61 .arm62 .type arm_func, %function63 64arm_func:65 .balign 466/// adr r0, tfunc67 .inst 0xe24f000868 .reloc 0, R_ARM_ALU_PC_G0, tfunc69/// adr r0, afunc70 .inst 0xe24f000871 .reloc 4, R_ARM_ALU_PC_G0, afunc72 bx lr73 74 .section .os6, "ax", %progbits75 .type afunc, %function76 .balign 477afunc:78 bx lr79 80// CHECK:      00020410 <dat1>:81// CHECK-NEXT: 20410: andeq   r0, r0, r082 83// CHECK:      00020414 <dat2>:84// CHECK-NEXT: 20414: andeq   r0, r0, r085 86// CHECK:     00020800 <_start>:87/// 0x20800 + 0x8 - 0x3f8 = 0x11410 = dat188// CHECK-NEXT: 20800: sub     r0, pc, #101689/// 0x20804 + 0x8 - 0x3f8 = 0x11414 = dat290// CHECK-NEXT: 20804: sub     r0, pc, #101691/// 0x20808 + 0x8 + 0x400 = 0x11c10 = dat392// CHECK-NEXT: 20808: add     r0, pc, #64, #2893/// 0x2080c + 0x8 + 0x400 = 0x11c14 = dat494// CHECK-NEXT: 2080c: add     r0, pc, #64, #2895 96// CHECK:      00020c10 <dat3>:97// CHECK-NEXT: 20c10: andeq   r0, r0, r098 99// CHECK:      00020c14 <dat4>:100// CHECK-NEXT: 20c14: andeq   r0, r0, r0101 102// CHECK:      00020c18 <tfunc>:103// CHECK-NEXT: 20c18: bx      lr104 105// CHECK:      00020c1c <arm_func>:106/// 0x20c1c + 0x8 - 0xb = 11c19 = tfunc107// CHECK-NEXT: 20c1c: sub     r0, pc, #11108/// 0x20c20 + 0x8 = 0x11c28 = afunc109// CHECK-NEXT: 20c20: add     r0, pc, #0110// CHECK-NEXT: 20c24: bx      lr111 112// CHECK:      00020c28 <afunc>:113// CHECK-NEXT: 20c28: bx      lr114