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,6 +1,4 @@
/*
* out.c — emit a static ELF64 executable.
*
* Layout (file order) without .data:
* [0..64) ELF header
* [64..120) one program header (PT_LOAD R+X)
@@ -13,9 +11,6 @@
* [176..0x1000) zero pad
* [0x1000..) .text bytes
* [data_off..) .data bytes (file offset and vaddr page-aligned)
*
* No interpreter, no dynamic, no .bss yet. Entry point is the address
* of the symbol named "_start" (or whatever main supplies via -e).
*/
#include "l.h"
#include <stdio.h>
@@ -102,9 +97,6 @@ l_emit_elf(Lnk *l, FILE *f, u64 base, u64 entry)
eh.e_phentsize = sizeof(Phdr);
eh.e_phnum = has_data ? 2 : 1;
/* R+X load covering [0, rx_end). When .data is present we still
* round up to a page in memsz so the loader doesn't try to give
* the same page both R+X and R+W permissions. */
Phdr phx = {0};
phx.p_type = PT_LOAD;
phx.p_flags = PF_R | PF_X;
@@ -131,14 +123,12 @@ l_emit_elf(Lnk *l, FILE *f, u64 base, u64 entry)
fwrite(&phx, 1, sizeof phx, f);
if (has_data) fwrite(&phw, 1, sizeof phw, f);
/* pad to text_off */
long here = ftell(f);
for (long i = here; i < (long)text_off; i++) fputc(0, f);
if (l->textlen) fwrite(l->text, 1, l->textlen, f);
if (has_data && data_file_len > 0) {
/* pad to data_off */
here = ftell(f);
for (long i = here; i < (long)data_off; i++) fputc(0, f);
fwrite(l->data, 1, data_file_len, f);