File tree Expand file tree Collapse file tree 3 files changed +94
-0
lines changed Expand file tree Collapse file tree 3 files changed +94
-0
lines changed Original file line number Diff line number Diff line change
1
+ # RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
2
+
3
+ # RUN: not wasm-ld --experimental-pic -shared %t.o -o /dev/null 2>&1 | \
4
+ # RUN: FileCheck %s
5
+
6
+ # RUN: not wasm-ld --experimental-pic -shared %t.o -o /dev/null --unresolved-symbols=report-all 2>&1 | \
7
+ # RUN: FileCheck %s
8
+
9
+ # RUN: not wasm-ld --experimental-pic -shared %t.o -o /dev/null --warn-unresolved-symbols 2>&1 | \
10
+ # RUN: FileCheck %s
11
+
12
+ # RUN: not wasm-ld --experimental-pic -shared %t.o -o /dev/null --unresolved-symbols=ignore-all 2>&1 | \
13
+ # RUN: FileCheck %s
14
+
15
+ # RUN: not wasm-ld --experimental-pic -shared %t.o -o /dev/null --unresolved-symbols=import-dynamic 2>&1 | \
16
+ # RUN: FileCheck %s
17
+
18
+ .functype external_func () -> ()
19
+
20
+ use_undefined_function:
21
+ .functype use_undefined_function () -> ()
22
+ i32.const external_func@TBREL
23
+ # CHECK: error: {{.*}}.o: relocation R_WASM_TABLE_INDEX_REL_SLEB is not supported against an undefined symbol `external_func`
24
+ drop
25
+ end_function
26
+
27
+ use_undefined_data:
28
+ .functype use_undefined_data () -> ()
29
+ i32.const external_data@MBREL
30
+ # CHECK: error: {{.*}}.o: relocation R_WASM_MEMORY_ADDR_REL_SLEB is not supported against an undefined symbol `external_data`
31
+ drop
32
+ end_function
33
+
34
+ .globl _start
35
+ _start:
36
+ .functype _start () -> ()
37
+ call use_undefined_function
38
+ call use_undefined_data
39
+ end_function
Original file line number Diff line number Diff line change
1
+ # RUN: llvm-mc -filetype=obj -triple=wasm64-unknown-unknown -o %t.o %s
2
+
3
+ # RUN: not wasm-ld -mwasm64 --experimental-pic -shared %t.o -o /dev/null 2>&1 | \
4
+ # RUN: FileCheck %s
5
+
6
+ # RUN: not wasm-ld -mwasm64 --experimental-pic -shared %t.o -o /dev/null --unresolved-symbols=report-all 2>&1 | \
7
+ # RUN: FileCheck %s
8
+
9
+ # RUN: not wasm-ld -mwasm64 --experimental-pic -shared %t.o -o /dev/null --warn-unresolved-symbols 2>&1 | \
10
+ # RUN: FileCheck %s
11
+
12
+ # RUN: not wasm-ld -mwasm64 --experimental-pic -shared %t.o -o /dev/null --unresolved-symbols=ignore-all 2>&1 | \
13
+ # RUN: FileCheck %s
14
+
15
+ # RUN: not wasm-ld -mwasm64 --experimental-pic -shared %t.o -o /dev/null --unresolved-symbols=import-dynamic 2>&1 | \
16
+ # RUN: FileCheck %s
17
+
18
+ .functype external_func () -> ()
19
+
20
+ use_undefined_function:
21
+ .functype use_undefined_function () -> ()
22
+ i64.const external_func@TBREL
23
+ # CHECK: error: {{.*}}.o: relocation R_WASM_TABLE_INDEX_REL_SLEB64 is not supported against an undefined symbol `external_func`
24
+ drop
25
+ end_function
26
+
27
+ use_undefined_data:
28
+ .functype use_undefined_data () -> ()
29
+ i64.const external_data@MBREL
30
+ # CHECK: error: {{.*}}.o: relocation R_WASM_MEMORY_ADDR_REL_SLEB64 is not supported against an undefined symbol `external_data`
31
+ drop
32
+ end_function
33
+
34
+ .globl _start
35
+ _start:
36
+ .functype _start () -> ()
37
+ call use_undefined_function
38
+ call use_undefined_data
39
+ end_function
Original file line number Diff line number Diff line change @@ -173,6 +173,22 @@ void scanRelocations(InputChunk *chunk) {
173
173
}
174
174
}
175
175
176
+ if (sym->isUndefined ()) {
177
+ switch (reloc.Type ) {
178
+ case R_WASM_TABLE_INDEX_REL_SLEB:
179
+ case R_WASM_TABLE_INDEX_REL_SLEB64:
180
+ case R_WASM_MEMORY_ADDR_REL_SLEB:
181
+ case R_WASM_MEMORY_ADDR_REL_SLEB64:
182
+ // These relocation types are for symbols that exists relative to
183
+ // `__memory_base` or `__table_base` and as such only make sense for
184
+ // defined symbols.
185
+ error (toString (file) + " : relocation " + relocTypeToString (reloc.Type ) +
186
+ " is not supported against an undefined symbol `" +
187
+ toString (*sym) + " `" );
188
+ break ;
189
+ }
190
+ }
191
+
176
192
if (sym->isUndefined () && !config->relocatable && !sym->isWeak ()) {
177
193
// Report undefined symbols
178
194
reportUndefined (file, sym);
You can’t perform that action at this time.
0 commit comments