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
24
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 | \
58# 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
711
812## 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 | \
1014# RUN: FileCheck -check-prefix=ERRUND %s
1115
1216## 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 | \
1418# RUN: FileCheck -check-prefix=ERR1 %s
1519# ERR1: unknown --unresolved-symbols value: xxx
1620## 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 | \
1822# RUN: FileCheck -check-prefix=ERR1 %s
1923
2024## Ignore all should not produce error and should not produce
2125## any imports. It should create a stub function in the place of the missing
2226## 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
2428# RUN: obj2yaml %t2.wasm | FileCheck -check-prefix=IGNORE %s
2529
2630## --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
2832# RUN: obj2yaml %t2.wasm | FileCheck -check-prefix=IGNORE %s
2933
3034# IGNORE-NOT: - Type: IMPORT
6165## by importing them but still report errors/warning for missing data symbols.
6266## `--allow-undefined` should behave like `--import-undefined` +
6367## `--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
6569# RUN: obj2yaml %t3.wasm | FileCheck -check-prefix=IMPORT %s
6670# IMPORT: - Type: IMPORT
6771# IMPORT-NEXT: Imports:
7276# IMPORT-NEXT: - Type: FUNCTION
7377
7478## 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
7882
7983## 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
8185# RUN: llvm-readobj %t4.wasm > /dev/null 2>&1
8286
83- .functype undef_func () -> ()
84- .functype get_data_addr () -> (i32)
85- .functype get_func_addr () -> (i32)
86-
8787## 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
8989# ERRNOPIC: relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol `undef_data`; recompile with -fPIC
9090# ERRNOPIC: relocation R_WASM_TABLE_INDEX_SLEB cannot be used against symbol `undef_func`; recompile with -fPIC
9191
92+ #--- main.s
93+
94+ .functype undef_func () -> ()
95+ .functype get_data_addr () -> (i32)
96+ .functype get_func_addr () -> (i32)
97+
9298.globl _start
9399_start:
94100 .functype _start () -> ()
@@ -112,3 +118,12 @@ get_func_addr:
112118 i32.const undef_func
113119 return
114120 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