104 lines · plain
1# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/start.s -o %t.start.o2# RUN: wasm-ld --export-memory=foo -o %t.wasm %t.start.o3# RUN: obj2yaml %t.wasm | FileCheck %s4 5# Verify that the --export-memory=<name> option changes the exported name of the module's memory6 7# CHECK: - Type: EXPORT8# CHECK-NEXT: Exports:9# CHECK-NEXT: - Name: foo10# CHECK-NEXT: Kind: MEMORY11# CHECK-NEXT: Index: 012# CHECK-NEXT: - Name: _start13# CHECK-NEXT: Kind: FUNCTION14# CHECK-NEXT: Index: 015# CHECK-NEXT: - Type:16 17# RUN:wasm-ld --export-memory --export-memory -o %t.unnamed.wasm %t.start.o18# RUN: obj2yaml %t.unnamed.wasm | FileCheck -check-prefix=CHECK-UNNAMED %s19 20# Verify that the --export-memory option without a parameter exports the memory21# as "memory"22 23# CHECK-UNNAMED: - Type: EXPORT24# CHECK-UNNAMED-NEXT: Exports:25# CHECK-UNNAMED-NEXT: - Name: memory26# CHECK-UNNAMED-NEXT: Kind: MEMORY27# CHECK-UNNAMED-NEXT: Index: 028# CHECK-UNNAMED-NEXT: - Name: _start29# CHECK-UNNAMED-NEXT: Kind: FUNCTION30# CHECK-UNNAMED-NEXT: Index: 031# CHECK-UNNAMED-NEXT: - Type:32 33# RUN:wasm-ld --export-memory=foo --export-memory=foo -o %t.duplicate.wasm %t.start.o34# RUN: obj2yaml %t.duplicate.wasm | FileCheck -check-prefix=CHECK-DUPLICATE %s35 36# Verify that passing --export-memory with the same name twice works37 38# CHECK-DUPLICATE: - Type: EXPORT39# CHECK-DUPLICATE-NEXT: Exports:40# CHECK-DUPLICATE-NEXT: - Name: foo41# CHECK-DUPLICATE-NEXT: Kind: MEMORY42# CHECK-DUPLICATE-NEXT: Index: 043# CHECK-DUPLICATE-NEXT: - Name: _start44# CHECK-DUPLICATE-NEXT: Kind: FUNCTION45# CHECK-DUPLICATE-NEXT: Index: 046# CHECK-DUPLICATE-NEXT: - Type:47 48# RUN:wasm-ld --import-memory=foo,bar -o %t.import.wasm %t.start.o49# RUN: obj2yaml %t.import.wasm | FileCheck -check-prefix=CHECK-IMPORT %s50 51# Verify that memory imports can be renamed, and that no memory is exported by52# default when memory is being imported53 54# CHECK-IMPORT: - Type: IMPORT55# CHECK-IMPORT-NEXT: Imports:56# CHECK-IMPORT-NEXT: - Module: foo57# CHECK-IMPORT-NEXT: Field: bar58# CHECK-IMPORT-NEXT: Kind: MEMORY59# CHECK-IMPORT-NEXT: Memory:60# CHECK-IMPORT-NEXT: Minimum: 0x161# CHECK-IMPORT: - Type: EXPORT62# CHECK-IMPORT-NEXT: Exports:63# CHECK-IMPORT-NEXT: - Name: _start64# CHECK-IMPORT-NEXT: Kind: FUNCTION65# CHECK-IMPORT-NEXT: Index: 066# CHECK-IMPORT-NEXT: - Type:67 68# RUN:wasm-ld --import-memory=foo -o %t.import.wasm %t.start.o69# RUN: obj2yaml %t.import.wasm | FileCheck -check-prefix=CHECK-IMPORT-DEFAULT %s70 71# Verify that memory import module defaults to `env`, which is the default72# module for all imports.73 74# CHECK-IMPORT-DEFAULT: - Type: IMPORT75# CHECK-IMPORT-DEFAULT-NEXT: Imports:76# CHECK-IMPORT-DEFAULT-NEXT: - Module: env77# CHECK-IMPORT-DEFAULT-NEXT: Field: foo78# CHECK-IMPORT-DEFAULT-NEXT: Kind: MEMORY79# CHECK-IMPORT-DEFAULT-NEXT: Memory:80# CHECK-IMPORT-DEFAULT-NEXT: Minimum: 0x181# CHECK-IMPORT-DEFAULT-NEXT: - Type:82 83# RUN:wasm-ld --import-memory=foo,bar --export-memory=qux -o %t.both.wasm %t.start.o84# RUN: obj2yaml %t.both.wasm | FileCheck -check-prefix=CHECK-BOTH %s85 86# Verify that memory can be both imported and exported from a module87 88# CHECK-BOTH: - Type: IMPORT89# CHECK-BOTH-NEXT: Imports:90# CHECK-BOTH-NEXT: - Module: foo91# CHECK-BOTH-NEXT: Field: bar92# CHECK-BOTH-NEXT: Kind: MEMORY93# CHECK-BOTH-NEXT: Memory:94# CHECK-BOTH-NEXT: Minimum: 0x195# CHECK-BOTH: - Type: EXPORT96# CHECK-BOTH-NEXT: Exports:97# CHECK-BOTH-NEXT: - Name: qux98# CHECK-BOTH-NEXT: Kind: MEMORY99# CHECK-BOTH-NEXT: Index: 0100# CHECK-BOTH-NEXT: - Name: _start101# CHECK-BOTH-NEXT: Kind: FUNCTION102# CHECK-BOTH-NEXT: Index: 0103# CHECK-BOTH-NEXT: - Type:104