-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lld][WebAssembly] Fix for --import-table when combined with referenc…
…e types (#97451) When reference types are enabled clang will generate call_indirect instructions that explicitly reference the global `__indirect_function_table` symbol. In this case the resulting global symbol was not being correctly marked with explicit import name/module, resulting in the linker reporting errors when it was referenced. This issue was reported in WebAssembly/tool-conventions#158
- Loading branch information
Showing
3 changed files
with
40 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# RUN: llvm-mc -mattr=+reference-types -filetype=obj -triple=wasm32-unknown-unknown %s -o %t.o | ||
# RUN: wasm-ld --import-table -o %t.wasm %t.o | ||
# RUN: obj2yaml %t.wasm | FileCheck %s | ||
|
||
.globl __indirect_function_table | ||
.tabletype __indirect_function_table, funcref | ||
|
||
.globl _start | ||
_start: | ||
.functype _start () -> () | ||
i32.const 1 | ||
call_indirect __indirect_function_table, () -> () | ||
end_function | ||
|
||
# Verify the --import-table flag creates a table import | ||
|
||
# CHECK: - Type: IMPORT | ||
# CHECK-NEXT: Imports: | ||
# CHECK-NEXT: - Module: env | ||
# CHECK-NEXT: Field: __indirect_function_table | ||
# CHECK-NEXT: Kind: TABLE | ||
# CHECK-NEXT: Table: | ||
# CHECK-NEXT: Index: 0 | ||
# CHECK-NEXT: ElemType: FUNCREF | ||
# CHECK-NEXT: Limits: | ||
# CHECK-NEXT: Minimum: 0x1 |
16 changes: 8 additions & 8 deletions
16
lld/test/wasm/import-table.test → lld/test/wasm/import-table.s
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters