feat(relinker): support packed ELF64 relative relocations #11463
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11463"
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 Mherberts on 2026-10-26T14:41:22Z.
What
An ELF64 x86-64 executable or bundled module containing
DT_RELRcurrently fails conversion. Add decoding ofDT_RELR/DT_RELRSZ/DT_RELRENTaccording to gABI 6.2, Relative Relocation Table.Expand address entries and 63-bit bitmap windows into ordinary
R_X86_64_RELATIVErelocations, taking implicit addends from file data or zero-filled load memory. Executables and bundled modules then use the existing Linux, Windows and macOS relocation writers. The relative-relocation index also consumes RELR so reachability analysis retains its pointer targets; guest lifecycle arrays see the normalized relocations before initializer validation.Validate complete metadata, entry/table sizes, file and memory bounds, ambiguous mappings, bitmap address overflow and overlapping storage. Cross-segment storage units and relocation composition remain rejected and are recorded in
docs/dev/debt/relinker.md.Tested
Windows x64, build 26200; WinLibs GCC 15.2.0 r7; Ninja, Release,
ANYPS5_RELINKER_ONLY=ON,BUILD_TESTING=ON, Python 3.13. Current head7c90e64474ec7d3ebc6d143f06f6e2ad3b04a726is rebased onto upstreammain2ee8e9751a06bd4cb7edb8d17f433d56a39a7025. The previous refreshed head wasfabd547a2df833e1bc71e145ea6a656918d18d68. Initial feature validation was atfad2ff38efac4c7f098a31b7ce1ef5bbbe1266efon3ead2d7251, followed by the Linux fixture fixeb2dd32a51588d2b36285169182b556512d2f047; results on those heads are identified below.On current head
7c90e64474, the complete relinker-only build passes. 10/10 focused CTests pass in 36.32 s:relr_relocations,dynamic_segment,none_relocations,guest_none_relocations,optional_plt,optional_rela,relr_conversion,guest_relr_conversion,elf_header,strict_nid_filter.Coordination with #11979: moved the two RELR conversion-test registrations beside
optional_rela, away from itswindows_process_parametersinsertion afterelf_header. Test commands and timeouts are unchanged.git range-diffshows the three previous commits preserved exactly through the rebase, plus this CMake-only move.Integration proof:
git merge-tree --write-tree HEAD refs/pr/11979and its reverse both exit 0 against #11979 head0cb4dde2eec3249a9b96f86e602d3262d853095a, producing the same treed9c9c37da88b72b568b548e05eae7142b4dba0cd. That tree retains each ofrelr_relocations,relr_conversion,guest_relr_conversionandwindows_process_parametersexactly once, with their test sources present. No landing-order dependency remains between these two PRs.Current registration audits pass: all 40 native test executables and all 203 Python test scripts have a CTest/workflow entry. Conventions against
upstream/mainandgit diff --checkpass. The required check against the fork's olderorigin/maincompletes with 0 errors and 43 upstream debt warnings.Current overlap recheck used the official branch checker through the public-API adapter with 1,315 open PRs. Only this PR's own previous remote head is reported, on its four new RELR files; #11979 is no longer reported. The base-conflicting shared files in #5021, #6713 and #10861 were manually inspected: their changes concern other test registrations, TLS debt and syscall/code-extent analysis, not the relocated RELR registration or decoder.
At
fabd547a2d, the complete relinker-only build passes. Five focused CTests pass in 8.03 s:relr_relocations,optional_rela,relr_conversion,guest_relr_conversionandstrict_nid_filter.Linux CI correction at
eb2dd32: the original synthetic entries returned intoEntryStubBuilder's intentionalUD2, causing the twoSIGILLfailures. Linux fixtures now call the original entry, compare its expected result (42/11), and reachINT3only on success; a mismatch reachesUD2. Native assertions requireSIGTRAPon x86-64 and use the existing core-dump guard. The five focused tests pass locally (6.91 s), and the new Ubuntu relinker job passes. The original Ubuntu job passed 314/316 tests, failing only those two runtime assertions.At
fad2ff3, 88/88 related CTests passed in 85.69 s:ctest --test-dir build-verify -R '(relr|rela|relocation|guest|tls|optional_plt|dynamic_segment|linux_fixed_base|windows_gui|strict_nid_filter)' --output-on-failure --parallel 2. This includes the existing imports, TLS, module lifecycle and reachability coverage. The complete CTest suite was not run.New native tests exercise every bitmap bit, chained/empty windows, independent address entries, implicit and partially zero-filled addends, bounds, invalid metadata, overlaps and overflow. They also verify the relative-relocation index.
The two new conversion tests cover 103 conversions/rejections across Linux fixed-address ELF, Linux PIE, PE and Mach-O, for executables and bundled modules. They inspect the exact normalized Linux relocation sets and counts, absence of RELR tags, and load-page congruence. Nine successful cases execute on Windows; module fixtures require a relocated function pointer and an initializer's state change to return the expected result. Cases include mixed RELA/RELR, BSS and partial-file words, even unaligned slots, empty tables and malformed inputs.
Negative control: built an isolated, clean
git archivesnapshot ofmain3ead2d7251with the same GCC 15.2.0 and Release relinker-only configuration. The same conversion tests fail there withDT_RELR relocations are not supportedfor executables andUnsupported dynamic tag 35for modules; the feature build passes.At
fabd547a2d,python tools/check_conventions.py --base upstream/main,python tools/check_test_registration.py build-verifyandgit diff --checkpass. The required conventions comparison against the fork's olderorigin/mainalso completes with zero errors and 32 debt-length warnings in already-merged upstream content.At
fabd547a2d, overlap recheck: the officialtools/pr_overlap.pybranch comparison used the public-API adapter and a fresh inventory of 1,339 open PRs. Its only confirmed entry is this PR's own previous remote head, matched on the four new RELR files. The base-conflicting warnings #5021, #6713, #10479 and #10861 were manually checked: their shared changes concern other test registrations, TLS notes, software interrupt tables and code-boundary scanning. The include-only collision with #11525 was removed by moving the RELR include away from the header it removes;git merge-tree --write-tree HEAD refs/pr/11525returns success. No dependency on those PRs.Linux and macOS artifacts were converted and inspected on Windows; native execution on those hosts, commercial titles and GPUs were not tested locally.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T14:57:07Z.
Review: CHANGES_REQUESTED
The current Ubuntu relinker job has two reproducible failures on this head. Internal ctest changing into directory: /marc/AnyPS5/build-relinker builds successfully, but both and fail at on the / case: execution returns (SIGILL) instead of the fixture's expected 42/11. The preceding output-format and relocation-set assertions pass, so this is specifically the generated Linux executable's runtime behavior. Windows relinker and ASan pass; macOS jobs are still queued. Please reproduce and correct the Linux execution failure (or establish that the runner/test setup is at fault with evidence) before merge, then rerun the focused conversion tests.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T14:57:12Z.
Review: CHANGES_REQUESTED
The current Ubuntu relinker job has two failures on this head. Its log shows that the relinker builds successfully, but both
relr_conversionandguest_relr_conversionfail attest_relr_relocations.py:129on theaddresses/linuxcase: execution returns-4(SIGILL) instead of the fixture's expected 42/11. The preceding output-format and relocation-set assertions pass, so this is specifically the generated Linux executable's runtime behavior.The Windows relinker and ASan jobs pass; macOS jobs are still queued. Please reproduce and correct the Linux execution failure, or establish with evidence that the runner/test setup is at fault, before merge; then rerun the focused conversion tests.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T15:12:33Z.
Review: CHANGES_REQUESTED
I reviewed the updated head
eb2dd32a51588d2b36285169182b556512d2f047. The Linux fixture now validates the generated entry's result before reaching the relinker's intentional return trap; I rebuilt the relinker locally and bothrelr_conversionandguest_relr_conversionpass. Current checks also pass forgit diff --check, conventions, and a clean merge-tree preview againstmain.The updated hosted run
40345897734has Ubuntu and ASan passing; Windows is running and both macOS jobs are queued. The original Linux failure is resolved by the fixture correction, not a change to RELR conversion logic.One repository rule remains: this branch's merge base is
3ead2d725174, while currentmainis7903201bb426. I found no intervening changes under the touched relinker paths, and the merge preview is clean, but CONTRIBUTING requires branches to stay current withmain. Please sync the branch before merge. I am requesting changes only for that branch-freshness requirement; the prior Linux runtime finding is withdrawn.Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-26T15:42:54Z.
Review: APPROVED
Reviewed
eb2dd32a5158against2dbe9b99f577. No actionable findings.The parser rejects incomplete metadata, invalid mappings, bitmap overflow and overlapping relocation storage before normalizing RELR into the existing RELA pipeline. Guest-image conversion and reachability indexing consume the decoded entries; fixtures check relocation output and guest initializer/input side effects.
Validation: The local Release relinker-only build passed (312 build steps);
relr_relocations,relr_conversion,guest_relr_conversionandoptional_relapassed (4/4), as did an independent PT_LOAD-end overflow check. Hosted relinker jobs merged the PR head into checkout7903201bb426: Windows CTest 312/312, Ubuntu 316/316 and macOS 306/306 on both runners (0 failures; no skipped tests listed). Hosted ASAN passed 34/34tls_function_coveragetests; it did not run RELR tests.The local full CTest run did not complete: unrelated shader-cache tests failed while creating or using temporary CMake/Ninja builds. My cached-binary control was fixture-incompatible, so the author's pinned-base negative control remains unverified. Other hosted workflow jobs were skipped.
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-27T01:27:19Z.
Review: COMMENTED
Ran on macOS: Apple M2 Max, macOS 27.2, Xcode 27 clang, relinker-only Release. Head
fabd547a2dapplied on currentmaincb45ae2ddf(clean merge). Two builds: arm64 native, and x86_64 under Rosetta with/usr/bin/python33.9.6. Full suite: arm64 312/312, Rosetta 310/310 (main: 309/309 and 307/307, plus the 3 new tests).One addition from macOS. For
--macos,test_relr_relocations.pychecks only the Mach-O magic; it executes outputs only on Windows and Linux hosts. So I executed the macOS outputs:addresses,bitmap,mixed,zero-fill-addends,even-unaligned-slot) with--macos --skip-sce-module. I ran each Mach-O under Rosetta with stub x86_64 dylibs forlibkernel.prxandlibc.prx, whereAps5StartGuest_nid_no_patchcalls the entry and exits with its return value (theSTARTpattern oftest_macos_trace_imports.py).jmp [0x800]reaches 0x210 through the RELR-relocated slot. The result is the same whether the relinker was built arm64 or x86_64.main, the same inputs fail withDT_RELR relocations are not supported.If you want that covered by the test itself, the run fits under
sys.platform == "darwin"the same waytest_macos_trace_imports.pydoes it. That is optional and not a blocker.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.