1
- # RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %s -o %t1.o
1
+ # RUN: split-file %s %t
2
+ # RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %t/main.s -o %t/main.o
3
+ # RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %t/secondary.s -o %t/secondary.o
2
4
3
- ## Check that %t1 .o contains undefined symbol undef_func.
4
- # RUN: not wasm-ld %t1 .o -o /dev/null 2>&1 | \
5
+ ## Check that %t/main .o contains undefined symbol undef_func.
6
+ # RUN: not wasm-ld --no-gc-sections %t/main.o %t/secondary .o -o /dev/null 2>&1 | \
5
7
# RUN: FileCheck -check-prefix=ERRUND %s
6
- # ERRUND: error: {{.*}}1.o: undefined symbol: undef_func
8
+ # ERRUND: error: {{.*}}main.o: undefined symbol: undef_func
9
+ # ERRUND: error: {{.*}}secondary.o: undefined symbol: undef_func
7
10
8
11
## 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 | \
12
+ # RUN: not wasm-ld --no-gc-sections %t/main.o %t/secondary .o -o /dev/null --unresolved-symbols=report-all 2>&1 | \
10
13
# RUN: FileCheck -check-prefix=ERRUND %s
11
14
12
15
## Error out if unknown option value was set.
13
- # RUN: not wasm-ld %t1 .o -o /dev/null --unresolved-symbols=xxx 2>&1 | \
16
+ # RUN: not wasm-ld %t/main .o -o /dev/null --unresolved-symbols=xxx 2>&1 | \
14
17
# RUN: FileCheck -check-prefix=ERR1 %s
15
18
# ERR1: unknown --unresolved-symbols value: xxx
16
19
## Check alias.
17
- # RUN: not wasm-ld %t1 .o -o /dev/null --unresolved-symbols xxx 2>&1 | \
20
+ # RUN: not wasm-ld %t/main .o -o /dev/null --unresolved-symbols xxx 2>&1 | \
18
21
# RUN: FileCheck -check-prefix=ERR1 %s
19
22
20
23
## Ignore all should not produce error and should not produce
21
24
## any imports. It should create a stub function in the place of the missing
22
25
## function symbol.
23
- # RUN: wasm-ld %t1 .o -o %t2.wasm --unresolved-symbols=ignore-all
26
+ # RUN: wasm-ld %t/main .o -o %t2.wasm --unresolved-symbols=ignore-all
24
27
# RUN: obj2yaml %t2.wasm | FileCheck -check-prefix=IGNORE %s
25
28
26
29
## --warn-unresolved-symbols should behave the same
27
- # RUN: wasm-ld %t1 .o -o %t2.wasm --warn-unresolved-symbols
30
+ # RUN: wasm-ld %t/main .o -o %t2.wasm --warn-unresolved-symbols
28
31
# RUN: obj2yaml %t2.wasm | FileCheck -check-prefix=IGNORE %s
29
32
30
33
# IGNORE-NOT: - Type: IMPORT
61
64
## by importing them but still report errors/warning for missing data symbols.
62
65
## `--allow-undefined` should behave like `--import-undefined` +
63
66
## `--unresolve-symbols=ignore`
64
- # RUN: wasm-ld %t1 .o -o %t3.wasm --import-undefined --unresolved-symbols=ignore-all
67
+ # RUN: wasm-ld %t/main .o -o %t3.wasm --import-undefined --unresolved-symbols=ignore-all
65
68
# RUN: obj2yaml %t3.wasm | FileCheck -check-prefix=IMPORT %s
66
69
# IMPORT: - Type: IMPORT
67
70
# IMPORT-NEXT: Imports:
72
75
# IMPORT-NEXT: - Type: FUNCTION
73
76
74
77
## Check that --import-undefined reports unresolved data symbols.
75
- # RUN: not wasm-ld %t1 .o -o %t3.wasm --import-undefined --unresolved-symbols=report-all 2>&1 | FileCheck -check-prefix=IMPORTUNDEFINED %s
76
- # IMPORTUNDEFINED-NOT: error: {{.*}}1 .o: undefined symbol: undef_func
77
- # IMPORTUNDEFINED: error: {{.*}}1 .o: undefined symbol: undef_data
78
+ # RUN: not wasm-ld %t/main .o -o %t3.wasm --import-undefined --unresolved-symbols=report-all 2>&1 | FileCheck -check-prefix=IMPORTUNDEFINED %s
79
+ # IMPORTUNDEFINED-NOT: error: {{.*}}main .o: undefined symbol: undef_func
80
+ # IMPORTUNDEFINED: error: {{.*}}main .o: undefined symbol: undef_data
78
81
79
82
## Do not report undefines if linking relocatable.
80
- # RUN: wasm-ld -r %t1 .o -o %t4.wasm --unresolved-symbols=report-all
83
+ # RUN: wasm-ld -r %t/main .o -o %t4.wasm --unresolved-symbols=report-all
81
84
# RUN: llvm-readobj %t4.wasm > /dev/null 2>&1
82
85
83
- .functype undef_func () -> ()
84
- .functype get_data_addr () -> (i32)
85
- .functype get_func_addr () -> (i32)
86
-
87
86
## import-dynamic should fail due to incompatible relocations.
88
- # RUN: not wasm-ld %t1 .o -o %t5.wasm --unresolved-symbols=import-dynamic 2>&1 | FileCheck -check-prefix=ERRNOPIC %s
87
+ # RUN: not wasm-ld %t/main .o -o %t5.wasm --unresolved-symbols=import-dynamic 2>&1 | FileCheck -check-prefix=ERRNOPIC %s
89
88
# ERRNOPIC: relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol `undef_data`; recompile with -fPIC
90
89
# ERRNOPIC: relocation R_WASM_TABLE_INDEX_SLEB cannot be used against symbol `undef_func`; recompile with -fPIC
91
90
91
+ #--- main.s
92
+
93
+ .functype undef_func () -> ()
94
+ .functype get_data_addr () -> (i32)
95
+ .functype get_func_addr () -> (i32)
96
+
92
97
.globl _start
93
98
_start:
94
99
.functype _start () -> ()
@@ -112,3 +117,12 @@ get_func_addr:
112
117
i32.const undef_func
113
118
return
114
119
end_function
120
+
121
+ #--- secondary.s
122
+
123
+ .functype undef_func () -> ()
124
+ .globl foo
125
+ foo:
126
+ .functype foo () -> ()
127
+ call undef_func
128
+ end_function
0 commit comments