1# REQUIRES: x86
2# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-freebsd %s -o %tx64
3# RUN: ld.lld -m elf_amd64_fbsd %tx64 -o %t2x64
4# RUN: llvm-readobj --file-headers %t2x64 | FileCheck --check-prefix=AMD64 %s
5# RUN: ld.lld %tx64 -o %t3x64
6# RUN: llvm-readobj --file-headers %t3x64 | FileCheck --check-prefix=AMD64 %s
7# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.sysv
8# RUN: ld.lld -m elf_amd64_fbsd %t.sysv -o %t.freebsd
9# RUN: llvm-readobj --file-headers %t.freebsd | FileCheck --check-prefix=AMD64 %s
10# RUN: echo 'OUTPUT_FORMAT(elf64-x86-64-freebsd)' > %t4x64.script
11# RUN: ld.lld %t4x64.script %tx64 -o %t4x64
12# RUN: llvm-readobj --file-headers %t4x64 | FileCheck --check-prefix=AMD64 %s
13# AMD64:      ElfHeader {
14# AMD64-NEXT:   Ident {
15# AMD64-NEXT:     Magic: (7F 45 4C 46)
16# AMD64-NEXT:     Class: 64-bit (0x2)
17# AMD64-NEXT:     DataEncoding: LittleEndian (0x1)
18# AMD64-NEXT:     FileVersion: 1
19# AMD64-NEXT:     OS/ABI: FreeBSD (0x9)
20# AMD64-NEXT:     ABIVersion: 0
21# AMD64-NEXT:     Unused: (00 00 00 00 00 00 00)
22# AMD64-NEXT:   }
23# AMD64-NEXT:   Type: Executable (0x2)
24# AMD64-NEXT:   Machine: EM_X86_64 (0x3E)
25# AMD64-NEXT:   Version: 1
26# AMD64-NEXT:   Entry:
27# AMD64-NEXT:   ProgramHeaderOffset: 0x40
28# AMD64-NEXT:   SectionHeaderOffset:
29# AMD64-NEXT:   Flags [ (0x0)
30# AMD64-NEXT:   ]
31# AMD64-NEXT:   HeaderSize: 64
32# AMD64-NEXT:   ProgramHeaderEntrySize: 56
33# AMD64-NEXT:   ProgramHeaderCount:
34# AMD64-NEXT:   SectionHeaderEntrySize: 64
35# AMD64-NEXT:   SectionHeaderCount:
36# AMD64-NEXT:   StringTableSectionIndex:
37# AMD64-NEXT: }
38
39# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %tx64
40# RUN: ld.lld -m elf_x86_64 %tx64 -o %t2x64
41# RUN: llvm-readobj --file-headers %t2x64 | FileCheck --check-prefix=X86-64 %s
42# RUN: ld.lld %tx64 -o %t3x64
43# RUN: llvm-readobj --file-headers %t3x64 | FileCheck --check-prefix=X86-64 %s
44# RUN: echo 'OUTPUT_FORMAT(elf64-x86-64)' > %t4x64.script
45# RUN: ld.lld %t4x64.script %tx64 -o %t4x64
46# RUN: ld.lld %tx64 -o %t4x64 %t4x64.script
47# RUN: llvm-readobj --file-headers %t4x64 | FileCheck --check-prefix=X86-64 %s
48# X86-64:      ElfHeader {
49# X86-64-NEXT:   Ident {
50# X86-64-NEXT:     Magic: (7F 45 4C 46)
51# X86-64-NEXT:     Class: 64-bit (0x2)
52# X86-64-NEXT:     DataEncoding: LittleEndian (0x1)
53# X86-64-NEXT:     FileVersion: 1
54# X86-64-NEXT:     OS/ABI: SystemV (0x0)
55# X86-64-NEXT:     ABIVersion: 0
56# X86-64-NEXT:     Unused: (00 00 00 00 00 00 00)
57# X86-64-NEXT:   }
58# X86-64-NEXT:   Type: Executable (0x2)
59# X86-64-NEXT:   Machine: EM_X86_64 (0x3E)
60# X86-64-NEXT:   Version: 1
61# X86-64-NEXT:   Entry:
62# X86-64-NEXT:   ProgramHeaderOffset: 0x40
63# X86-64-NEXT:   SectionHeaderOffset:
64# X86-64-NEXT:   Flags [ (0x0)
65# X86-64-NEXT:   ]
66# X86-64-NEXT:   HeaderSize: 64
67# X86-64-NEXT:   ProgramHeaderEntrySize: 56
68# X86-64-NEXT:   ProgramHeaderCount:
69# X86-64-NEXT:   SectionHeaderEntrySize: 64
70# X86-64-NEXT:   SectionHeaderCount:
71# X86-64-NEXT:   StringTableSectionIndex:
72# X86-64-NEXT: }
73
74# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux-gnux32 %s -o %tx32
75# RUN: ld.lld -m elf32_x86_64 %tx32 -o %t2x32
76# RUN: llvm-readobj --file-headers %t2x32 | FileCheck --check-prefix=X32 %s
77# RUN: ld.lld %tx32 -o %t3x32
78# RUN: llvm-readobj --file-headers %t3x32 | FileCheck --check-prefix=X32 %s
79# RUN: echo 'OUTPUT_FORMAT(elf32-x86-64)' > %t4x32.script
80# RUN: ld.lld %t4x32.script %tx32 -o %t4x32
81# RUN: llvm-readobj --file-headers %t4x32 | FileCheck --check-prefix=X32 %s
82# X32:      ElfHeader {
83# X32-NEXT:   Ident {
84# X32-NEXT:     Magic: (7F 45 4C 46)
85# X32-NEXT:     Class: 32-bit (0x1)
86# X32-NEXT:     DataEncoding: LittleEndian (0x1)
87# X32-NEXT:     FileVersion: 1
88# X32-NEXT:     OS/ABI: SystemV (0x0)
89# X32-NEXT:     ABIVersion: 0
90# X32-NEXT:     Unused: (00 00 00 00 00 00 00)
91# X32-NEXT:   }
92# X32-NEXT:   Type: Executable (0x2)
93# X32-NEXT:   Machine: EM_X86_64 (0x3E)
94# X32-NEXT:   Version: 1
95# X32-NEXT:   Entry:
96# X32-NEXT:   ProgramHeaderOffset: 0x34
97# X32-NEXT:   SectionHeaderOffset:
98# X32-NEXT:   Flags [ (0x0)
99# X32-NEXT:   ]
100# X32-NEXT:   HeaderSize: 52
101# X32-NEXT:   ProgramHeaderEntrySize: 32
102# X32-NEXT:   ProgramHeaderCount:
103# X32-NEXT:   SectionHeaderEntrySize: 40
104# X32-NEXT:   SectionHeaderCount:
105# X32-NEXT:   StringTableSectionIndex:
106# X32-NEXT: }
107
108# RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %s -o %tx86
109# RUN: ld.lld -m elf_i386 %tx86 -o %t2x86
110# RUN: llvm-readobj --file-headers %t2x86 | FileCheck --check-prefix=X86 %s
111# RUN: ld.lld %tx86 -o %t3x86
112# RUN: llvm-readobj --file-headers %t3x86 | FileCheck --check-prefix=X86 %s
113# RUN: echo 'OUTPUT_FORMAT(elf32-i386)' > %t4x86.script
114# RUN: ld.lld %t4x86.script %tx86 -o %t4x86
115# RUN: llvm-readobj --file-headers %t4x86 | FileCheck --check-prefix=X86 %s
116# X86:      ElfHeader {
117# X86-NEXT:   Ident {
118# X86-NEXT:     Magic: (7F 45 4C 46)
119# X86-NEXT:     Class: 32-bit (0x1)
120# X86-NEXT:     DataEncoding: LittleEndian (0x1)
121# X86-NEXT:     FileVersion: 1
122# X86-NEXT:     OS/ABI: SystemV (0x0)
123# X86-NEXT:     ABIVersion: 0
124# X86-NEXT:     Unused: (00 00 00 00 00 00 00)
125# X86-NEXT:   }
126# X86-NEXT:   Type: Executable (0x2)
127# X86-NEXT:   Machine: EM_386 (0x3)
128# X86-NEXT:   Version: 1
129# X86-NEXT:   Entry:
130# X86-NEXT:   ProgramHeaderOffset: 0x34
131# X86-NEXT:   SectionHeaderOffset:
132# X86-NEXT:   Flags [ (0x0)
133# X86-NEXT:   ]
134# X86-NEXT:   HeaderSize: 52
135# X86-NEXT:   ProgramHeaderEntrySize: 32
136# X86-NEXT:   ProgramHeaderCount:
137# X86-NEXT:   SectionHeaderEntrySize: 40
138# X86-NEXT:   SectionHeaderCount:
139# X86-NEXT:   StringTableSectionIndex:
140# X86-NEXT: }
141
142# RUN: llvm-mc -filetype=obj -triple=i686-unknown-freebsd %s -o %tx86fbsd
143# RUN: ld.lld -m elf_i386_fbsd %tx86fbsd -o %t2x86fbsd
144# RUN: llvm-readobj --file-headers %t2x86fbsd | FileCheck --check-prefix=X86FBSD %s
145# RUN: ld.lld %tx86fbsd -o %t3x86fbsd
146# RUN: llvm-readobj --file-headers %t3x86fbsd | FileCheck --check-prefix=X86FBSD %s
147# RUN: echo 'OUTPUT_FORMAT(elf32-i386-freebsd)' > %t4x86fbsd.script
148# RUN: ld.lld %t4x86fbsd.script %tx86fbsd -o %t4x86fbsd
149# RUN: llvm-readobj --file-headers %t4x86fbsd | FileCheck --check-prefix=X86FBSD %s
150# X86FBSD:      ElfHeader {
151# X86FBSD-NEXT:   Ident {
152# X86FBSD-NEXT:     Magic: (7F 45 4C 46)
153# X86FBSD-NEXT:     Class: 32-bit (0x1)
154# X86FBSD-NEXT:     DataEncoding: LittleEndian (0x1)
155# X86FBSD-NEXT:     FileVersion: 1
156# X86FBSD-NEXT:     OS/ABI: FreeBSD (0x9)
157# X86FBSD-NEXT:     ABIVersion: 0
158# X86FBSD-NEXT:     Unused: (00 00 00 00 00 00 00)
159# X86FBSD-NEXT:   }
160# X86FBSD-NEXT:   Type: Executable (0x2)
161# X86FBSD-NEXT:   Machine: EM_386 (0x3)
162# X86FBSD-NEXT:   Version: 1
163# X86FBSD-NEXT:   Entry:
164# X86FBSD-NEXT:   ProgramHeaderOffset: 0x34
165# X86FBSD-NEXT:   SectionHeaderOffset:
166# X86FBSD-NEXT:   Flags [ (0x0)
167# X86FBSD-NEXT:   ]
168# X86FBSD-NEXT:   HeaderSize: 52
169# X86FBSD-NEXT:   ProgramHeaderEntrySize: 32
170# X86FBSD-NEXT:   ProgramHeaderCount:
171# X86FBSD-NEXT:   SectionHeaderEntrySize: 40
172# X86FBSD-NEXT:   SectionHeaderCount:
173# X86FBSD-NEXT:   StringTableSectionIndex:
174# X86FBSD-NEXT: }
175
176# RUN: llvm-mc -filetype=obj -triple=i586-intel-elfiamcu %s -o %tiamcu
177# RUN: ld.lld -m elf_iamcu %tiamcu -o %t2iamcu
178# RUN: llvm-readobj --file-headers %t2iamcu | FileCheck --check-prefix=IAMCU %s
179# RUN: ld.lld %tiamcu -o %t3iamcu
180# RUN: llvm-readobj --file-headers %t3iamcu | FileCheck --check-prefix=IAMCU %s
181# RUN: echo 'OUTPUT_FORMAT(elf32-iamcu)' > %t4iamcu.script
182# RUN: ld.lld %t4iamcu.script %tiamcu -o %t4iamcu
183# RUN: llvm-readobj --file-headers %t4iamcu | FileCheck --check-prefix=IAMCU %s
184# IAMCU:      ElfHeader {
185# IAMCU-NEXT:   Ident {
186# IAMCU-NEXT:     Magic: (7F 45 4C 46)
187# IAMCU-NEXT:     Class: 32-bit (0x1)
188# IAMCU-NEXT:     DataEncoding: LittleEndian (0x1)
189# IAMCU-NEXT:     FileVersion: 1
190# IAMCU-NEXT:     OS/ABI: SystemV (0x0)
191# IAMCU-NEXT:     ABIVersion: 0
192# IAMCU-NEXT:     Unused: (00 00 00 00 00 00 00)
193# IAMCU-NEXT:   }
194# IAMCU-NEXT:   Type: Executable (0x2)
195# IAMCU-NEXT:   Machine: EM_IAMCU (0x6)
196# IAMCU-NEXT:   Version: 1
197# IAMCU-NEXT:   Entry:
198# IAMCU-NEXT:   ProgramHeaderOffset: 0x34
199# IAMCU-NEXT:   SectionHeaderOffset:
200# IAMCU-NEXT:   Flags [ (0x0)
201# IAMCU-NEXT:   ]
202# IAMCU-NEXT:   HeaderSize: 52
203# IAMCU-NEXT:   ProgramHeaderEntrySize: 32
204# IAMCU-NEXT:   ProgramHeaderCount:
205# IAMCU-NEXT:   SectionHeaderEntrySize: 40
206# IAMCU-NEXT:   SectionHeaderCount:
207# IAMCU-NEXT:   StringTableSectionIndex:
208# IAMCU-NEXT: }
209
210.globl _start
211_start:
212