loader: skip R_X86_64_NONE relocations #1534

Closed
github-bot wants to merge 1 commit from gh-pr/1534/head into gh-pr/1534/base
Owner

@⁠Nawid3333 on GitHub · 2026-10-15 18:48 UTC · original
Nawid3333:loader/skip-r-x86-64-none → main · +33 −0 · 4 files · 1 commits · closed without merging

Hello Kitty Island Adventure (PPSA18176) stops while it loads Media/Modules/PS5Util.prx with sceKernelLoadStartModule (#610). eboot.bin, libc.prx and libSceNpCppWebApi.prx relocate fine; the relocation pass over PS5Util.prx ends with (line numbers from build 719e025):

--- Relocate program: /path/to/PPSA18176/Media/Modules/PS5Util.prx ---
--- Build ---
Official build KytyPS5-2026-10-04-719e025
--- Error ---
unknown type: 0
 in /home/runner/work/KytyPS5/KytyPS5/src/loader/runtimeLinker.cpp:868

That module has a relocation entry of type 0, R_X86_64_NONE. It is a no-op: the x86-64 ABI defines no computation for it, and FreeBSD's rtld skips it (reloc.c). GetRelocationInfo still has no case for it at 9e41d832 and ends in default: EXIT("unknown type: %d\n", ...).

RelocateRecord now returns true for such an entry before resolving anything, so the entry is marked done in rela_bits and nothing is written. A case in GetRelocationInfo alone would not be enough: the entry would come back unresolved, get a stub, and the stub address would be written at base_vaddr + r_offset, over the module's first 8 bytes when r_offset is 0.

This is #1146 by @⁠NevesHenry (cause found by @⁠tucubanit0 in #610), the same patch (identical patch-id), applied to 9e41d832 without conflicts. #1146 was based on d2413fc2; the only upstream commit touching runtimeLinker.cpp since then, cb375ec3 (LoadExec), doesn't touch the relocation code. #1146 was closed on 2026-10-08, two days before the README asked PRs to name the game they fix (947627d1); the bug still stops this game, so I'm sending it again. If #1146 was closed on purpose, tell me and I'll close this one.

Testing (Windows 11, clang-cl 19.1.5, Release; tree: 9e41d832 + this commit):

  • TestRelocationSkipsNoneEntries (tests/VirtualMemoryAllocationTests.cpp, CTest virtual_memory_allocation): a type-0 entry at offset 0 leaves the module's first word unchanged, and an R_X86_64_RELATIVE entry next to it is still applied. It passes; with the early return removed, the test program exits with unknown type: 0, the error from #610.
  • shader_cfg, resource_tracking, resource_materialization, scalar_provenance, shader_vertex_metadata, lru_cache, ime_dialog, audio_out2_port, pad_haptics and controller_settings still pass.
  • main's CI is red at 9e41d832 on Linux and Windows because two test files don't build (run; the last green run was df5b9b92). #1504 fixes that, so this PR's own CI will be red until it lands. CI on my fork for this commit with #1504 on top: green on Windows, Linux and macOS, virtual_memory_allocation passes on all three: https://github.com/Nawid3333/KytyPS5/actions/runs/38785275527
  • I don't have the game, so I can't say how far it gets after this; the next stop may be something else.

AI use (per the README's AI policy): the commit is NevesHenry's and was written with Claude, per its trailer. For this resubmission Claude Code (Anthropic) re-applied it, ran the checks above on my machine and wrote this description.

**@⁠Nawid3333** on GitHub · 2026-10-15 18:48 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1534) `Nawid3333:loader/skip-r-x86-64-none` → `main` · +33 −0 · 4 files · 1 commits · closed without merging Hello Kitty Island Adventure (PPSA18176) stops while it loads `Media/Modules/PS5Util.prx` with `sceKernelLoadStartModule` (#610). `eboot.bin`, `libc.prx` and `libSceNpCppWebApi.prx` relocate fine; the relocation pass over `PS5Util.prx` ends with (line numbers from build 719e025): ``` --- Relocate program: /path/to/PPSA18176/Media/Modules/PS5Util.prx --- --- Build --- Official build KytyPS5-2026-10-04-719e025 --- Error --- unknown type: 0 in /home/runner/work/KytyPS5/KytyPS5/src/loader/runtimeLinker.cpp:868 ``` That module has a relocation entry of type 0, `R_X86_64_NONE`. It is a no-op: the x86-64 ABI defines no computation for it, and FreeBSD's rtld skips it ([reloc.c](https://github.com/freebsd/freebsd-src/blob/8d2708de5d6112a492744d367cfdfb8fd219227a/libexec/rtld-elf/amd64/reloc.c#L212-L214)). `GetRelocationInfo` still has no case for it at 9e41d832 and ends in `default: EXIT("unknown type: %d\n", ...)`. `RelocateRecord` now returns true for such an entry before resolving anything, so the entry is marked done in `rela_bits` and nothing is written. A `case` in `GetRelocationInfo` alone would not be enough: the entry would come back unresolved, get a stub, and the stub address would be written at `base_vaddr + r_offset`, over the module's first 8 bytes when `r_offset` is 0. This is #1146 by @⁠NevesHenry (cause found by @⁠tucubanit0 in #610), the same patch (identical patch-id), applied to 9e41d832 without conflicts. #1146 was based on d2413fc2; the only upstream commit touching `runtimeLinker.cpp` since then, cb375ec3 (LoadExec), doesn't touch the relocation code. #1146 was closed on 2026-10-08, two days before the README asked PRs to name the game they fix (947627d1); the bug still stops this game, so I'm sending it again. If #1146 was closed on purpose, tell me and I'll close this one. **Testing** (Windows 11, clang-cl 19.1.5, Release; tree: 9e41d832 + this commit): - `TestRelocationSkipsNoneEntries` (tests/VirtualMemoryAllocationTests.cpp, CTest `virtual_memory_allocation`): a type-0 entry at offset 0 leaves the module's first word unchanged, and an `R_X86_64_RELATIVE` entry next to it is still applied. It passes; with the early return removed, the test program exits with `unknown type: 0`, the error from #610. - `shader_cfg`, `resource_tracking`, `resource_materialization`, `scalar_provenance`, `shader_vertex_metadata`, `lru_cache`, `ime_dialog`, `audio_out2_port`, `pad_haptics` and `controller_settings` still pass. - main's CI is red at 9e41d832 on Linux and Windows because two test files don't build ([run](https://github.com/KytyPS5/KytyPS5/actions/runs/38471675595); the last green run was df5b9b92). #1504 fixes that, so this PR's own CI will be red until it lands. CI on my fork for this commit with #1504 on top: green on Windows, Linux and macOS, `virtual_memory_allocation` passes on all three: https://github.com/Nawid3333/KytyPS5/actions/runs/38785275527 - I don't have the game, so I can't say how far it gets after this; the next stop may be something else. **AI use** (per the README's AI policy): the commit is NevesHenry's and was written with Claude, per its trailer. For this resubmission Claude Code (Anthropic) re-applied it, ran the checks above on my machine and wrote this description.
GetRelocationInfo had no case for relocation type 0, so loading a module
with an R_X86_64_NONE entry stopped with "unknown type: 0" (#610, the
PS5Util.prx of Hello Kitty Island Adventure). The type is a no-op and
FreeBSD's rtld skips it.

Return early from RelocateRecord so the entry is marked done without
writing anything. A case in GetRelocationInfo alone would leave it
unresolved, and the stub address would be written at base + r_offset.

Co-authored-by: tucubanit0 <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:58:54 +00:00
github-bot closed this pull request 2026-11-26 09:58:54 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-15 18:51 UTC · original

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a255ceb8-16d8-4e3b-803d-12387f5d578e
📥 Commits

Reviewing files that changed from the base of the PR and between 9e41d8320a and 21c8605f5a.

📒 Files selected for processing: 4
  • src/loader/elf.h
  • src/loader/runtimeLinker.cpp
  • src/loader/runtimeLinker.h
  • tests/VirtualMemoryAllocationTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

📝 Walkthrough

The loader defines R_X86_64_NONE and treats entries of this type as successful without resolving or patching their targets. A new test checks that a NONE target remains unchanged and a RELATIVE target is updated. The test is registered in the standard virtual-memory allocation test sequence.

Suggested reviewers: nmzik

Priority: ➖ Normal

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 21c86

The change appears to implement the intended no-op relocation behavior and includes a regression test. No actionable merge risk is identified from the supplied evidence.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description check Passed The description directly explains the R_X86_64_NONE relocation failure, the proposed fix, affected game, and test results.
Title check Passed The title clearly and concisely describes the main change: skipping R_X86_64_NONE relocations in the loader.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-15 18:51 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1534#issuecomment-6199805614) <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/1534?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary><strong>ℹ️ Recent review info</strong></summary> <dl> <dd> <details> <summary><strong>⚙️ Run configuration</strong></summary> <dl> <dd> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `a255ceb8-16d8-4e3b-803d-12387f5d578e` </dd> </dl> </details> <details> <summary><strong>📥 Commits</strong></summary> <dl> <dd> Reviewing files that changed from the base of the PR and between 9e41d8320a2774b303fbad344c2347e8d0292e83 and 21c8605f5ad27dd92a56bd94d47227b1d5a5401b. </dd> </dl> </details> <details> <summary><strong>📒 Files selected for processing: 4</strong></summary> <dl> <dd> * `src/loader/elf.h` * `src/loader/runtimeLinker.cpp` * `src/loader/runtimeLinker.h` * `tests/VirtualMemoryAllocationTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </dd> </dl> </details> <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> The loader defines `R_X86_64_NONE` and treats entries of this type as successful without resolving or patching their targets. A new test checks that a NONE target remains unchanged and a RELATIVE target is updated. The test is registered in the standard virtual-memory allocation test sequence. **Suggested reviewers:** `nmzik` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"21c8605f5ad27dd92a56bd94d47227b1d5a5401b" --> **Change:** Bug fix <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong>⚪ Minimal</strong> · up to <code>21c86</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **⚪ Minimal** · up to `21c86` --> <!-- final_review_risk_coverage:{"sourceCommitId":"21c8605f5ad27dd92a56bd94d47227b1d5a5401b","coveredCommitId":"21c8605f5ad27dd92a56bd94d47227b1d5a5401b","kind":"reviewed"} --> The change appears to implement the intended no-op relocation behavior and includes a regression test. No actionable merge risk is identified from the supplied evidence. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4 · <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> 1</strong></summary> <dl> <dd> <strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> Failed checks: 1 warning</strong> | Check name | Status | Explanation | Resolution | | :---------------- | :----------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Warning](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg) | Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 4 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> Passed checks: 4 passed</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------- | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description directly explains the R_X86_64_NONE relocation failure, the proposed fix, affected game, and test results. | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly and concisely describes the main change: skipping R_X86_64_NONE relocations in the loader. | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1534)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>❤️ Share</strong></summary> <dl> <dd> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </dd> </dl> </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
Author
Owner

@⁠Nmzik on GitHub · 2026-10-15 20:47 UTC · original

That bug was closed on purpose. The game dump is invalid

**@⁠Nmzik** on GitHub · 2026-10-15 20:47 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1534#issuecomment-6201941817) That bug was closed on purpose. The game dump is invalid
Author
Owner

@⁠Nawid3333 on GitHub · 2026-10-15 20:48 UTC · original

oh did not see that ok

**@⁠Nawid3333** on GitHub · 2026-10-15 20:48 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1534#issuecomment-6201967051) oh did not see that ok
Author
Owner

@⁠Nawid3333 on GitHub · 2026-10-15 20:52 UTC · original

Any thing i can focus on i have time this weekend @⁠Nmzik

**@⁠Nawid3333** on GitHub · 2026-10-15 20:52 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1534#issuecomment-6202043540) Any thing i can focus on i have time this weekend @⁠Nmzik
Author
Owner

@⁠Nmzik on GitHub · 2026-10-16 01:15 UTC · original

@⁠Nawid3333 If you have a spare time would you be able to look at shader opcodes. Maybe we can emit less instructions for some of them while still preserving correctness (just an idea)

**@⁠Nmzik** on GitHub · 2026-10-16 01:15 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1534#issuecomment-6205785180) @⁠Nawid3333 If you have a spare time would you be able to look at shader opcodes. Maybe we can emit less instructions for some of them while still preserving correctness (just an idea)
Author
Owner

@⁠Nawid3333 on GitHub · 2026-10-20 19:39 UTC · original

@⁠nmzik A short update and a question. After your idea here I opened five "fewer instructions" PRs (#1554, #1565, #1566, #1567, #1568).

Right now I'm working on:

  • the missing f16 interpolation opcodes that stop Anno 1800 and AC Black Flag Resynced (#281)
  • the GPU thread cost in Demon's Souls (most of it is buffer readbacks), measured with and without #1254

What I can provide: tests on Windows with an RX 9070 XT, measured game runs, full GPU test suite runs, and hardware-exact opcode fixes with tests.

What would help you most right now? And please close any of my open PRs you don't need; I'd rather have a few useful ones than many open.

**@⁠Nawid3333** on GitHub · 2026-10-20 19:39 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1534#issuecomment-6299730462) @⁠nmzik A short update and a question. After your idea here I opened five "fewer instructions" PRs (#1554, #1565, #1566, #1567, #1568). Right now I'm working on: - the missing f16 interpolation opcodes that stop Anno 1800 and AC Black Flag Resynced (#281) - the GPU thread cost in Demon's Souls (most of it is buffer readbacks), measured with and without #1254 What I can provide: tests on Windows with an RX 9070 XT, measured game runs, full GPU test suite runs, and hardware-exact opcode fixes with tests. What would help you most right now? And please close any of my open PRs you don't need; I'd rather have a few useful ones than many open.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.