Skip to content

port(wasm): Resolve __data_end and __heap_base as linker data addresses#2188

Open
lapla-cogito wants to merge 1 commit into
wild-linker:mainfrom
lapla-cogito:dataheap
Open

port(wasm): Resolve __data_end and __heap_base as linker data addresses#2188
lapla-cogito wants to merge 1 commit into
wild-linker:mainfrom
lapla-cogito:dataheap

Conversation

@lapla-cogito

Copy link
Copy Markdown
Member

Clang references these as undefined data symbols with MEMORY_ADDR relocations, not as globals. Assign absolute addresses after static data layout (data_end, and data_end plus the reserved stack gap for heap_base) and grow memory when the stack gap is required.

Part of #1431

@lapla-cogito lapla-cogito changed the title Resolve __data_end and __heap_base as linker data addresses port(wasm): Resolve __data_end and __heap_base as linker data addresses Jul 8, 2026
Comment thread libwild/src/wasm.rs
data_end: u32,
) -> Result<Option<LinkerDefinedDataAddress>> {
match name {
b"__data_end" => Ok(Some(LinkerDefinedDataAddress {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to previous PRs, the matching on symbol names makes me wary. It feels potentially wasteful and like it ideally shouldn't be necessary. Fine for now, but longer-term it'd be good to consider alternatives.

@@ -0,0 +1,4 @@
extern char __data_end;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this actually cause a symbol reference to be emitted? At least from my previous observations when compiling for x86_64, it doesn't - you'd need to actually have code that references the symbol for that.

Comment thread libwild/src/wasm.rs
.ok_or_else(|| crate::error!("Wasm __heap_base address overflow"))?;
Ok(Some(LinkerDefinedDataAddress {
address,
needs_stack_gap: true,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is it about __heap_base that means it needs stack gap? Could be good to document that here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants