Commit Graph

2 Commits

Author SHA1 Message Date
2480f4c272 w6l+selfhost: BSS optimisation — trim trailing .data zeros from filesz
Scan the consolidated .data buffer (post-relocation) for trailing zero
bytes; set the R+W PT_LOAD's p_filesz to exclude them while p_memsz
covers the full region. The loader zero-fills the gap, so behaviour is
unchanged. Saves up to a page per binary on programs whose globals are
zero-init.

Mirrored in selfhost/cmd/w6l/out.ww so test 992's byte-identity diff
still holds. Dynamic-link path is untouched — it still errors on any
mutable global; that's the next feature.
2026-05-12 13:44:27 +09:00
38e0b6510a w6l: route writable globals into a second PT_LOAD
Second step toward top-level mutable `let`. The static path now loads
.data PROGBITS sections from input .o files, page-aligns them after
.text, and emits a second PT_LOAD (R+W) covering them. Relocations
targeting data symbols compute against the data VA; text→text
displacements still cancel the absolute VAs and stay correct.

Inputs without any .data keep the original single-PT_LOAD layout
byte-for-byte — 992 (selfhost w6l .o diff) and 995 (self-rebuild)
depend on that invariant.

Dynamic-link path (-l/-L) rejects .data for now with a clear error;
folding writable globals into the existing R+W segment alongside
.got.plt/.dynamic is a follow-up.
2026-05-12 11:42:30 +09:00