toolchain: banner purge + WHY-only comment sweep (rule 8)

selfhost/, cmd/, internal/ join the tree-wide sweep: every section
banner dies (91 selfhost + the cmd C-style dividers -> 0); narration
and stale contracts deleted (pre-#22 bundler notes, retired
single-PT_LOAD and no-archive claims, superseded ABI tables); every
ref/harec/qbe cite, task cite, encoding/ELF contract, and rule-10
twin pointer kept; lost lifetime/rationale lines restored where the
sweep over-cut (elf_globals ownership, kwtab linear-scan). Comment-
only proven: all five wwstage tool binaries byte-identical across
the sweep; test-commit, test-byteid (161+1399, 0 pinned-divergent),
and test-bootstrap (fixed point + 991-995 byte-id) all exit 0.
The read-through banked 66 latent-bug leads (checkpoint).
This commit is contained in:
2026-08-08 23:14:03 +09:00
parent 83f5956df2
commit 62b9d20383
60 changed files with 232 additions and 1045 deletions

View File

@@ -1,11 +1,4 @@
// selfhost/cmd/w6l/out.ww — port of cmd/w6l/out.c.
//
// Emit a static ELF64 executable. File layout (per the C original):
// [0..64) Ehdr
// [64..120) Phdr (one PT_LOAD)
// [120..0x1000) zero pad
// [0x1000..) .text bytes
// Single PT_LOAD covers the whole file, R+X. No interpreter, no .bss.
// Port of cmd/w6l/out.c.
package w6l;
@@ -27,8 +20,6 @@ def PF_R: u32 = 4u32;
def TEXT_OFF: u64 = 4096u64; // 0x1000
def PAGE_SZ: u64 = 4096u64;
// ---- little-endian byte writers ----------------------------------------
fn wru16(buf: *u8, off: u64, v: u16) void = {
buf[off] = (v & 255u16): u8;
buf[off + 1u64] = ((v >> 8u16) & 255u16): u8;
@@ -46,8 +37,6 @@ fn wru64(buf: *u8, off: u64, v: u64) void = {
wru32(buf, off + 4u64, ((v >> 32u64) & 4294967295u64): u32);
};
// ---- emit ---------------------------------------------------------------
export fn emitelf(l: *lnk, fd: i32, base: u64, entry: u64) i32 = {
// Dispatch: any loaded shared object plus any dynamic ref means
// we owe the loader a real PT_INTERP/PT_DYNAMIC binary.
@@ -92,7 +81,7 @@ export fn emitelf(l: *lnk, fd: i32, base: u64, entry: u64) i32 = {
let hdr: []u8 = alloc([], TEXT_OFF)!;
hdr.len = TEXT_OFF: i32;
// --- Ehdr (64 bytes) ---
// Ehdr (64 bytes).
hdr[0u64] = 127u8; // 0x7f
hdr[1u64] = 'E';
hdr[2u64] = 'L';
@@ -115,7 +104,7 @@ export fn emitelf(l: *lnk, fd: i32, base: u64, entry: u64) i32 = {
wru16(hdr.ptr, 60u64, 0u16); // e_shnum
wru16(hdr.ptr, 62u64, 0u16); // e_shstrndx
// --- Phdr #1 (R+X) at offset 64 ---
// Phdr #1 (R+X) at offset 64.
wru32(hdr.ptr, 64u64, PT_LOAD);
wru32(hdr.ptr, 68u64, PF_R | PF_X);
wru64(hdr.ptr, 72u64, 0u64); // p_offset
@@ -126,7 +115,7 @@ export fn emitelf(l: *lnk, fd: i32, base: u64, entry: u64) i32 = {
wru64(hdr.ptr, 112u64, TEXT_OFF); // p_align
if (hasdata) {
// --- Phdr #2 (R+W) at offset 64+56=120 ---
// Phdr #2 (R+W) at offset 64+56=120.
wru32(hdr.ptr, 120u64, PT_LOAD);
wru32(hdr.ptr, 124u64, PF_R | PF_W);
wru64(hdr.ptr, 128u64, dataoff); // p_offset
@@ -137,7 +126,6 @@ export fn emitelf(l: *lnk, fd: i32, base: u64, entry: u64) i32 = {
wru64(hdr.ptr, 168u64, PAGE_SZ); // p_align
};
// Write [0..0x1000) then .text.
let r1: (i64 | os.oserror) = os.writeall(fd, hdr.ptr, TEXT_OFF);
let n1: i64 = 0i64;
match (r1) {