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: CODE (0xA)
30 ; CHECK-NEXT: Offset: 103
32 ; CHECK-NEXT: Section {
33 ; CHECK-NEXT: Type: DATA (0xB)
34 ; CHECK-NEXT: Size: 19
35 ; CHECK-NEXT: Offset: 113
36 ; CHECK-NEXT: Segments [
37 ; CHECK-NEXT: Segment {
38 ; CHECK-NEXT: Name: .data.foo
40 ; CHECK-NEXT: Offset: 0
42 ; CHECK-NEXT: Segment {
43 ; CHECK-NEXT: Name: .data.ptr2
45 ; CHECK-NEXT: Offset: 4
49 ; CHECK-NEXT: Section {
50 ; CHECK-NEXT: Type: CUSTOM (0x0)
51 ; CHECK-NEXT: Size: 121
52 ; CHECK-NEXT: Offset: 138
53 ; CHECK-NEXT: Name: .debug_str
55 ; CHECK-NEXT: Section {
56 ; CHECK-NEXT: Type: CUSTOM (0x0)
57 ; CHECK-NEXT: Size: 84
58 ; CHECK-NEXT: Offset: 276
59 ; CHECK-NEXT: Name: .debug_abbrev
61 ; CHECK-NEXT: Section {
62 ; CHECK-NEXT: Type: CUSTOM (0x0)
63 ; CHECK-NEXT: Size: 106
64 ; CHECK-NEXT: Offset: 380
65 ; CHECK-NEXT: Name: .debug_info
67 ; CHECK-NEXT: Section {
68 ; CHECK-NEXT: Type: CUSTOM (0x0)
70 ; CHECK-NEXT: Offset: 504
71 ; CHECK-NEXT: Name: .debug_macinfo
73 ; CHECK-NEXT: Section {
74 ; CHECK-NEXT: Type: CUSTOM (0x0)
75 ; CHECK-NEXT: Size: 42
76 ; CHECK-NEXT: Offset: 526
77 ; CHECK-NEXT: Name: .debug_pubnames
79 ; CHECK-NEXT: Section {
80 ; CHECK-NEXT: Type: CUSTOM (0x0)
81 ; CHECK-NEXT: Size: 26
82 ; CHECK-NEXT: Offset: 590
83 ; CHECK-NEXT: Name: .debug_pubtypes
85 ; CHECK-NEXT: Section {
86 ; CHECK-NEXT: Type: CUSTOM (0x0)
87 ; CHECK-NEXT: Size: 57
88 ; CHECK-NEXT: Offset: 638
89 ; CHECK-NEXT: Name: .debug_line
91 ; CHECK-NEXT: Section {
92 ; CHECK-NEXT: Type: CUSTOM (0x0)
93 ; CHECK-NEXT: Size: 88
94 ; CHECK-NEXT: Offset: 713
95 ; CHECK-NEXT: Name: linking
97 ; CHECK-NEXT: Section {
98 ; CHECK-NEXT: Type: CUSTOM (0x0)
100 ; CHECK-NEXT: Offset: 815
101 ; CHECK-NEXT: Name: reloc.DATA
103 ; CHECK-NEXT: Section {
104 ; CHECK-NEXT: Type: CUSTOM (0x0)
105 ; CHECK-NEXT: Size: 58
106 ; CHECK-NEXT: Offset: 841
107 ; CHECK-NEXT: Name: reloc..debug_info
109 ; CHECK-NEXT: Section {
110 ; CHECK-NEXT: Type: CUSTOM (0x0)
111 ; CHECK-NEXT: Size: 6
112 ; CHECK-NEXT: Offset: 923
113 ; CHECK-NEXT: Name: reloc..debug_pubnames
115 ; CHECK-NEXT: Section {
116 ; CHECK-NEXT: Type: CUSTOM (0x0)
117 ; CHECK-NEXT: Size: 6
118 ; CHECK-NEXT: Offset: 957
119 ; CHECK-NEXT: Name: reloc..debug_pubtypes
121 ; CHECK-NEXT: Section {
122 ; CHECK-NEXT: Type: CUSTOM (0x0)
123 ; CHECK-NEXT: Size: 6
124 ; CHECK-NEXT: Offset: 991
125 ; CHECK-NEXT: Name: reloc..debug_line
127 ; CHECK-NEXT: Section {
128 ; CHECK-NEXT: Type: CUSTOM (0x0)
129 ; CHECK-NEXT: Size: 77
130 ; CHECK-NEXT: Offset: 1021
131 ; CHECK-NEXT: Name: producers
134 ; CHECK-NEXT:Relocations [
135 ; CHECK-NEXT: Section (6) DATA {
136 ; CHECK-NEXT: 0x6 R_WASM_MEMORY_ADDR_I32 myextern 0
137 ; CHECK-NEXT: 0xF R_WASM_TABLE_INDEX_I32 f2
139 ; CHECK-NEXT: Section (9) .debug_info {
140 ; CHECK-NEXT: 0x6 R_WASM_SECTION_OFFSET_I32 .debug_abbrev 0
141 ; CHECK-NEXT: 0xC R_WASM_SECTION_OFFSET_I32 .debug_str 0
142 ; CHECK-NEXT: 0x12 R_WASM_SECTION_OFFSET_I32 .debug_str 55
143 ; CHECK-NEXT: 0x16 R_WASM_SECTION_OFFSET_I32 .debug_line 0
144 ; CHECK-NEXT: 0x1A R_WASM_SECTION_OFFSET_I32 .debug_str 62
145 ; CHECK-NEXT: 0x1E R_WASM_FUNCTION_OFFSET_I32 f2 0
146 ; CHECK-NEXT: 0x27 R_WASM_SECTION_OFFSET_I32 .debug_str 105
147 ; CHECK-NEXT: 0x33 R_WASM_MEMORY_ADDR_I32 foo 0
148 ; CHECK-NEXT: 0x3D R_WASM_SECTION_OFFSET_I32 .debug_str 109
149 ; CHECK-NEXT: 0x44 R_WASM_SECTION_OFFSET_I32 .debug_str 113
150 ; CHECK-NEXT: 0x50 R_WASM_MEMORY_ADDR_I32 ptr2 0
151 ; CHECK-NEXT: 0x5B R_WASM_FUNCTION_OFFSET_I32 f2 0
152 ; CHECK-NEXT: 0x63 R_WASM_SECTION_OFFSET_I32 .debug_str 118
154 ; CHECK-NEXT: Section (11) .debug_pubnames {
155 ; CHECK-NEXT: 0x6 R_WASM_SECTION_OFFSET_I32 .debug_info 0
157 ; CHECK-NEXT: Section (12) .debug_pubtypes {
158 ; CHECK-NEXT: 0x6 R_WASM_SECTION_OFFSET_I32 .debug_info 0
160 ; CHECK-NEXT: Section (13) .debug_line {
161 ; CHECK-NEXT: 0x2B R_WASM_FUNCTION_OFFSET_I32 f2 0
164 ; CHECK-NEXT:Symbols [
165 ; CHECK-NEXT: Symbol {
166 ; CHECK-NEXT: Name: f2
167 ; CHECK-NEXT: Type: FUNCTION (0x0)
168 ; CHECK-NEXT: Flags [ (0x4)
169 ; CHECK-NEXT: VISIBILITY_HIDDEN (0x4)
171 ; CHECK-NEXT: ElementIndex: 0x0
173 ; CHECK-NEXT: Symbol {
174 ; CHECK-NEXT: Name: foo
175 ; CHECK-NEXT: Type: DATA (0x1)
176 ; CHECK-NEXT: Flags [ (0x4)
177 ; CHECK-NEXT: VISIBILITY_HIDDEN (0x4)
179 ; CHECK-NEXT: Offset: 0x0
180 ; CHECK-NEXT: Segment: 0x0
181 ; CHECK-NEXT: Size: 0x4
183 ; CHECK-NEXT: Symbol {
184 ; CHECK-NEXT: Name: myextern
185 ; CHECK-NEXT: Type: DATA (0x1)
186 ; CHECK-NEXT: Flags [ (0x10)
187 ; CHECK-NEXT: UNDEFINED (0x10)
189 ; CHECK-NEXT: ImportName:
190 ; CHECK-NEXT: ImportModule:
192 ; CHECK-NEXT: Symbol {
193 ; CHECK-NEXT: Name: ptr2
194 ; CHECK-NEXT: Type: DATA (0x1)
195 ; CHECK-NEXT: Flags [ (0x4)
196 ; CHECK-NEXT: VISIBILITY_HIDDEN (0x4)
198 ; CHECK-NEXT: Offset: 0x0
199 ; CHECK-NEXT: Segment: 0x1
200 ; CHECK-NEXT: Size: 0x4
202 ; CHECK-NEXT: Symbol {
203 ; CHECK-NEXT: Name: .debug_str
204 ; CHECK-NEXT: Type: SECTION (0x3)
205 ; CHECK-NEXT: Flags [ (0x2)
206 ; CHECK-NEXT: BINDING_LOCAL (0x2)
208 ; CHECK-NEXT: ElementIndex: 0x6
210 ; CHECK-NEXT: Symbol {
211 ; CHECK-NEXT: Name: .debug_abbrev
212 ; CHECK-NEXT: Type: SECTION (0x3)
213 ; CHECK-NEXT: Flags [ (0x2)
214 ; CHECK-NEXT: BINDING_LOCAL (0x2)
216 ; CHECK-NEXT: ElementIndex: 0x7
218 ; CHECK-NEXT: Symbol {
219 ; CHECK-NEXT: Name: .debug_info
220 ; CHECK-NEXT: Type: SECTION (0x3)
221 ; CHECK-NEXT: Flags [ (0x2)
222 ; CHECK-NEXT: BINDING_LOCAL (0x2)
224 ; CHECK-NEXT: ElementIndex: 0x8
226 ; CHECK-NEXT: Symbol {
227 ; CHECK-NEXT: Name: .debug_line
228 ; CHECK-NEXT: Type: SECTION (0x3)
229 ; CHECK-NEXT: Flags [ (0x2)
230 ; CHECK-NEXT: BINDING_LOCAL (0x2)
232 ; CHECK-NEXT: ElementIndex: 0xC
236 ; generated from the following C code using: clang --target=wasm32 -g -O0 -S -emit-llvm test.c
237 ; extern int myextern;
238 ; void f2(void) { return; }
240 ; int* foo = &myextern;
241 ; void (*ptr2)(void) = f2;
243 target triple = "wasm32-unknown-unknown"
245 source_filename = "test.c"
247 @myextern = external global i32, align 4
248 @foo = hidden global i32* @myextern, align 4, !dbg !0
249 @ptr2 = hidden global void ()* @f2, align 4, !dbg !6
251 ; Function Attrs: noinline nounwind optnone
252 define hidden void @f2() #0 !dbg !17 {
257 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" }
260 !llvm.module.flags = !{!13, !14, !15}
263 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
264 !1 = distinct !DIGlobalVariable(name: "foo", scope: !2, file: !3, line: 4, type: !11, isLocal: false, isDefinition: true)
265 !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)
266 !3 = !DIFile(filename: "test.c", directory: "/usr/local/google/home/sbc/dev/wasm/simple")
269 !6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
270 !7 = distinct !DIGlobalVariable(name: "ptr2", scope: !2, file: !3, line: 5, type: !8, isLocal: false, isDefinition: true)
271 !8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 32)
272 !9 = !DISubroutineType(types: !10)
274 !11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 32)
275 !12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
276 !13 = !{i32 2, !"Dwarf Version", i32 4}
277 !14 = !{i32 2, !"Debug Info Version", i32 3}
278 !15 = !{i32 1, !"wchar_size", i32 4}
279 !16 = !{!"clang version 7.0.0 (trunk 332303) (llvm/trunk 332406)"}
280 !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)
281 !18 = !DILocation(line: 2, column: 17, scope: !17)