Skip to content

Pack the relative relocations (RELR) to free ESP Stage 2 room - #609

Merged
RyanTheTide merged 3 commits into
mainfrom
fix/esp-stage2-room
Nov 30, 2026
Merged

RyanTheTide merged 3 commits into
mainfrom
fix/esp-stage2-room

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

The ESP Stage 2 on main (a382495) has 6192 B of headroom before _file_limit (fedora:44 tools/stage1_size.sh, floor 4096, warning 8192). #601 (T8152 DCP handoff) needs about 2.8 KB, so main + #601 fails the floor at 3496 B, and #113 and #604 add more.

About 74 KiB of that region was .rela.dyn: one 24-byte R_AARCH64_RELATIVE entry per aligned pointer (2900 in the ESP Stage 2, 2816 in Stage 1). This links with -z pack-relative-relocs (lld; GNU ld 2.38+), so those pointers go to .relr.dyn (about 10 KiB) and keep their link-time value in the file. Nothing is dropped: same code, same data, same pointers, and no flavour or SoC is gated.

  • Makefile: -z pack-relative-relocs in LDFLAGS.
  • aura-raw.ld, aura.ld: a .relr.dyn output section (_relr_start/_relr_end) after .rela.dyn, at the end of the read-execute region. _rodata_content_end and the step padding move to it.
  • src/startup.c, src/start.S: apply_relr() runs right after apply_rela(), once, after any move to run_base/top_of_kernel_data. It is a leaf function with no globals and no stack, like apply_rela(). apply_rela() still handles what the linker doesn't pack (unaligned words). It still stops on anything that isn't a relative relocation.
  • proxyclient/aura/loadobjs.py: the check that the ELF is the running image (image_mismatch()) compares .rela.dyn, .relr.dyn and the linker's build ID. Packed words carry their addends, so the tables alone can match across builds. The build ID is linked with --build-id=sha1 and kept as .note.gnu.build-id (_build_id_start/_end, 36 bytes) in both scripts.
  • tools/stage1_room.py: comments only. The room is still measured to _rodata_content_end and _file_vital_end.

Numbers (headroom before _file_limit)

fedora:44 sh tools/stage1_size.sh fedora USE_CLANG=1 BUILTIN_LOGO=aurora BUILDSTD=1 (the CI RUSTFLAGS):

flavour main a382495 this PR main + this + #601 main + this + #601 + #113 + #604
esp-stage2 6192 77088 77088 76480
stage1 44592 110128 110128 109520
stage1-secure-audit 110248 175784 175784 158792
stage1-secure-enforce 110248 175784 175784 175176
stage1-dev-audit 28016 93552 93552 92944

Freed: +70896 B ESP Stage 2 headroom, +65536 B for every Stage 1 flavour. The headroom is the data room once that is a step or more, so the jump is in 16 KiB steps.

GNU ld before 2.43 (Ubuntu 24.04 ships 2.42, which the gcc legs use) ignores -z pack-relative-relocs on AArch64. It prints -z pack-relative-relocs ignored and keeps every pointer in .rela.dyn. The image is still correct (apply_relr() gets an empty table, and the layout checks pass), but those builds don't gain anything. stage1_size.sh with aurora-s1gcc (GNU ld 2.42):

So with a 2.42 toolchain #601 still doesn't fit. That needs a toolchain-independent follow-up or a newer binutils on those legs. The candidate follow-up moves the 16 KiB .data.smp_shared page out of the file into .bss: its only non-zero initialisers are smp_reset_stacks[].mpidr = ~0, boot_cpu_idx = -1 and spin_table = spin_table_image. The data must stay correct for every SMP path, which needs its own row. GNU ld 2.43+ (tested with 2.46) packs like lld.

Buildbox clang 22 (make USE_CLANG=1 BUILDSTD=1, headroom main -> this):

  • ESP Stage 2 release (RELEASE=1 CHAINLOADING=1 ESP_STAGE2=1): 6800 -> 77088
  • ESP Stage 2 + DEBUGUSB_PROXY=1: 6680 -> 77080
  • SPTM_VIRT=1 SPTM_VIRT_ESP=1 AURACTL=1 EXTRA_CFLAGS=-Oz (ESP): 499008 -> 531776
  • default Stage 1: 77232 -> 142768

