xref: /llvm-project/llvm/test/ExecutionEngine/RuntimeDyld/AArch64/COFF_AArch64.s (revision dc3ee330891c230f85242b442de9afe7fdb96da2)
1// RUN: llvm-mc -triple aarch64-windows -filetype obj -o %t.obj %s
2// RUN: llvm-rtdyld -triple aarch64-windows -dummy-extern dummy=0x79563413 -dummy-extern dummyA=0x78566879 -target-addr-start=40960000000000 -verify -check %s %t.obj
3
4  .text
5  .def _bnamed
6  .scl 2
7	.type 32
8  .endef
9
10  .globl _bnamed
11  .align 2
12_bnamed:
13  ret
14
15  .def _foo
16  .scl 2
17	.type 32
18  .endef
19  .globl _foo
20  .align 2
21_foo:
22  movz  w0, #0
23  ret
24
25  .globl _test_adr_relocation
26  .align 2
27
28# IMAGE_REL_ARM64_REL21
29# rtdyld-check:  decode_operand(adr1, 1) = (_const[20:0] - adr1[20:0])
30_test_adr_relocation:
31adr1:
32  adr x0, _const
33  ret
34
35  .globl _test_branch26_reloc
36  .align 2
37
38# IMAGE_REL_ARM64_BRANCH26, test long branch
39# rtdyld-check:  decode_operand(brel, 0)[25:0] = (stub_addr(COFF_AArch64.s.tmp.obj/.text, dummy) - brel)[27:2]
40_test_branch26_reloc:
41brel:
42  b dummy
43  ret
44
45  .globl _test_branch19_reloc
46  .align 2
47
48# IMAGE_REL_ARM64_BRANCH19
49# rtdyld-check:  decode_operand(bcond, 1)[18:0] = (_foo - bcond)[20:2]
50_test_branch19_reloc:
51  mov x0, #3
52  cmp x0, #2
53bcond:
54  bne _foo
55  ret
56
57  .globl _test_branch14_reloc
58  .align 2
59
60# IMAGE_REL_ARM64_BRANCH14
61# rtdyld-check:  decode_operand(tbz_branch, 2)[13:0] = (_bnamed - tbz_branch)[15:2]
62_test_branch14_reloc:
63  mov x1, #0
64tbz_branch:
65  tbz x1, #0, _bnamed
66  ret
67
68  .globl  _test_adrp_ldr_reloc
69  .align  2
70
71# IMAGE_REL_ARM64_PAGEBASE_REL21
72# rtdyld-check:  decode_operand(adrp1, 1) = (_const[32:12] - adrp1[32:12])
73_test_adrp_ldr_reloc:
74adrp1:
75  adrp x0, _const
76
77# IMAGE_REL_ARM64_PAGEOFFSET_12L
78# rtdyld-check:  decode_operand(ldr1, 2) = _const[11:3]
79ldr1:
80  ldr  x0, [x0, #:lo12:_const]
81  ret
82
83  .globl  _test_add_reloc
84  .align  2
85
86# IMAGE_REL_ARM64_PAGEOFFSET_12A
87# rtdyld-check: decode_operand(add1, 2) = (tgt+4)[11:0]
88_test_add_reloc:
89add1:
90  add x0, x0, tgt@PAGEOFF+4
91  ret
92
93  .section .data
94  .globl _test_addr64_reloc
95  .align 2
96
97# IMAGE_REL_ARM64_ADDR64
98# rtdyld-check:  *{8}addr64 = tgt+4
99_test_addr64_reloc:
100addr64:
101  .quad tgt+4
102
103# IMAGE_REL_ARM64_ADDR32
104# rtdyld-check:  *{4}_test_addr32_reloc = 0x78566879
105_test_addr32_reloc:
106  .long dummyA
107
108  .globl _relocations
109  .align 2
110
111# IMAGE_REL_ARM64_ADDR32NB, RVA of the target
112# rtdyld-check:  *{4}_relocations = _foo - 40960000000000
113_relocations:
114  .long _foo@IMGREL
115
116# IMAGE_REL_ARM64_ADDR32NB
117# rtdyld-check:  *{4}imgrel2 = _string - 40960000000000+5
118imgrel2:
119  .long _string@IMGREL+5
120
121# IMAGE_REL_ARM64_SECTION
122# rtdyld-check: *{2}secindex = 1
123secindex:
124  .secidx _test_addr32_reloc
125
126# IMAGE_REL_ARM64_SECREL
127# rtdyld-check: *{4}secrel = string - section_addr(COFF_AArch64.s.tmp.obj, .data)
128secrel:
129  .secrel32 string
130
131  .globl _const
132  .align 3
133_const:
134  .quad 4614256650576692846
135
136tgt:
137  .word 1
138  .word 2
139  .word 3
140  .word 4
141  .word 5
142
143  .globl string
144  .align 2
145string:
146  .asciz "Hello World\n"
147
148  .section .rdata,"dr"
149  .globl _string
150  .align 2
151_string:
152  .asciz "Hello World\n"
153