1// RUN: llvm-mc -triple thumbv7-windows-itanium -filetype obj -o %t.obj %s
2// RUN: llvm-rtdyld -triple thumbv7-windows -dummy-extern OutputDebugStringA=0x78563412 -dummy-extern ExitProcess=0x54769890 -dummy-extern unnamed_addr=0x00001024 -verify -check %s %t.obj
3
4	.text
5	.syntax unified
6
7	.def unnamed_addr
8		.scl 2
9		.type 32
10	.endef
11	.global unnamed_addr
12
13	.def branch24t
14		.scl 2
15		.type 32
16	.endef
17	.global branch24t
18	.p2align 1
19	.code 16
20	.thumb_func
21branch24t:
22@ rel1:
23#	b unnamed_addr					@ IMAGE_REL_ARM_BRANCH24T
24
25	.def function
26		.scl 2
27		.type 32
28	.endef
29	.globl function
30	.p2align 1
31	.code 16
32	.thumb_func
33function:
34	push.w {r11, lr}
35	mov r11, sp
36rel2:							@ IMAGE_REL_ARM_MOV32T
37	movw r0, :lower16:__imp_OutputDebugStringA
38# rtdyld-check: decode_operand(rel2, 1) = (__imp_OutputDebugStringA&0x0000ffff)
39	movt r0, :upper16:__imp_OutputDebugStringA
40# TODO rtdyld-check: decode_operand(rel2, 1) = (__imp_OutputDebugStringA&0xffff0000>>16)
41	ldr r1, [r0]
42rel3:							@ IMAGE_REL_ARM_MOV32T
43	movw r0, :lower16:string
44# rtdyld-check: decode_operand(rel3, 1) = (string&0x0000ffff)
45	movt r0, :upper16:string
46# TODO rtdyld-check: decode_operand(rel3, 1) = (string&0xffff0000>>16)
47	blx r1
48rel4:							@ IMAGE_REL_ARM_MOV32T
49	movw r0, :lower16:__imp_ExitProcess
50# rtdyld-check: decode_operand(rel4, 1) = (__imp_ExitProcess&0x0000ffff)
51	movt r0, :upper16:__imp_ExitProcess
52# TODO rtdyld-check: decode_operand(rel4, 1) = (__imp_ExitProcess&0xffff0000>>16)
53	ldr r1, [r0]
54	movs r0, #0
55	pop.w {r11, lr}
56	bx r1
57
58	.def main
59		.scl 2
60		.type 32
61	.endef
62	.globl main
63	.p2align 1
64	.code 16
65	.thumb_func
66main:
67	push.w {r11, lr}
68	mov r11, sp
69rel5:
70#	bl function					@ IMAGE_REL_ARM_BLX23T
71	movs r0, #0
72	pop.w {r11, pc}
73
74	.section .rdata,"dr"
75	.global string
76string:
77	.asciz "Hello World\n"
78
79	.data
80
81	.p2align 2
82__imp_OutputDebugStringA:
83@ rel6:
84	.long OutputDebugStringA			@ IMAGE_REL_ARM_ADDR32
85# rtdyld-check: *{4}__imp_OutputDebugStringA = 0x78563412
86
87	.p2align 2
88__imp_ExitProcess:
89@ rel7:
90	.long ExitProcess				@ IMAGE_REL_ARM_ADDR32
91# rtdyld-check: *{4}__imp_ExitProcess = 0x54769890
92
93	.global relocations
94relocations:
95@ rel8:
96	.long function(imgrel)				@ IMAGE_REL_ARM_ADDR32NB
97# rtdyld-check: *{4}relocations = function - section_addr(COFF_Thumb.s.tmp.obj, .text)
98rel9:
99	.secidx __imp_OutputDebugStringA		@ IMAGE_REL_ARM_SECTION
100# rtdyld-check: *{2}rel9 = 1
101rel10:
102	.long relocations(secrel32)			@ IMAGE_REL_ARM_SECREL
103# rtdyld-check: *{4}rel10 = relocations - section_addr(COFF_Thumb.s.tmp.obj, .data)
104rel11:
105	.secrel32 relocations				@ IMAGE_REL_ARM_SECREL
106# rtdyld-check: *{4}rel11 = relocations - section_addr(COFF_Thumb.s.tmp.obj, .data)
107
108