1 ; RUN: llc -mcpu=mvp -generate-arange-section -filetype=obj %s -o - | llvm-readobj -S -r --symbols - | FileCheck %s
4 ; CHECK-NEXT:Arch: wasm32
5 ; CHECK-NEXT:AddressSize: 32bit
6 ; CHECK-NEXT:Sections [
7 ; CHECK-NEXT: Section {
8 ; CHECK-NEXT: Type: TYPE (0x1)
10 ; CHECK-NEXT: Offset: 14
12 ; CHECK-NEXT: Section {
13 ; CHECK-NEXT: Type: IMPORT (0x2)
14 ; CHECK-NEXT: Size: 81
15 ; CHECK-NEXT: Offset: 24
17 ; CHECK-NEXT: Section {
18 ; CHECK-NEXT: Type: FUNCTION (0x3)
20 ; CHECK-NEXT: Offset: 111
22 ; CHECK-NEXT: Section {
23 ; CHECK-NEXT: Type: ELEM (0x9)
25 ; CHECK-NEXT: Offset: 119
27 ; CHECK-NEXT: Section {
28 ; CHECK-NEXT: Type: DATACOUNT (0xC)
30 ; CHECK-NEXT: Offset: 132
32 ; CHECK-NEXT: Section {
33 ; CHECK-NEXT: Type: CODE (0xA)
35 ; CHECK-NEXT: Offset: 139
37 ; CHECK-NEXT: Section {
38 ; CHECK-NEXT: Type: DATA (0xB)
39 ; CHECK-NEXT: Size: 19
40 ; CHECK-NEXT: Offset: 149
41 ; CHECK-NEXT: Segments [
42 ; CHECK-NEXT: Segment {
43 ; CHECK-NEXT: Name: .data.foo
45 ; CHECK-NEXT: Offset: 0
47 ; CHECK-NEXT: Segment {
48 ; CHECK-NEXT: Name: .data.ptr2
50 ; CHECK-NEXT: Offset: 4
54 ; CHECK-NEXT: Section {
55 ; CHECK-NEXT: Type: CUSTOM (0x0)
56 ; CHECK-NEXT: Size: 86
57 ; CHECK-NEXT: Offset: 174
58 ; CHECK-NEXT: Name: .debug_abbrev
60 ; CHECK-NEXT: Section {
61 ; CHECK-NEXT: Type: CUSTOM (0x0)
62 ; CHECK-NEXT: Size: 114
63 ; CHECK-NEXT: Offset: 280
64 ; CHECK-NEXT: Name: .debug_info
66 ; CHECK-NEXT: Section {
67 ; CHECK-NEXT: Type: CUSTOM (0x0)
68 ; CHECK-NEXT: Size: 48
69 ; CHECK-NEXT: Offset: 412
70 ; CHECK-NEXT: Name: .debug_aranges
72 ; CHECK-NEXT: Section {
73 ; CHECK-NEXT: Type: CUSTOM (0x0)
74 ; CHECK-NEXT: Size: 121
75 ; CHECK-NEXT: Offset: 481
76 ; CHECK-NEXT: Name: .debug_str
78 ; CHECK-NEXT: Section {
79 ; CHECK-NEXT: Type: CUSTOM (0x0)
80 ; CHECK-NEXT: Size: 42
81 ; CHECK-NEXT: Offset: 619
82 ; CHECK-NEXT: Name: .debug_pubnames
84 ; CHECK-NEXT: Section {
85 ; CHECK-NEXT: Type: CUSTOM (0x0)
86 ; CHECK-NEXT: Size: 26
87 ; CHECK-NEXT: Offset: 683
88 ; CHECK-NEXT: Name: .debug_pubtypes
90 ; CHECK-NEXT: Section {
91 ; CHECK-NEXT: Type: CUSTOM (0x0)
92 ; CHECK-NEXT: Size: 56
93 ; CHECK-NEXT: Offset: 731
94 ; CHECK-NEXT: Name: .debug_line
96 ; CHECK-NEXT: Section {
97 ; CHECK-NEXT: Type: CUSTOM (0x0)
98 ; CHECK-NEXT: Size: 91
99 ; CHECK-NEXT: Offset: 805
100 ; CHECK-NEXT: Name: linking
102 ; CHECK-NEXT: Section {
103 ; CHECK-NEXT: Type: CUSTOM (0x0)
104 ; CHECK-NEXT: Size: 9
105 ; CHECK-NEXT: Offset: 910
106 ; CHECK-NEXT: Name: reloc.DATA
108 ; CHECK-NEXT: Section {
109 ; CHECK-NEXT: Type: CUSTOM (0x0)
110 ; CHECK-NEXT: Size: 61
111 ; CHECK-NEXT: Offset: 936
112 ; CHECK-NEXT: Name: reloc..debug_info
114 ; CHECK-NEXT: Section {
115 ; CHECK-NEXT: Type: CUSTOM (0x0)
116 ; CHECK-NEXT: Size: 18
117 ; CHECK-NEXT: Offset: 1021
118 ; CHECK-NEXT: Name: reloc..debug_aranges
120 ; CHECK-NEXT: Section {
121 ; CHECK-NEXT: Type: CUSTOM (0x0)
122 ; CHECK-NEXT: Size: 6
123 ; CHECK-NEXT: Offset: 1066
124 ; CHECK-NEXT: Name: reloc..debug_pubnames
126 ; CHECK-NEXT: Section {
127 ; CHECK-NEXT: Type: CUSTOM (0x0)
128 ; CHECK-NEXT: Size: 6
129 ; CHECK-NEXT: Offset: 1100
130 ; CHECK-NEXT: Name: reloc..debug_pubtypes
132 ; CHECK-NEXT: Section {
133 ; CHECK-NEXT: Type: CUSTOM (0x0)
134 ; CHECK-NEXT: Size: 6
135 ; CHECK-NEXT: Offset: 1134
136 ; CHECK-NEXT: Name: reloc..debug_line
138 ; CHECK-NEXT: Section {
139 ; CHECK-NEXT: Type: CUSTOM (0x0)
140 ; CHECK-NEXT: Size: 77
141 ; CHECK-NEXT: Offset: 1164
142 ; CHECK-NEXT: Name: producers
145 ; CHECK-NEXT:Relocations [
146 ; CHECK-NEXT: Section (7) DATA {
147 ; CHECK-NEXT: 0x6 R_WASM_MEMORY_ADDR_I32 myextern 0
148 ; CHECK-NEXT: 0xF R_WASM_TABLE_INDEX_I32 f2
150 ; CHECK-NEXT: Section (9) .debug_info {
151 ; CHECK-NEXT: 0x6 R_WASM_SECTION_OFFSET_I32 .debug_abbrev 0
152 ; CHECK-NEXT: 0xC R_WASM_SECTION_OFFSET_I32 .debug_str 0
153 ; CHECK-NEXT: 0x12 R_WASM_SECTION_OFFSET_I32 .debug_str 55
154 ; CHECK-NEXT: 0x16 R_WASM_SECTION_OFFSET_I32 .debug_line 0
155 ; CHECK-NEXT: 0x1A R_WASM_SECTION_OFFSET_I32 .debug_str 62
156 ; CHECK-NEXT: 0x1E R_WASM_FUNCTION_OFFSET_I32 f2 0
157 ; CHECK-NEXT: 0x27 R_WASM_SECTION_OFFSET_I32 .debug_str 105
158 ; CHECK-NEXT: 0x33 R_WASM_MEMORY_ADDR_I32 foo 0
159 ; CHECK-NEXT: 0x3D R_WASM_SECTION_OFFSET_I32 .debug_str 109
160 ; CHECK-NEXT: 0x44 R_WASM_SECTION_OFFSET_I32 .debug_str 113
161 ; CHECK-NEXT: 0x50 R_WASM_MEMORY_ADDR_I32 ptr2 0
162 ; CHECK-NEXT: 0x5B R_WASM_FUNCTION_OFFSET_I32 f2 0
163 ; CHECK-NEXT: 0x66 R_WASM_GLOBAL_INDEX_I32 __stack_pointer
164 ; CHECK-NEXT: 0x6B R_WASM_SECTION_OFFSET_I32 .debug_str 118
166 ; CHECK-NEXT: Section (10) .debug_aranges {
167 ; CHECK-NEXT: 0x6 R_WASM_SECTION_OFFSET_I32 .debug_info 0
168 ; CHECK-NEXT: 0x10 R_WASM_MEMORY_ADDR_I32 foo 0
169 ; CHECK-NEXT: 0x18 R_WASM_MEMORY_ADDR_I32 ptr2 0
170 ; CHECK-NEXT: 0x20 R_WASM_FUNCTION_OFFSET_I32 f2 0
172 ; CHECK-NEXT: Section (12) .debug_pubnames {
173 ; CHECK-NEXT: 0x6 R_WASM_SECTION_OFFSET_I32 .debug_info 0
175 ; CHECK-NEXT: Section (13) .debug_pubtypes {
176 ; CHECK-NEXT: 0x6 R_WASM_SECTION_OFFSET_I32 .debug_info 0
178 ; CHECK-NEXT: Section (14) .debug_line {
179 ; CHECK-NEXT: 0x2E R_WASM_FUNCTION_OFFSET_I32 f2 1
182 ; CHECK-NEXT:Symbols [
183 ; CHECK-NEXT: Symbol {
184 ; CHECK-NEXT: Name: f2
185 ; CHECK-NEXT: Type: FUNCTION (0x0)
186 ; CHECK-NEXT: Flags [ (0x4)
187 ; CHECK-NEXT: VISIBILITY_HIDDEN (0x4)
189 ; CHECK-NEXT: ElementIndex: 0x0
191 ; CHECK-NEXT: Symbol {
192 ; CHECK-NEXT: Name: foo
193 ; CHECK-NEXT: Type: DATA (0x1)
194 ; CHECK-NEXT: Flags [ (0x4)
195 ; CHECK-NEXT: VISIBILITY_HIDDEN (0x4)
197 ; CHECK-NEXT: Offset: 0x0
198 ; CHECK-NEXT: Segment: 0x0
199 ; CHECK-NEXT: Size: 0x4
201 ; CHECK-NEXT: Symbol {
202 ; CHECK-NEXT: Name: myextern
203 ; CHECK-NEXT: Type: DATA (0x1)
204 ; CHECK-NEXT: Flags [ (0x10)
205 ; CHECK-NEXT: UNDEFINED (0x10)
208 ; CHECK-NEXT: Symbol {
209 ; CHECK-NEXT: Name: ptr2
210 ; CHECK-NEXT: Type: DATA (0x1)
211 ; CHECK-NEXT: Flags [ (0x4)
212 ; CHECK-NEXT: VISIBILITY_HIDDEN (0x4)
214 ; CHECK-NEXT: Offset: 0x0
215 ; CHECK-NEXT: Segment: 0x1
216 ; CHECK-NEXT: Size: 0x4
218 ; CHECK-NEXT: Symbol {
219 ; CHECK-NEXT: Name: .debug_abbrev
220 ; CHECK-NEXT: Type: SECTION (0x3)
221 ; CHECK-NEXT: Flags [ (0x2)
222 ; CHECK-NEXT: BINDING_LOCAL (0x2)
224 ; CHECK-NEXT: ElementIndex: 0x7
226 ; CHECK-NEXT: Symbol {
227 ; CHECK-NEXT: Name: .debug_info
228 ; CHECK-NEXT: Type: SECTION (0x3)
229 ; CHECK-NEXT: Flags [ (0x2)
230 ; CHECK-NEXT: BINDING_LOCAL (0x2)
232 ; CHECK-NEXT: ElementIndex: 0x8
234 ; CHECK-NEXT: Symbol {
235 ; CHECK-NEXT: Name: __stack_pointer
236 ; CHECK-NEXT: Type: GLOBAL (0x2)
237 ; CHECK-NEXT: Flags [ (0x10)
238 ; CHECK-NEXT: UNDEFINED (0x10)
240 ; CHECK-NEXT: ImportModule: env
241 ; CHECK-NEXT: ElementIndex: 0x0
243 ; CHECK-NEXT: Symbol {
244 ; CHECK-NEXT: Name: .debug_str
245 ; CHECK-NEXT: Type: SECTION (0x3)
246 ; CHECK-NEXT: Flags [ (0x2)
247 ; CHECK-NEXT: BINDING_LOCAL (0x2)
249 ; CHECK-NEXT: ElementIndex: 0xA
251 ; CHECK-NEXT: Symbol {
252 ; CHECK-NEXT: Name: .debug_line
253 ; CHECK-NEXT: Type: SECTION (0x3)
254 ; CHECK-NEXT: Flags [ (0x2)
255 ; CHECK-NEXT: BINDING_LOCAL (0x2)
257 ; CHECK-NEXT: ElementIndex: 0xD
261 ; generated from the following C code using: clang --target=wasm32 -g -O0 -S -emit-llvm test.c
262 ; extern int myextern;
263 ; void f2(void) { return; }
265 ; int* foo = &myextern;
266 ; void (*ptr2)(void) = f2;
268 target triple = "wasm32-unknown-unknown"
270 source_filename = "test.c"
272 @myextern = external global i32, align 4
273 @foo = hidden global ptr @myextern, align 4, !dbg !0
274 @ptr2 = hidden global ptr @f2, align 4, !dbg !6
276 ; Function Attrs: noinline nounwind optnone
277 define hidden void @f2() #0 !dbg !17 {
282 attributes #0 = { noinline nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="mvp" "unsafe-fp-math"="false" "use-soft-float"="false" }
285 !llvm.module.flags = !{!13, !14, !15}
288 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
289 !1 = distinct !DIGlobalVariable(name: "foo", scope: !2, file: !3, line: 4, type: !11, isLocal: false, isDefinition: true)
290 !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 7.0.0 (trunk 332303) (llvm/trunk 332406)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
291 !3 = !DIFile(filename: "test.c", directory: "/usr/local/google/home/sbc/dev/wasm/simple")
294 !6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
295 !7 = distinct !DIGlobalVariable(name: "ptr2", scope: !2, file: !3, line: 5, type: !8, isLocal: false, isDefinition: true)
296 !8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 32)
297 !9 = !DISubroutineType(types: !10)
299 !11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 32)
300 !12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
301 !13 = !{i32 2, !"Dwarf Version", i32 4}
302 !14 = !{i32 2, !"Debug Info Version", i32 3}
303 !15 = !{i32 1, !"wchar_size", i32 4}
304 !16 = !{!"clang version 7.0.0 (trunk 332303) (llvm/trunk 332406)"}
305 !17 = distinct !DISubprogram(name: "f2", scope: !3, file: !3, line: 2, type: !9, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !2, retainedNodes: !4)
306 !18 = !DILocation(line: 2, column: 17, scope: !17)