loader: skip R_X86_64_NONE relocations #1146

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

@⁠NevesHenry on GitHub · 2026-10-07 15:18 UTC · original
NevesHenry:loader/skip-none-relocations → main · +33 −0 · 4 files · 1 commits · closed without merging

Summary

GetRelocationInfo has no case for relocation type 0, R_X86_64_NONE, so loading a module that contains one stops the emulator with unknown type: 0. R_X86_64_NONE is a no-op, and FreeBSD's rtld skips it (reloc.c, releng/11.0).

RelocateRecord now returns true for these entries before resolving them. They are marked done in rela_bits and nothing is written. Adding only a case to GetRelocationInfo would not be enough: the entry would come back unresolved and get a stub, and the stub's address would be written at base_vaddr + r_offset.

@⁠tucubanit0 found the cause and suggested this fix in #610 (comment). The commit credits them as co-author.

Evidence

#610 Hello Kitty Island Adventure (PPSA18176) doesn't boot. The game reads Media/boot.config, then loads Media/Modules/PS5Util.prx with sceKernelLoadStartModule. eboot.bin, libc.prx and libSceNpCppWebApi.prx relocate fine, and the error comes while relocating that module:

	module_file_name = /app0/Media/Modules/PS5Util.prx
Loading: /path/to/PPSA18176/Media/Modules/PS5Util.prx
...
--- 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

This shows on two builds and two systems: d3d7bd3 on Windows (issue log) and 719e025 on Linux (log in tucubanit0's comment).

In the other logs attached to issues here, PS5Util.prx (a Unity module) is relocated in 60 other issues with no error, and unknown type: 0 appears only in #610. So only this game's copy has such entries.

I don't have the game, so I can't say how far it gets with this change. tucubanit0 noted that the log also shows unresolved imports that may be the next blocker.

Testing

TestRelocationSkipsNoneEntries (hook in runtimeLinker.cpp, run by virtual_memory_allocation_tests) passes an all-zero R_X86_64_NONE entry and an R_X86_64_RELATIVE entry to RelocateRecord over a two-word buffer. It checks that both report done, that the NONE entry leaves the memory alone and that the RELATIVE entry writes base + addend.

I ran it in an Ubuntu 24.04 container (clang 18, Release, no LTO). Results:

  • with main's RelocateRecord, the test exits with unknown type: 0, the error from #610
  • with only a case R_X86_64_NONE: break; in GetRelocationInfo, it fails with "R_X86_64_NONE was not skipped or changed module memory"
  • with this change, all cases pass

In the same container, kyty_emulator and kyty_tests build, and the 34 ctest tests that don't need a Vulkan device pass. I left out the other 16 (kernel_file_system and the ones that run shader_recompiler_compute_tests) because they can't create a Vulkan instance there, with or without this change.

The changed lines in src/ are clean under clang-format 22.1.3. Not built on Windows or macOS.

AI assistance

An AI coding assistant (Claude Code) helped me check the logs and the FreeBSD source, write the change and the test, and run the builds above. I reviewed the code and the test results. All communication on this PR comes from me.

🤖 Generated with Claude Code

**@⁠NevesHenry** on GitHub · 2026-10-07 15:18 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1146) `NevesHenry:loader/skip-none-relocations` → `main` · +33 −0 · 4 files · 1 commits · closed without merging ## Summary `GetRelocationInfo` has no case for relocation type 0, `R_X86_64_NONE`, so loading a module that contains one stops the emulator with `unknown type: 0`. `R_X86_64_NONE` is a no-op, and FreeBSD's rtld skips it ([reloc.c](https://github.com/freebsd/freebsd-src/blob/8d2708de5d6112a492744d367cfdfb8fd219227a/libexec/rtld-elf/amd64/reloc.c#L212-L214), releng/11.0). `RelocateRecord` now returns true for these entries before resolving them. They are marked done in `rela_bits` and nothing is written. Adding only a `case` to `GetRelocationInfo` would not be enough: the entry would come back unresolved and get a stub, and the stub's address would be written at `base_vaddr + r_offset`. @⁠tucubanit0 found the cause and suggested this fix in #610 ([comment](https://git.gtahub.st/github/KytyPS5--KytyPS5/issues/610)). The commit credits them as co-author. ## Evidence #610 Hello Kitty Island Adventure (PPSA18176) doesn't boot. The game reads `Media/boot.config`, then loads `Media/Modules/PS5Util.prx` with `sceKernelLoadStartModule`. `eboot.bin`, `libc.prx` and `libSceNpCppWebApi.prx` relocate fine, and the error comes while relocating that module: ``` module_file_name = /app0/Media/Modules/PS5Util.prx Loading: /path/to/PPSA18176/Media/Modules/PS5Util.prx ... --- 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 ``` This shows on two builds and two systems: d3d7bd3 on Windows (issue log) and 719e025 on Linux (log in tucubanit0's comment). In the other logs attached to issues here, `PS5Util.prx` (a Unity module) is relocated in 60 other issues with no error, and `unknown type: 0` appears only in #610. So only this game's copy has such entries. I don't have the game, so I can't say how far it gets with this change. tucubanit0 noted that the log also shows unresolved imports that may be the next blocker. ## Testing `TestRelocationSkipsNoneEntries` (hook in `runtimeLinker.cpp`, run by `virtual_memory_allocation_tests`) passes an all-zero `R_X86_64_NONE` entry and an `R_X86_64_RELATIVE` entry to `RelocateRecord` over a two-word buffer. It checks that both report done, that the NONE entry leaves the memory alone and that the RELATIVE entry writes `base + addend`. I ran it in an Ubuntu 24.04 container (clang 18, Release, no LTO). Results: - with main's `RelocateRecord`, the test exits with `unknown type: 0`, the error from #610 - with only a `case R_X86_64_NONE: break;` in `GetRelocationInfo`, it fails with "R_X86_64_NONE was not skipped or changed module memory" - with this change, all cases pass In the same container, `kyty_emulator` and `kyty_tests` build, and the 34 ctest tests that don't need a Vulkan device pass. I left out the other 16 (`kernel_file_system` and the ones that run `shader_recompiler_compute_tests`) because they can't create a Vulkan instance there, with or without this change. The changed lines in `src/` are clean under clang-format 22.1.3. Not built on Windows or macOS. ## AI assistance An AI coding assistant (Claude Code) helped me check the logs and the FreeBSD source, write the change and the test, and run the builds above. I reviewed the code and the test results. All communication on this PR comes from me. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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:44:57 +00:00
github-bot closed this pull request 2026-11-26 09:44:57 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-07 15:22 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: dec40352-6f00-461e-a48a-a1fd884ef875
📥 Commits

