Andrew Kelley
744bb5d16a
wasm linker: change rules about symbol visibility
...
export by default means export, as expected. if you want hidden
visibility then use hidden visibility.
2025-01-15 18:31:44 -08:00
Andrew Kelley
dcb4134835
wasm linker: delete commented out code
...
this logic has not yet been ported to the new design, but the logic is
safe and sound in the git history and does not need to also live as
commented out code
2025-01-15 18:19:46 -08:00
Andrew Kelley
9dd6efb7e4
wasm linker: fix TLS data segments
...
fix calculation of alignment and size
include __tls_align and __tls_size globals along with __tls_base
include them only if the TLS segment is emitted
add missing reloc logic for memory_addr_tls_sleb
fix name of data segments to include only the prefix
2025-01-15 18:17:37 -08:00
Andrew Kelley
10db1b9eda
wasm linker: fix explicit exports not affecting object files
2025-01-15 18:17:20 -08:00
Andrew Kelley
a4b7e9b97d
fix compiler unit tests
2025-01-15 15:22:57 -08:00
Andrew Kelley
ae16414121
wasm linker: ability to get data and functions from objects
2025-01-15 15:11:37 -08:00
Andrew Kelley
a7bd1a631b
wasm codegen: fix mistaking extern data as function
2025-01-15 15:11:37 -08:00
Andrew Kelley
204e689bdb
tests: remove dead code
2025-01-15 15:11:37 -08:00
Andrew Kelley
42602dc96b
test/link/wasm/export-data: update expected behavior
...
Object being linked has neither functions nor globals named "foo" or
"bar" and so these names correctly fail to be exported when creating an
executable.
2025-01-15 15:11:37 -08:00
Andrew Kelley
50d053f31c
test/wasm/infer-features: update to expected behavior
...
I intentionally simplified the target features functionality to use the
target features that are explicitly specified to the linker and ignore
the "tooling conventions"
this makes the wasm linker behave the same as ELF, COFF, and MachO.
2025-01-15 15:11:37 -08:00
Andrew Kelley
9ddb1c5092
wasm linker: implement --export-table
2025-01-15 15:11:37 -08:00
Andrew Kelley
ec5fc6a2a8
test/link/wasm/function-table: delete bad test
...
this tests for importing a function table, but the example source does
not try to use an imported table, so it's a useless check. it's unclear
what the behavior is even supposed to do in this case.
the other two cases are left alone.
2025-01-15 15:11:37 -08:00
Andrew Kelley
ae119e395a
test/link/wasm/segment: delete bad test
...
- doesn't run the exe
- checks for data segment named .rodata which is not a thing
- checks for data segment named .bss which is not needed
2025-01-15 15:11:37 -08:00
Andrew Kelley
c565191f30
test/link/wasm/type: remove redundant tests
...
This test passes now, but let's not run it for the other optimization
modes since they don't affect linker behavior.
2025-01-15 15:11:36 -08:00
Andrew Kelley
617eca13eb
wasm-linker: remap function types during flush
...
this is technically not necessary, and loses value the bigger the output
binary is, however it means a smaller output file, so let's do it.
2025-01-15 15:11:36 -08:00
Andrew Kelley
c2a918b7a3
wasm linker: implement __wasm_init_tls synthetic function
2025-01-15 15:11:36 -08:00
Andrew Kelley
f7f8878716
wasm linker: correct export visibility logic
...
exports are hidden unless protected or rdynamic or explicitly asked for,
matching master branch
2025-01-15 15:11:36 -08:00
Andrew Kelley
9143575ec3
test/wasm/export: delete redundant tests
...
the other optimization modes don't affect linking
2025-01-15 15:11:36 -08:00
Andrew Kelley
7ae2f21e2b
delete bad linker test: bss
...
The purpose of this test is unclear. It checks for the existence of bss
section which is completely unnecessary since those zeroes can be
omitted from the binary.
Furthermore the code generated for __wasm_init_memory looks wrong.
Finally, the CheckObject DSL is brittle, it only checks for exact
matches of entire lines in an ad-hoc text format. Conclusion, it's a bad
test, delete it.
2025-01-15 15:11:36 -08:00
Andrew Kelley
b37ad5110c
wasm linker: always passive when importing memory
...
and detect passive inits from Zcu
don't forget to intern function type for __wasm_init_memory
make that function the start function if it is present
don't skip emitting passive data segment data to the binary
2025-01-15 15:11:36 -08:00
Andrew Kelley
c535422423
wasm linker: implement hidden visibility
2025-01-15 15:11:36 -08:00
Andrew Kelley
f89ef2f7cd
Compilation.saveState implement saving wasm linker state
2025-01-15 15:11:36 -08:00
Andrew Kelley
9285f91ccc
wasm linker: incremental test coverage
2025-01-15 15:11:36 -08:00
Andrew Kelley
1fe1d55c7b
wasm linker: reset function exports after flush
2025-01-15 15:11:36 -08:00
Andrew Kelley
1afa6e260e
build: respect -Duse-llvm option when doing behavior tests
2025-01-15 15:11:36 -08:00
Andrew Kelley
4cc9cfa7e8
wasm linker: track overaligned uavs
2025-01-15 15:11:36 -08:00
Andrew Kelley
ba4521ac85
wasm linker: fix data segment names
2025-01-15 15:11:36 -08:00
Andrew Kelley
0cf163089e
wasm linker: fix @tagName for auto-numbered non-exhaustive enums
2025-01-15 15:11:36 -08:00
Andrew Kelley
cde84c8795
wasm linker: fix missed addend for uav and nav fixups
2025-01-15 15:11:36 -08:00
Andrew Kelley
dd9a647210
wasm linker: fix bad export index math
2025-01-15 15:11:36 -08:00
Andrew Kelley
8abdebecdc
wasm linker: implement @tagName for sparse enums
2025-01-15 15:11:36 -08:00
Andrew Kelley
b5261599d7
wasm linker: implement @tagName functions when tags are autoassigned
2025-01-15 15:11:36 -08:00
Andrew Kelley
d0d0847cd0
wasm linker: don't crash on ref to void
2025-01-15 15:11:36 -08:00
Andrew Kelley
e5d78f0b55
codegen: empty tuple can be stored in a runtime var
2025-01-15 15:11:36 -08:00
Andrew Kelley
fbdcb2289b
wasm linker: don't pretend it's possible to export data symbols
2025-01-15 15:11:36 -08:00
Andrew Kelley
0dd0ebb6e2
frontend: don't increment remaining_prelink_tasks for windows implibs
...
yet because they aren't hooked up to the new linker API
2025-01-15 15:11:36 -08:00
Andrew Kelley
220af3f446
wasm-linker: add updateFunc log
2025-01-15 15:11:36 -08:00
Andrew Kelley
7b255235d6
wasm linker: fix off-by-one in function table indexes
2025-01-15 15:11:36 -08:00
Andrew Kelley
e44bafe5ff
wasm linker: mark symbol deps on intrinsics
2025-01-15 15:11:36 -08:00
Andrew Kelley
e18a397c85
wasm linker: fix corruption of string bytes
...
if any fixups are emitted in lowering data, keep the string bytes
allocated even if all zeroes because it is used as a fixup staging area.
2025-01-15 15:11:36 -08:00
Andrew Kelley
9c14645b58
wasm codegen: fix freeing of locals
2025-01-15 15:11:36 -08:00
Andrew Kelley
a327d238f1
wasm linker: handle function data references properly
2025-01-15 15:11:36 -08:00
Andrew Kelley
d999a8e33b
wasm-linker: fix splitSegmentName and add unit test
2025-01-15 15:11:36 -08:00
Andrew Kelley
788b7f8f11
wasm linker: don't call init functions unless object included
2025-01-15 15:11:36 -08:00
Andrew Kelley
1c4b4fb516
implement indirect function table for object functions
2025-01-15 15:11:36 -08:00
Andrew Kelley
d9d49ce995
wasm linker: handle weak globals in relocs
2025-01-15 15:11:36 -08:00
Andrew Kelley
7a4d4357e8
wasm linker: don't try to lower nav zcu data before updateNav is called
2025-01-15 15:11:36 -08:00
Andrew Kelley
21a2888561
wasm linker: don't assume nav callees are fully resolved
...
codegen can be called which contains calls to navs which have only their
type resolved. this means the indirect function table needs to track nav
indexes not ip indexes.
2025-01-15 15:11:36 -08:00
Andrew Kelley
5186c6c4ee
wasm linker: distinguish symbol name vs import name, and implement weak
2025-01-15 15:11:36 -08:00
Andrew Kelley
3474057e5e
wasm linker: fix not merging object memories
2025-01-15 15:11:36 -08:00