32244 Commits

Author SHA1 Message Date
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
Andrew Kelley
e6a5fe7c55 wasm linker: apply object relocations to data segments 2025-01-15 15:11:36 -08:00
Andrew Kelley
290d97bd09 wasm linker: emit __heap_base and __heap_end globals and datas 2025-01-15 15:11:36 -08:00
Andrew Kelley
94648a0383 fix merge conflicts with updating line numbers 2025-01-15 15:11:36 -08:00
Andrew Kelley
b41b5fe529 wasm linker: implement __wasm_init_memory 2025-01-15 15:11:36 -08:00
Andrew Kelley
1fd708b1bc wasm linker: implement data relocs 2025-01-15 15:11:36 -08:00
Andrew Kelley
abdbc38574 wasm linker: implement data symbols 2025-01-15 15:11:36 -08:00
Andrew Kelley
a4bee3009a wasm linker: implement __wasm_call_ctors 2025-01-15 15:11:36 -08:00
Andrew Kelley
9ccf500508 implement function relocations
not all relocation types are implemented yet
2025-01-15 15:11:36 -08:00
Andrew Kelley
5b18af85cb type checking for synthetic functions 2025-01-15 15:11:36 -08:00
Andrew Kelley
a4895f3c42 wasm object parsing: fix handling of weak functions and globals 2025-01-15 15:11:36 -08:00
Andrew Kelley
4fccb5ae7a wasm linker: improve error messages by making source locations more lazy 2025-01-15 15:11:36 -08:00
Andrew Kelley
7d224516c4 wasm linker: chase relocations for references 2025-01-15 15:11:36 -08:00
Andrew Kelley
c5822879a1 fix bad archive name calculation 2025-01-15 15:11:36 -08:00