The relocation count is the same in every image: main's .rela.dyn entries match the words the packed .relr.dyn decodes to (ESP Stage 2 2900, Stage 1 2816, SPTM-virt 1345), with no duplicates.

Tested:

Row needed before merge: this changes how every image relocates itself at boot (Stage 1 and ESP Stage 2), so it needs a one-shot boot on one lab Mac. Proposed: J615 (M3 Air, T8122). There the ESP Stage 2 moves above the DCP log buffer before relocating, which is the most sensitive path. A method-T chain one-shot of Stage 1 + ESP Stage 2 built at this head (kits/aura/20261123-stage1-signoff/s1so.sh) should boot to Linux with the logo and the console. A second family (J473) is the regression row. It has not been run yet.

Risk: two-way · all Macs (ESP Stage 2 layout)

@DjDeveloperr: code-owner ping. This is the room for #601/#113/#604.

Every image carried one 24-byte .rela.dyn entry per aligned pointer:
about 74 KiB in the ESP Stage 2, inside the region that must end below
the DCP log buffer (_file_limit). It had 6 KiB of headroom left, too
little for the pending T8152 DCP handoff.

Link with -z pack-relative-relocs (lld and GNU ld 2.38+). The aligned
pointers go to .relr.dyn, about 10 KiB, and keep their link-time value
in the file; apply_relr() adds the base once after apply_rela(), which
still handles what the linker does not pack (unaligned words). Both
linker scripts place .relr.dyn at the end of the read-execute region,
and the proxyclient sanity check compares both tables.

fedora:44 stage1_size: ESP Stage 2 headroom 6192 -> 77088 B, Stage 1
44592 -> 110128 B; nothing is dropped, every flavour keeps its code.

test_relr_apply links an image with address and bitmap entries, a gap
and an unaligned pointer with both linkers, relocates it with the
production apply_rela()/apply_relr() on the host and checks it against
the unpacked link.

Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
@RyanTheTide
RyanTheTide requested review from a team as code owners November 30, 2026 07:36
@github-actions github-actions Bot added blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 30, 2026
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Merge readiness at 649298bc: not ready yet

Check Detail
CI at head ok 29 checks passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok comment at 649298bc
Conflicts ok none
PR text ok Risk: two-way · all Macs (ESP Stage 2 layout) @DjDeveloperr: code-owner ping. This is the room for #601/#113/#604.

Areas: none matched in CODEOWNERS

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: HOLD at f4c24747

Blockers:

  • Pending CI at head f4c24747: 8 checks are still queued/in-progress (build, ESP stage 2 vital size, format-check, gcc, Pytest (ubuntu-latest + gcc), Pytest (ubuntu-latest + llvm), Pytest (macos-26 + llvm-brew), Pytest (macos-15 + llvm-brew)). 12 checks have already passed, including Pytest (ubuntu-24.04-arm, native start.S), fedora, alarm, nix, clang-macos, selftest, policy, pr-text, and readiness.
  • Exact-head hardware boot rows at f4c24747: As noted in the PR description, record the Stage 1 + ESP Stage 2 boot-to-Linux row on J615 (exercising the M3 relocate-after-move path) and the second-family regression row (J473) at f4c24747. Code and tests are clean; ready to approve once CI and the hardware rows land.

