fix(relinker): reject overflowing ELF file offsets #7037

Merged
namanipie merged 1 commit from upstream-pr/7037 into main 2026-10-31 21:32:46 +00:00
namanipie commented 2026-10-17 07:01:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by namanipie on 2026-10-17T07:01:56Z.


What

Hardens CodeInstructionCollector and EntryPointCollector against 64-bit integer overflow when translating virtual addresses to ELF file offsets. Previously, a PT_LOAD segment with an offset near UINT64_MAX could wrap around to a small offset within file bounds and bypass range checks. Adds a discriminating regression test in relinker_conversion_tests covering CodeInstructionCollector; the EntryPointCollector check is defense in depth.

Tested

Windows 11 x86_64, MinGW-w64 GCC 15.2.0:

  • Built with -DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON
  • relinker_conversion_tests passed: verified discriminating red/green behavior on CodeInstructionCollector wrapping test (main fails with "Invalid conversion was accepted", passes on this branch) across DT_INIT_ARRAY, DT_FINI_ARRAY, and DT_PREINIT_ARRAY, with controls
  • ctest --test-dir build-relinker -R "^relinker_conversion$" --repeat until-fail:20 passed 20/20
  • Full ctest --test-dir build-relinker passed 181 / 181 tests
  • python tools/check_conventions.py --base origin/main passed

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4898110845 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7037). Originally posted by [namanipie](https://github.com/namanipie) on 2026-10-17T07:01:56Z. --- ### What Hardens `CodeInstructionCollector` and `EntryPointCollector` against 64-bit integer overflow when translating virtual addresses to ELF file offsets. Previously, a `PT_LOAD` segment with an offset near `UINT64_MAX` could wrap around to a small offset within file bounds and bypass range checks. Adds a discriminating regression test in `relinker_conversion_tests` covering `CodeInstructionCollector`; the `EntryPointCollector` check is defense in depth. ### Tested Windows 11 x86_64, MinGW-w64 GCC 15.2.0: - Built with `-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON` - `relinker_conversion_tests` passed: verified discriminating red/green behavior on `CodeInstructionCollector` wrapping test (`main` fails with "Invalid conversion was accepted", passes on this branch) across `DT_INIT_ARRAY`, `DT_FINI_ARRAY`, and `DT_PREINIT_ARRAY`, with controls - `ctest --test-dir build-relinker -R "^relinker_conversion$" --repeat until-fail:20` passed 20/20 - Full `ctest --test-dir build-relinker` passed 181 / 181 tests - `python tools/check_conventions.py --base origin/main` passed ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
fogydes commented 2026-10-17 07:14:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fogydes on 2026-10-17T07:14:37Z.

Review: COMMENTED


Windows run and verification of head bcf46ec0da on main 6a32550fd:

Windows 11 x86-64, WinLibs GCC 15.2.0, Ninja Release, -DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON.

  • relinker_conversion_tests built cleanly with zero compiler warnings.
  • ctest --test-dir build-relinker -R "^relinker_conversion$" --repeat until-fail:20: passed 20/20.
  • python tools/check_conventions.py --base origin/main: passed with 0 findings.
  • python tools/pr_overlap.py: 0 confirmed collisions across all open PRs.

Code Review: The upper-bound checks (relative > std::numeric_limits<std::uint64_t>::max() - header.Offset) in CodeInstructionCollector.cpp and EntryPointCollector.cpp safely guard against 64-bit integer wrapping before computing file offsets, preventing out-of-bounds segments from mapping to wrapped in-bounds offsets.

AI-assisted: yes. I ran the builds, tests, and checks above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5556792813 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7037#pullrequestreview-5556792813). Originally posted by [fogydes](https://github.com/fogydes) on 2026-10-17T07:14:37Z. **Review:** COMMENTED --- Windows run and verification of head `bcf46ec0da` on `main` `6a32550fd`: Windows 11 x86-64, WinLibs GCC 15.2.0, Ninja Release, `-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON`. - `relinker_conversion_tests` built cleanly with zero compiler warnings. - `ctest --test-dir build-relinker -R "^relinker_conversion$" --repeat until-fail:20`: passed 20/20. - `python tools/check_conventions.py --base origin/main`: passed with 0 findings. - `python tools/pr_overlap.py`: 0 confirmed collisions across all open PRs. **Code Review**: The upper-bound checks (`relative > std::numeric_limits<std::uint64_t>::max() - header.Offset`) in `CodeInstructionCollector.cpp` and `EntryPointCollector.cpp` safely guard against 64-bit integer wrapping before computing file offsets, preventing out-of-bounds segments from mapping to wrapped in-bounds offsets. AI-assisted: yes. I ran the builds, tests, and checks above on my machine.
oneandonlydean commented 2026-10-17 07:35:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T07:35:32Z.


Thanks, this is the direct-call guard I asked about on #6392. Since #5741 already rejects that input in ElfReader::ReadProgramHeaders, could you change 'fixes #6392' in the description to say it hardens the two collectors, and add a test for the EntryPointCollector hunk? Happy to merge after that.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6231273703 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7037#issuecomment-6231273703). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-17T07:35:32Z. --- Thanks, this is the direct-call guard I asked about on #6392. Since #5741 already rejects that input in ElfReader::ReadProgramHeaders, could you change 'fixes #6392' in the description to say it hardens the two collectors, and add a test for the EntryPointCollector hunk? Happy to merge after that.
oneandonlydean commented 2026-10-17 10:12:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T10:12:38Z.


Thanks. The guard itself looks right. Two things before it can merge:

  1. The new test passes on main too, so it doesn't cover the change. In ConversionTests.cpp:177-181 the case uses Offset = 2^64-17 with MappedAddress = 0. The first lookup has relative = 0, so nothing wraps, and main's existing range(offset, size) already rejects the huge offset. Please choose Offset and the looked-up address so that Offset + relative wraps to a small offset inside the image. Then main's range() accepts it and only your new check rejects it, so the test fails on main and passes here. Please add the same kind of case for the init/fini array path in EntryPointCollector, which has no test yet.
  2. #6392 is already closed: the PT_LOAD range check from #5741 stops that input before either collector runs. This PR is the separate direct-call guard mentioned there, so please drop the "fixes #6392" line from the description.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6232684804 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7037#issuecomment-6232684804). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-17T10:12:38Z. --- Thanks. The guard itself looks right. Two things before it can merge: 1. **The new test passes on main too, so it doesn't cover the change.** In `ConversionTests.cpp:177-181` the case uses `Offset = 2^64-17` with `MappedAddress = 0`. The first lookup has `relative = 0`, so nothing wraps, and main's existing `range(offset, size)` already rejects the huge offset. Please choose `Offset` and the looked-up address so that `Offset + relative` wraps to a small offset *inside* the image. Then main's `range()` accepts it and only your new check rejects it, so the test fails on main and passes here. Please add the same kind of case for the init/fini array path in `EntryPointCollector`, which has no test yet. 2. **#6392 is already closed:** the PT_LOAD range check from #5741 stops that input before either collector runs. This PR is the separate direct-call guard mentioned there, so please drop the "fixes #6392" line from the description.
simonbbby commented 2026-10-17 10:22:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by simonbbby on 2026-10-17T10:22:52Z.


Tested the requested direct-call paths on exact head bcf46ec0da38080d3a030aeb6e79b8e5e81c0801 (Ubuntu 24.04 x86-64, GCC 13.3, Release relinker-only). There is a guard-order constraint on the EntryPointCollector test request.

A discriminating CodeInstructionCollector fixture works. I used a real executable segment at file offset 0x200, VA 0x2000, with returns at 0x2000 and 0x2008; a flags-zero data PT_LOAD with offset UINT64_MAX-63, VA 0x8000, file/memory size 0x410; and an eight-byte init/fini/preinit array at VA 0x8400. Its file offset wraps to 0x3c0.

For all three array types:

  • Parent collector: a zero at 0x3c0 yields {0x2000}; replacing only that word with 0x2008 yields {0x2000,0x2008}. The wrapped read changes the collected roots.
  • Fixed collector: both variants throw Code analysis: file range exceeds image.
  • Nonwrapping control (data offset 0x300, array word at 0x700): both implementations accept, with exactly the expected root sets.

That supplies six red/green overflow cases plus six valid controls. I also reproduced the current relinker_conversion_tests passing with both collector objects reverted to the parent and the PR's new test retained.

EntryPointCollector::Collect already calls ElfReader(elfBytes).ReadProgramHeaders() itself. Even a direct call rejects all six wrapping cases on both parent and fix with Segment offset out of bounds, before collectArray. This follows from the production checks: the reader bounds fileOffset + fileSize against the image using subtraction, and collectArray bounds relative + arraySz against fileSize. With those checks intact, fileOffset + relative cannot overflow. A rejection test through this public API therefore covers the existing reader guard, not the added overflow branch. I did not bypass/mock that reader to claim new-hunk coverage.

The parent control rebuilds only the two changed collector objects; the remaining production archive and test object are identical. No CLI/title exposure or current-main merge result is claimed.

Standalone direct-call probe used for these results
#include <relinker/analysis/CodeInstructionCollector.hpp>
#include <relinker/analysis/UnusedNidFilter/IEntryPointCollector.hpp>
#include <domain/Types.hpp>
#include <cstring>
#include <iostream>
#include <limits>
#include <optional>
#include <string>
using namespace Relinker::UnusedNidFilter;
struct Empty final:IRelativeRelocationIndex{std::optional<Relinker::VirtualAddress>TargetOfSlot(Relinker::VirtualAddress)const override{return std::nullopt;}std::vector<Relinker::VirtualAddress>Targets()const override{return {};}};
static void put(std::vector<std::uint8_t>&b,std::size_t off,std::uint64_t value,unsigned size=8){for(unsigned i=0;i<size;++i)b[off+i]=(value>>(8*i))&255;}
int main(){for(bool wrap:{false,true})for(unsigned tag:{25,26,32})for(bool nonzero:{false,true}){
std::vector<std::uint8_t> b(4096);b[0]=0x7f;b[1]='E';b[2]='L';b[3]='F';b[4]=2;b[5]=1;b[6]=1;put(b,16,3,2);put(b,18,62,2);put(b,20,1,4);put(b,24,0x2000);put(b,32,64);put(b,52,64,2);put(b,54,56,2);put(b,56,3,2);
auto offset=wrap?UINT64_MAX-63:0x300ull;
std::vector<Domain::ProgramHeader> hs={{1,5,0x200,0x2000,0,64,64,1},{1,0,offset,0x8000,0,0x410,0x410,1},{2,0,0x100,0x9000,0,48,48,1}};
for(unsigned i=0;i<hs.size();++i){auto&h=hs[i];auto o=64+i*56;put(b,o,h.Type,4);put(b,o+4,h.Flags,4);put(b,o+8,h.Offset);put(b,o+16,h.MappedAddress);put(b,o+32,h.FileSize);put(b,o+40,h.MemorySize);put(b,o+48,h.Alignment);}
put(b,0x100,tag);put(b,0x108,0x8400);put(b,0x110,tag==25?27:tag==26?28:33);put(b,0x118,8);b[0x200]=0xc3;b[0x208]=0xc3;put(b,wrap?0x3c0:0x700,nonzero?0x2008:0);
std::cout<<"wrap="<<wrap<<" tag="<<tag<<" root="<<nonzero;
try{auto v=Relinker::CodeInstructionCollector().Collect(b,hs);std::cout<<" code=accept[";for(auto a:v)std::cout<<std::hex<<a<<",";std::cout<<std::dec<<"]";}catch(const Domain::RelinkerException&e){std::cout<<" code=reject:"<<e.what();}
try{Empty e;auto v=MakeEntryPointCollector()->Collect(b,0x2000,64,e);std::cout<<" entry=accept[";for(auto a:v)std::cout<<std::hex<<a<<",";std::cout<<std::dec<<"]";}catch(const Domain::RelinkerException&e){std::cout<<" entry=reject:"<<e.what();}
std::cout<<"\n";
}}

The probe links against the normal production librelinker_core.a; its relocation-index input is empty. It prints the exact root sets and rejection messages above.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6232769616 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7037#issuecomment-6232769616). Originally posted by [simonbbby](https://github.com/simonbbby) on 2026-10-17T10:22:52Z. --- Tested the requested direct-call paths on exact head `bcf46ec0da38080d3a030aeb6e79b8e5e81c0801` (Ubuntu 24.04 x86-64, GCC 13.3, Release relinker-only). There is a guard-order constraint on the `EntryPointCollector` test request. **A discriminating `CodeInstructionCollector` fixture works.** I used a real executable segment at file offset `0x200`, VA `0x2000`, with returns at `0x2000` and `0x2008`; a flags-zero data `PT_LOAD` with offset `UINT64_MAX-63`, VA `0x8000`, file/memory size `0x410`; and an eight-byte init/fini/preinit array at VA `0x8400`. Its file offset wraps to `0x3c0`. For all three array types: - Parent collector: a zero at `0x3c0` yields `{0x2000}`; replacing only that word with `0x2008` yields `{0x2000,0x2008}`. The wrapped read changes the collected roots. - Fixed collector: both variants throw `Code analysis: file range exceeds image`. - Nonwrapping control (data offset `0x300`, array word at `0x700`): both implementations accept, with exactly the expected root sets. That supplies **six red/green overflow cases** plus six valid controls. I also reproduced the current `relinker_conversion_tests` passing with both collector objects reverted to the parent and the PR's new test retained. **`EntryPointCollector::Collect` already calls `ElfReader(elfBytes).ReadProgramHeaders()` itself.** Even a direct call rejects all six wrapping cases on both parent and fix with `Segment offset out of bounds`, before `collectArray`. This follows from the production checks: the reader bounds `fileOffset + fileSize` against the image using subtraction, and `collectArray` bounds `relative + arraySz` against `fileSize`. With those checks intact, `fileOffset + relative` cannot overflow. A rejection test through this public API therefore covers the existing reader guard, not the added overflow branch. I did not bypass/mock that reader to claim new-hunk coverage. The parent control rebuilds only the two changed collector objects; the remaining production archive and test object are identical. No CLI/title exposure or current-main merge result is claimed. <details><summary>Standalone direct-call probe used for these results</summary> ```cpp #include <relinker/analysis/CodeInstructionCollector.hpp> #include <relinker/analysis/UnusedNidFilter/IEntryPointCollector.hpp> #include <domain/Types.hpp> #include <cstring> #include <iostream> #include <limits> #include <optional> #include <string> using namespace Relinker::UnusedNidFilter; struct Empty final:IRelativeRelocationIndex{std::optional<Relinker::VirtualAddress>TargetOfSlot(Relinker::VirtualAddress)const override{return std::nullopt;}std::vector<Relinker::VirtualAddress>Targets()const override{return {};}}; static void put(std::vector<std::uint8_t>&b,std::size_t off,std::uint64_t value,unsigned size=8){for(unsigned i=0;i<size;++i)b[off+i]=(value>>(8*i))&255;} int main(){for(bool wrap:{false,true})for(unsigned tag:{25,26,32})for(bool nonzero:{false,true}){ std::vector<std::uint8_t> b(4096);b[0]=0x7f;b[1]='E';b[2]='L';b[3]='F';b[4]=2;b[5]=1;b[6]=1;put(b,16,3,2);put(b,18,62,2);put(b,20,1,4);put(b,24,0x2000);put(b,32,64);put(b,52,64,2);put(b,54,56,2);put(b,56,3,2); auto offset=wrap?UINT64_MAX-63:0x300ull; std::vector<Domain::ProgramHeader> hs={{1,5,0x200,0x2000,0,64,64,1},{1,0,offset,0x8000,0,0x410,0x410,1},{2,0,0x100,0x9000,0,48,48,1}}; for(unsigned i=0;i<hs.size();++i){auto&h=hs[i];auto o=64+i*56;put(b,o,h.Type,4);put(b,o+4,h.Flags,4);put(b,o+8,h.Offset);put(b,o+16,h.MappedAddress);put(b,o+32,h.FileSize);put(b,o+40,h.MemorySize);put(b,o+48,h.Alignment);} put(b,0x100,tag);put(b,0x108,0x8400);put(b,0x110,tag==25?27:tag==26?28:33);put(b,0x118,8);b[0x200]=0xc3;b[0x208]=0xc3;put(b,wrap?0x3c0:0x700,nonzero?0x2008:0); std::cout<<"wrap="<<wrap<<" tag="<<tag<<" root="<<nonzero; try{auto v=Relinker::CodeInstructionCollector().Collect(b,hs);std::cout<<" code=accept[";for(auto a:v)std::cout<<std::hex<<a<<",";std::cout<<std::dec<<"]";}catch(const Domain::RelinkerException&e){std::cout<<" code=reject:"<<e.what();} try{Empty e;auto v=MakeEntryPointCollector()->Collect(b,0x2000,64,e);std::cout<<" entry=accept[";for(auto a:v)std::cout<<std::hex<<a<<",";std::cout<<std::dec<<"]";}catch(const Domain::RelinkerException&e){std::cout<<" entry=reject:"<<e.what();} std::cout<<"\n"; }} ``` The probe links against the normal production `librelinker_core.a`; its relocation-index input is empty. It prints the exact root sets and rejection messages above. </details>
namanipie commented 2026-10-17 11:03:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by namanipie on 2026-10-17T11:03:40Z.


Updated head to abfe81309bc42e72b705c1a655a5f2b3764f3e88:

  1. PR description: Dropped Closes #6392 from the description and updated the summary to state that this hardens both collectors.
  2. Discriminating test: In ConversionTests.cpp, replaced the previous non-discriminating test with a fixture using a real executable segment (Flags = 1) at file offset 0x200, VA 0x2000, a dynamic segment, and a non-executable data PT_LOAD (Flags = 0) at offset UINT64_MAX - 63, VA 0x8000, file size 0x410. The initializer array at VA 0x8400 wraps to file offset 0x3c0.
    • On main (parent), the wrapped read is accepted and modifies the collected roots (or returns without throwing), causing the test assertion to fail with Invalid conversion was accepted.
    • On this branch, fileOffset catches the integer overflow and throws Code analysis: file range exceeds image, passing all 6 wrapping rejection cases and 6 non-wrapping controls across DT_INIT_ARRAY, DT_FINI_ARRAY, and DT_PREINIT_ARRAY.
  3. EntryPointCollector guard: As noted by @simonbbby, EntryPointCollector::Collect directly calls ElfReader(elfBytes).ReadProgramHeaders(), which checks _rangeFits against the image and throws Segment offset out of bounds before collectArray can be reached. The guard in EntryPointCollector.cpp remains in place as an internal direct-call defense-in-depth hardening.

Ran checks and verification on Windows 11 x86-64, MinGW-w64 GCC 15.2.0, Ninja Release:

  • relinker_conversion_tests built cleanly with zero compiler warnings.
  • ctest --test-dir build-relinker -R "^relinker_conversion$" --repeat until-fail:20: passed 20/20.
  • ctest --test-dir build-relinker: passed 181/181 (100%).
  • python tools/check_conventions.py --base origin/main: passed with 0 findings.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6233140621 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7037#issuecomment-6233140621). Originally posted by [namanipie](https://github.com/namanipie) on 2026-10-17T11:03:40Z. --- Updated head to `abfe81309bc42e72b705c1a655a5f2b3764f3e88`: 1. **PR description**: Dropped `Closes #6392` from the description and updated the summary to state that this hardens both collectors. 2. **Discriminating test**: In `ConversionTests.cpp`, replaced the previous non-discriminating test with a fixture using a real executable segment (`Flags = 1`) at file offset `0x200`, VA `0x2000`, a dynamic segment, and a non-executable data `PT_LOAD` (`Flags = 0`) at offset `UINT64_MAX - 63`, VA `0x8000`, file size `0x410`. The initializer array at VA `0x8400` wraps to file offset `0x3c0`. - On `main` (parent), the wrapped read is accepted and modifies the collected roots (or returns without throwing), causing the test assertion to fail with `Invalid conversion was accepted`. - On this branch, `fileOffset` catches the integer overflow and throws `Code analysis: file range exceeds image`, passing all 6 wrapping rejection cases and 6 non-wrapping controls across `DT_INIT_ARRAY`, `DT_FINI_ARRAY`, and `DT_PREINIT_ARRAY`. 3. **EntryPointCollector guard**: As noted by @simonbbby, `EntryPointCollector::Collect` directly calls `ElfReader(elfBytes).ReadProgramHeaders()`, which checks `_rangeFits` against the image and throws `Segment offset out of bounds` before `collectArray` can be reached. The guard in `EntryPointCollector.cpp` remains in place as an internal direct-call defense-in-depth hardening. Ran checks and verification on Windows 11 x86-64, MinGW-w64 GCC 15.2.0, Ninja Release: - `relinker_conversion_tests` built cleanly with zero compiler warnings. - `ctest --test-dir build-relinker -R "^relinker_conversion$" --repeat until-fail:20`: passed 20/20. - `ctest --test-dir build-relinker`: passed 181/181 (100%). - `python tools/check_conventions.py --base origin/main`: passed with 0 findings.
Baconzido commented 2026-10-18 07:50:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Baconzido on 2026-10-18T07:50:55Z.


Red/green on macOS for the current head, since the validations above are on bcf46ec0d and the new test's red run is only the author's.

Apple M5 Pro (arm64), macOS 27.0.1, AppleClang 21.0.0, CMake 4.4.4, Release relinker-only (-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON). Head abfe81309 merged onto main 1c523bdb4 (clean merge).

  • With the PR: full ctest 185/185; relinker_conversion passes 20/20 with --repeat until-fail:20. No compiler warnings in the rebuilt objects.
  • Negative control A, both collectors reverted to main, ConversionTests.cpp kept: relinker_conversion fails with Invalid conversion was accepted.
  • Negative control B, only CodeInstructionCollector.cpp reverted: fails the same way. The new test covers this hunk.
  • Negative control C, only EntryPointCollector.cpp reverted: relinker_conversion passes. This matches @simonbbby's note: EntryPointCollector::Collect runs ReadProgramHeaders() first, so that hunk cannot be reached through the public API and the test does not cover it.

Not checked: Linux, x86-64 under Rosetta.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6247323468 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7037#issuecomment-6247323468). Originally posted by [Baconzido](https://github.com/Baconzido) on 2026-10-18T07:50:55Z. --- Red/green on macOS for the current head, since the validations above are on `bcf46ec0d` and the new test's red run is only the author's. Apple M5 Pro (arm64), macOS 27.0.1, AppleClang 21.0.0, CMake 4.4.4, Release relinker-only (`-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON`). Head `abfe81309` merged onto `main` `1c523bdb4` (clean merge). - With the PR: full ctest 185/185; `relinker_conversion` passes 20/20 with `--repeat until-fail:20`. No compiler warnings in the rebuilt objects. - Negative control A, both collectors reverted to `main`, `ConversionTests.cpp` kept: `relinker_conversion` fails with `Invalid conversion was accepted`. - Negative control B, only `CodeInstructionCollector.cpp` reverted: fails the same way. The new test covers this hunk. - Negative control C, only `EntryPointCollector.cpp` reverted: `relinker_conversion` passes. This matches @simonbbby's note: `EntryPointCollector::Collect` runs `ReadProgramHeaders()` first, so that hunk cannot be reached through the public API and the test does not cover it. Not checked: Linux, x86-64 under Rosetta. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
screamm commented 2026-10-18 15:04:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-18T15:04:15Z.


Windows run of the current head, since the earlier Windows result is for bcf46ec0d. Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2, head abfe81309 scratch-merged onto main a62c724c3 (clean; #7098 merges alongside it cleanly). Relinker, its tests and libs built; no full-tree build, no GPU involved.

  • relinker_conversion, --repeat until-fail:3: 3 of 3.
  • Negative controls (test file kept): both collectors from main: relinker_conversion_tests fails with Invalid conversion was accepted; only CodeInstructionCollector.cpp from main: same failure; only EntryPointCollector.cpp from main: passes. This agrees with the macOS result above: the test covers the CodeInstructionCollector hunk, the EntryPointCollector hunk is not reached because Collect runs ReadProgramHeaders() first.
  • On a hand-made ELF whose PT_LOAD has p_offset 2^64-64 or 2^64-256, main and this PR both stop with Segment offset out of bounds on the Linux, Windows and macOS targets, so the new checks are only reachable through direct Collect calls, as the test does.
  • All 103 registered relinker tests, 3 repeats: 98 pass; 4 Python tests hit their 20-30 s limits while other builds ran on the host and pass run directly; one test needed helper DLLs my targeted build lacked at first.
  • Relinking every local title (51 with an eboot.elf) with main's relinker and with this PR: --windows gives identical SHA-256 for all 312 output files (PPSA99995 rc 2 in both, same Unsupported Windows guest TLS instruction failure); the Linux target gives identical SHA-256 for all 122 files.
  • tools/check_conventions.py --base origin/main and git diff --check: pass.

Small suggestion: the PR body still says the regression test covers both collectors; it covers CodeInstructionCollector only, so the description could say the EntryPointCollector change is defence in depth.

Not checked: Linux and macOS hosts, running a relinked executable, full-tree build, the non-GPU suite.

Written with Claude Code assistance (validation by a subagent, reviewed in this session).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6251437817 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7037#issuecomment-6251437817). Originally posted by [screamm](https://github.com/screamm) on 2026-10-18T15:04:15Z. --- Windows run of the current head, since the earlier Windows result is for `bcf46ec0d`. Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2, head `abfe81309` scratch-merged onto main `a62c724c3` (clean; #7098 merges alongside it cleanly). Relinker, its tests and `libs` built; no full-tree build, no GPU involved. - `relinker_conversion`, `--repeat until-fail:3`: 3 of 3. - Negative controls (test file kept): both collectors from main: `relinker_conversion_tests` fails with `Invalid conversion was accepted`; only `CodeInstructionCollector.cpp` from main: same failure; only `EntryPointCollector.cpp` from main: passes. This agrees with the macOS result above: the test covers the `CodeInstructionCollector` hunk, the `EntryPointCollector` hunk is not reached because `Collect` runs `ReadProgramHeaders()` first. - On a hand-made ELF whose `PT_LOAD` has `p_offset` 2^64-64 or 2^64-256, main and this PR both stop with `Segment offset out of bounds` on the Linux, Windows and macOS targets, so the new checks are only reachable through direct `Collect` calls, as the test does. - All 103 registered relinker tests, 3 repeats: 98 pass; 4 Python tests hit their 20-30 s limits while other builds ran on the host and pass run directly; one test needed helper DLLs my targeted build lacked at first. - Relinking every local title (51 with an `eboot.elf`) with main's relinker and with this PR: `--windows` gives identical SHA-256 for all 312 output files (PPSA99995 rc 2 in both, same `Unsupported Windows guest TLS instruction` failure); the Linux target gives identical SHA-256 for all 122 files. - `tools/check_conventions.py --base origin/main` and `git diff --check`: pass. Small suggestion: the PR body still says the regression test covers both collectors; it covers `CodeInstructionCollector` only, so the description could say the `EntryPointCollector` change is defence in depth. Not checked: Linux and macOS hosts, running a relinked executable, full-tree build, the non-GPU suite. Written with Claude Code assistance (validation by a subagent, reviewed in this session).
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!7037
No description provided.