• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %s -o %t1.o
2
3## Check that %t1.o contains undefined symbol undef.
4# RUN: not wasm-ld %t1.o -o /dev/null 2>&1 | \
5# RUN:   FileCheck -check-prefix=ERRUND %s
6# ERRUND: error: {{.*}}1.o: undefined symbol: undef
7
8## report-all is the default one. Check that we get the same error
9# RUN: not wasm-ld %t1.o -o /dev/null --unresolved-symbols=report-all 2>&1 | \
10# RUN:   FileCheck -check-prefix=ERRUND %s
11
12## Error out if unknown option value was set.
13# RUN: not wasm-ld %t1.o -o /dev/null --unresolved-symbols=xxx 2>&1 | \
14# RUN:   FileCheck -check-prefix=ERR1 %s
15# ERR1: unknown --unresolved-symbols value: xxx
16## Check alias.
17# RUN: not wasm-ld %t1.o -o /dev/null --unresolved-symbols xxx 2>&1 | \
18# RUN:   FileCheck -check-prefix=ERR1 %s
19
20## Ignore all should not produce error and should not produce
21# any imports.  It should create a stub function in the place of the missing
22# function symbol.
23# RUN: wasm-ld %t1.o -o %t2.wasm --unresolved-symbols=ignore-all
24# RUN: obj2yaml %t2.wasm | FileCheck -check-prefix=IGNORE %s
25# IGNORE-NOT: - Type:            IMPORT
26# IGNORE-NOT: - Type:            ELEM
27#
28#      IGNORE:  - Type:            CODE
29# IGNORE-NEXT:    Functions:
30# IGNORE-NEXT:      - Index:           0
31# IGNORE-NEXT:        Locals:          []
32# IGNORE-NEXT:        Body:            000B
33# IGNORE-NEXT:      - Index:           1
34# IGNORE-NEXT:        Locals:          []
35# IGNORE-NEXT:        Body:            1080808080001082808080001083808080000B
36# IGNORE-NEXT:      - Index:           2
37# IGNORE-NEXT:        Locals:          []
38# IGNORE-NEXT:        Body:            4180808080000F0B
39# IGNORE-NEXT:      - Index:           3
40# IGNORE-NEXT:        Locals:          []
41# IGNORE-NEXT:        Body:            4180808080000F0B
42#
43#      IGNORE:  - Type:            CUSTOM
44# IGNORE-NEXT:    Name:            name
45# IGNORE-NEXT:    FunctionNames:
46# IGNORE-NEXT:      - Index:           0
47# IGNORE-NEXT:        Name:            undefined
48# IGNORE-NEXT:      - Index:           1
49# IGNORE-NEXT:        Name:            _start
50# IGNORE-NEXT:      - Index:           2
51# IGNORE-NEXT:        Name:            get_data_addr
52# IGNORE-NEXT:      - Index:           3
53# IGNORE-NEXT:        Name:            get_func_addr
54
55## import-functions should not produce errors and should resolve in
56# imports for the missing functions but not the missing data symbols.
57# `--allow-undefined` should behave exactly the same.
58# RUN: wasm-ld %t1.o -o %t3.wasm --unresolved-symbols=import-functions
59# RUN: obj2yaml %t3.wasm | FileCheck -check-prefix=IMPORT %s
60#      IMPORT:  - Type:            IMPORT
61# IMPORT-NEXT:    Imports:
62# IMPORT-NEXT:      - Module:          env
63# IMPORT-NEXT:        Field:           undef
64# IMPORT-NEXT:        Kind:            FUNCTION
65# IMPORT-NEXT:        SigIndex:        0
66# IMPORT-NEXT:  - Type:            FUNCTION
67
68## Do not report undefines if linking relocatable.
69# RUN: wasm-ld -r %t1.o -o %t4.wasm --unresolved-symbols=report-all
70# RUN: llvm-readobj %t4.wasm > /dev/null 2>&1
71
72.globl _start
73_start:
74    .functype _start () -> ()
75    call undef
76    call get_data_addr
77    call get_func_addr
78    end_function
79
80.globl get_data_addr
81get_data_addr:
82    .functype get_data_addr () -> (i32)
83    i32.const undef_data
84    return
85    end_function
86
87.globl get_func_addr
88get_func_addr:
89    .functype get_func_addr () -> (i32)
90    i32.const undef
91    return
92    end_function
93
94.functype undef () -> ()
95