1# REQUIRES: aarch64
2# RUN: llvm-mc -filetype=obj -triple=aarch64-unknown-freebsd %s -o %t
3# RUN: ld.lld %t -o %t2
4# RUN: llvm-readobj --file-headers --sections -l --symbols %t2 \
5# RUN:   | FileCheck %s
6
7# exits with return code 42 on FreeBSD/AArch64
8.globl _start
9_start:
10  mov    x0, 42
11  mov    x8, 1
12  svc    0
13
14# CHECK:      ElfHeader {
15# CHECK-NEXT:   Ident {
16# CHECK-NEXT:     Magic: (7F 45 4C 46)
17# CHECK-NEXT:     Class: 64-bit (0x2)
18# CHECK-NEXT:     DataEncoding: LittleEndian (0x1)
19# CHECK-NEXT:     FileVersion: 1
20# CHECK-NEXT:     OS/ABI: FreeBSD (0x9)
21# CHECK-NEXT:     ABIVersion: 0
22# CHECK-NEXT:     Unused: (00 00 00 00 00 00 00)
23# CHECK-NEXT:   }
24# CHECK-NEXT:   Type: Executable (0x2)
25# CHECK-NEXT:   Machine: EM_AARCH64 (0xB7)
26# CHECK-NEXT:   Version: 1
27# CHECK-NEXT:   Entry: [[ENTRY:0x[0-9A-F]+]]
28# CHECK-NEXT:   ProgramHeaderOffset: 0x40
29# CHECK-NEXT:   SectionHeaderOffset: 0x1B8
30# CHECK-NEXT:   Flags [ (0x0)
31# CHECK-NEXT:   ]
32# CHECK-NEXT:   HeaderSize: 64
33# CHECK-NEXT:   ProgramHeaderEntrySize: 56
34# CHECK-NEXT:   ProgramHeaderCount: 4
35# CHECK-NEXT:   SectionHeaderEntrySize: 64
36# CHECK-NEXT:   SectionHeaderCount: 6
37# CHECK-NEXT:   StringTableSectionIndex: 4
38# CHECK-NEXT: }
39# CHECK-NEXT: Sections [
40# CHECK-NEXT:   Section {
41# CHECK-NEXT:     Index: 0
42# CHECK-NEXT:     Name:  (0)
43# CHECK-NEXT:     Type: SHT_NULL (0x0)
44# CHECK-NEXT:     Flags [ (0x0)
45# CHECK-NEXT:     ]
46# CHECK-NEXT:     Address: 0x0
47# CHECK-NEXT:     Offset: 0x0
48# CHECK-NEXT:     Size: 0
49# CHECK-NEXT:     Link: 0
50# CHECK-NEXT:     Info: 0
51# CHECK-NEXT:     AddressAlignment: 0
52# CHECK-NEXT:     EntrySize: 0
53# CHECK-NEXT:   }
54# CHECK-NEXT:   Section {
55# CHECK-NEXT:     Index: 1
56# CHECK-NEXT:     Name: .text
57# CHECK-NEXT:     Type: SHT_PROGBITS (0x1)
58# CHECK-NEXT:     Flags [ (0x6)
59# CHECK-NEXT:       SHF_ALLOC (0x2)
60# CHECK-NEXT:       SHF_EXECINSTR (0x4)
61# CHECK-NEXT:     ]
62# CHECK-NEXT:     Address: 0x210120
63# CHECK-NEXT:     Offset: 0x120
64# CHECK-NEXT:     Size: 12
65# CHECK-NEXT:     Link: 0
66# CHECK-NEXT:     Info: 0
67# CHECK-NEXT:     AddressAlignment: 4
68# CHECK-NEXT:     EntrySize: 0
69# CHECK-NEXT:   }
70# CHECK-NEXT:   Section {
71# CHECK-NEXT:     Index: 2
72# CHECK-NEXT:     Name: .comment
73# CHECK-NEXT:     Type: SHT_PROGBITS (0x1)
74# CHECK-NEXT:     Flags [ (0x30)
75# CHECK-NEXT:       SHF_MERGE (0x10)
76# CHECK-NEXT:       SHF_STRINGS (0x20)
77# CHECK-NEXT:     ]
78# CHECK-NEXT:     Address: 0x0
79# CHECK-NEXT:     Offset: 0x12C
80# CHECK-NEXT:     Size: 8
81# CHECK-NEXT:     Link: 0
82# CHECK-NEXT:     Info: 0
83# CHECK-NEXT:     AddressAlignment: 1
84# CHECK-NEXT:     EntrySize: 1
85# CHECK-NEXT:   }
86# CHECK-NEXT:   Section {
87# CHECK-NEXT:     Index: 3
88# CHECK-NEXT:     Name: .symtab
89# CHECK-NEXT:     Type: SHT_SYMTAB (0x2)
90# CHECK-NEXT:     Flags [ (0x0)
91# CHECK-NEXT:     ]
92# CHECK-NEXT:     Address: 0x0
93# CHECK-NEXT:     Offset: 0x138
94# CHECK-NEXT:     Size: 72
95# CHECK-NEXT:     Link: 5
96# CHECK-NEXT:     Info: 2
97# CHECK-NEXT:     AddressAlignment: 8
98# CHECK-NEXT:     EntrySize: 24
99# CHECK-NEXT:   }
100# CHECK-NEXT:   Section {
101# CHECK-NEXT:     Index: 4
102# CHECK-NEXT:     Name: .shstrtab
103# CHECK-NEXT:     Type: SHT_STRTAB (0x3)
104# CHECK-NEXT:     Flags [ (0x0)
105# CHECK-NEXT:     ]
106# CHECK-NEXT:     Address: 0x0
107# CHECK-NEXT:     Offset: 0x180
108# CHECK-NEXT:     Size: 42
109# CHECK-NEXT:     Link: 0
110# CHECK-NEXT:     Info: 0
111# CHECK-NEXT:     AddressAlignment: 1
112# CHECK-NEXT:     EntrySize: 0
113# CHECK-NEXT:   }
114# CHECK-NEXT:   Section {
115# CHECK-NEXT:     Index: 5
116# CHECK-NEXT:     Name: .strtab
117# CHECK-NEXT:     Type: SHT_STRTAB (0x3)
118# CHECK-NEXT:     Flags [ (0x0)
119# CHECK-NEXT:     ]
120# CHECK-NEXT:     Address: 0x0
121# CHECK-NEXT:     Offset: 0x1AA
122# CHECK-NEXT:     Size: 13
123# CHECK-NEXT:     Link: 0
124# CHECK-NEXT:     Info: 0
125# CHECK-NEXT:     AddressAlignment: 1
126# CHECK-NEXT:     EntrySize: 0
127# CHECK-NEXT:   }
128# CHECK-NEXT: ]
129# CHECK-NEXT: ProgramHeaders [
130# CHECK-NEXT:   ProgramHeader {
131# CHECK-NEXT:     Type: PT_PHDR (0x6)
132# CHECK-NEXT:     Offset: 0x40
133# CHECK-NEXT:     VirtualAddress: 0x200040
134# CHECK-NEXT:     PhysicalAddress: 0x200040
135# CHECK-NEXT:     FileSize: 224
136# CHECK-NEXT:     MemSize: 224
137# CHECK-NEXT:     Flags [ (0x4)
138# CHECK-NEXT:       PF_R (0x4)
139# CHECK-NEXT:     ]
140# CHECK-NEXT:     Alignment: 8
141# CHECK-NEXT:   }
142# CHECK-NEXT:   ProgramHeader {
143# CHECK-NEXT:     Type: PT_LOAD (0x1)
144# CHECK-NEXT:     Offset: 0x0
145# CHECK-NEXT:     VirtualAddress: 0x200000
146# CHECK-NEXT:     PhysicalAddress: 0x200000
147# CHECK-NEXT:     FileSize: 288
148# CHECK-NEXT:     MemSize: 288
149# CHECK-NEXT:     Flags [
150# CHECK-NEXT:       PF_R
151# CHECK-NEXT:     ]
152# CHECK-NEXT:     Alignment: 65536
153# CHECK-NEXT:   }
154# CHECK-NEXT:   ProgramHeader {
155# CHECK-NEXT:     Type: PT_LOAD (0x1)
156# CHECK-NEXT:     Offset: 0x120
157# CHECK-NEXT:     VirtualAddress: 0x210120
158# CHECK-NEXT:     PhysicalAddress: 0x210120
159# CHECK-NEXT:     FileSize: 12
160# CHECK-NEXT:     MemSize: 12
161# CHECK-NEXT:     Flags [ (0x5)
162# CHECK-NEXT:       PF_R (0x4)
163# CHECK-NEXT:       PF_X (0x1)
164# CHECK-NEXT:     ]
165# CHECK-NEXT:     Alignment: 65536
166# CHECK-NEXT:   }
167# CHECK-NEXT:   ProgramHeader {
168# CHECK-NEXT:     Type: PT_GNU_STACK
169# CHECK-NEXT:     Offset: 0x0
170# CHECK-NEXT:     VirtualAddress: 0x0
171# CHECK-NEXT:     PhysicalAddress: 0x0
172# CHECK-NEXT:     FileSize: 0
173# CHECK-NEXT:     MemSize: 0
174# CHECK-NEXT:     Flags [
175# CHECK-NEXT:       PF_R
176# CHECK-NEXT:       PF_W
177# CHECK-NEXT:     ]
178# CHECK-NEXT:     Alignment: 0
179# CHECK-NEXT:   }
180# CHECK-NEXT: ]
181# CHECK-NEXT: Symbols [
182# CHECK-NEXT:   Symbol {
183# CHECK-NEXT:     Name:  (0)
184# CHECK-NEXT:     Value: 0x0
185# CHECK-NEXT:     Size: 0
186# CHECK-NEXT:     Binding: Local (0x0)
187# CHECK-NEXT:     Type: None (0x0)
188# CHECK-NEXT:     Other: 0
189# CHECK-NEXT:     Section: Undefined (0x0)
190# CHECK-NEXT:   }
191# CHECK-NEXT:   Symbol {
192# CHECK-NEXT:     Name: $x.0
193# CHECK-NEXT:     Value: 0x210120
194# CHECK-NEXT:     Size: 0
195# CHECK-NEXT:     Binding: Local (0x0)
196# CHECK-NEXT:     Type: None (0x0)
197# CHECK-NEXT:     Other: 0
198# CHECK-NEXT:     Section: .text
199# CHECK-NEXT:   }
200# CHECK-NEXT:   Symbol {
201# CHECK-NEXT:     Name: _start
202# CHECK-NEXT:     Value: [[ENTRY]]
203# CHECK-NEXT:     Size: 0
204# CHECK-NEXT:     Binding: Global (0x1)
205# CHECK-NEXT:     Type: None (0x0)
206# CHECK-NEXT:     Other: 0
207# CHECK-NEXT:     Section: .text
208# CHECK-NEXT:   }
209# CHECK-NEXT: ]
210