From 5e0d80a8873cbea2be4ba7e176e9ccf51bb2f2a1 Mon Sep 17 00:00:00 2001 From: Drew T <50529377+Druthulu@users.noreply.github.com> Date: Mon, 15 Jun 2026 20:49:45 -0600 Subject: [PATCH] =?UTF-8?q?refactor(phase-9):=20T7=20=E2=80=94=20ld=5Finte?= =?UTF-8?q?rleave.py=20--front/--tail;=20gate=20extract=20call=20to=20BINA?= =?UTF-8?q?RY=3Dmain?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ld_interleave.py: argparse [ld] + --front/--tail (repeatable; default to the EXE's sandwich objects, transitional); the .data->.rodata->.data island is EXE-specific - Makefile extract: ld_interleave call wrapped in ifeq(BINARY,main) (overlays have no rodata island) and passes --front 53198.data.o --tail 6324C.data.o explicitly - GATES: positive extract+build -> 143dbb89 (tail_data=1 from the threaded flag); negative --tail BOGUS.data.o -> 'tail data object not found' exit=1 (threaded); restore -> 143dbb89 --- Makefile | 6 +++++- phase-ends/CURRENT_PHASE.md | 4 ++-- tools/ld_interleave.py | 20 +++++++++++++++----- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 42a1bcc43..6357399cc 100644 --- a/Makefile +++ b/Makefile @@ -294,11 +294,15 @@ OBJS := $(ASM_SRCS:%.s=build/%.o) $(C_SRCS:%.c=build/%.o) extract: @mkdir -p $(OUT_DIR) $(SPLAT) split $(SPLAT_YAML) +ifeq ($(BINARY),main) # Phase 7 (LZSS): reorder splat's section-major .main into the real # .data(front) -> .rodata -> .data(tail) sandwich, so the migrated LZSS # jtbl_80072A38 (800.o .rodata) lands at 0x80072A38 between 531DC.data and # 6324C.data. Idempotent; keyed off splat's exact output (re-run = no-op). - $(PYTHON) tools/ld_interleave.py $(LD_SCRIPT) + # EXE-only (overlays have no rodata island) — gated to BINARY=main; --front/--tail + # name the sandwich .data objects (cookbook §8). + $(PYTHON) tools/ld_interleave.py --front 53198.data.o --tail 6324C.data.o $(LD_SCRIPT) +endif # The linker script is an `extract` output, not produced by `build` — guard with a # friendly message instead of make's raw "No rule to make target". diff --git a/phase-ends/CURRENT_PHASE.md b/phase-ends/CURRENT_PHASE.md index 81a463fce..5d9ce901c 100644 --- a/phase-ends/CURRENT_PHASE.md +++ b/phase-ends/CURRENT_PHASE.md @@ -29,8 +29,8 @@ - [x] **T4** — `psyq_link_region.py` + `psyq_link_lib.py` [A3]: threaded vram_base/exe through build_region/placement/classify (+ link_lib); pass `--vram-base`/`--exe` to psyq_identify argv; argparse mains. **VRAM_BASE import KEPT** as transitional default source (removed T8, not dropped now — lower churn, consistent). DONE: link_lib libcd 18/18; wrong base ⇒ 6/18 (threaded); link_region byte-identical True; clean build ⇒ `143dbb89`. - [x] **T5** — `psyq_integrate.py` + `progress.py` + Makefile (ONE COMMIT) [A4+B1]: integrate argparse (flags before positionals, `nargs="*"` window) threads vram_base/exe/symbols; 9 Makefile call sites pass `--vram-base/--exe/--symbols $(main_*)`; progress regex `(?:\s+--\S+\s+\S+)*` consumes leading flags + `--binary` selector. DONE: positive `143dbb89`; report 52/**959**/7/50.24% (regex OK); **negative** main_VRAM_BASE=0x8000F804 ⇒ `cae22f7e`≠target; **without-SDK fallback** ⇒ `143dbb89`. - [x] **T6** — `dup_report.py` + `difficulty.py` [B2+B3]: argparse `--binary` (default main) + BINARIES table; Makefile `report` threads `--binary $(BINARY)`. DONE: progress.md + duplicates.md UNCHANGED (pure no-op); difficulty.md old-code==new-code output (proven) ⇒ its 12/12 diff is the **Phase-8 deferred regen** (9 harvested fns left the queue) — regenerated + committed here (resolves the Phase-8 deferral). Build untouched (report-only). -- [ ] **T7** — `ld_interleave.py` [C3]: `--front`/`--tail`/`--ld`; gate call under `ifeq ($(BINARY),main)`. Gate: build no-op (extract critical path). ← **CURRENT** -- [ ] **T8** — curation helpers de-default [C1/C2/E1/D]: make_snd_used / make_apicard_used / gen_lib_subsegs (`--vram-base`) / split_src_region (`--symbols`). Gate: helpers regenerate identical curated dirs; build no-op. +- [x] **T7** — `ld_interleave.py` [C3]: argparse `--front`/`--tail`/`ld` (EXE defaults, transitional); `extract` recipe gates the call under `ifeq ($(BINARY),main)` + passes `--front 53198.data.o --tail 6324C.data.o`. DONE: positive (extract path) ⇒ `143dbb89` (tail_data=1 from the flag); negative `--tail BOGUS.data.o` ⇒ "tail data object not found" exit=1 (threaded); restore ⇒ `143dbb89`. +- [ ] **T8** — curation helpers de-default [C1/C2/E1/D]: make_snd_used / make_apicard_used / gen_lib_subsegs (`--vram-base`) / split_src_region (`--symbols`) + **remove the transitional EXE/VRAM_BASE globals + param defaults across the link pipeline → required (no-EXE-default end state)**. Gate: helpers regenerate identical curated dirs; build no-op + full negative control. ← **CURRENT** - [ ] **T9** — `diff_settings.py`: `BFM_BINARY` env-var selector + BINARIES table. Gate: asm-differ scores 0 on a known match. - [ ] **T10** — Docs (SETUP/cookbook/psyq-worklist/README; R16/R21) + `make expected` refresh + final both-ways milestone proof + negative control demonstrated/reverted. diff --git a/tools/ld_interleave.py b/tools/ld_interleave.py index 94d9909f0..fbc68f765 100644 --- a/tools/ld_interleave.py +++ b/tools/ld_interleave.py @@ -22,12 +22,22 @@ TAIL_DATA). All other (empty) .data objects go in the front group. Idempotent: keyed off splat's exact section-major output; re-running on an already-patched script is a no-op (the markers won't match). Run post-extract. """ -import re, sys +import re, sys, argparse -LD = sys.argv[1] if len(sys.argv) > 1 else "build/us/SLUS_007.26.ld" -# object basenames whose (.data) belongs to the front / tail region -FRONT_DATA = ("53198.data.o",) -TAIL_DATA = ("6324C.data.o",) +_ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) +_ap.add_argument("ld", nargs="?", default="build/us/SLUS_007.26.ld", + help="splat-generated linker script to rewrite in place") +_ap.add_argument("--front", action="append", + help="object basename whose .data belongs to the FRONT region (repeatable)") +_ap.add_argument("--tail", action="append", + help="object basename whose .data belongs to the TAIL region (repeatable)") +_a = _ap.parse_args() +LD = _a.ld +# object basenames whose (.data) belongs to the front / tail region. Defaults are the EXE's +# LZSS-sandwich objects (TRANSITIONAL — the Makefile passes --front/--tail explicitly, and the +# whole step is gated to BINARY=main since overlays have no rodata island). See cookbook §8. +FRONT_DATA = tuple(_a.front) if _a.front else ("53198.data.o",) +TAIL_DATA = tuple(_a.tail) if _a.tail else ("6324C.data.o",) src = open(LD).read()