• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -filetype=obj %s -o - | llvm-readobj -r -S --symbols - | FileCheck %s
2
3; CHECK: Format: WASM
4; CHECK-NEXT:Arch: wasm32
5; CHECK-NEXT:AddressSize: 32bit
6; CHECK-NEXT:Sections [
7; CHECK-NEXT:  Section {
8; CHECK-NEXT:    Type: TYPE (0x1)
9; CHECK-NEXT:    Size: 4
10; CHECK-NEXT:    Offset: 8
11; CHECK-NEXT:  }
12; CHECK-NEXT:  Section {
13; CHECK-NEXT:    Type: IMPORT (0x2)
14; CHECK-NEXT:    Size: 81
15; CHECK-NEXT:    Offset: 18
16; CHECK-NEXT:  }
17; CHECK-NEXT:  Section {
18; CHECK-NEXT:    Type: FUNCTION (0x3)
19; CHECK-NEXT:    Size: 2
20; CHECK-NEXT:    Offset: 105
21; CHECK-NEXT:  }
22; CHECK-NEXT:  Section {
23; CHECK-NEXT:    Type: ELEM (0x9)
24; CHECK-NEXT:    Size: 7
25; CHECK-NEXT:    Offset: 113
26; CHECK-NEXT:  }
27; CHECK-NEXT:  Section {
28; CHECK-NEXT:    Type: DATACOUNT (0xC)
29; CHECK-NEXT:    Size: 1
30; CHECK-NEXT:    Offset: 126
31; CHECK-NEXT:  }
32; CHECK-NEXT:  Section {
33; CHECK-NEXT:    Type: CODE (0xA)
34; CHECK-NEXT:    Size: 4
35; CHECK-NEXT:    Offset: 133
36; CHECK-NEXT:  }
37; CHECK-NEXT:  Section {
38; CHECK-NEXT:    Type: DATA (0xB)
39; CHECK-NEXT:    Size: 19
40; CHECK-NEXT:    Offset: 143
41; CHECK-NEXT:    Segments [
42; CHECK-NEXT:      Segment {
43; CHECK-NEXT:        Name: .data.foo
44; CHECK-NEXT:        Size: 4
45; CHECK-NEXT:        Offset: 0
46; CHECK-NEXT:      }
47; CHECK-NEXT:      Segment {
48; CHECK-NEXT:        Name: .data.ptr2
49; CHECK-NEXT:        Size: 4
50; CHECK-NEXT:        Offset: 4
51; CHECK-NEXT:      }
52; CHECK-NEXT:    ]
53; CHECK-NEXT:  }
54; CHECK-NEXT:  Section {
55; CHECK-NEXT:    Type: CUSTOM (0x0)
56; CHECK-NEXT:    Size: 86
57; CHECK-NEXT:    Offset: 168
58; CHECK-NEXT:    Name: .debug_abbrev
59; CHECK-NEXT:  }
60; CHECK-NEXT:  Section {
61; CHECK-NEXT:    Type: CUSTOM (0x0)
62; CHECK-NEXT:    Size: 114
63; CHECK-NEXT:    Offset: 274
64; CHECK-NEXT:    Name: .debug_info
65; CHECK-NEXT:  }
66; CHECK-NEXT:  Section {
67; CHECK-NEXT:    Type: CUSTOM (0x0)
68; CHECK-NEXT:    Size: 121
69; CHECK-NEXT:    Offset: 406
70; CHECK-NEXT:    Name: .debug_str
71; CHECK-NEXT:  }
72; CHECK-NEXT:  Section {
73; CHECK-NEXT:    Type: CUSTOM (0x0)
74; CHECK-NEXT:    Size: 42
75; CHECK-NEXT:    Offset: 544
76; CHECK-NEXT:    Name: .debug_pubnames
77; CHECK-NEXT:  }
78; CHECK-NEXT:  Section {
79; CHECK-NEXT:    Type: CUSTOM (0x0)
80; CHECK-NEXT:    Size: 26
81; CHECK-NEXT:    Offset: 608
82; CHECK-NEXT:    Name: .debug_pubtypes
83; CHECK-NEXT:  }
84; CHECK-NEXT:  Section {
85; CHECK-NEXT:    Type: CUSTOM (0x0)
86; CHECK-NEXT:    Size: 57
87; CHECK-NEXT:    Offset: 656
88; CHECK-NEXT:    Name: .debug_line
89; CHECK-NEXT:  }
90; CHECK-NEXT:  Section {
91; CHECK-NEXT:    Type: CUSTOM (0x0)
92; CHECK-NEXT:    Size: 91
93; CHECK-NEXT:    Offset: 731
94; CHECK-NEXT:    Name: linking
95; CHECK-NEXT:  }
96; CHECK-NEXT:  Section {
97; CHECK-NEXT:    Type: CUSTOM (0x0)
98; CHECK-NEXT:    Size: 9
99; CHECK-NEXT:    Offset: 836
100; CHECK-NEXT:    Name: reloc.DATA
101; CHECK-NEXT:  }
102; CHECK-NEXT:  Section {
103; CHECK-NEXT:    Type: CUSTOM (0x0)
104; CHECK-NEXT:    Size: 61
105; CHECK-NEXT:    Offset: 862
106; CHECK-NEXT:    Name: reloc..debug_info
107; CHECK-NEXT:  }
108; CHECK-NEXT:  Section {
109; CHECK-NEXT:    Type: CUSTOM (0x0)
110; CHECK-NEXT:    Size: 6
111; CHECK-NEXT:    Offset: 947
112; CHECK-NEXT:    Name: reloc..debug_pubnames
113; CHECK-NEXT:  }
114; CHECK-NEXT:  Section {
115; CHECK-NEXT:    Type: CUSTOM (0x0)
116; CHECK-NEXT:    Size: 6
117; CHECK-NEXT:    Offset: 981
118; CHECK-NEXT:    Name: reloc..debug_pubtypes
119; CHECK-NEXT:  }
120; CHECK-NEXT:  Section {
121; CHECK-NEXT:    Type: CUSTOM (0x0)
122; CHECK-NEXT:    Size: 6
123; CHECK-NEXT:    Offset: 1015
124; CHECK-NEXT:    Name: reloc..debug_line
125; CHECK-NEXT:  }
126; CHECK-NEXT:  Section {
127; CHECK-NEXT:    Type: CUSTOM (0x0)
128; CHECK-NEXT:    Size: 77
129; CHECK-NEXT:    Offset: 1045
130; CHECK-NEXT:    Name: producers
131; CHECK-NEXT:  }
132; CHECK-NEXT:]
133; CHECK-NEXT:Relocations [
134; CHECK-NEXT:  Section (7) DATA {
135; CHECK-NEXT:    0x6 R_WASM_MEMORY_ADDR_I32 myextern 0
136; CHECK-NEXT:    0xF R_WASM_TABLE_INDEX_I32 f2
137; CHECK-NEXT:  }
138; CHECK-NEXT:  Section (9) .debug_info {
139; CHECK-NEXT:    0x6 R_WASM_SECTION_OFFSET_I32 .debug_abbrev 0
140; CHECK-NEXT:    0xC R_WASM_SECTION_OFFSET_I32 .debug_str 0
141; CHECK-NEXT:    0x12 R_WASM_SECTION_OFFSET_I32 .debug_str 55
142; CHECK-NEXT:    0x16 R_WASM_SECTION_OFFSET_I32 .debug_line 0
143; CHECK-NEXT:    0x1A R_WASM_SECTION_OFFSET_I32 .debug_str 62
144; CHECK-NEXT:    0x1E R_WASM_FUNCTION_OFFSET_I32 f2 0
145; CHECK-NEXT:    0x27 R_WASM_SECTION_OFFSET_I32 .debug_str 105
146; CHECK-NEXT:    0x33 R_WASM_MEMORY_ADDR_I32 foo 0
147; CHECK-NEXT:    0x3D R_WASM_SECTION_OFFSET_I32 .debug_str 109
148; CHECK-NEXT:    0x44 R_WASM_SECTION_OFFSET_I32 .debug_str 113
149; CHECK-NEXT:    0x50 R_WASM_MEMORY_ADDR_I32 ptr2 0
150; CHECK-NEXT:    0x5B R_WASM_FUNCTION_OFFSET_I32 f2 0
151; CHECK-NEXT:    0x66 R_WASM_GLOBAL_INDEX_I32 __stack_pointer
152; CHECK-NEXT:    0x6B R_WASM_SECTION_OFFSET_I32 .debug_str 118
153; CHECK-NEXT:  }
154; CHECK-NEXT:  Section (11) .debug_pubnames {
155; CHECK-NEXT:    0x6 R_WASM_SECTION_OFFSET_I32 .debug_info 0
156; CHECK-NEXT:  }
157; CHECK-NEXT:  Section (12) .debug_pubtypes {
158; CHECK-NEXT:    0x6 R_WASM_SECTION_OFFSET_I32 .debug_info 0
159; CHECK-NEXT:  }
160; CHECK-NEXT:  Section (13) .debug_line {
161; CHECK-NEXT:    0x2B R_WASM_FUNCTION_OFFSET_I32 f2 0
162; CHECK-NEXT:  }
163; CHECK-NEXT:]
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)
170; CHECK-NEXT:    ]
171; CHECK-NEXT:    ElementIndex: 0x0
172; CHECK-NEXT:  }
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)
178; CHECK-NEXT:    ]
179; CHECK-NEXT:    Offset: 0x0
180; CHECK-NEXT:    Segment: 0x0
181; CHECK-NEXT:    Size: 0x4
182; CHECK-NEXT:  }
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)
188; CHECK-NEXT:    ]
189; CHECK-NEXT:  }
190; CHECK-NEXT:  Symbol {
191; CHECK-NEXT:    Name: ptr2
192; CHECK-NEXT:    Type: DATA (0x1)
193; CHECK-NEXT:    Flags [ (0x4)
194; CHECK-NEXT:      VISIBILITY_HIDDEN (0x4)
195; CHECK-NEXT:    ]
196; CHECK-NEXT:    Offset: 0x0
197; CHECK-NEXT:    Segment: 0x1
198; CHECK-NEXT:    Size: 0x4
199; CHECK-NEXT:  }
200; CHECK-NEXT:  Symbol {
201; CHECK-NEXT:    Name: .debug_abbrev
202; CHECK-NEXT:    Type: SECTION (0x3)
203; CHECK-NEXT:    Flags [ (0x2)
204; CHECK-NEXT:      BINDING_LOCAL (0x2)
205; CHECK-NEXT:    ]
206; CHECK-NEXT:    ElementIndex: 0x7
207; CHECK-NEXT:  }
208; CHECK-NEXT:  Symbol {
209; CHECK-NEXT:    Name: .debug_info
210; CHECK-NEXT:    Type: SECTION (0x3)
211; CHECK-NEXT:    Flags [ (0x2)
212; CHECK-NEXT:      BINDING_LOCAL (0x2)
213; CHECK-NEXT:    ]
214; CHECK-NEXT:    ElementIndex: 0x8
215; CHECK-NEXT:  }
216; CHECK-NEXT:  Symbol {
217; CHECK-NEXT:    Name: __stack_pointer
218; CHECK-NEXT:    Type: GLOBAL (0x2)
219; CHECK-NEXT:    Flags [ (0x10)
220; CHECK-NEXT:      UNDEFINED (0x10)
221; CHECK-NEXT:    ]
222; CHECK-NEXT:    ImportModule: env
223; CHECK-NEXT:    ElementIndex: 0x0
224; CHECK-NEXT:  }
225; CHECK-NEXT:  Symbol {
226; CHECK-NEXT:    Name: .debug_str
227; CHECK-NEXT:    Type: SECTION (0x3)
228; CHECK-NEXT:    Flags [ (0x2)
229; CHECK-NEXT:      BINDING_LOCAL (0x2)
230; CHECK-NEXT:    ]
231; CHECK-NEXT:    ElementIndex: 0x9
232; CHECK-NEXT:  }
233; CHECK-NEXT:  Symbol {
234; CHECK-NEXT:    Name: .debug_line
235; CHECK-NEXT:    Type: SECTION (0x3)
236; CHECK-NEXT:    Flags [ (0x2)
237; CHECK-NEXT:      BINDING_LOCAL (0x2)
238; CHECK-NEXT:    ]
239; CHECK-NEXT:    ElementIndex: 0xC
240; CHECK-NEXT:  }
241; CHECK-NEXT:]
242
243; generated from the following C code using: clang --target=wasm32 -g -O0 -S -emit-llvm test.c
244; extern int myextern;
245; void f2(void) { return; }
246;
247; int* foo = &myextern;
248; void (*ptr2)(void) = f2;
249
250target triple = "wasm32-unknown-unknown"
251
252source_filename = "test.c"
253
254@myextern = external global i32, align 4
255@foo = hidden global i32* @myextern, align 4, !dbg !0
256@ptr2 = hidden global void ()* @f2, align 4, !dbg !6
257
258; Function Attrs: noinline nounwind optnone
259define hidden void @f2() #0 !dbg !17 {
260entry:
261  ret void, !dbg !18
262}
263
264attributes #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"="generic" "unsafe-fp-math"="false" "use-soft-float"="false" }
265
266!llvm.dbg.cu = !{!2}
267!llvm.module.flags = !{!13, !14, !15}
268!llvm.ident = !{!16}
269
270!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
271!1 = distinct !DIGlobalVariable(name: "foo", scope: !2, file: !3, line: 4, type: !11, isLocal: false, isDefinition: true)
272!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)
273!3 = !DIFile(filename: "test.c", directory: "/usr/local/google/home/sbc/dev/wasm/simple")
274!4 = !{}
275!5 = !{!0, !6}
276!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
277!7 = distinct !DIGlobalVariable(name: "ptr2", scope: !2, file: !3, line: 5, type: !8, isLocal: false, isDefinition: true)
278!8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 32)
279!9 = !DISubroutineType(types: !10)
280!10 = !{null}
281!11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 32)
282!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
283!13 = !{i32 2, !"Dwarf Version", i32 4}
284!14 = !{i32 2, !"Debug Info Version", i32 3}
285!15 = !{i32 1, !"wchar_size", i32 4}
286!16 = !{!"clang version 7.0.0 (trunk 332303) (llvm/trunk 332406)"}
287!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)
288!18 = !DILocation(line: 2, column: 17, scope: !17)
289