1; RUN: llvm-mc -n -triple arm64-apple-darwin10 %s -filetype=obj -o - | llvm-readobj -r --expand-relocs | FileCheck %s
2
3	.text
4_fred:
5	bl	_func
6	bl	_func + 20
7
8	adrp	x3, _data@page
9        ldr	w2, [x3, _data@pageoff]
10
11        add	x3, x3, _data@pageoff + 4
12
13	adrp	x3, _data@page+1
14        ldr	w2, [x3, _data@pageoff + 4]
15
16	adrp	x3, _data_ext@gotpage
17        ldr	w2, [x3, _data_ext@gotpageoff]
18        adrp    x0, L_.str@PAGE
19
20	.data
21_data:
22        .quad _foo
23        .quad _foo + 4
24        .quad _foo - _bar
25        .quad _foo - _bar + 4
26
27        .long _foo - _bar
28
29        .quad _foo@got
30        .long _foo@got - .
31
32        .section __TEXT,__cstring,cstring_literals
33L_.str:
34        .asciz "foo"
35
36
37; CHECK:     Relocations [
38; CHECK-NEXT:  Section __text {
39; CHECK-NEXT:    Relocation {
40; CHECK-NEXT:       Offset: 0x24
41; CHECK-NEXT:       PCRel: 1
42; CHECK-NEXT:       Length: 2
43; CHECK-NEXT:       Type: ARM64_RELOC_PAGE21 (3)
44; CHECK-NEXT:       Symbol: L_.str
45; CHECK-NEXT:     }
46; CHECK-NEXT:    Relocation {
47; CHECK-NEXT:       Offset: 0x20
48; CHECK-NEXT:       PCRel: 0
49; CHECK-NEXT:       Length: 2
50; CHECK-NEXT:       Type: ARM64_RELOC_GOT_LOAD_PAGEOFF12 (6)
51; CHECK-NEXT:       Symbol: _data_ext
52; CHECK-NEXT:     }
53; CHECK-NEXT:     Relocation {
54; CHECK-NEXT:       Offset: 0x1C
55; CHECK-NEXT:       PCRel: 1
56; CHECK-NEXT:       Length: 2
57; CHECK-NEXT:       Type: ARM64_RELOC_GOT_LOAD_PAGE21 (5)
58; CHECK-NEXT:       Symbol: _data_ext
59; CHECK-NEXT:     }
60; CHECK-NEXT:     Relocation {
61; CHECK-NEXT:       Offset: 0x18
62; CHECK-NEXT:       PCRel: 0
63; CHECK-NEXT:       Length: 2
64; CHECK-NEXT:       Type: ARM64_RELOC_ADDEND (10)
65; CHECK-NEXT:       Section: - (4)
66; CHECK-NEXT:     }
67; CHECK-NEXT:     Relocation {
68; CHECK-NEXT:       Offset: 0x18
69; CHECK-NEXT:       PCRel: 0
70; CHECK-NEXT:       Length: 2
71; CHECK-NEXT:       Type: ARM64_RELOC_PAGEOFF12 (4)
72; CHECK-NEXT:       Symbol: _data
73; CHECK-NEXT:     }
74; CHECK-NEXT:     Relocation {
75; CHECK-NEXT:       Offset: 0x14
76; CHECK-NEXT:       PCRel: 0
77; CHECK-NEXT:       Length: 2
78; CHECK-NEXT:       Type: ARM64_RELOC_ADDEND (10)
79; CHECK-NEXT:       Section: __text
80; CHECK-NEXT:     }
81; CHECK-NEXT:     Relocation {
82; CHECK-NEXT:       Offset: 0x14
83; CHECK-NEXT:       PCRel: 1
84; CHECK-NEXT:       Length: 2
85; CHECK-NEXT:       Type: ARM64_RELOC_PAGE21 (3)
86; CHECK-NEXT:       Symbol: _data
87; CHECK-NEXT:     }
88; CHECK-NEXT:     Relocation {
89; CHECK-NEXT:       Offset: 0x10
90; CHECK-NEXT:       PCRel: 0
91; CHECK-NEXT:       Length: 2
92; CHECK-NEXT:       Type: ARM64_RELOC_ADDEND (10)
93; CHECK-NEXT:       Section: - (4)
94; CHECK-NEXT:     }
95; CHECK-NEXT:     Relocation {
96; CHECK-NEXT:       Offset: 0x10
97; CHECK-NEXT:       PCRel: 0
98; CHECK-NEXT:       Length: 2
99; CHECK-NEXT:       Type: ARM64_RELOC_PAGEOFF12 (4)
100; CHECK-NEXT:       Symbol: _data
101; CHECK-NEXT:     }
102; CHECK-NEXT:     Relocation {
103; CHECK-NEXT:       Offset: 0xC
104; CHECK-NEXT:       PCRel: 0
105; CHECK-NEXT:       Length: 2
106; CHECK-NEXT:       Type: ARM64_RELOC_PAGEOFF12 (4)
107; CHECK-NEXT:       Symbol: _data
108; CHECK-NEXT:     }
109; CHECK-NEXT:     Relocation {
110; CHECK-NEXT:       Offset: 0x8
111; CHECK-NEXT:       PCRel: 1
112; CHECK-NEXT:       Length: 2
113; CHECK-NEXT:       Type: ARM64_RELOC_PAGE21 (3)
114; CHECK-NEXT:       Symbol: _data
115; CHECK-NEXT:     }
116; CHECK-NEXT:     Relocation {
117; CHECK-NEXT:       Offset: 0x4
118; CHECK-NEXT:       PCRel: 0
119; CHECK-NEXT:       Length: 2
120; CHECK-NEXT:       Type: ARM64_RELOC_ADDEND (10)
121; CHECK-NEXT:       Section: - (20)
122; CHECK-NEXT:     }
123; CHECK-NEXT:     Relocation {
124; CHECK-NEXT:       Offset: 0x4
125; CHECK-NEXT:       PCRel: 1
126; CHECK-NEXT:       Length: 2
127; CHECK-NEXT:       Type: ARM64_RELOC_BRANCH26 (2)
128; CHECK-NEXT:       Symbol: _func
129; CHECK-NEXT:     }
130; CHECK-NEXT:     Relocation {
131; CHECK-NEXT:       Offset: 0x0
132; CHECK-NEXT:       PCRel: 1
133; CHECK-NEXT:       Length: 2
134; CHECK-NEXT:       Type: ARM64_RELOC_BRANCH26 (2)
135; CHECK-NEXT:       Symbol: _func
136; CHECK-NEXT:     }
137; CHECK-NEXT:   }
138; CHECK-NEXT:   Section __data {
139; CHECK-NEXT:     Relocation {
140; CHECK-NEXT:       Offset: 0x2C
141; CHECK-NEXT:       PCRel: 1
142; CHECK-NEXT:       Length: 2
143; CHECK-NEXT:       Type: ARM64_RELOC_POINTER_TO_GOT (7)
144; CHECK-NEXT:       Symbol: _foo
145; CHECK-NEXT:     }
146; CHECK-NEXT:     Relocation {
147; CHECK-NEXT:       Offset: 0x24
148; CHECK-NEXT:       PCRel: 0
149; CHECK-NEXT:       Length: 3
150; CHECK-NEXT:       Type: ARM64_RELOC_POINTER_TO_GOT (7)
151; CHECK-NEXT:       Symbol: _foo
152; CHECK-NEXT:     }
153; CHECK-NEXT:     Relocation {
154; CHECK-NEXT:       Offset: 0x20
155; CHECK-NEXT:       PCRel: 0
156; CHECK-NEXT:       Length: 2
157; CHECK-NEXT:       Type: ARM64_RELOC_SUBTRACTOR (1)
158; CHECK-NEXT:       Symbol: _bar
159; CHECK-NEXT:     }
160; CHECK-NEXT:     Relocation {
161; CHECK-NEXT:       Offset: 0x20
162; CHECK-NEXT:       PCRel: 0
163; CHECK-NEXT:       Length: 2
164; CHECK-NEXT:       Type: ARM64_RELOC_UNSIGNED (0)
165; CHECK-NEXT:       Symbol: _foo
166; CHECK-NEXT:     }
167; CHECK-NEXT:     Relocation {
168; CHECK-NEXT:       Offset: 0x18
169; CHECK-NEXT:       PCRel: 0
170; CHECK-NEXT:       Length: 3
171; CHECK-NEXT:       Type: ARM64_RELOC_SUBTRACTOR (1)
172; CHECK-NEXT:       Symbol: _bar
173; CHECK-NEXT:     }
174; CHECK-NEXT:     Relocation {
175; CHECK-NEXT:       Offset: 0x18
176; CHECK-NEXT:       PCRel: 0
177; CHECK-NEXT:       Length: 3
178; CHECK-NEXT:       Type: ARM64_RELOC_UNSIGNED (0)
179; CHECK-NEXT:       Symbol: _foo
180; CHECK-NEXT:     }
181; CHECK-NEXT:     Relocation {
182; CHECK-NEXT:       Offset: 0x10
183; CHECK-NEXT:       PCRel: 0
184; CHECK-NEXT:       Length: 3
185; CHECK-NEXT:       Type: ARM64_RELOC_SUBTRACTOR (1)
186; CHECK-NEXT:       Symbol: _bar
187; CHECK-NEXT:     }
188; CHECK-NEXT:     Relocation {
189; CHECK-NEXT:       Offset: 0x10
190; CHECK-NEXT:       PCRel: 0
191; CHECK-NEXT:       Length: 3
192; CHECK-NEXT:       Type: ARM64_RELOC_UNSIGNED (0)
193; CHECK-NEXT:       Symbol: _foo
194; CHECK-NEXT:     }
195; CHECK-NEXT:     Relocation {
196; CHECK-NEXT:       Offset: 0x8
197; CHECK-NEXT:       PCRel: 0
198; CHECK-NEXT:       Length: 3
199; CHECK-NEXT:       Type: ARM64_RELOC_UNSIGNED (0)
200; CHECK-NEXT:       Symbol: _foo
201; CHECK-NEXT:     }
202; CHECK-NEXT:     Relocation {
203; CHECK-NEXT:       Offset: 0x0
204; CHECK-NEXT:       PCRel: 0
205; CHECK-NEXT:       Length: 3
206; CHECK-NEXT:       Type: ARM64_RELOC_UNSIGNED (0)
207; CHECK-NEXT:       Symbol: _foo
208; CHECK-NEXT:     }
209; CHECK-NEXT:   }
210; CHECK-NEXT: ]
211