test(relinker): add C++ end-to-end fixture and --to-intel Linux stub test #431
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/431"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-03T05:57:25Z.
What
C++ infrastructure for end-to-end relinker tests, plus its first user.
core/relinker/tests/support/ElfFixture.hpp:MakeExecutable(code)builds a minimal PS5 executable (code PT_LOAD at vaddr 0, PT_DYNAMIC, spare program header slots), same layout the Python tests use.MappedImagemaps the PT_LOAD segments of an output ELF with their own R/W/X permissions so its code can be called.core/relinker/tests/support/RelinkerProcess.hpp:RunRelinker(relinker, args, log)(posix_spawn, exit code + combined output),TempDirectory, file helpers.core/relinker/CMakeLists.txt: everycore/relinker/tests/e2e/*.cppbecomesrelinker_e2e_<Name>and receives$<TARGET_FILE:relinker>. New tests don't touch CMake. Registered on x86-64 Unix only, since the tests run relinked code.e2e/ToIntelLinuxStubs.cpp: relinks an executable with one EXTRQ and one INSERTQ (immediate forms) with--skip-sce-module --to-intel, checks that both sites becamejmp rel32+ NOP into a segment outside the original code, then calls the relinked function. The stubs run from their Linux segment and return through their branches. Until now the Linux placement was only covered by callingLinuxElfPatcherdirectly inAmd64OnlyConverterTests.cpp, without running the relinker or the stubs.No change to the relinker itself.
Tested
Linux x86-64 (Ryzen 5 7535HS), full Release build,
ctest126/126.PF_X: SIGSEGVjmp: "SSE4a site was not replaced by a jump"--to-intelconversion skipped inmain.cpp: "Relinker did not report two stubs"main. It adds coverage and doesn't fix a bug.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T07:10:27Z.
@boykopovar this one needs your call on test layout: it adds a new
core/relinker/tests/{e2e,support}tree where everye2e/*.cppis registered byfile(GLOB ...), while the other relinker tests sit next to their component (relinker/tests/,codegen/tests/,elfpatcher/tests/) and are listed one by one incore/relinker/CMakeLists.txt.The test itself is fine: I rebuilt it on today's main (after #432, #433 and #464) and it still passes, and the expected EXTRQ/INSERTQ values check out. My read: I'd keep the existing pattern (put it under
relinker/tests/and register it explicitly), but if you want a shared C++ end-to-end harness, this is a reasonable start for one.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-07T14:08:08Z.
Followed @oneandonlydean's suggestion so this no longer needs a layout decision:
core/relinker/relinker/tests/ToIntelLinuxStubsTests.cpp(+ElfFixture.hpp,RelinkerProcess.hppalongside), registered explicitly asto_intel_linux_stubs. No newtests/{e2e,support}tree, nofile(GLOB).main.Rebuilt and ran the full ctest (397/397) locally. With the SSE4a stub body removed, the test fails ("computed the wrong value"). Merging once CI is green.