Checked:

  • src/startup.c (apply_relr()) & src/start.S: implements ELF SHT_RELR decoding accurately — even entries set where = (uint64_t *)(base + *e) and relocate *where++ += base; odd entries iterate bits 1..63 (bits = *e >> 1) over word = where and unconditionally advance where += 63 regardless of trailing zero bits. Leaf function with no globals or stack, called once in _start right after apply_rela() using callee-saved x20 (_base) after any M3 image move and I-cache invalidation.
  • Makefile, aura-raw.ld, aura.ld, tools/stage1_room.py: -z pack-relative-relocs added alongside existing LDFLAGS; .relr.dyn (_relr_start/_relr_end) placed immediately after .rela.dyn inside the RX region (:text in aura-raw.ld, :rodata in aura.ld), moving _rodata_content_end and the closing ALIGN(_layout_step) / ALIGN(0x10000) cleanly to .relr.dyn while keeping *(.rela.init) outside [_rela_start, _rela_end).
  • proxyclient/aura/loadobjs.py: compares both .rela.dyn and .relr.dyn against the target when present (if start not in addrs: continue preserves compatibility with older images; proxy.readmem(addr, 0) handles empty .rela.dyn safely).
  • tests/python/test_relr_apply.py & tests/python/test_rela_layout.py: links with both GNU ld and lld using the exact Makefile LDFLAGS (--no-apply-dynamic-relocs + -z pack-relative-relocs), covering multi-bitmap runs (140 words), sparse addresses, intra-bitmap gaps, and unaligned .rela.dyn fallback, verifying exact word values and zero unintended byte mutations.
Evidence
  • Diff reviewed: aura#609 at f4c24747dd005c5dc035ee96ce4316125661bb28 (+286/-23, 9 files, 1 commit, MERGEABLE on main).
  • Verified proxyclient/tools/validate_legacy_boot.py loads PT_LOAD at link-time p_vaddr (base = 0), where RELR-packed words already carry their link-time values in the file and .rela.dyn remains present as an output section.
  • Nit (non-blocking): tests/python/test_relr_apply.py defines BASE = 0x40000000ULL and silences it with (void)BASE; since the harness relocates directly to (uint64_t)mem.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: FINISH at f4c24747.

Blocker: proxyclient/aura/loadobjs.py, in _load_base_symbols(), accepts a mismatched ELF when a packed relocation's addend changes but its slot stays put. RELR stores the slots. The addends moved from the table into the words being relocated, so checking both table byte ranges no longer catches this case. The client then uses the accepted ELF's addresses for symbol calls and injected object references.

Checked: Linked the PR's layout fixture twice with its raw linker script and Makefile flags, changing only the aligned .quad _start + 8 to .quad _start + 12. With both GNU ld and lld the packed .rela.dyn and .relr.dyn bytes matched while the relocated word differed. The unpacked .rela.dyn bytes differed on both linkers and would have tripped the old check. Preserve the match check with a stable image identity or by comparing packed relocation values against their live rebased equivalents where those values remain immutable. Please add a host regression with matching tables and different addends.

Keep the pending hosted checks and exact-head boot evidence from the earlier review as separate landing gates.

GNU ld before 2.43 (Ubuntu 24.04 has 2.42) ignores -z pack-relative-relocs
on AArch64 with a warning and keeps every pointer in .rela.dyn. The image
is still right (apply_relr() has nothing to do), but test_rela_layout and
test_relr_apply expected packed entries. They now accept that case when
the linker printed the warning, and test_relr_apply still relocates the
image and checks every word.

Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: FINISH at 5820fe17.

Checked: Reviewed the linker-test follow-up and ran both focused test files at this head. All six cases passed locally with GNU ld 2.46.1 and lld 22.1.6. The older GNU ld warning path still needs the hosted toolchain result.

Blocker: The proxyclient code is unchanged from the previous review. The test follow-up accepts an empty RELR table on older linkers, while the packed images can still pass the identity check with different pointer addends and matching relocation tables. Preserve that check and cover the mismatched-ELF case in a host test. Hosted checks and the exact-head boot evidence still apply.

loadobjs.py refused an ELF that was not the running image by comparing
.rela.dyn, which held every pointer's addend. A packed relocation keeps
its addend in the word it relocates, and the image may change that word
at run time, so two builds can now have the same tables and different
pointers.

Link with --build-id=sha1 and keep the note in the read-only region
(.note.gnu.build-id, _build_id_start/_end, 36 bytes) in both linker
scripts. image_mismatch() compares the relocation tables and the build
ID; an older image without the symbols is compared as before.

