llvm-project
70 строк · 2.4 Кб
1# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
2# RUN: wasm-ld --relocatable -o %t.wasm %t.o
3# RUN: obj2yaml %t.wasm | FileCheck %s
4
5.globaltype __stack_pointer, i32
6
7.globl _start
8_start:
9.functype _start () -> (i32)
10global.get __stack_pointer
11i32.const 16
12i32.sub
13drop
14i32.const 0
15end_function
16
17# CHECK: --- !WASM
18# CHECK-NEXT: FileHeader:
19# CHECK-NEXT: Version: 0x1
20# CHECK-NEXT: Sections:
21# CHECK-NEXT: - Type: TYPE
22# CHECK-NEXT: Signatures:
23# CHECK-NEXT: - Index: 0
24# CHECK-NEXT: ParamTypes:
25# CHECK-NEXT: ReturnTypes:
26# CHECK-NEXT: - I32
27# CHECK-NEXT: - Type: IMPORT
28# CHECK-NEXT: Imports:
29# CHECK-NEXT: - Module: env
30# CHECK-NEXT: Field: __stack_pointer
31# CHECK-NEXT: Kind: GLOBAL
32# CHECK-NEXT: GlobalType: I32
33# CHECK-NEXT: GlobalMutable: true
34# CHECK-NEXT: - Type: FUNCTION
35# CHECK-NEXT: FunctionTypes: [ 0 ]
36# CHECK-NEXT: - Type: MEMORY
37# CHECK-NEXT: Memories:
38# CHECK-NEXT: - Minimum: 0x0
39# CHECK-NEXT: - Type: CODE
40# CHECK-NEXT: Relocations:
41# CHECK-NEXT: - Type: R_WASM_GLOBAL_INDEX_LEB
42# CHECK-NEXT: Index: 1
43# CHECK-NEXT: Offset: 0x4
44# CHECK-NEXT: Functions:
45# CHECK-NEXT: - Index: 0
46# CHECK-NEXT: Locals:
47# CHECK-NEXT: Body: 23808080800041106B1A41000B
48# CHECK-NEXT: - Type: CUSTOM
49# CHECK-NEXT: Name: linking
50# CHECK-NEXT: Version: 2
51# CHECK-NEXT: SymbolTable:
52# CHECK-NEXT: - Index: 0
53# CHECK-NEXT: Kind: FUNCTION
54# CHECK-NEXT: Name: _start
55# CHECK-NEXT: Flags: [ ]
56# CHECK-NEXT: Function: 0
57# CHECK-NEXT: - Index: 1
58# CHECK-NEXT: Kind: GLOBAL
59# CHECK-NEXT: Name: __stack_pointer
60# CHECK-NEXT: Flags: [ UNDEFINED ]
61# CHECK-NEXT: Global: 0
62# CHECK-NEXT: - Type: CUSTOM
63# CHECK-NEXT: Name: name
64# CHECK-NEXT: FunctionNames:
65# CHECK-NEXT: - Index: 0
66# CHECK-NEXT: Name: _start
67# CHECK-NEXT: GlobalNames:
68# CHECK-NEXT: - Index: 0
69# CHECK-NEXT: Name: __stack_pointer
70# CHECK-NEXT: ...
71