xref: /llvm-project/lld/test/wasm/stack-first.test (revision 13ca0c87edd026813ef7cbf3fbeb0efdb9c8bd3c)
1; Test that the --stack-first option places the stack at the start of linear
2; memory.  In this case the --stack-first option is being passed along with a
3; stack size of 512.  This means (since the stack grows down) the stack pointer
4; global should be initialized to 512.
5; Also test that __heap_base is still aligned with the --stack-first option.
6
7RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/stack-first.s -o %t.o
8RUN: wasm-ld -z stack-size=512 --stack-first --export=__data_end --export=__heap_base --export=someByte -o %t.wasm %t.o
9RUN: obj2yaml %t.wasm | FileCheck %s
10
11CHECK:        - Type:            GLOBAL
12CHECK-NEXT:     Globals:
13CHECK-NEXT:       - Index:           0
14CHECK-NEXT:         Type:            I32
15CHECK-NEXT:         Mutable:         true
16CHECK-NEXT:         InitExpr:
17CHECK-NEXT:           Opcode:          I32_CONST
18CHECK-NEXT:           Value:           512
19CHECK-NEXT:       - Index:           1
20CHECK-NEXT:         Type:            I32
21CHECK-NEXT:         Mutable:         false
22CHECK-NEXT:         InitExpr:
23CHECK-NEXT:           Opcode:          I32_CONST
24CHECK-NEXT:           Value:           512
25CHECK-NEXT:       - Index:           2
26CHECK-NEXT:         Type:            I32
27CHECK-NEXT:         Mutable:         false
28CHECK-NEXT:         InitExpr:
29CHECK-NEXT:           Opcode:          I32_CONST
30CHECK-NEXT:           Value:           513
31CHECK-NEXT:       - Index:           3
32CHECK-NEXT:         Type:            I32
33CHECK-NEXT:         Mutable:         false
34CHECK-NEXT:         InitExpr:
35CHECK-NEXT:           Opcode:          I32_CONST
36CHECK-NEXT:           Value:           528
37CHECK-NEXT:   - Type:            EXPORT
38CHECK-NEXT:     Exports:
39CHECK-NEXT:       - Name:            memory
40CHECK-NEXT:         Kind:            MEMORY
41CHECK-NEXT:         Index:           0
42CHECK-NEXT:       - Name:            _start
43CHECK-NEXT:         Kind:            FUNCTION
44CHECK-NEXT:         Index:           0
45CHECK-NEXT:       - Name:            someByte
46CHECK-NEXT:         Kind:            GLOBAL
47CHECK-NEXT:         Index:           1
48CHECK-NEXT:       - Name:            __data_end
49CHECK-NEXT:         Kind:            GLOBAL
50CHECK-NEXT:         Index:           2
51CHECK-NEXT:       - Name:            __heap_base
52CHECK-NEXT:         Kind:            GLOBAL
53CHECK-NEXT:         Index:           3
54