test_relr_apply links two images that differ only in one packed
pointer's addend: their tables match, and image_mismatch() still tells
them apart (with GNU ld before 2.43, by .rela.dyn as before).

Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Fixed in 649298b: the App's loadobjs.py finding is right. With RELR the addends live in the relocated words, so matching .rela.dyn/.relr.dyn bytes no longer identify the build.

  • Link with --build-id=sha1. Both linker scripts keep the note in the read-only region as .note.gnu.build-id (_build_id_start/_build_id_end, 36 bytes, nothing in it changes at run time).
  • image_mismatch() in proxyclient/aura/loadobjs.py compares .rela.dyn, .relr.dyn and the build ID against the target. An image without those symbols (an older link) is compared as before.
  • New host regression test_proxyclient_tells_builds_with_other_addends_apart (GNU ld and lld). It links the fixture twice, changing only one packed pointer from target + 0x40 to target + 0x44. It asserts the two relocation tables are byte-identical, and that image_mismatch() accepts the same image and refuses the other one (by .note.gnu.build-id). With GNU ld before 2.43, which doesn't pack, it refuses by .rela.dyn as before. With the build ID taken out of the check, both cases fail.

Full host pytest: 1505 passed, 28 skipped. The fedora:44 stage1_size.sh numbers are unchanged (ESP Stage 2 77088 B). The relocation tests also pass with GNU ld 2.42 (aurora-s1gcc) and 2.46. The (void)BASE nit is gone.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: HOLD at 649298bc for hosted checks and boot evidence. The packed-pointer identity blocker is resolved.

Checked: Ran eight focused relocation and identity tests at this head with GNU ld and lld. Both linkers produce identical relocation tables for the two different packed pointer values, and the production proxyclient check now rejects the mismatch at the build ID. The note is in the raw file-backed load region and inside the Mach-O read-only file range. I also checked older fixtures without a build ID on both linkers. A matching ELF is accepted and a mismatched RELA table is rejected.

Please retain the exact-head boot rows and the owner disposition for the affected boot paths before landing.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Boot rows at 649298b.

Tested:

  • J615 (MacBook Air M3, T8122), method-T chain one-shot: the installed Stage 1 (1.0.0b13) took the aura-try marker once and chainloaded this PR's Stage 1 (RELEASE=1 CHAINLOADING=1 BUILTIN_LOGO=aurora USE_CLANG=1 BUILDSTD=1, clang 22). That Stage 1 loaded this PR's ESP Stage 2 (same flags + ESP_STAGE2=1) composed with the Mac's own DTB/U-Boot tail. The configured Stage 2, the installed Stage 1, LocalPolicy, NVRAM and GRUB were not written. Both images link with an empty .rela.dyn; all their relative relocations are in .relr.dyn.
    • Stage 1 log: aura 1.0.0b17-g649298bc, cmdline: aura-trial, aura moved itself from 0x10007174000 to 0x10004d44000, the run base stage 1 gave it, fb: display logo, fb console: max rows 54, max cols 74, chainload: image staged at 0x10009620000 runs its first 0x3b4000 bytes at 0x10004d44000. So both images moved to their run base and then relocated. The Stage 2 version in /chosen is 1.0.0b17-g649298bc.
    • Linux: running, Enforcing, 0 failed units, 0 AVC, simpledrm fb0 + fbcon, gdm up.
    • A/B control on the same path: the merge base a382495, built with the same flags. Same move lines and the same fb/console lines. Kernel errors: the set with this PR is a subset of the base set (base has one extra brcmfmac ring-pointer line). Apart from the version and the next-stage hash, the Stage 1 log matches base line for line.
  • J615, proxy + loadobjs: the installed Stage 1's CDC proxy window was caught from the tether host. This PR's dev build (proxy mode) was chainloaded over it with chainload.py -r and came up as aura uartproxy 1.0.0b17-g64929. Then LinkedProgram(u, base_object=...):
    • accepts the matching ELF (1213 symbols);
    • refuses a build of this head with one printf string changed, this PR's release ESP Stage 2 ELF, and the base a382495 ELF ("Mismatch between ... and image on target").
    • Then p.reboot().
  • After the rows the J615 is back on its saved kernel and configured Stage 2 (hash unchanged): no aura-try or aura-proxy marker, empty next_entry, Enforcing, 0 failed.

