1 ## Test writing stub elf with minimal sections.
3 # RUN: llvm-ifs --output-elf=%t.elf32l --arch=x86_64 --bitwidth=32 --endianness=little %s
4 # RUN: llvm-readobj -h -S --string-dump .dynstr --string-dump .shstrtab --dyn-symbols --dynamic-table %t.elf32l | FileCheck %s -DCLASS="32-bit (0x1)" -DDE="LittleEndian (0x1)" -DHS=52 -DPHES=32 -DSHES=40 -DDYNSYMAL=4 -DDYNSYMES=16 -DDYNAMICAL=4 -DDYNAMICES=8 -DDYNTABZ=0
6 # RUN: llvm-ifs --output-elf=%t.elf32b --arch=x86_64 --bitwidth=32 --endianness=big %s
7 # RUN: llvm-readobj -h -S --string-dump .dynstr --string-dump .shstrtab --dyn-symbols --dynamic-table %t.elf32b | FileCheck %s -DCLASS="32-bit (0x1)" -DDE="BigEndian (0x2)" -DHS=52 -DPHES=32 -DSHES=40 -DDYNSYMAL=4 -DDYNSYMES=16 -DDYNAMICAL=4 -DDYNAMICES=8 -DDYNTABZ=0
9 # RUN: llvm-ifs --output-elf=%t.elf64l --arch=x86_64 --bitwidth=64 --endianness=little %s
10 # RUN: llvm-readobj -h -S --string-dump .dynstr --string-dump .shstrtab --dyn-symbols --dynamic-table %t.elf64l | FileCheck %s -DCLASS="64-bit (0x2)" -DDE="LittleEndian (0x1)" -DHS=64 -DPHES=56 -DSHES=64 -DDYNSYMAL=8 -DDYNSYMES=24 -DDYNAMICAL=8 -DDYNAMICES=16 -DDYNTABZ=000000000
12 # RUN: llvm-ifs --output-elf=%t.elf64l --target=x86_64-linux-gnu %s
13 # RUN: llvm-readobj -h -S --string-dump .dynstr --string-dump .shstrtab --dyn-symbols --dynamic-table %t.elf64l | FileCheck %s -DCLASS="64-bit (0x2)" -DDE="LittleEndian (0x1)" -DHS=64 -DPHES=56 -DSHES=64 -DDYNSYMAL=8 -DDYNSYMES=24 -DDYNAMICAL=8 -DDYNAMICES=16 -DDYNTABZ=000000000
15 # RUN: llvm-ifs --output-elf=%t.elf64b --arch=x86_64 --bitwidth=64 --endianness=big %s
16 # RUN: llvm-readobj -h -S --string-dump .dynstr --string-dump .shstrtab --dyn-symbols --dynamic-table %t.elf64b | FileCheck %s -DCLASS="64-bit (0x2)" -DDE="BigEndian (0x2)" -DHS=64 -DPHES=56 -DSHES=64 -DDYNSYMAL=8 -DDYNSYMES=24 -DDYNAMICAL=8 -DDYNAMICES=16 -DDYNTABZ=000000000
18 # RUN: not llvm-ifs --output-elf=%t --arch=x86_64 --bitwidth=64 --endianness=big --target=x86_64-linux-gnu %s 2>&1 | FileCheck %s --check-prefix=TRIPLEERR
20 # RUN: not llvm-ifs --output-elf=%t --bitwidth=64 --endianness=big %s 2>&1 | FileCheck %s -DMSG="Arch" --check-prefix=TARGETERR
22 # RUN: not llvm-ifs --output-elf=%t --arch=x86_64 --endianness=big %s 2>&1 | FileCheck %s -DMSG="BitWidth" --check-prefix=TARGETERR
24 # RUN: not llvm-ifs --output-elf=%t --arch=x86_64 --bitwidth=64 %s 2>&1 | FileCheck %s -DMSG="Endianness" --check-prefix=TARGETERR
26 # RUN: llvm-ifs --output-ifs=%t.target --target=x86_64-linux-gnu %s
27 # RUN: not llvm-ifs --output-elf=%t --target=aarch64-linux-gnu %t.target 2>&1 | FileCheck %s -DMSG="Triple" --check-prefix=CONFLICTERR
29 # RUN: llvm-ifs --output-ifs=%t.target --arch=x86_64 --endianness=little --bitwidth=64 %s
30 # RUN: not llvm-ifs --output-elf=%t --arch=AArch64 %t.target 2>&1 | FileCheck %s -DMSG=Arch --check-prefix=CONFLICTERR
31 # RUN: not llvm-ifs --output-elf=%t --endianness=big %t.target 2>&1 | FileCheck %s -DMSG=Endianness --check-prefix=CONFLICTERR
32 # RUN: not llvm-ifs --output-elf=%t --bitwidth=32 %t.target 2>&1 | FileCheck %s -DMSG=BitWidth --check-prefix=CONFLICTERR
34 # RUN: llvm-ifs --output-ifs=%t.ifs --output-elf=%t.elf --target=x86_64-linux-gnu %s
35 # RUN: llvm-ifs --output-elf=%t.elf2 --target=x86_64-linux-gnu %t.ifs
36 # RUN: llvm-readobj -h -S --string-dump .dynstr --string-dump .shstrtab --dyn-symbols --dynamic-table %t.elf | FileCheck %s -DCLASS="64-bit (0x2)" -DDE="LittleEndian (0x1)" -DHS=64 -DPHES=56 -DSHES=64 -DDYNSYMAL=8 -DDYNSYMES=24 -DDYNAMICAL=8 -DDYNAMICES=16 -DDYNTABZ=000000000
37 # RUN: llvm-readobj -h -S --string-dump .dynstr --string-dump .shstrtab --dyn-symbols --dynamic-table %t.elf2 | FileCheck %s -DCLASS="64-bit (0x2)" -DDE="LittleEndian (0x1)" -DHS=64 -DPHES=56 -DSHES=64 -DDYNSYMAL=8 -DDYNSYMES=24 -DDYNAMICAL=8 -DDYNAMICES=16 -DDYNTABZ=000000000
39 # RUN: llvm-ifs --output-elf=- --target=riscv64-linux-gnu %s | llvm-readelf -h - | FileCheck %s --check-prefix=MACHINE
41 # RUN: not llvm-ifs --output-elf=- --arch=riscv64 --endianness=little --bitwidth=64 %s 2>&1 | FileCheck %s -DMSG=riscv64 --check-prefix=ARCHERR
48 - { Name: bar, Type: Object, Size: 42 }
49 - { Name: baz, Type: TLS, Size: 3 }
50 - { Name: plus, Type: Func }
55 # CHECK-NEXT: Magic: (7F 45 4C 46)
56 # CHECK-NEXT: Class: [[CLASS]]
57 # CHECK-NEXT: DataEncoding: [[DE]]
58 # CHECK-NEXT: FileVersion: 1
59 # CHECK-NEXT: OS/ABI: SystemV (0x0)
60 # CHECK-NEXT: ABIVersion: 0
61 # CHECK-NEXT: Unused: (00 00 00 00 00 00 00)
63 # CHECK-NEXT: Type: SharedObject (0x3)
64 # CHECK-NEXT: Machine: EM_X86_64 (0x3E)
65 # CHECK-NEXT: Version: 1
66 # CHECK-NEXT: Entry: 0x0
67 # CHECK: Flags [ (0x0)
69 # CHECK-NEXT: HeaderSize: [[HS]]
70 # CHECK-NEXT: ProgramHeaderEntrySize: [[PHES]]
71 # CHECK: SectionHeaderEntrySize: [[SHES]]
72 # CHECK: SectionHeaderCount: 5
73 # CHECK: StringTableSectionIndex: 4
76 # CHECK-NEXT: Index: 0
77 # CHECK-NEXT: Name: (0)
78 # CHECK-NEXT: Type: SHT_NULL
81 # CHECK-NEXT: Address: 0x0
82 # CHECK-NEXT: Offset: 0x0
86 # CHECK-NEXT: AddressAlignment: 0
87 # CHECK-NEXT: EntrySize: 0
89 # CHECK-NEXT: Section {
90 # CHECK-NEXT: Index: 1
91 # CHECK-NEXT: Name: .dynsym
92 # CHECK-NEXT: Type: SHT_DYNSYM
94 # CHECK-NEXT: SHF_ALLOC
96 # CHECK-NEXT: Address:
100 # CHECK-NEXT: Info: 1
101 # CHECK-NEXT: AddressAlignment: [[DYNSYMAL]]
102 # CHECK-NEXT: EntrySize: [[DYNSYMES]]
104 # CHECK-NEXT: Section {
105 # CHECK-NEXT: Index: 2
106 # CHECK-NEXT: Name: .dynstr
107 # CHECK-NEXT: Type: SHT_STRTAB
108 # CHECK-NEXT: Flags [
109 # CHECK-NEXT: SHF_ALLOC
111 # CHECK-NEXT: Address:
112 # CHECK-NEXT: Offset:
114 # CHECK-NEXT: Link: 0
115 # CHECK-NEXT: Info: 0
116 # CHECK-NEXT: AddressAlignment: 1
117 # CHECK-NEXT: EntrySize: 0
119 # CHECK-NEXT: Section {
120 # CHECK-NEXT: Index: 3
121 # CHECK-NEXT: Name: .dynamic
122 # CHECK-NEXT: Type: SHT_DYNAMIC
123 # CHECK-NEXT: Flags [
124 # CHECK-NEXT: SHF_ALLOC
126 # CHECK-NEXT: Address:
127 # CHECK-NEXT: Offset:
129 # CHECK-NEXT: Link: 2
130 # CHECK-NEXT: Info: 0
131 # CHECK-NEXT: AddressAlignment: [[DYNAMICAL]]
132 # CHECK-NEXT: EntrySize: [[DYNAMICES]]
134 # CHECK-NEXT: Section {
135 # CHECK-NEXT: Index: 4
136 # CHECK-NEXT: Name: .shstrtab
137 # CHECK-NEXT: Type: SHT_STRTAB
138 # CHECK-NEXT: Flags [
140 # CHECK-NEXT: Address:
141 # CHECK-NEXT: Offset:
143 # CHECK-NEXT: Link: 0
144 # CHECK-NEXT: Info: 0
145 # CHECK-NEXT: AddressAlignment: 1
146 # CHECK-NEXT: EntrySize: 0
149 # CHECK: DynamicSection [ (5 entries)
150 # CHECK-NEXT: Tag Type Name/Value
151 # CHECK-NEXT: 0x[[DYNTABZ]]0000006 SYMTAB
152 # CHECK-NEXT: 0x[[DYNTABZ]]0000005 STRTAB
153 # CHECK-NEXT: 0x[[DYNTABZ]]000000A STRSZ
154 # CHECK-NEXT: 0x[[DYNTABZ]]0000001 NEEDED Shared library: [libc.so.6]
155 # CHECK-NEXT: 0x[[DYNTABZ]]0000000 NULL
162 # CHECK-NEXT: Binding: Local
163 # CHECK-NEXT: Type: None
164 # CHECK-NEXT: Other: 0
165 # CHECK-NEXT: Section: Undefined
167 # CHECK-NEXT: Symbol {
168 # CHECK-NEXT: Name: bar
170 # CHECK-NEXT: Size: 42
171 # CHECK-NEXT: Binding: Global
172 # CHECK-NEXT: Type: Object
173 # CHECK-NEXT: Other: 0
174 # CHECK-NEXT: Section: .dynsym
176 # CHECK-NEXT: Symbol {
177 # CHECK-NEXT: Name: baz
179 # CHECK-NEXT: Size: 3
180 # CHECK-NEXT: Binding: Global
181 # CHECK-NEXT: Type: TLS
182 # CHECK-NEXT: Other: 0
183 # CHECK-NEXT: Section: .dynsym
185 # CHECK-NEXT: Symbol {
186 # CHECK-NEXT: Name: plus
189 # CHECK-NEXT: Binding: Global
190 # CHECK-NEXT: Type: Function
191 # CHECK-NEXT: Other: 0
192 # CHECK-NEXT: Section: .dynsym
195 # CHECK: String dump of section '.dynstr':
196 # CHECK-NEXT: [ 1] baz
197 # CHECK-NEXT: [ 5] plus
198 # CHECK-NEXT: [ a] bar
199 # CHECK-NEXT: [ e] libc.so.6
201 # CHECK: String dump of section '.shstrtab':
202 # CHECK-NEXT: [ 1] .dynstr
203 # CHECK-NEXT: [ 9] .dynsym
204 # CHECK-NEXT: [ 11] .dynamic
205 # CHECK-NEXT: [ 1a] .shstrtab
207 # TRIPLEERR: error: Target triple cannot be used simultaneously with ELF target format
208 # TARGETERR: error: [[MSG]] is not defined in the text stub
209 # CONFLICTERR: error: Supplied [[MSG]] conflicts with the text stub
211 # MACHINE: Machine: RISC-V
213 # ARCHERR: error: unknown arch '[[MSG]]'