llvm-project
60 строк · 2.0 Кб
1# Test in default mode
2# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
3# RUN: not wasm-ld --export=missing -o %t.wasm %t.o 2>&1 | FileCheck -check-prefix=CHECK-ERROR %s
4# RUN: wasm-ld --export=hidden_function -o %t.wasm %t.o
5# RUN: obj2yaml %t.wasm | FileCheck %s
6
7# Now test in Emscripten mode
8# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-emscripten -o %t.o %s
9# RUN: not wasm-ld --export=missing -o %t.wasm %t.o 2>&1 | FileCheck -check-prefix=CHECK-ERROR %s
10# RUN: wasm-ld --export=hidden_function -o %t.wasm %t.o
11# RUN: obj2yaml %t.wasm | FileCheck %s --check-prefixes=CHECK,EMSCRIPTEN
12
13# Not exported by default, but forced via commandline
14.hidden hidden_function
15.globl hidden_function
16hidden_function:
17.functype hidden_function () -> (i32)
18i32.const 0
19end_function
20
21# Not exported by default
22.globl default_function
23default_function:
24.functype default_function () -> (i32)
25i32.const 0
26end_function
27
28# Exported in emscripten mode which treats .no_dead_strip as a signal to export
29.no_dead_strip used_function
30.globl used_function
31used_function:
32.functype used_function () -> (i32)
33i32.const 0
34end_function
35
36# Exported by default
37.globl _start
38_start:
39.functype _start () -> ()
40end_function
41
42# CHECK-ERROR: error: symbol exported via --export not found: missing
43
44# CHECK-NOT: - Name: default_function
45
46# CHECK: - Type: EXPORT
47# CHECK-NEXT: Exports:
48# CHECK-NEXT: - Name: memory
49# CHECK-NEXT: Kind: MEMORY
50# CHECK-NEXT: Index: 0
51# CHECK-NEXT: - Name: hidden_function
52# CHECK-NEXT: Kind: FUNCTION
53# CHECK-NEXT: Index: 0
54# EMSCRIPTEN-NEXT: - Name: used_function
55# EMSCRIPTEN-NEXT: Kind: FUNCTION
56# EMSCRIPTEN-NEXT: Index: 1
57# CHECK-NEXT: - Name: _start
58# CHECK-NEXT: Kind: FUNCTION
59# CHECK-NEXT: Index: 2
60# CHECK-NEXT: - Type: CODE
61