Not run yet: the J473 (T8112) second-family regression row. The J473 has been reserved by another lab task since 19:50. This row is queued for it: an ESP Stage 2 aura-try one-shot plus a method-T chain, on the same scripts.

Risk: the J615 rows cover one family (T8122) on both the move-then-relocate path and the proxy chainload path. Until the J473 row runs, the other families rely on the host tests (test_relr_apply, test_rela_layout, GNU ld and lld).

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: HOLD at 649298bc for pending hosted checks and the J473 second-family row.

Checked: The J615 one-shot reached Linux with the exact Stage 1 and ESP Stage 2 after the move-and-relocate path. The same-machine base control preserved the display and console behavior. The live proxy accepted its matching ELF and rejected all three mismatches, including the same-head build with one changed string. The restoration receipt shows the saved boot returned with the trial markers cleared.

The J615 boot and live proxy checks are satisfied. Keep the J473 regression or an explicit maintainer disposition, plus the current ESP vital-size and format checks.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Second-family row: MacBook Neo (J700, T8140), built together with #611. PASS.

Tested:

  • Tree: main 7dbbeb1 + Pack the relative relocations (RELR) to free ESP Stage 2 room #609 649298b + smp: keep the SMP_SHARED state in .bss, out of the file (16 KiB on every toolchain) #611 e7a148f, merged locally (9b012556). ESP Stage 2 with the package flags
    (make BUILDSTD=1 RELEASE=1 CHAINLOADING=1 ESP_STAGE2=1 USE_CLANG=1 BUILTIN_LOGO=aurora, buildbox clang 22), 1.0.0b17-g9b012556.
    .rela.dyn 0 B, .relr.dyn present, .note.gnu.build-id present. tools/stage1_size.sh (clang 22, USE_CLANG=1 BUILTIN_LOGO=aurora BUILDSTD=1):
    all five flavours link and pass, esp-stage2 headroom 93472 B, stage1 126512 B.
  • Neo one-shot: that aura.bin + the Neo's own DTB/U-Boot tail from its installed Stage 2, as an aura-try trial under the
    installed Stage 1 1.0.0b10-gdab56f2f (trial guard + dead-man). Stage 1: chainload: trial boot of m1n1/s2try-609-611.bin,
    image staged at 0x10010ca0000 runs its first 0x3b4000 bytes at 0x10005bf0000. Linux came up on it (aurora,trial set,
    stage2 1.0.0b17-g9b012556), Enforcing, 0 failed units, 0 AVC.
  • Same checks on the saved Stage 2 (1.0.0b17) just before, as the A/B baseline: 6/6 CPUs, cpu1-5 offline/online, s2idle and
    deep resume via rtc0, all PASS on both. Kernel error lines identical (one dwc3 genpd_prepare returns -11 per sleep, on both).
  • Restored: saved Stage 2 running, aura-try absent, trial files removed, GRUB boot_success=1, next_entry empty, Enforcing,
    0 failed. Silent (nothing played). Stage 1, LocalPolicy, NVRAM and the installed Stage 2 were not written.

Evidence: traces/boot/20261130-609-611-neo (README, per-boot logs). With the J615 row this covers both requested families
for the boot/relocation path (Neo instead of J473 as the second family; J473 was held all evening).

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Maintainer decision on the second-family row (closeout, at 649298bc): the Neo (T8140) row counts as this PR's second-family regression, in place of the J473. The J473 has been held for a physical check since 19:50.

The Neo row booted this PR's code (combined with #611) through the same one-shot ESP Stage 2 path: Stage 1 chainloads the trial image, which moves to its run base and then applies the packed relocations. It came up with all 6 CPUs, passed three CPU offline/online cycles, one s2idle and two deep-sleep resumes, Enforcing with 0 failed units, and the same kernel error lines as baseline. Together with the J615 method-T chain and the proxy loadobjs build-ID checks, both relocation paths are covered (in-place and after a move) on two SoC families (T8122 and T8140).

The J473 row is still welcome as an extra check after merge; its kit is ready in kits/aura/20261130-609-rows/j473/.

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Nov 30, 2026

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at 649298bc

Blockers:

  • None. All 22 hosted CI checks at 649298bc have passed and both SoC families' hardware rows (J615 T8122 + Neo T8140 per maintainer closeout disposition) are in.

