1 ; RUN: llc -mcpu=mvp -generate-arange-section -filetype=obj %s -o - | llvm-readobj -S -r --symbols - | FileCheck %s
4 ; CHECK-NEXT: Arch: wasm64
5 ; CHECK-NEXT: AddressSize: 64bit
6 ; CHECK-NEXT: Sections [
7 ; CHECK-NEXT: Section {
8 ; CHECK-NEXT: Type: TYPE (0x1)
10 ; CHECK-NEXT: Offset: 8
12 ; CHECK-NEXT: Section {
13 ; CHECK-NEXT: Type: IMPORT (0x2)
14 ; CHECK-NEXT: Size: 81
15 ; CHECK-NEXT: Offset: 18
17 ; CHECK-NEXT: Section {
18 ; CHECK-NEXT: Type: FUNCTION (0x3)
20 ; CHECK-NEXT: Offset: 105
22 ; CHECK-NEXT: Section {
23 ; CHECK-NEXT: Type: ELEM (0x9)
25 ; CHECK-NEXT: Offset: 113
27 ; CHECK-NEXT: Section {
28 ; CHECK-NEXT: Type: DATACOUNT (0xC)
30 ; CHECK-NEXT: Offset: 126
32 ; CHECK-NEXT: Section {
33 ; CHECK-NEXT: Type: CODE (0xA)
35 ; CHECK-NEXT: Offset: 133
37 ; CHECK-NEXT: Section {
38 ; CHECK-NEXT: Type: DATA (0xB)
39 ; CHECK-NEXT: Size: 27
40 ; CHECK-NEXT: Offset: 143
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: 8
54 ; CHECK-NEXT: Section {
55 ; CHECK-NEXT: Type: CUSTOM (0x0)
56 ; CHECK-NEXT: Size: 86
57 ; CHECK-NEXT: Offset: 176
58 ; CHECK-NEXT: Name: .debug_abbrev
60 ; CHECK-NEXT: Section {
61 ; CHECK-NEXT: Type: CUSTOM (0x0)
62 ; CHECK-NEXT: Size: 130
63 ; CHECK-NEXT: Offset: 282
64 ; CHECK-NEXT: Name: .debug_info
66 ; CHECK-NEXT: Section {
67 ; CHECK-NEXT: Type: CUSTOM (0x0)
68 ; CHECK-NEXT: Size: 80
69 ; CHECK-NEXT: Offset: 430
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: 531
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: 669
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: 733
88 ; CHECK-NEXT: Name: .debug_pubtypes
90 ; CHECK-NEXT: Section {
91 ; CHECK-NEXT: Type: CUSTOM (0x0)
92 ; CHECK-NEXT: Size: 60
93 ; CHECK-NEXT: Offset: 781
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: 859
100 ; CHECK-NEXT: Name: linking
102 ; CHECK-NEXT: Section {
103 ; CHECK-NEXT: Type: CUSTOM (0x0)
104 ; CHECK-NEXT: Size: 9
105 ; CHECK-NEXT: Offset: 964
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: 990
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: 1075
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: 1120
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: 1154
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: 1188
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: 1218
142 ; CHECK-NEXT: Name: producers
144 ; CHECK-NEXT: Section {
145 ; CHECK-NEXT: Type: CUSTOM (0x0)
146 ; CHECK-NEXT: Size: 11
147 ; CHECK-NEXT: Offset: 1311
148 ; CHECK-NEXT: Name: target_features
151 ; CHECK-NEXT: Relocations [
152 ; CHECK-NEXT: Section (7) DATA {
153 ; CHECK-NEXT: 0x6 R_WASM_MEMORY_ADDR_I64 myextern 0
154 ; CHECK-NEXT: 0x13 R_WASM_TABLE_INDEX_I64 f2
156 ; CHECK-NEXT: Section (9) .debug_info {
157 ; CHECK-NEXT: 0x6 R_WASM_SECTION_OFFSET_I32 .debug_abbrev 0
158 ; CHECK-NEXT: 0xC R_WASM_SECTION_OFFSET_I32 .debug_str 0
159 ; CHECK-NEXT: 0x12 R_WASM_SECTION_OFFSET_I32 .debug_str 55
160 ; CHECK-NEXT: 0x16 R_WASM_SECTION_OFFSET_I32 .debug_line 0
161 ; CHECK-NEXT: 0x1A R_WASM_SECTION_OFFSET_I32 .debug_str 62
162 ; CHECK-NEXT: 0x1E R_WASM_FUNCTION_OFFSET_I64 f2 0
163 ; CHECK-NEXT: 0x2B R_WASM_SECTION_OFFSET_I32 .debug_str 105
164 ; CHECK-NEXT: 0x37 R_WASM_MEMORY_ADDR_I64 foo 0
165 ; CHECK-NEXT: 0x45 R_WASM_SECTION_OFFSET_I32 .debug_str 109
166 ; CHECK-NEXT: 0x4C R_WASM_SECTION_OFFSET_I32 .debug_str 113
167 ; CHECK-NEXT: 0x58 R_WASM_MEMORY_ADDR_I64 ptr2 0
168 ; CHECK-NEXT: 0x67 R_WASM_FUNCTION_OFFSET_I64 f2 0
169 ; CHECK-NEXT: 0x76 R_WASM_GLOBAL_INDEX_I32 __stack_pointer
170 ; CHECK-NEXT: 0x7B R_WASM_SECTION_OFFSET_I32 .debug_str 118
172 ; CHECK-NEXT: Section (10) .debug_aranges {
173 ; CHECK-NEXT: 0x6 R_WASM_SECTION_OFFSET_I32 .debug_info 0
174 ; CHECK-NEXT: 0x10 R_WASM_MEMORY_ADDR_I64 foo 0
175 ; CHECK-NEXT: 0x20 R_WASM_MEMORY_ADDR_I64 ptr2 0
176 ; CHECK-NEXT: 0x30 R_WASM_FUNCTION_OFFSET_I64 f2 0
178 ; CHECK-NEXT: Section (12) .debug_pubnames {
179 ; CHECK-NEXT: 0x6 R_WASM_SECTION_OFFSET_I32 .debug_info 0
181 ; CHECK-NEXT: Section (13) .debug_pubtypes {
182 ; CHECK-NEXT: 0x6 R_WASM_SECTION_OFFSET_I32 .debug_info 0
184 ; CHECK-NEXT: Section (14) .debug_line {
185 ; CHECK-NEXT: 0x2E R_WASM_FUNCTION_OFFSET_I64 f2 1
188 ; CHECK-NEXT: Symbols [
189 ; CHECK-NEXT: Symbol {
190 ; CHECK-NEXT: Name: f2
191 ; CHECK-NEXT: Type: FUNCTION (0x0)
192 ; CHECK-NEXT: Flags [ (0x4)
193 ; CHECK-NEXT: VISIBILITY_HIDDEN (0x4)
195 ; CHECK-NEXT: ElementIndex: 0x0
197 ; CHECK-NEXT: Symbol {
198 ; CHECK-NEXT: Name: foo
199 ; CHECK-NEXT: Type: DATA (0x1)
200 ; CHECK-NEXT: Flags [ (0x4)
201 ; CHECK-NEXT: VISIBILITY_HIDDEN (0x4)
203 ; CHECK-NEXT: Offset: 0x0
204 ; CHECK-NEXT: Segment: 0x0
205 ; CHECK-NEXT: Size: 0x8
207 ; CHECK-NEXT: Symbol {
208 ; CHECK-NEXT: Name: myextern
209 ; CHECK-NEXT: Type: DATA (0x1)
210 ; CHECK-NEXT: Flags [ (0x10)
211 ; CHECK-NEXT: UNDEFINED (0x10)
214 ; CHECK-NEXT: Symbol {
215 ; CHECK-NEXT: Name: ptr2
216 ; CHECK-NEXT: Type: DATA (0x1)
217 ; CHECK-NEXT: Flags [ (0x4)
218 ; CHECK-NEXT: VISIBILITY_HIDDEN (0x4)
220 ; CHECK-NEXT: Offset: 0x0
221 ; CHECK-NEXT: Segment: 0x1
222 ; CHECK-NEXT: Size: 0x8
224 ; CHECK-NEXT: Symbol {
225 ; CHECK-NEXT: Name: .debug_abbrev
226 ; CHECK-NEXT: Type: SECTION (0x3)
227 ; CHECK-NEXT: Flags [ (0x2)
228 ; CHECK-NEXT: BINDING_LOCAL (0x2)
230 ; CHECK-NEXT: ElementIndex: 0x7
232 ; CHECK-NEXT: Symbol {
233 ; CHECK-NEXT: Name: .debug_info
234 ; CHECK-NEXT: Type: SECTION (0x3)
235 ; CHECK-NEXT: Flags [ (0x2)
236 ; CHECK-NEXT: BINDING_LOCAL (0x2)
238 ; CHECK-NEXT: ElementIndex: 0x8
240 ; CHECK-NEXT: Symbol {
241 ; CHECK-NEXT: Name: __stack_pointer
242 ; CHECK-NEXT: Type: GLOBAL (0x2)
243 ; CHECK-NEXT: Flags [ (0x10)
244 ; CHECK-NEXT: UNDEFINED (0x10)
246 ; CHECK-NEXT: ImportModule: env
247 ; CHECK-NEXT: ElementIndex: 0x0
249 ; CHECK-NEXT: Symbol {
250 ; CHECK-NEXT: Name: .debug_str
251 ; CHECK-NEXT: Type: SECTION (0x3)
252 ; CHECK-NEXT: Flags [ (0x2)
253 ; CHECK-NEXT: BINDING_LOCAL (0x2)
255 ; CHECK-NEXT: ElementIndex: 0xA
257 ; CHECK-NEXT: Symbol {
258 ; CHECK-NEXT: Name: .debug_line
259 ; CHECK-NEXT: Type: SECTION (0x3)
260 ; CHECK-NEXT: Flags [ (0x2)
261 ; CHECK-NEXT: BINDING_LOCAL (0x2)
263 ; CHECK-NEXT: ElementIndex: 0xD
267 ; generated from the following C code using: clang --target=wasm64 -g -O0 -S -emit-llvm test.c
268 ; extern int myextern;
269 ; void f2(void) { return; }
271 ; int* foo = &myextern;
272 ; void (*ptr2)(void) = f2;
274 target triple = "wasm64-unknown-unknown"
276 source_filename = "test.c"
278 @myextern = external global i32, align 4
279 @foo = hidden global ptr @myextern, align 4, !dbg !0
280 @ptr2 = hidden global ptr @f2, align 4, !dbg !6
282 ; Function Attrs: noinline nounwind optnone
283 define hidden void @f2() #0 !dbg !17 {
288 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" }
291 !llvm.module.flags = !{!13, !14, !15}
294 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
295 !1 = distinct !DIGlobalVariable(name: "foo", scope: !2, file: !3, line: 4, type: !11, isLocal: false, isDefinition: true)
296 !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)
297 !3 = !DIFile(filename: "test.c", directory: "/usr/local/google/home/sbc/dev/wasm/simple")
300 !6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
301 !7 = distinct !DIGlobalVariable(name: "ptr2", scope: !2, file: !3, line: 5, type: !8, isLocal: false, isDefinition: true)
302 !8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 64)
303 !9 = !DISubroutineType(types: !10)
305 !11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64)
306 !12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
307 !13 = !{i32 2, !"Dwarf Version", i32 4}
308 !14 = !{i32 2, !"Debug Info Version", i32 3}
309 !15 = !{i32 1, !"wchar_size", i32 4}
310 !16 = !{!"clang version 7.0.0 (trunk 332303) (llvm/trunk 332406)"}
311 !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)
312 !18 = !DILocation(line: 2, column: 17, scope: !17)