127 lines · plain
1# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s2#3# Should fail without mutable globals feature enabled.4# RUN: not wasm-ld --export-all %t.o -o %t.wasm 2>&1 | FileCheck -check-prefix=CHECK-ERR %s5# RUN: not wasm-ld --export=foo_global %t.o -o %t.wasm 2>&1 | FileCheck -check-prefix=CHECK-ERR %s6 7# RUN: wasm-ld --extra-features=mutable-globals --export=foo_global %t.o -o %t.wasm8# RUN: obj2yaml %t.wasm | FileCheck %s9 10# Explcitly check that __stack_pointer can be exported11# RUN: wasm-ld --extra-features=mutable-globals --export=__stack_pointer %t.o -o %t.wasm12# RUN: obj2yaml %t.wasm | FileCheck -check-prefix=CHECK-SP %s13 14# RUN: wasm-ld --extra-features=mutable-globals --export-all %t.o -o %t.wasm15# RUN: obj2yaml %t.wasm | FileCheck -check-prefix=CHECK-ALL %s16 17.globl _start18.globl foo_global19.globl bar_global20 21.globaltype bar_global, i32, immutable22bar_global:23 24.globaltype foo_global, i3225foo_global:26 27_start:28 .functype _start () -> ()29 end_function30 31# Add a target feature and ensure that it is preserved when --extra-features is32# used above.33.section .custom_section.target_features,"",@34 .int8 135 .int8 4336 .int8 737 .ascii "atomics"38 39# CHECK-ERR: mutable global exported but 'mutable-globals' feature not present in inputs: `foo_global`. Use --no-check-features to suppress40# CHECK-ERR-NOT: bar_global41 42# CHECK: - Type: EXPORT43# CHECK-NEXT: Exports:44# CHECK-NEXT: - Name: memory45# CHECK-NEXT: Kind: MEMORY46# CHECK-NEXT: Index: 047# CHECK-NEXT: - Name: _start48# CHECK-NEXT: Kind: FUNCTION49# CHECK-NEXT: Index: 050# CHECK-NEXT: - Name: foo_global51# CHECK-NEXT: Kind: GLOBAL52# CHECK-NEXT: Index: 153# CHECK-NEXT: - Type: CODE54 55# CHECK-SP: - Type: EXPORT56# CHECK-SP-NEXT: Exports:57# CHECK-SP-NEXT: - Name: memory58# CHECK-SP-NEXT: Kind: MEMORY59# CHECK-SP-NEXT: Index: 060# CHECK-SP-NEXT: - Name: __stack_pointer61# CHECK-SP-NEXT: Kind: GLOBAL62# CHECK-SP-NEXT: Index: 063# CHECK-SP-NEXT: - Name: _start64# CHECK-SP-NEXT: Kind: FUNCTION65# CHECK-SP-NEXT: Index: 066# CHECK-SP-NEXT: - Type: CODE67 68# CHECK-ALL: - Type: EXPORT69# CHECK-ALL-NEXT: Exports:70# CHECK-ALL-NEXT: - Name: memory71# CHECK-ALL-NEXT: Kind: MEMORY72# CHECK-ALL-NEXT: Index: 073# CHECK-ALL-NEXT: - Name: __wasm_call_ctors74# CHECK-ALL-NEXT: Kind: FUNCTION75# CHECK-ALL-NEXT: Index: 076# CHECK-ALL-NEXT: - Name: __stack_pointer77# CHECK-ALL-NEXT: Kind: GLOBAL78# CHECK-ALL-NEXT: Index: 079# CHECK-ALL-NEXT: - Name: _start80# CHECK-ALL-NEXT: Kind: FUNCTION81# CHECK-ALL-NEXT: Index: 182# CHECK-ALL-NEXT: - Name: foo_global83# CHECK-ALL-NEXT: Kind: GLOBAL84# CHECK-ALL-NEXT: Index: 185# CHECK-ALL-NEXT: - Name: bar_global86# CHECK-ALL-NEXT: Kind: GLOBAL87# CHECK-ALL-NEXT: Index: 288# CHECK-ALL-NEXT: - Name: __dso_handle89# CHECK-ALL-NEXT: Kind: GLOBAL90# CHECK-ALL-NEXT: Index: 391# CHECK-ALL-NEXT: - Name: __data_end92# CHECK-ALL-NEXT: Kind: GLOBAL93# CHECK-ALL-NEXT: Index: 494# CHECK-ALL-NEXT: - Name: __stack_low95# CHECK-ALL-NEXT: Kind: GLOBAL96# CHECK-ALL-NEXT: Index: 597# CHECK-ALL-NEXT: - Name: __stack_high98# CHECK-ALL-NEXT: Kind: GLOBAL99# CHECK-ALL-NEXT: Index: 6100# CHECK-ALL-NEXT: - Name: __global_base101# CHECK-ALL-NEXT: Kind: GLOBAL102# CHECK-ALL-NEXT: Index: 7103# CHECK-ALL-NEXT: - Name: __heap_base104# CHECK-ALL-NEXT: Kind: GLOBAL105# CHECK-ALL-NEXT: Index: 8106# CHECK-ALL-NEXT: - Name: __heap_end107# CHECK-ALL-NEXT: Kind: GLOBAL108# CHECK-ALL-NEXT: Index: 9109# CHECK-ALL-NEXT: - Name: __memory_base110# CHECK-ALL-NEXT: Kind: GLOBAL111# CHECK-ALL-NEXT: Index: 10112# CHECK-ALL-NEXT: - Name: __table_base113# CHECK-ALL-NEXT: Kind: GLOBAL114# CHECK-ALL-NEXT: Index: 11115# CHECK-ALL-NEXT: - Name: __wasm_first_page_end116# CHECK-ALL-NEXT: Kind: GLOBAL117# CHECK-ALL-NEXT: Index: 12118# CHECK-ALL-NEXT: - Type: CODE119 120# CHECK-ALL: Name: target_features121# CHECK-ALL-NEXT: Features:122# CHECK-ALL-NEXT: - Prefix: USED123# CHECK-ALL-NEXT: Name: atomics124# CHECK-ALL-NEXT: - Prefix: USED125# CHECK-ALL-NEXT: Name: mutable-globals126# CHECK-ALL-NEXT: ...127