Reviewing files that changed from the base of the PR and between d2413fc2eb and 29e9bcad07.

📒 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

Walkthrough

The loader now defines R_X86_64_NONE and treats entries of this type as complete without resolving symbols or patching memory. A test checks that a no-op relocation leaves its target unchanged and that a relative relocation updates its target. The test is registered in the standard test sequence.

Suggested reviewers: nmzik

Priority: ➖ Normal

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 29e9b

The change skips no-op relocations while preserving other relocation behavior in the described tests. No concrete merge-blocking issue is evident; proceed with normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ 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 checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description directly explains the R_X86_64_NONE relocation issue, the implementation, the regression test, and the reported validation results.
Title check ✅ Passed The title clearly and concisely summarizes the primary 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.
  • Autopilot · 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-07 15:22 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1146#issuecomment-6040995364) <!-- 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/1146?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=2" alt="Review in Change Stack →" width="220" height="32"></a> <!-- review_stack_entry_end --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary>ℹ️ Recent review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `dec40352-6f00-461e-a48a-a1fd884ef875` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between d2413fc2ebd91d1b7234197c2dd5bd48e1cb6a51 and 29e9bcad07ee60fc0bf87ea11c23b1e36e24a38c. </details> <details> <summary>📒 Files selected for processing (4)</summary> * `src/loader/elf.h` * `src/loader/runtimeLinker.cpp` * `src/loader/runtimeLinker.h` * `tests/VirtualMemoryAllocationTests.cpp` </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. </details> --- <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough The loader now defines `R_X86_64_NONE` and treats entries of this type as complete without resolving symbols or patching memory. A test checks that a no-op relocation leaves its target unchanged and that a relative relocation updates its target. The test is registered in the standard test sequence. **Suggested reviewers:** `nmzik` </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"29e9bcad07ee60fc0bf87ea11c23b1e36e24a38c" --> **Change:** Bug fix <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** _⚪ Minimal_ · up to `29e9b` <!-- final_review_risk_coverage:{"sourceCommitId":"29e9bcad07ee60fc0bf87ea11c23b1e36e24a38c","coveredCommitId":"29e9bcad07ee60fc0bf87ea11c23b1e36e24a38c","kind":"reviewed"} --> The change skips no-op relocations while preserving other relocation behavior in the described tests. No concrete merge-blocking issue is evident; proceed with normal checks. <!-- final_review_risk_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary>🚥 Pre-merge checks | ✅ 4 | ❌ 1</summary> ### ❌ 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. | <details> <summary>✅ Passed checks (4 passed)</summary> | Check name | Status | Explanation | | :------------------------: | :------- | :-------------------------------------------------------------------------------------------------------------------------------------------------- | | Description check | ✅ Passed | The description directly explains the R_X86_64_NONE relocation issue, the implementation, the regression test, and the reported validation results. | | Title check | ✅ Passed | The title clearly and concisely summarizes the primary 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. | </details> </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">Autopilot</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=1146)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary>❤️ Share</summary> - [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) </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->

Pull request closed

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