blob: d581c7e04e7485e924ccc08950fcb5c22c902852 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
(module
(import "wasi_snapshot_preview1" "environ_sizes_get" (func $wasi_environ_sizes_get (param i32 i32) (result i32)))
(import "wasi_snapshot_preview1" "environ_get" (func $wasi_environ_get (param i32 i32) (result i32)))
(import "wasi_snapshot_preview1" "args_sizes_get" (func $wasi_args_sizes_get (param i32 i32) (result i32)))
(import "wasi_snapshot_preview1" "args_get" (func $wasi_args_get (param i32 i32) (result i32)))
(import "wasi_snapshot_preview1" "something_else" (func $wasi_something_else (result i32)))
(memory 256 256)
(data (i32.const 0) "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") ;; the final 4 'a's will remain
(func $test1 (export "test1")
;; This is ok to call: when ignoring external input we assume there is no
;; environment to read.
(i32.store
(i32.const 0) ;; the result (0) will be written to address 0
(call $wasi_environ_sizes_get
(i32.const 4) ;; count (0) will be written to address 4
(i32.const 0)
)
)
(i32.store
(i32.const 8) ;; the result (0) will be written to address 8
(call $wasi_environ_get
(i32.const 0)
(i32.const 0)
)
)
)
(func $test2 (export "test2")
;; This is also ok to call: when ignoring external input we assume there are
;; not args passed to main.
(i32.store
(i32.const 12) ;; the result (0) will be written to address 12
(call $wasi_args_sizes_get
(i32.const 16) ;; argc (0) will be written to address 16
(i32.const 0)
)
)
(i32.store
(i32.const 20) ;; the result (0) will be written to address 20
(call $wasi_args_get
(i32.const 0)
(i32.const 0)
)
)
)
(func $test2b (export "test2b") (param $x i32)
;; This is also ok to call: when ignoring external input we assume the
;; args are zeros.
(i32.store
(i32.const 24) ;; the result (0) will be written to address 24
(local.get $x)
)
)
(func $test3 (export "test3")
;; This is *not* ok to call, and we will *not* reach the final store after
;; this call. This function will not be evalled and will remain in the
;; output.
(drop
(call $wasi_something_else)
)
(i32.store
(i32.const 28)
(i32.const 100)
)
)
)
|