Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: tests_lit/llvm2ice_tests/elf_container.ll

Issue 678533005: Subzero: Add basic ELFObjectWriter (text section, symtab, strtab, headers) (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: minor cleanup Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/llvm2ice.cpp ('k') | unittest/IceELFSectionTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 ; Tests that we generate an ELF container with fields that make sense,
2 ; cross-validating against llvm-mc.
3
4 ; For the integrated ELF writer, we can't pipe the output because we need
5 ; to seek backward and patch up the file headers. So, use a temporary file.
6 ; RUN: %p2i -i %s --args -O2 --verbose none -elf-writer -o %t \
7 ; RUN: && llvm-readobj -file-headers -sections -section-data \
8 ; RUN: -relocations -symbols %t | FileCheck %s
9
10 ; RUN: %p2i -i %s --args -O2 --verbose none \
11 ; RUN: | llvm-mc -triple=i686-none-nacl -filetype=obj -o - \
12 ; RUN: | llvm-readobj -file-headers -sections -section-data \
13 ; RUN: -relocations -symbols - | FileCheck %s
14
15 ; Use intrinsics to test external calls.
16 declare void @llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1)
17 declare void @llvm.memset.p0i8.i32(i8*, i8, i32, i32, i1)
18
19 ; Test some global data relocs (data, rodata, bss).
20 @bytes = internal global [7 x i8] c"abcdefg", align 1
21 @const_bytes = internal constant [7 x i8] c"abcdefg", align 1
22
23 @ptr = internal global i32 ptrtoint ([7 x i8]* @bytes to i32), align 4
24 @const_ptr = internal constant i32 ptrtoint ([7 x i8]* @bytes to i32), align 4
25
26 @ptr_to_func = internal global i32 ptrtoint (double ()* @returnDoubleConst to i3 2), align 4
27 @const_ptr_to_func = internal constant i32 ptrtoint (double ()* @returnDoubleCon st to i32), align 4
28
29 @short_zero = internal global [2 x i8] zeroinitializer, align 2
30 @double_zero = internal global [8 x i8] zeroinitializer, align 8
31 @const_short_zero = internal constant [2 x i8] zeroinitializer, align 2
32 @const_double_zero = internal constant [8 x i8] zeroinitializer, align 8
33
34
35 @addend_ptr = internal global i32 add (i32 ptrtoint (i32* @ptr to i32), i32 128)
36 @const_addend_ptr = internal constant i32 add (i32 ptrtoint (i32* @ptr to i32), i32 64)
37
38 ; Use float/double constants to test constant pools.
39 define internal float @returnFloatConst() {
40 entry:
41 %f = fadd float 0x3FF3AE1480000000, 0x3FF3AE1400000000
42 ret float %f
43 }
44
45 define internal double @returnDoubleConst() {
46 entry:
47 %d = fadd double 1.230000e+00, 3.210000e+00
48 ret double %d
49 }
50
51 define internal void @test_memcpy(i32 %iptr_dst, i32 %len) {
52 entry:
53 %dst = inttoptr i32 %iptr_dst to i8*
54 %src = bitcast [7 x i8]* @bytes to i8*
55 call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dst, i8* %src,
56 i32 %len, i32 1, i1 false)
57 ret void
58 }
59
60 define internal void @test_memset(i32 %iptr_dst, i32 %wide_val, i32 %len) {
61 entry:
62 %val = trunc i32 %wide_val to i8
63 %dst = inttoptr i32 %iptr_dst to i8*
64 call void @llvm.memset.p0i8.i32(i8* %dst, i8 %val,
65 i32 %len, i32 1, i1 false)
66 ret void
67 }
68
69 ; Test non-internal functions too.
70 define void @_start(i32) {
71 %f = call float @returnFloatConst()
72 %d = call double @returnDoubleConst()
73 call void @test_memcpy(i32 0, i32 99)
74 call void @test_memset(i32 0, i32 0, i32 99)
75 ret void
76 }
77
78
79 ; CHECK: ElfHeader {
80 ; CHECK: Ident {
81 ; CHECK: Magic: (7F 45 4C 46)
82 ; CHECK: Class: 32-bit
83 ; CHECK: DataEncoding: LittleEndian
84 ; CHECK: OS/ABI: SystemV (0x0)
85 ; CHECK: ABIVersion: 0
86 ; CHECK: Unused: (00 00 00 00 00 00 00)
87 ; CHECK: }
88 ; CHECK: Type: Relocatable (0x1)
89 ; CHECK: Machine: EM_386 (0x3)
90 ; CHECK: Version: 1
91 ; CHECK: Entry: 0x0
92 ; CHECK: ProgramHeaderOffset: 0x0
93 ; CHECK: SectionHeaderOffset: 0x{{[1-9A-F][0-9A-F]*}}
94 ; CHECK: Flags [ (0x0)
95 ; CHECK: ]
96 ; CHECK: HeaderSize: 52
97 ; CHECK: ProgramHeaderEntrySize: 0
98 ; CHECK: ProgramHeaderCount: 0
99 ; CHECK: SectionHeaderEntrySize: 40
100 ; CHECK: SectionHeaderCount: {{[1-9][0-9]*}}
101 ; CHECK: StringTableSectionIndex: {{[1-9][0-9]*}}
102 ; CHECK: }
103
104
105 ; CHECK: Sections [
106 ; CHECK: Section {
107 ; CHECK: Index: 0
108 ; CHECK: Name: (0)
109 ; CHECK: Type: SHT_NULL
110 ; CHECK: Flags [ (0x0)
111 ; CHECK: ]
112 ; CHECK: Address: 0x0
113 ; CHECK: Offset: 0x0
114 ; CHECK: Size: 0
115 ; CHECK: Link: 0
116 ; CHECK: Info: 0
117 ; CHECK: AddressAlignment: 0
118 ; CHECK: EntrySize: 0
119 ; CHECK: SectionData (
120 ; CHECK-NEXT: )
121 ; CHECK: }
122 ; CHECK: Section {
123 ; CHECK: Index: {{[1-9][0-9]*}}
124 ; CHECK: Name: .text
125 ; CHECK: Type: SHT_PROGBITS
126 ; CHECK: Flags [ (0x6)
127 ; CHECK: SHF_ALLOC
128 ; CHECK: SHF_EXECINSTR
129 ; CHECK: ]
130 ; CHECK: Address: 0x0
131 ; CHECK: Offset: 0x{{[1-9A-F][0-9A-F]*}}
132 ; CHECK: Size: {{[1-9][0-9]*}}
133 ; CHECK: Link: 0
134 ; CHECK: Info: 0
135 ; CHECK: AddressAlignment: 32
136 ; CHECK: EntrySize: 0
137 ; CHECK: SectionData (
138 ; There's probably halt padding (0xF4) in there somewhere.
139 ; CHECK: {{.*}}F4
140 ; CHECK: )
141 ; CHECK: }
142 ; CHECK: Section {
143 ; CHECK: Index: {{[1-9][0-9]*}}
144 ; CHECK: Name: .shstrtab
145 ; CHECK: Type: SHT_STRTAB
146 ; CHECK: Flags [ (0x0)
147 ; CHECK: ]
148 ; CHECK: Address: 0x0
149 ; CHECK: Offset: 0x{{[1-9A-F][0-9A-F]*}}
150 ; CHECK: Size: {{[1-9][0-9]*}}
151 ; CHECK: Link: 0
152 ; CHECK: Info: 0
153 ; CHECK: AddressAlignment: 1
154 ; CHECK: EntrySize: 0
155 ; CHECK: SectionData (
156 ; CHECK: {{.*}}.text{{.*}}
157 ; CHECK: )
158 ; CHECK: }
159 ; CHECK: Section {
160 ; CHECK: Index: {{[1-9][0-9]*}}
161 ; CHECK: Name: .symtab
162 ; CHECK: Type: SHT_SYMTAB
163 ; CHECK: Flags [ (0x0)
164 ; CHECK: ]
165 ; CHECK: Address: 0x0
166 ; CHECK: Offset: 0x{{[1-9A-F][0-9A-F]*}}
167 ; CHECK: Size: {{[1-9][0-9]*}}
168 ; CHECK: Link: [[STRTAB_INDEX:[1-9][0-9]*]]
169 ; CHECK: Info: [[GLOBAL_START_INDEX:[1-9][0-9]*]]
170 ; CHECK: AddressAlignment: 4
171 ; CHECK: EntrySize: 16
172 ; CHECK: }
173 ; CHECK: Section {
174 ; CHECK: Index: [[STRTAB_INDEX]]
175 ; CHECK: Name: .strtab
176 ; CHECK: Type: SHT_STRTAB
177 ; CHECK: Flags [ (0x0)
178 ; CHECK: ]
179 ; CHECK: Address: 0x0
180 ; CHECK: Offset: 0x{{[1-9A-F][0-9A-F]*}}
181 ; CHECK: Size: {{[1-9][0-9]*}}
182 ; CHECK: Link: 0
183 ; CHECK: Info: 0
184 ; CHECK: AddressAlignment: 1
185 ; CHECK: EntrySize: 0
186 ; CHECK: }
187
188
189 ; CHECK: Relocations [
190 ; TODO: fill it out.
191 ; CHECK: ]
192
193
194 ; CHECK: Symbols [
195 ; CHECK-NEXT: Symbol {
196 ; CHECK-NEXT: Name: (0)
197 ; CHECK-NEXT: Value: 0x0
198 ; CHECK-NEXT: Size: 0
199 ; CHECK-NEXT: Binding: Local
200 ; CHECK-NEXT: Type: None
201 ; CHECK-NEXT: Other: 0
202 ; CHECK-NEXT: Section: Undefined (0x0)
203 ; CHECK-NEXT: }
204 ; TODO: fill in the data symbols.
205 ; CHECK: Symbol {
206 ; CHECK: Name: returnDoubleConst
207 ; CHECK-NEXT: Value: 0x{{[1-9A-F][0-9A-F]*}}
208 ; CHECK-NEXT: Size: 0
209 ; CHECK-NEXT: Binding: Local
210 ; CHECK-NEXT: Type: None
211 ; CHECK-NEXT: Other: 0
212 ; CHECK-NEXT: Section: .text
213 ; CHECK-NEXT: }
214 ; CHECK: Symbol {
215 ; CHECK: Name: returnFloatConst
216 ; This happens to be the first function, so its offset is 0 within the text.
217 ; CHECK-NEXT: Value: 0x0
218 ; CHECK-NEXT: Size: 0
219 ; CHECK-NEXT: Binding: Local
220 ; CHECK-NEXT: Type: None
221 ; CHECK-NEXT: Other: 0
222 ; CHECK-NEXT: Section: .text
223 ; CHECK-NEXT: }
224 ; CHECK: Symbol {
225 ; CHECK: Name: test_memcpy
226 ; CHECK-NEXT: Value: 0x{{[1-9A-F][0-9A-F]*}}
227 ; CHECK-NEXT: Size: 0
228 ; CHECK-NEXT: Binding: Local
229 ; CHECK-NEXT: Type: None
230 ; CHECK-NEXT: Other: 0
231 ; CHECK-NEXT: Section: .text
232 ; CHECK-NEXT: }
233 ; CHECK: Symbol {
234 ; CHECK: Name: _start
235 ; CHECK-NEXT: Value: 0x{{[1-9A-F][0-9A-F]*}}
236 ; CHECK-NEXT: Size: 0
237 ; CHECK-NEXT: Binding: Global
238 ; CHECK-NEXT: Type: Function
239 ; CHECK-NEXT: Other: 0
240 ; CHECK-NEXT: Section: .text
241 ; CHECK-NEXT: }
242 ; CHECK: ]
OLDNEW
« no previous file with comments | « src/llvm2ice.cpp ('k') | unittest/IceELFSectionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698