1 ## Test writing stub elf with minimal sections.
3 # RUN: llvm-ifs --output-format=ELF --output=%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-format=ELF --output=%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-format=ELF --output=%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-format=ELF --output=%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-format=ELF --output=%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-format=ELF --output=%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-format=ELF --output=%t --bitwidth=64 --endianness=big %s 2>&1 | FileCheck %s -DMSG="Arch" --check-prefix=TARGETERR
22 # RUN: not llvm-ifs --output-format=ELF --output=%t --arch=x86_64 --endianness=big %s 2>&1 | FileCheck %s -DMSG="BitWidth" --check-prefix=TARGETERR
24 # RUN: not llvm-ifs --output-format=ELF --output=%t --arch=x86_64 --bitwidth=64 %s 2>&1 | FileCheck %s -DMSG="Endianness" --check-prefix=TARGETERR
26 # RUN: llvm-ifs --output-format=IFS --output=%t.target --target=x86_64-linux-gnu %s
27 # RUN: not llvm-ifs --output-format=ELF --output=%t --target=aarch64-linux-gnu %t.target 2>&1 | FileCheck %s -DMSG="Triple" --check-prefix=CONFLICTERR
29 # RUN: llvm-ifs --output-format=IFS --output=%t.target --arch=x86_64 --endianness=little --bitwidth=64 %s
30 # RUN: not llvm-ifs --output-format=ELF --output=%t --arch=AArch64 %t.target 2>&1 | FileCheck %s -DMSG=Arch --check-prefix=CONFLICTERR
31 # RUN: not llvm-ifs --output-format=ELF --output=%t --endianness=big %t.target 2>&1 | FileCheck %s -DMSG=Endianness --check-prefix=CONFLICTERR
32 # RUN: not llvm-ifs --output-format=ELF --output=%t --bitwidth=32 %t.target 2>&1 | FileCheck %s -DMSG=BitWidth --check-prefix=CONFLICTERR
39 - { Name: bar, Type: Object, Size: 42 }
40 - { Name: baz, Type: TLS, Size: 3 }
41 - { Name: plus, Type: Func }
46 # CHECK-NEXT: Magic: (7F 45 4C 46)
47 # CHECK-NEXT: Class: [[CLASS]]
48 # CHECK-NEXT: DataEncoding: [[DE]]
49 # CHECK-NEXT: FileVersion: 1
50 # CHECK-NEXT: OS/ABI: SystemV (0x0)
51 # CHECK-NEXT: ABIVersion: 0
52 # CHECK-NEXT: Unused: (00 00 00 00 00 00 00)
54 # CHECK-NEXT: Type: SharedObject (0x3)
55 # CHECK-NEXT: Machine: EM_X86_64 (0x3E)
56 # CHECK-NEXT: Version: 1
57 # CHECK-NEXT: Entry: 0x0
58 # CHECK: Flags [ (0x0)
60 # CHECK-NEXT: HeaderSize: [[HS]]
61 # CHECK-NEXT: ProgramHeaderEntrySize: [[PHES]]
62 # CHECK: SectionHeaderEntrySize: [[SHES]]
63 # CHECK: SectionHeaderCount: 5
64 # CHECK: StringTableSectionIndex: 4
67 # CHECK-NEXT: Index: 0
68 # CHECK-NEXT: Name: (0)
69 # CHECK-NEXT: Type: SHT_NULL
72 # CHECK-NEXT: Address: 0x0
73 # CHECK-NEXT: Offset: 0x0
77 # CHECK-NEXT: AddressAlignment: 0
78 # CHECK-NEXT: EntrySize: 0
80 # CHECK-NEXT: Section {
81 # CHECK-NEXT: Index: 1
82 # CHECK-NEXT: Name: .dynsym
83 # CHECK-NEXT: Type: SHT_DYNSYM
85 # CHECK-NEXT: SHF_ALLOC
87 # CHECK-NEXT: Address:
92 # CHECK-NEXT: AddressAlignment: [[DYNSYMAL]]
93 # CHECK-NEXT: EntrySize: [[DYNSYMES]]
95 # CHECK-NEXT: Section {
96 # CHECK-NEXT: Index: 2
97 # CHECK-NEXT: Name: .dynstr
98 # CHECK-NEXT: Type: SHT_STRTAB
100 # CHECK-NEXT: SHF_ALLOC
102 # CHECK-NEXT: Address:
103 # CHECK-NEXT: Offset:
105 # CHECK-NEXT: Link: 0
106 # CHECK-NEXT: Info: 0
107 # CHECK-NEXT: AddressAlignment: 1
108 # CHECK-NEXT: EntrySize: 0
110 # CHECK-NEXT: Section {
111 # CHECK-NEXT: Index: 3
112 # CHECK-NEXT: Name: .dynamic
113 # CHECK-NEXT: Type: SHT_DYNAMIC
114 # CHECK-NEXT: Flags [
115 # CHECK-NEXT: SHF_ALLOC
117 # CHECK-NEXT: Address:
118 # CHECK-NEXT: Offset:
120 # CHECK-NEXT: Link: 2
121 # CHECK-NEXT: Info: 0
122 # CHECK-NEXT: AddressAlignment: [[DYNAMICAL]]
123 # CHECK-NEXT: EntrySize: [[DYNAMICES]]
125 # CHECK-NEXT: Section {
126 # CHECK-NEXT: Index: 4
127 # CHECK-NEXT: Name: .shstrtab
128 # CHECK-NEXT: Type: SHT_STRTAB
129 # CHECK-NEXT: Flags [
131 # CHECK-NEXT: Address:
132 # CHECK-NEXT: Offset:
134 # CHECK-NEXT: Link: 0
135 # CHECK-NEXT: Info: 0
136 # CHECK-NEXT: AddressAlignment: 1
137 # CHECK-NEXT: EntrySize: 0
140 # CHECK: DynamicSection [ (4 entries)
141 # CHECK-NEXT: Tag Type Name/Value
142 # CHECK-NEXT: 0x[[DYNTABZ]]0000006 SYMTAB
143 # CHECK-NEXT: 0x[[DYNTABZ]]0000005 STRTAB
144 # CHECK-NEXT: 0x[[DYNTABZ]]0000001 NEEDED Shared library: [libc.so.6]
145 # CHECK-NEXT: 0x[[DYNTABZ]]0000000 NULL
152 # CHECK-NEXT: Binding: Local
153 # CHECK-NEXT: Type: None
154 # CHECK-NEXT: Other: 0
155 # CHECK-NEXT: Section: Undefined
157 # CHECK-NEXT: Symbol {
158 # CHECK-NEXT: Name: bar
160 # CHECK-NEXT: Size: 42
161 # CHECK-NEXT: Binding: Global
162 # CHECK-NEXT: Type: Object
163 # CHECK-NEXT: Other: 0
164 # CHECK-NEXT: Section: .dynsym
166 # CHECK-NEXT: Symbol {
167 # CHECK-NEXT: Name: baz
169 # CHECK-NEXT: Size: 3
170 # CHECK-NEXT: Binding: Global
171 # CHECK-NEXT: Type: TLS
172 # CHECK-NEXT: Other: 0
173 # CHECK-NEXT: Section: .dynsym
175 # CHECK-NEXT: Symbol {
176 # CHECK-NEXT: Name: plus
179 # CHECK-NEXT: Binding: Global
180 # CHECK-NEXT: Type: Function
181 # CHECK-NEXT: Other: 0
182 # CHECK-NEXT: Section: .dynsym
185 # CHECK: String dump of section '.dynstr':
186 # CHECK-NEXT: [ 1] baz
187 # CHECK-NEXT: [ 5] plus
188 # CHECK-NEXT: [ a] bar
189 # CHECK-NEXT: [ e] libc.so.6
191 # CHECK: String dump of section '.shstrtab':
192 # CHECK-NEXT: [ 1] .dynstr
193 # CHECK-NEXT: [ 9] .dynsym
194 # CHECK-NEXT: [ 11] .dynamic
195 # CHECK-NEXT: [ 1a] .shstrtab
197 # TRIPLEERR: error: Target triple cannot be used simultaneously with ELF target format
198 # TARGETERR: error: [[MSG]] is not defined in the text stub
199 # CONFLICTERR: error: Supplied [[MSG]] conflicts with the text stub