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