Checked:

  • Hosted CI at 649298bc: 22/22 passed (build, ESP stage 2 vital size, format-check, gcc, clang-macos, all Pytest matrices including native ARM start.S, fedora, alarm, nix, selftest, pr-text, policy, readiness), 0 failed, 0 queued.
  • Two-family hardware verification at 649298bc:
    • J615 (M3, T8122): Method-T chain one-shot with both Stage 1 and ESP Stage 2 linked with empty .rela.dyn and all relative relocations in .relr.dyn (both moved to run base and relocated; Linux Enforcing, 0 failed units, 0 AVC, A/B control against a3824954 matches line-for-line), plus proxy loadobjs build-ID checks accepting the matching ELF (1,213 symbols) and rejecting modified/release/base ELFs.
    • Neo (T8140): Accepted by maintainer closeout disposition as the second-family regression row (one-shot ESP Stage 2 move + packed relocations, 6 CPUs up, 3 CPU offline/online cycles, 1 s2idle + 2 deep-sleep resumes, Enforcing, 0 failed units, baseline-identical kernel errors).
  • Prior code audit (+376/-23, 9 files): RELR decoder, linker scripts, GNU ld compatibility test, and build-ID check in proxyclient remain clean.
Evidence
  • Hosted CI at 649298bc: 22/22 passed, 0 failed, 0 queued.
  • Post-merge note (non-blocking): J473 row remains optional post-merge verification as noted in the maintainer comment.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Merging at 649298bc (merge) under the 6-point rule. (1) The review App's verdict at this head: APPROVED. (2) CI is green at this head (readiness excluded). (3/4) Rows: J615 method-T chain (Stage 1 + ESP Stage 2 at 649298b) + proxy loadobjs build-ID PASS (traces/boot/20261130-609-rows); second family = Neo T8140 combined #609+#611 one-shot PASS: CPUs, offline/online, s2idle, 2 deep resumes (traces/boot/20261130-609-611-neo); J473 row replaced by the Neo row (maintainer decision). (5) No blocking review is open. (6) Dj was pinged with no objection. Revert: git revert -m 1 <commit>.

@RyanTheTide
RyanTheTide merged commit d78ccc8 into main Nov 30, 2026
34 checks passed
@RyanTheTide
RyanTheTide deleted the fix/esp-stage2-room branch November 30, 2026 12:24
rolotrealanis98 pushed a commit to rolotrealanis98/aura that referenced this pull request Nov 30, 2026
The state a core reads with its MMU off or uncached (reset stacks, spin
table, S2R mailbox, kernel park slots) had a 16 KiB page of its own in
.data. Every byte of it but three initial values is zero, yet the page
sat in the file part of every image, before _file_vital_end, where the
ESP Stage 2 has to end below the panel DCP's log buffer.

Put it on its own pages at the start of .bss (.bss.smp_shared) in both
linker scripts. memory.c still maps exactly those pages uncached and
smp.c still cleans them to PoC; S2R cleans [_data_start, _bss_end) as
before. _start_c clears .bss and then calls smp_shared_init(), which
sets the three values that do not start as zero: boot_cpu_idx -1,
spin_table at spin_table_image, and an MPIDR of ~0 in every
smp_reset_stacks entry. Nothing reads them earlier: no secondary runs
and no reset can come back to this image before smp_init().

This frees 16 KiB of the file on every toolchain. Packed relocations
(aura#609) free more, but only with lld or GNU ld 2.43 and later; the
release workflow and the installer's UEFI-only build link with Ubuntu
24.04's GNU ld 2.42, which ignores -z pack-relative-relocs on AArch64.
gcc + GNU ld 2.42, ESP Stage 2 headroom: main 4160 B, this 27392 B;
main + this + aurora-silicon#601 + aurora-silicon#604 (with or without aurora-silicon#609) 10424 B.

Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
RyanTheTide added a commit that referenced this pull request Dec 1, 2026
Picks up main's size work (#609 RELR, #611 SMP .bss) so the gcc esp-stage2 build clears the 4 KiB headroom floor; no conflicts.

Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant