fix(relinker): accept zero-sized data symbols at load boundaries #4985

Closed
Ondra97 wants to merge 1 commit from upstream-pr/4985 into main
Ondra97 commented 2026-10-13 07:18:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-13T07:18:31Z.


What

Bundled modules with zero-sized defined data or NOTYPE symbols at a load boundary were rejected because the reader and native export writers required one byte. A fixture whose writable load ends at 0x2400 and whose data symbol denotes that address failed before producing output.

Accept these symbols as validated address points, including the load endpoint. Function symbols still require executable bytes, nonempty ranges must remain contained, and writable ranges still reject size zero before the size - 1 calculation.

The ELF symbol specification allows zero to mean no or unknown size. GNU ld's documented boundary labels assign a symbol to the end of an output section.

Tested

Windows 11 x64, WinLibs MinGW-w64 GCC 15.2.0, Python 3.14; final base main c2565f014:

  • New regression failed on the original implementation, then passed.
  • Release relinker-only build succeeds; complete CTest suite: 140/140 pass, no skips.
  • 39 fixture conversions across Linux ELF, Windows PE and Mach-O verify numeric exports and local/RELATIVE pointer values, including page-aligned ends. Invalid functions, initializers, writes, gaps and nonempty ranges remain rejected.
  • Direct C++ checks preserve rejection of empty writable ranges and endpoint writes.
  • Conventions, test registration and whitespace checks pass.
  • All 493 open PR heads were inspected; repository overlap checks report no overlap, including #4140, #4547 and #4739.

Linux/Mac output was inspected on Windows; no Linux or macOS execution, full runtime build or commercial title run.

Checklist

  • Based on current main; no other open PR implements the same fix
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; no silent stub added
  • No notes, investigation Markdown files or images added to the repository
  • New third-party code is a submodule built from source: no dependency added
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • AI-assisted: yes (Codex)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4839776819 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4985). Originally posted by [Ondra97](https://github.com/Ondra97) on 2026-10-13T07:18:31Z. --- ### What Bundled modules with zero-sized defined data or NOTYPE symbols at a load boundary were rejected because the reader and native export writers required one byte. A fixture whose writable load ends at `0x2400` and whose data symbol denotes that address failed before producing output. Accept these symbols as validated address points, including the load endpoint. Function symbols still require executable bytes, nonempty ranges must remain contained, and writable ranges still reject size zero before the `size - 1` calculation. The [ELF symbol specification](https://refspecs.linuxfoundation.org/elf/gabi4%2B/ch4.symtab.html) allows zero to mean no or unknown size. [GNU ld's documented boundary labels](https://sourceware.org/binutils/docs/ld/Output-Section-LMA.html) assign a symbol to the end of an output section. ### Tested Windows 11 x64, WinLibs MinGW-w64 GCC 15.2.0, Python 3.14; final base `main` `c2565f014`: - New regression failed on the original implementation, then passed. - Release relinker-only build succeeds; complete CTest suite: 140/140 pass, no skips. - 39 fixture conversions across Linux ELF, Windows PE and Mach-O verify numeric exports and local/RELATIVE pointer values, including page-aligned ends. Invalid functions, initializers, writes, gaps and nonempty ranges remain rejected. - Direct C++ checks preserve rejection of empty writable ranges and endpoint writes. - Conventions, test registration and whitespace checks pass. - All 493 open PR heads were inspected; repository overlap checks report no overlap, including #4140, #4547 and #4739. Linux/Mac output was inspected on Windows; no Linux or macOS execution, full runtime build or commercial title run. ### Checklist - [x] Based on current `main`; no other open PR implements the same fix - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw; no silent stub added - [x] No notes, investigation Markdown files or images added to the repository - [x] New third-party code is a submodule built from source: no dependency added - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] AI-assisted: yes (Codex)
coltken95 commented 2026-10-13 11:10:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by coltken95 on 2026-10-13T11:10:48Z.


Linux validation (Ubuntu 24.04, GCC 13.3, Release), this PR's commit on main at 77b9f7270:

  • guest_zero_sized_symbols, guest_module_identity and guest_export_lookup pass, so the relinked Linux output is executed here, not only inspected.
  • With main's relinker sources and this PR's tests, guest_zero_sized_symbols fails and the other two pass, so the new test catches the rejection.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6144239135 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4985#issuecomment-6144239135). Originally posted by [coltken95](https://github.com/coltken95) on 2026-10-13T11:10:48Z. --- Linux validation (Ubuntu 24.04, GCC 13.3, Release), this PR's commit on `main` at 77b9f7270: - `guest_zero_sized_symbols`, `guest_module_identity` and `guest_export_lookup` pass, so the relinked Linux output is executed here, not only inspected. - With `main`'s relinker sources and this PR's tests, `guest_zero_sized_symbols` fails and the other two pass, so the new test catches the rejection. AI-assisted: yes
xXPBSXx commented 2026-10-13 11:51:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T11:51:42Z.


Windows test: head c9a49a682 merged onto current main 5d50886ee, together with 9 other open pull requests in one build (the merges were conflict-free); a failure would have been bisected per PR. Windows 10, MinGW GCC (WinLibs), Ninja Release, -j2: full build 0 errors; ctest for the tests this change adds or touches: guest_zero_sized_symbols passed, windows_guest_export_aliases passed; python tools/check_conventions.py --base upstream/main passed for the combined tree. I did not run the new tests against main without the change.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6144911458 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4985#issuecomment-6144911458). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-13T11:51:42Z. --- Windows test: head `c9a49a682` merged onto current `main` `5d50886ee`, together with 9 other open pull requests in one build (the merges were conflict-free); a failure would have been bisected per PR. Windows 10, MinGW GCC (WinLibs), Ninja Release, `-j2`: full build 0 errors; ctest for the tests this change adds or touches: guest_zero_sized_symbols passed, windows_guest_export_aliases passed; `python tools/check_conventions.py --base upstream/main` passed for the combined tree. I did not run the new tests against `main` without the change. AI-assisted (Claude Code).
oneandonlydean commented 2026-10-14 02:33:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:33:23Z.


Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6159592833 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4985#issuecomment-6159592833). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T02:33:23Z. --- Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!4985
No description provided.