selfhost/cmd/w6l: strip *arena cascade (γ-4)

amalloc has 0 callers post-γ-2; the *arena threaded through w6l's
mklnk/resolvelib/cstrtostr/elfglobals/dcstrtostr and the lnk.a
field are vestigial.

Drop `import mem;` from sym/main/obj/dyn/dynout, remove lnk.a
struct field, strip *arena from the five signatures, update 13
call sites. Drop a dead `let a: *arena = l.a;` in dynout. Comments
at pass.ww/obj.ww/main.ww retidied to match post-strip reality.
main.combined.ww auto-regenerated.

Verified 132/132 incl. 992_w6l_ww + 996_dyn_ww + 995_self_rebuild
byte-identity.
This commit is contained in:
2026-05-21 12:00:46 +09:00
parent 12e0b4057f
commit 6faf00223e
7 changed files with 48 additions and 158 deletions

View File

@@ -12,7 +12,6 @@ package w6l;
import os;
import rt;
import mem;
import strings;
import sym;
@@ -158,7 +157,7 @@ fn cstrlen(p: *u8) u64 = {
return n;
};
// pathstr — view a NUL-terminated *u8 as a str. Bridges argv/arena
// pathstr — view a NUL-terminated *u8 as a str. Bridges argv-style
// callers to lib/os entrypoints (str post-task-#23). Shared with
// main.ww and dyn.ww via the w6l bundle.
fn pathstr(p: *u8) str = {
@@ -181,7 +180,7 @@ fn cstreq(p: *u8, lit: str) bool = {
};
// Build a ww str from a NUL-terminated *u8 (for passing to intern).
fn cstrtostr(a: *arena, p: *u8) str = {
fn cstrtostr(p: *u8) str = {
let n: u64 = cstrlen(p);
let view: str;
view.ptr = p;
@@ -201,7 +200,7 @@ type defent = struct {
};
type armember = struct {
data: *u8, // arena copy of the member's ELF bytes
data: *u8, // owned heap copy of the member's ELF bytes
size: u64,
defs: *defent, // linked list of defined globals
loaded: i32,
@@ -236,9 +235,9 @@ fn arfield(p: *u8, n: u64) u64 = {
};
// elfglobals — return a linked list of names of globally-defined
// (STB_GLOBAL) symbols whose section is `.text`. Names are arena
// copies, so the source ELF buffer can be freed afterward.
fn elfglobals(a: *arena, buf: *u8, len: u64) *defent = {
// (STB_GLOBAL) symbols whose section is `.text`. Names are owned
// heap copies, so the source ELF buffer can be freed afterward.
fn elfglobals(buf: *u8, len: u64) *defent = {
if (len < EHDR_SIZE) { return nil; };
if (buf[0u64] != 127u8) { return nil; };
if (buf[1u64] != 69u8) { return nil; };
@@ -302,7 +301,7 @@ fn elfglobals(a: *arena, buf: *u8, len: u64) *defent = {
if (intext || indt) {
let nmp: *u8 = strtab + (stname: u64);
if (nmp[0u64] != 0u8) {
let nm: str = cstrtostr(a, nmp);
let nm: str = cstrtostr(nmp);
let de: *defent = alloc(defent { name = nm, dnext = head })!;
head = de;
};
@@ -355,7 +354,7 @@ fn loadarchive(l: *lnk, path: *u8, buf: *u8, len: u64) i32 = {
i += 1u64;
};
m.data = mb;
m.defs = elfglobals(l.a, mb, hdrsize);
m.defs = elfglobals(mb, hdrsize);
if (head == nil) { head = m; }
else { tail.mnext = m; };
tail = m;
@@ -473,7 +472,7 @@ fn loadimage(l: *lnk, path: *u8, buf: *u8, len: u64) i32 = {
// Track this object.
let ob: *lobj = alloc(lobj {
path = cstrtostr(l.a, path),
path = cstrtostr(path),
buf = buf,
len = len,
textoff = l.textlen,
@@ -504,7 +503,7 @@ fn loadimage(l: *lnk, path: *u8, buf: *u8, len: u64) i32 = {
let stvalue: u64 = rdu64(buf, symp + SYM_VALUE);
let nmp: *u8 = strtab + (stname: u64);
if (nmp[0u64] != 0u8) {
let nm: str = cstrtostr(l.a, nmp);
let nm: str = cstrtostr(nmp);
let gs: *lsym = intern(l, nm);
if (stshndx != 0u16) {
let intext: bool = (stshndx: i32) == idxtext;
@@ -568,7 +567,7 @@ fn loadimage(l: *lnk, path: *u8, buf: *u8, len: u64) i32 = {
let sname: u32 = rdu32(buf, sp + SYM_NAME);
let snm: *u8 = strtab + (sname: u64);
if (snm[0u64] != 0u8) {
let nm: str = cstrtostr(l.a, snm);
let nm: str = cstrtostr(snm);
nr.sym = intern(l, nm);
};
};
@@ -604,7 +603,7 @@ fn loadimage(l: *lnk, path: *u8, buf: *u8, len: u64) i32 = {
let sname: u32 = rdu32(buf, sp + SYM_NAME);
let snm: *u8 = strtab + (sname: u64);
if (snm[0u64] != 0u8) {
let nm: str = cstrtostr(l.a, snm);
let nm: str = cstrtostr(snm);
nr.sym = intern(l, nm);
};
};