Fix RELRO load-segment congruence #3

Open
mpereiraesaa wants to merge 2 commits from mpereiraesaa/fix/relro-load-congruence into main
mpereiraesaa commented 2026-09-05 05:32:31 -05:00 (Migrated from github.com)

Summary

  • derive the RELRO program header from .data.rel.ro instead of .got
  • validate p_offset % p_align == p_vaddr % p_align for generated load segments
  • add a regression test and native-tooling troubleshooting documentation

Why

Additional relocations can place .got after the beginning of .data.rel.ro. Using the .got file offset together with the .data.rel.ro virtual address produces an incongruent RELRO mapping for the PS5 loader's 16 KiB alignment requirement, causing the native title to fail before main().

Validation

  • python3 -m unittest discover -s tests -p "test_*.py"
  • six tests pass, including the new RELRO congruence regression
  • validated with a native-title smoke build on firmware 12.02; the application reached main() and completed cleanly

No proprietary SDK files, dumps, binaries, NIDs, or firmware-derived material are included.

Update: second commit

The first commit anchored RELRO at .data.rel.ro unconditionally. That breaks the Hello World template itself: it has no relocated read-only data, lld drops the empty .data.rel.ro output section, and the converter aborted with lacks required section .data.rel.ro. The second commit anchors RELRO at the first RELRO section (.data.rel.ro when lld keeps it, otherwise the GOT), keeps the 16 KiB load-congruence check, and adds tests/test_executable_writer.py, which links both shapes with the host Clang/lld and converts them. make ffpfsc on the template passes again with this branch.

## Summary - derive the RELRO program header from `.data.rel.ro` instead of `.got` - validate `p_offset % p_align == p_vaddr % p_align` for generated load segments - add a regression test and native-tooling troubleshooting documentation ## Why Additional relocations can place `.got` after the beginning of `.data.rel.ro`. Using the `.got` file offset together with the `.data.rel.ro` virtual address produces an incongruent RELRO mapping for the PS5 loader's 16 KiB alignment requirement, causing the native title to fail before `main()`. ## Validation - `python3 -m unittest discover -s tests -p "test_*.py"` - six tests pass, including the new RELRO congruence regression - validated with a native-title smoke build on firmware 12.02; the application reached `main()` and completed cleanly No proprietary SDK files, dumps, binaries, NIDs, or firmware-derived material are included. ## Update: second commit The first commit anchored RELRO at `.data.rel.ro` unconditionally. That breaks the Hello World template itself: it has no relocated read-only data, lld drops the empty `.data.rel.ro` output section, and the converter aborted with `lacks required section .data.rel.ro`. The second commit anchors RELRO at the first RELRO section (`.data.rel.ro` when lld keeps it, otherwise the GOT), keeps the 16 KiB load-congruence check, and adds `tests/test_executable_writer.py`, which links both shapes with the host Clang/lld and converts them. `make ffpfsc` on the template passes again with this branch.
This pull request is broken due to missing fork information.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'mpereiraesaa/fix/relro-load-congruence:mpereiraesaa/fix/relro-load-congruence'
git switch 'mpereiraesaa/fix/relro-load-congruence'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'mpereiraesaa/fix/relro-load-congruence'
git switch 'mpereiraesaa/fix/relro-load-congruence'
git rebase 'main'
git switch 'main'
git merge --ff-only 'mpereiraesaa/fix/relro-load-congruence'
git switch 'mpereiraesaa/fix/relro-load-congruence'
git rebase 'main'
git switch 'main'
git merge --no-ff 'mpereiraesaa/fix/relro-load-congruence'
git switch 'main'
git merge --squash 'mpereiraesaa/fix/relro-load-congruence'
git switch 'main'
git merge --ff-only 'mpereiraesaa/fix/relro-load-congruence'
git switch 'main'
git merge 'mpereiraesaa/fix/relro-load-congruence'
git push origin 'main'
Sign in to join this conversation.
No description provided.