1 RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/start.s -o %t.o
3 # Check for error on `--global-base` with `-shared` and `-pie`
4 RUN: not wasm-ld --global-base=2048 --experimental-pic -shared -o %t.wasm %t.o 2>&1 | FileCheck %s -check-prefix=SHARED-ERROR
5 RUN: not wasm-ld --global-base=2048 --experimental-pic -pie -o %t.wasm %t.o 2>&1 | FileCheck %s -check-prefix=SHARED-ERROR
6 SHARED-ERROR: error: --global-base may not be used with -shared/-pie
8 # Check for error on `--global-base` which is lower than that end of the stack
9 # when `--stack-first` is used.
10 RUN: not wasm-ld --global-base=2048 --stack-first -o %t.wasm %t.o 2>&1 | FileCheck %s -check-prefix=STACK-ERROR
11 STACK-ERROR: error: --global-base cannot be less than stack size when --stack-first is used
13 RUN: wasm-ld --export=__global_base --export=__data_end --allow-undefined -o %t.wasm %t.o
14 RUN: obj2yaml %t.wasm | FileCheck %s -check-prefix=CHECK-1024
15 CHECK-1024: - Type: GLOBAL
16 CHECK-1024-NEXT: Globals:
17 CHECK-1024-NEXT: - Index: 0
18 CHECK-1024-NEXT: Type: I32
19 CHECK-1024-NEXT: Mutable: true
20 CHECK-1024-NEXT: InitExpr:
21 CHECK-1024-NEXT: Opcode: I32_CONST
22 CHECK-1024-NEXT: Value: 66560
23 CHECK-1024-NEXT: - Index: 1
24 CHECK-1024-NEXT: Type: I32
25 CHECK-1024-NEXT: Mutable: false
26 CHECK-1024-NEXT: InitExpr:
27 CHECK-1024-NEXT: Opcode: I32_CONST
28 CHECK-1024-NEXT: Value: 1024
29 CHECK-1024-NEXT: - Index: 2
30 CHECK-1024-NEXT: Type: I32
31 CHECK-1024-NEXT: Mutable: false
32 CHECK-1024-NEXT: InitExpr:
33 CHECK-1024-NEXT: Opcode: I32_CONST
34 CHECK-1024-NEXT: Value: 1024
36 CHECK-1024: - Type: EXPORT
37 CHECK-1024: - Name: __data_end
38 CHECK-1024-NEXT: Kind: GLOBAL
39 CHECK-1024-NEXT: Index: 1
40 CHECK-1024-NEXT: - Name: __global_base
41 CHECK-1024-NEXT: Kind: GLOBAL
42 CHECK-1024-NEXT: Index: 2
44 RUN: wasm-ld --export=__global_base --export=__data_end --allow-undefined --global-base=16777216 -o %t.wasm %t.o
45 RUN: obj2yaml %t.wasm | FileCheck %s -check-prefix=CHECK-16777216
46 CHECK-16777216: - Type: GLOBAL
47 CHECK-16777216-NEXT: Globals:
48 CHECK-16777216-NEXT: - Index: 0
49 CHECK-16777216-NEXT: Type: I32
50 CHECK-16777216-NEXT: Mutable: true
51 CHECK-16777216-NEXT: InitExpr:
52 CHECK-16777216-NEXT: Opcode: I32_CONST
53 CHECK-16777216-NEXT: Value: 16842752
54 CHECK-16777216-NEXT: - Index: 1
55 CHECK-16777216-NEXT: Type: I32
56 CHECK-16777216-NEXT: Mutable: false
57 CHECK-16777216-NEXT: InitExpr:
58 CHECK-16777216-NEXT: Opcode: I32_CONST
59 CHECK-16777216-NEXT: Value: 16777216
60 CHECK-16777216-NEXT: - Index: 2
61 CHECK-16777216-NEXT: Type: I32
62 CHECK-16777216-NEXT: Mutable: false
63 CHECK-16777216-NEXT: InitExpr:
64 CHECK-16777216-NEXT: Opcode: I32_CONST
65 CHECK-16777216-NEXT: Value: 16777216
67 CHECK-16777216: - Type: EXPORT
68 CHECK-16777216: - Name: __data_end
69 CHECK-16777216-NEXT: Kind: GLOBAL
70 CHECK-16777216-NEXT: Index: 1
71 CHECK-16777216-NEXT: - Name: __global_base
72 CHECK-16777216-NEXT: Kind: GLOBAL
73 CHECK-16777216-NEXT: Index: 2