feat(cli): add --relocatable flag to force ET_REL output#83
Open
feat(cli): add --relocatable flag to force ET_REL output#83
Conversation
Currently synth produces a relocatable object (.o, ET_REL) only when the input wasm has imports — the relocations they generate trigger the relocatable code path. Self-contained wasm modules with no imports produce a complete ET_EXEC firmware with vector table, Reset_Handler, linear_memory section, etc. For linking into a host build system (e.g. integrating verified Rust kernel primitives compiled to wasm into a Zephyr build), the host expects a relocatable .o it can pull into its existing link step. Add a --relocatable CLI flag that forces ET_REL output regardless of whether the wasm has imports. The flag is additive — default behaviour is unchanged. Tested with gale-ffi.wasm (200 functions, 0 imports): output is now a 26645-byte ET_REL ARM EABI5 object with all gale_* symbols defined and no vector-table machinery. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Summary
--relocatableflag that forces ET_REL output regardless of whether the wasm has imports — for linking into a host build system that has its own startup code (e.g., integrating verified Rust kernel primitives compiled to wasm into a Zephyr build).Context
This unblocks a follow-up experiment on the gale engine bench: compiling gale-ffi (formally-verified Rust replacement for Zephyr kernel primitives) to wasm32, then using synth to lower the wasm to a Cortex-M4F relocatable .o that links into the existing Zephyr build alongside the C kernel. The rest of the build expects
libgale_ffi.a(which we'll wrap from synth's .o), so synth's output needs to be a relocatable, not a full firmware.Tested with gale-ffi.wasm (200 functions, 0 imports):
--relocatable: 27052-byte ET_EXEC firmware with Reset_Handler, vector table, linear_memory section.--relocatable: 26645-byte ET_REL ARM EABI5 object with all gale_* symbols defined and no firmware machinery.Test plan
cargo checkpassescargo install --path crates/synth-cli --forcesucceeds--relocatable) still produces ET_EXEC — verified withfile output.elf--relocatableproduces ET_REL — verified withfile output.oreporting "ELF 32-bit LSB relocatable, ARM, EABI5"nm