1 ; RUN: llc -filetype=obj %s -o - | llvm-readobj -r -S --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: 8
12 ; CHECK-NEXT: Section {
13 ; CHECK-NEXT: Type: IMPORT (0x2)
14 ; CHECK-NEXT: Size: 58
15 ; CHECK-NEXT: Offset: 18
17 ; CHECK-NEXT: Section {
18 ; CHECK-NEXT: Type: FUNCTION (0x3)
20 ; CHECK-NEXT: Offset: 82
22 ; CHECK-NEXT: Section {
23 ; CHECK-NEXT: Type: ELEM (0x9)
25 ; CHECK-NEXT: Offset: 90
27 ; CHECK-NEXT: Section {
28 ; CHECK-NEXT: Type: DATACOUNT (0xC)
30 ; CHECK-NEXT: Offset: 103
32 ; CHECK-NEXT: Section {
33 ; CHECK-NEXT: Type: CODE (0xA)
35 ; CHECK-NEXT: Offset: 110
37 ; CHECK-NEXT: Section {
38 ; CHECK-NEXT: Type: DATA (0xB)
39 ; CHECK-NEXT: Size: 19
40 ; CHECK-NEXT: Offset: 120
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: 121
57 ; CHECK-NEXT: Offset: 145
58 ; CHECK-NEXT: Name: .debug_str
60 ; CHECK-NEXT: Section {
61 ; CHECK-NEXT: Type: CUSTOM (0x0)
62 ; CHECK-NEXT: Size: 84
63 ; CHECK-NEXT: Offset: 283
64 ; CHECK-NEXT: Name: .debug_abbrev
66 ; CHECK-NEXT: Section {
67 ; CHECK-NEXT: Type: CUSTOM (0x0)
68 ; CHECK-NEXT: Size: 106
69 ; CHECK-NEXT: Offset: 387
70 ; CHECK-NEXT: Name: .debug_info
72 ; CHECK-NEXT: Section {
73 ; CHECK-NEXT: Type: CUSTOM (0x0)
75 ; CHECK-NEXT: Offset: 511
76 ; CHECK-NEXT: Name: .debug_macinfo
78 ; CHECK-NEXT: Section {
79 ; CHECK-NEXT: Type: CUSTOM (0x0)
80 ; CHECK-NEXT: Size: 42
81 ; CHECK-NEXT: Offset: 533
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: 597
88 ; CHECK-NEXT: Name: .debug_pubtypes
90 ; CHECK-NEXT: Section {
91 ; CHECK-NEXT: Type: CUSTOM (0x0)
92 ; CHECK-NEXT: Size: 57
93 ; CHECK-NEXT: Offset: 645
94 ; CHECK-NEXT: Name: .debug_line
96 ; CHECK-NEXT: Section {
97 ; CHECK-NEXT: Type: CUSTOM (0x0)
98 ; CHECK-NEXT: Size: 88
99 ; CHECK-NEXT: Offset: 720
100 ; CHECK-NEXT: Name: linking
102 ; CHECK-NEXT: Section {
103 ; CHECK-NEXT: Type: CUSTOM (0x0)
104 ; CHECK-NEXT: Size: 9
105 ; CHECK-NEXT: Offset: 822
106 ; CHECK-NEXT: Name: reloc.DATA
108 ; CHECK-NEXT: Section {
109 ; CHECK-NEXT: Type: CUSTOM (0x0)
110 ; CHECK-NEXT: Size: 58
111 ; CHECK-NEXT: Offset: 848
112 ; CHECK-NEXT: Name: reloc..debug_info
114 ; CHECK-NEXT: Section {
115 ; CHECK-NEXT: Type: CUSTOM (0x0)
116 ; CHECK-NEXT: Size: 6
117 ; CHECK-NEXT: Offset: 930
118 ; CHECK-NEXT: Name: reloc..debug_pubnames
120 ; CHECK-NEXT: Section {
121 ; CHECK-NEXT: Type: CUSTOM (0x0)
122 ; CHECK-NEXT: Size: 6
123 ; CHECK-NEXT: Offset: 964
124 ; CHECK-NEXT: Name: reloc..debug_pubtypes
126 ; CHECK-NEXT: Section {
127 ; CHECK-NEXT: Type: CUSTOM (0x0)
128 ; CHECK-NEXT: Size: 6
129 ; CHECK-NEXT: Offset: 998
130 ; CHECK-NEXT: Name: reloc..debug_line
132 ; CHECK-NEXT: Section {
133 ; CHECK-NEXT: Type: CUSTOM (0x0)
134 ; CHECK-NEXT: Size: 77
135 ; CHECK-NEXT: Offset: 1028
136 ; CHECK-NEXT: Name: producers
139 ; CHECK-NEXT:Relocations [
140 ; CHECK-NEXT: Section (7) DATA {
141 ; CHECK-NEXT: 0x6 R_WASM_MEMORY_ADDR_I32 myextern 0
142 ; CHECK-NEXT: 0xF R_WASM_TABLE_INDEX_I32 f2
144 ; CHECK-NEXT: Section (10) .debug_info {
145 ; CHECK-NEXT: 0x6 R_WASM_SECTION_OFFSET_I32 .debug_abbrev 0
146 ; CHECK-NEXT: 0xC R_WASM_SECTION_OFFSET_I32 .debug_str 0
147 ; CHECK-NEXT: 0x12 R_WASM_SECTION_OFFSET_I32 .debug_str 55
148 ; CHECK-NEXT: 0x16 R_WASM_SECTION_OFFSET_I32 .debug_line 0
149 ; CHECK-NEXT: 0x1A R_WASM_SECTION_OFFSET_I32 .debug_str 62
150 ; CHECK-NEXT: 0x1E R_WASM_FUNCTION_OFFSET_I32 f2 0
151 ; CHECK-NEXT: 0x27 R_WASM_SECTION_OFFSET_I32 .debug_str 105
152 ; CHECK-NEXT: 0x33 R_WASM_MEMORY_ADDR_I32 foo 0
153 ; CHECK-NEXT: 0x3D R_WASM_SECTION_OFFSET_I32 .debug_str 109
154 ; CHECK-NEXT: 0x44 R_WASM_SECTION_OFFSET_I32 .debug_str 113
155 ; CHECK-NEXT: 0x50 R_WASM_MEMORY_ADDR_I32 ptr2 0
156 ; CHECK-NEXT: 0x5B R_WASM_FUNCTION_OFFSET_I32 f2 0
157 ; CHECK-NEXT: 0x63 R_WASM_SECTION_OFFSET_I32 .debug_str 118
159 ; CHECK-NEXT: Section (12) .debug_pubnames {
160 ; CHECK-NEXT: 0x6 R_WASM_SECTION_OFFSET_I32 .debug_info 0
162 ; CHECK-NEXT: Section (13) .debug_pubtypes {
163 ; CHECK-NEXT: 0x6 R_WASM_SECTION_OFFSET_I32 .debug_info 0
165 ; CHECK-NEXT: Section (14) .debug_line {
166 ; CHECK-NEXT: 0x2B R_WASM_FUNCTION_OFFSET_I32 f2 0
169 ; CHECK-NEXT:Symbols [
170 ; CHECK-NEXT: Symbol {
171 ; CHECK-NEXT: Name: f2
172 ; CHECK-NEXT: Type: FUNCTION (0x0)
173 ; CHECK-NEXT: Flags [ (0x4)
174 ; CHECK-NEXT: VISIBILITY_HIDDEN (0x4)
176 ; CHECK-NEXT: ElementIndex: 0x0
178 ; CHECK-NEXT: Symbol {
179 ; CHECK-NEXT: Name: foo
180 ; CHECK-NEXT: Type: DATA (0x1)
181 ; CHECK-NEXT: Flags [ (0x4)
182 ; CHECK-NEXT: VISIBILITY_HIDDEN (0x4)
184 ; CHECK-NEXT: Offset: 0x0
185 ; CHECK-NEXT: Segment: 0x0
186 ; CHECK-NEXT: Size: 0x4
188 ; CHECK-NEXT: Symbol {
189 ; CHECK-NEXT: Name: myextern
190 ; CHECK-NEXT: Type: DATA (0x1)
191 ; CHECK-NEXT: Flags [ (0x10)
192 ; CHECK-NEXT: UNDEFINED (0x10)
194 ; CHECK-NEXT: ImportName:
195 ; CHECK-NEXT: ImportModule:
197 ; CHECK-NEXT: Symbol {
198 ; CHECK-NEXT: Name: ptr2
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: 0x1
205 ; CHECK-NEXT: Size: 0x4
207 ; CHECK-NEXT: Symbol {
208 ; CHECK-NEXT: Name: .debug_str
209 ; CHECK-NEXT: Type: SECTION (0x3)
210 ; CHECK-NEXT: Flags [ (0x2)
211 ; CHECK-NEXT: BINDING_LOCAL (0x2)
213 ; CHECK-NEXT: ElementIndex: 0x7
215 ; CHECK-NEXT: Symbol {
216 ; CHECK-NEXT: Name: .debug_abbrev
217 ; CHECK-NEXT: Type: SECTION (0x3)
218 ; CHECK-NEXT: Flags [ (0x2)
219 ; CHECK-NEXT: BINDING_LOCAL (0x2)
221 ; CHECK-NEXT: ElementIndex: 0x8
223 ; CHECK-NEXT: Symbol {
224 ; CHECK-NEXT: Name: .debug_info
225 ; CHECK-NEXT: Type: SECTION (0x3)
226 ; CHECK-NEXT: Flags [ (0x2)
227 ; CHECK-NEXT: BINDING_LOCAL (0x2)
229 ; CHECK-NEXT: ElementIndex: 0x9
231 ; CHECK-NEXT: Symbol {
232 ; CHECK-NEXT: Name: .debug_line
233 ; CHECK-NEXT: Type: SECTION (0x3)
234 ; CHECK-NEXT: Flags [ (0x2)
235 ; CHECK-NEXT: BINDING_LOCAL (0x2)
237 ; CHECK-NEXT: ElementIndex: 0xD
241 ; generated from the following C code using: clang --target=wasm32 -g -O0 -S -emit-llvm test.c
242 ; extern int myextern;
243 ; void f2(void) { return; }
245 ; int* foo = &myextern;
246 ; void (*ptr2)(void) = f2;
248 target triple = "wasm32-unknown-unknown"
250 source_filename = "test.c"
252 @myextern = external global i32, align 4
253 @foo = hidden global i32* @myextern, align 4, !dbg !0
254 @ptr2 = hidden global void ()* @f2, align 4, !dbg !6
256 ; Function Attrs: noinline nounwind optnone
257 define hidden void @f2() #0 !dbg !17 {
262 attributes #0 = { noinline nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "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"="generic" "unsafe-fp-math"="false" "use-soft-float"="false" }
265 !llvm.module.flags = !{!13, !14, !15}
268 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
269 !1 = distinct !DIGlobalVariable(name: "foo", scope: !2, file: !3, line: 4, type: !11, isLocal: false, isDefinition: true)
270 !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)
271 !3 = !DIFile(filename: "test.c", directory: "/usr/local/google/home/sbc/dev/wasm/simple")
274 !6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
275 !7 = distinct !DIGlobalVariable(name: "ptr2", scope: !2, file: !3, line: 5, type: !8, isLocal: false, isDefinition: true)
276 !8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 32)
277 !9 = !DISubroutineType(types: !10)
279 !11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 32)
280 !12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
281 !13 = !{i32 2, !"Dwarf Version", i32 4}
282 !14 = !{i32 2, !"Debug Info Version", i32 3}
283 !15 = !{i32 1, !"wchar_size", i32 4}
284 !16 = !{!"clang version 7.0.0 (trunk 332303) (llvm/trunk 332406)"}
285 !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)
286 !18 = !DILocation(line: 2, column: 17, scope: !17)