-
Notifications
You must be signed in to change notification settings - Fork 727
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Eagerly create symbol tables when writing relocatable binaries Instead of adding entries to the symbol table as they are referenced, when writing relocatable binaries, we're going to make symbols for all functions. This allows exported functions and globals to be written with the proper exported / no_strip flags, so that resulting files will link with wasm-ld. * Symbol table names are export names, without the dollar. In the previous commit, I wrongly assumed that the globally visible name for linking was taken from the exports section, whereas actually it's from the symbol table. Therefore this patch changes to strip off the dollar, and also to make all named bindings globally visible. The exported-to-the-host binding is mostly unrelated to the visible-to-other-compilation-units binding. Unnamed definitions aren't added to the symbol table. * Add symbol tables test * Rename Intern helper to EnsureUnique
- Loading branch information
Showing
4 changed files
with
202 additions
and
53 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
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
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,61 @@ | ||
;;; TOOL: run-objdump | ||
;;; ARGS0: -r | ||
;;; ARGS1: -x | ||
(module | ||
(type (;0;) (func)) | ||
(import "env" "b" (func (;0;) (type 0))) | ||
(func $a (type 0) | ||
call 0) | ||
(func (type 0) | ||
call 0) | ||
(func $b (type 0) | ||
call 0) | ||
(export "a" (func $a))) | ||
(;; STDOUT ;;; | ||
symbol-tables.wasm: file format wasm 0x1 | ||
Section Details: | ||
Type[1]: | ||
- type[0] () -> nil | ||
Import[1]: | ||
- func[0] sig=0 <env.b> <- env.b | ||
Function[3]: | ||
- func[1] sig=0 <a> | ||
- func[2] sig=0 | ||
- func[3] sig=0 <b> | ||
Export[1]: | ||
- func[1] <a> -> "a" | ||
Code[3]: | ||
- func[1] size=8 <a> | ||
- func[2] size=8 | ||
- func[3] size=8 <b> | ||
Custom: | ||
- name: "linking" | ||
- symbol table [count=3] | ||
- 0: F <env.b> func=0 undefined binding=global vis=default | ||
- 1: F <a> func=1 exported no_strip binding=global vis=hidden | ||
- 2: F <b> func=3 binding=global vis=default | ||
Custom: | ||
- name: "reloc.Code" | ||
- relocations for section: 4 (Code) [3] | ||
- R_WASM_FUNCTION_INDEX_LEB offset=0x000004(file=0x00002c) symbol=0 <env.b> | ||
- R_WASM_FUNCTION_INDEX_LEB offset=0x00000d(file=0x000035) symbol=0 <env.b> | ||
- R_WASM_FUNCTION_INDEX_LEB offset=0x000016(file=0x00003e) symbol=0 <env.b> | ||
Code Disassembly: | ||
00002a func[1] <a>: | ||
00002b: 10 80 80 80 80 00 | call 0 <env.b> | ||
00002c: R_WASM_FUNCTION_INDEX_LEB 0 <env.b> | ||
000031: 0b | end | ||
000033 func[2]: | ||
000034: 10 80 80 80 80 00 | call 0 <env.b> | ||
000035: R_WASM_FUNCTION_INDEX_LEB 0 <env.b> | ||
00003a: 0b | end | ||
00003c func[3] <b>: | ||
00003d: 10 80 80 80 80 00 | call 0 <env.b> | ||
00003e: R_WASM_FUNCTION_INDEX_LEB 0 <env.b> | ||
000043: 0b | end | ||
;;; STDOUT ;;) |