[Alignment][NFC] Instructions::getLoadStoreAlignment
[llvm-complete.git] / test / ExecutionEngine / RuntimeDyld / AArch64 / MachO_ARM64_relocations.s
blobba823fb2d44a2af40d9ccc8aa6caaa9165d207a9
1 # RUN: rm -rf %t && mkdir -p %t
2 # RUN: llvm-mc -triple=arm64-apple-ios7.0.0 -filetype=obj -o %t/foo.o %s
3 # RUN: llvm-rtdyld -triple=arm64-apple-ios7.0.0 -map-section foo.o,__text=0x10bc0 -dummy-extern _dummy1=0x100000 -verify -check=%s %t/foo.o
5 .section __TEXT,__text,regular,pure_instructions
6 .ios_version_min 7, 0
7 .globl _foo
8 .align 2
9 _foo:
10 movz w0, #0
11 ret
13 .globl _test_branch_reloc
14 .align 2
17 # Test ARM64_RELOC_BRANCH26 relocation. The branch instruction only encodes 26
18 # bits of the 28-bit possible branch range. The lower two bits are always zero
19 # and therefore ignored.
20 # rtdyld-check: decode_operand(br1, 0)[25:0] = (_foo - br1)[27:2]
21 _test_branch_reloc:
22 br1:
23 b _foo
24 ret
26 .globl _test_branch_reloc_bl
27 .align 2
28 # rtdyld-check: decode_operand(br2, 0)[25:0] = (_foo - br2)[27:2]
29 _test_branch_reloc_bl:
30 br2:
31 bl _foo
32 ret
34 # Test ARM64_RELOC_PAGE21 and ARM64_RELOC_PAGEOFF12 relocation. adrp encodes
35 # the PC-relative page (4 KiB) difference between the adrp instruction and the
36 # variable ptr. ldr encodes the offset of the variable within the page. The ldr
37 # instruction perfroms an implicit shift on the encoded immediate (imm<<3).
38 # rtdyld-check: decode_operand(adrp1, 1) = (_ptr[32:12] - adrp1[32:12])
39 # rtdyld-check: decode_operand(ldr1, 2) = _ptr[11:3]
40 .globl _test_adrp_ldr
41 .align 2
42 _test_adrp_ldr:
43 adrp1:
44 adrp x0, _ptr@PAGE
45 ldr1:
46 ldr x0, [x0, _ptr@PAGEOFF]
47 ret
49 # Test ARM64_RELOC_GOT_LOAD_PAGE21 and ARM64_RELOC_GOT_LOAD_PAGEOFF12
50 # relocation. adrp encodes the PC-relative page (4 KiB) difference between the
51 # adrp instruction and the GOT entry for ptr. ldr encodes the offset of the GOT
52 # entry within the page. The ldr instruction perfroms an implicit shift on the
53 # encoded immediate (imm<<3).
54 # rtdyld-check: *{8}(stub_addr(foo.o/__text, _ptr)) = _ptr
55 # rtdyld-check: decode_operand(adrp2, 1) = (stub_addr(foo.o/__text, _ptr)[32:12] - adrp2[32:12])
56 # rtdyld-check: decode_operand(ldr2, 2) = stub_addr(foo.o/__text, _ptr)[11:3]
57 .globl _test_adrp_ldr
58 .align 2
59 _test_got_adrp_ldr:
60 adrp2:
61 adrp x0, _ptr@GOTPAGE
62 ldr2:
63 ldr x0, [x0, _ptr@GOTPAGEOFF]
64 ret
66 # rtdyld-check: decode_operand(add1, 2) = (tgt+8)[11:2] << 2
67 .globl _test_explicit_addend_reloc
68 .align 4
69 _test_explicit_addend_reloc:
70 add1:
71 add x0, x0, tgt@PAGEOFF+8
73 .align 3
74 tgt:
75 .long 0
76 .long 0
77 .long 7
79 # Test ARM64_RELOC_UNSIGNED relocation. The absolute 64-bit address of the
80 # function should be stored at the 8-byte memory location.
81 # rtdyld-check: *{8}_ptr = _foo
82 .section __DATA,__data
83 .globl _ptr
84 .align 3
85 .fill 4096, 1, 0
86 _ptr:
87 .quad _foo
89 # Test ARM64_RELOC_SUBTRACTOR.
90 # rtdyld-check: *{8}_subtractor_result = _test_branch_reloc - _foo
91 _subtractor_result:
92 .quad _test_branch_reloc - _foo
94 # Test 32-bit relative ARM64_RELOC_POINTER_TO_GOT
95 # rtdyld-check: *{4}_pointer_to_got_32_rel = (stub_addr(foo.o/__data, _dummy1) - _pointer_to_got_32_rel)
96 _pointer_to_got_32_rel:
97 .long _dummy1@got - .
99 # Test 64-bit absolute ARM64_RELOC_POINTER_TO_GOT
100 # rtdyld-check: *{8}_pointer_to_got_64_abs = stub_addr(foo.o/__data, _dummy1)
101 _pointer_to_got_64_abs:
102 .quad _dummy1@got
104 .subsections_via_symbols