Check the type of __wasm_call_ctors and __wasm_apply_data_relocs - #2699
Merged
alexcrichton merged 1 commit intoSep 30, 2026
Merged
Conversation
The linker's start function calls both as `[] -> []`, but metadata extraction only recorded that they were exported. A library exporting either with another type still linked: `wasm-tools component link` then failed validation of the result with a type mismatch on a module instantiation argument, and with validation off (the `ComponentEncoder` default) the invalid component was returned. Check them when the metadata is read, with the same message the intrinsic imports use. `_initialize` and `_start` are left alone: the component encoder already rejects those with the wrong type when it classifies the exports. Refs bytecodealliance#2591
alexcrichton
approved these changes
Sep 30, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The linker calls
__wasm_call_ctorsand__wasm_apply_data_relocsas[] -> [], but when it reads a library it only notes that they're exported. A library exporting one with a different type still links, and the problem shows up at the very end:or as an invalid component with
--skip-validation. This checks both when the library is read, with the same message #2646 uses for the intrinsic imports:_initializeand_startare called the same way, but a wrong type there is already caught when the encoder classifies the exports, so I left them alone.The new
error-link-ctors-signaturetest fails without the change.Refs #2591