|
17 | 17 | ; RUN: wasm-ld -mwasm64 -no-gc-sections --no-entry %t.bulk-mem64.o -o %t.bulk-mem64.wasm
|
18 | 18 | ; RUN: obj2yaml %t.bulk-mem64.wasm | FileCheck %s --check-prefixes ACTIVE,ACTIVE64
|
19 | 19 |
|
| 20 | +;; In -pie mode segments are combined into one active segment. |
| 21 | +; RUN: wasm-ld --experimental-pic --import-memory -pie -no-gc-sections --no-entry %t.atomics.bulk-mem.pic.o -o %t.pic.wasm |
| 22 | +; RUN: obj2yaml %t.pic.wasm | FileCheck %s --check-prefixes ACTIVE-PIC |
| 23 | +; RUN: llvm-objdump --disassemble-symbols=__wasm_call_ctors,__wasm_init_memory --no-show-raw-insn --no-leading-addr %t.pic.wasm | FileCheck %s --check-prefixes PIC-NON-SHARED-DIS |
| 24 | + |
20 | 25 | ;; atomics, bulk memory, shared memory => passive segments
|
21 | 26 | ; RUN: wasm-ld -no-gc-sections --no-entry --shared-memory --max-memory=131072 %t.atomics.bulk-mem.o -o %t.atomics.bulk-mem.wasm
|
22 | 27 | ; RUN: obj2yaml %t.atomics.bulk-mem.wasm | FileCheck %s --check-prefix PASSIVE
|
|
28 | 33 | ; RUN: llvm-objdump --disassemble-symbols=__wasm_call_ctors,__wasm_init_memory --no-show-raw-insn --no-leading-addr %t.atomics.bulk-mem64.wasm | FileCheck %s --check-prefixes DIS,NOPIC-DIS -DPTR=i64
|
29 | 34 |
|
30 | 35 | ;; Also test in combination with PIC/pie
|
31 |
| -; RUN: wasm-ld --experimental-pic -pie -no-gc-sections --no-entry --shared-memory --max-memory=131072 %t.atomics.bulk-mem.pic.o -o %t.pic.wasm |
32 |
| -; RUN: obj2yaml %t.pic.wasm | FileCheck %s --check-prefixes PASSIVE-PIC,PASSIVE32-PIC |
33 |
| -; RUN: llvm-objdump --disassemble-symbols=__wasm_call_ctors,__wasm_init_memory --no-show-raw-insn --no-leading-addr %t.pic.wasm | FileCheck %s --check-prefixes DIS,PIC-DIS -DPTR=i32 |
| 36 | +; RUN: wasm-ld --experimental-pic -pie -no-gc-sections --no-entry --shared-memory --max-memory=131072 %t.atomics.bulk-mem.pic.o -o %t.shared.pic.wasm |
| 37 | +; RUN: obj2yaml %t.shared.pic.wasm | FileCheck %s --check-prefixes PASSIVE-PIC,PASSIVE32-PIC |
| 38 | +; RUN: llvm-objdump --disassemble-symbols=__wasm_call_ctors,__wasm_init_memory --no-show-raw-insn --no-leading-addr %t.shared.pic.wasm | FileCheck %s --check-prefixes DIS,PIC-DIS -DPTR=i32 |
34 | 39 |
|
35 | 40 | ;; Also test in combination with PIC/pie + wasm64
|
36 | 41 | ; RUN: wasm-ld -mwasm64 --experimental-pic -pie -no-gc-sections --no-entry --shared-memory --max-memory=131072 %t.atomics.bulk-mem.pic-mem64.o -o %t.pic-mem64.wasm
|
|
47 | 52 |
|
48 | 53 | @g = thread_local global i32 99, align 4
|
49 | 54 |
|
50 |
| -; ERROR: 'bulk-memory' feature must be used in order to use shared memory |
| 55 | +;; ERROR: 'bulk-memory' feature must be used in order to use shared memory |
51 | 56 |
|
52 | 57 | ; ACTIVE-LABEL: - Type: CODE
|
53 | 58 | ; ACTIVE-NEXT: Functions:
|
|
76 | 81 | ; ACTIVE-NEXT: - Index: 0
|
77 | 82 | ; ACTIVE-NEXT: Name: __wasm_call_ctors
|
78 | 83 |
|
| 84 | +;; In ACTIVE-PIC mode the memory is imported which means all data segments |
| 85 | +;; (except BSS) are combined in the single one. |
| 86 | +;; BSS is not included here, and instead initialized using `memory.init` in |
| 87 | +;; `__wasm_init_memory` |
| 88 | + |
| 89 | +; ACTIVE-PIC: - Type: DATA |
| 90 | +; ACTIVE-PIC-NEXT: Segments: |
| 91 | +; ACTIVE-PIC-NEXT: - SectionOffset: 6 |
| 92 | +; ACTIVE-PIC-NEXT: InitFlags: 0 |
| 93 | +; ACTIVE-PIC-NEXT: Offset: |
| 94 | +; ACTIVE-PIC-NEXT: Opcode: GLOBAL_GET |
| 95 | +; ACTIVE-PIC-NEXT: Index: 1 |
| 96 | +; ACTIVE-PIC-NEXT: Content: 63000000636F6E7374616E74000000002B00000068656C6C6F00676F6F646279650000002A000000 |
| 97 | + |
79 | 98 | ; PASSIVE-LABEL: - Type: START
|
80 | 99 | ; PASSIVE-NEXT: StartFunction: 2
|
81 | 100 | ; PASSIVE-LABEL: - Type: DATACOUNT
|
|
151 | 170 | ; PASSIVE-PIC-NEXT: - Index: 2
|
152 | 171 | ; PASSIVE-PIC-NEXT: Name: __wasm_init_memory
|
153 | 172 |
|
| 173 | +;; For the non-shared PIC case the __wasm_init_memory only deals with BSS since |
| 174 | +;; all other segments are active |
| 175 | +; PIC-NON-SHARED-DIS: <__wasm_init_memory>: |
| 176 | +; PIC-NON-SHARED-DIS-EMPTY: |
| 177 | +; PIC-NON-SHARED-DIS-NEXT: i32.const 40 |
| 178 | +; PIC-NON-SHARED-DIS-NEXT: global.get 1 |
| 179 | +; PIC-NON-SHARED-DIS-NEXT: i32.add |
| 180 | +; PIC-NON-SHARED-DIS-NEXT: i32.const 0 |
| 181 | +; PIC-NON-SHARED-DIS-NEXT: i32.const 10000 |
| 182 | +; PIC-NON-SHARED-DIS-NEXT: memory.fill 0 |
| 183 | +; PIC-NON-SHARED-DIS-NEXT: end |
| 184 | + |
154 | 185 | ;; no data relocations.
|
155 | 186 | ; DIS-LABEL: <__wasm_call_ctors>:
|
156 | 187 | ; DIS-EMPTY:
|
|
0 commit comments