Repository navigation
feat(relinker): support packed ELF64 relative relocations - #11463
Conversation
MarcZX10
left a comment
There was a problem hiding this comment.
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.
MarcZX10
left a comment
There was a problem hiding this comment.
The current Ubuntu relinker job has two failures on this head. Its log shows that the relinker builds successfully, but both relr_conversion and guest_relr_conversion fail at test_relr_relocations.py:129 on the addresses / linux case: 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.
|
Correction and local reproduction detail for my review above: I built this exact head on Linux and reran both focused CTests; both fail identically at the stated assertion. Inspecting the generated ELF shows the failure is in the test fixture's entry convention, not evidence of an incorrect RELR relocation: the Linux entry stub calls the original entry point and deliberately emits Independent local validation: clean |
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
MarcZX10
left a comment
There was a problem hiding this comment.
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 both relr_conversion and guest_relr_conversion pass. Current checks also pass for git diff --check, conventions, and a clean merge-tree preview against main.
The updated hosted run 40345897734 has 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 current main is 7903201bb426. I found no intervening changes under the touched relinker paths, and the merge preview is clean, but CONTRIBUTING requires branches to stay current with main. Please sync the branch before merge. I am requesting changes only for that branch-freshness requirement; the prior Linux runtime finding is withdrawn.
THEMANnt
left a comment
There was a problem hiding this comment.
Reviewed eb2dd32a5158 against 2dbe9b99f577. 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_conversion and optional_rela passed (4/4), as did an independent PT_LOAD-end overflow check. Hosted relinker jobs merged the PR head into checkout 7903201bb426: Windows CTest 312/312, Ubuntu 316/316 and macOS 306/306 on both runners (0 failures; no skipped tests listed). Hosted ASAN passed 34/34 tls_function_coverage tests; 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.
eb2dd32 to
fabd547
Compare
jotitadev
left a comment
There was a problem hiding this comment.
Ran on macOS: Apple M2 Max, macOS 27.2, Xcode 27 clang, relinker-only Release. Head fabd547a2d applied on current main cb45ae2ddf (clean merge). Two builds: arm64 native, and x86_64 under Rosetta with /usr/bin/python3 3.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.py checks only the Mach-O magic; it executes outputs only on Windows and Linux hosts. So I executed the macOS outputs:
- Run. I converted the five positive executable cases (
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). - Result. All five exit 42, so the entry's
jmp [0x800]reaches 0x210 through the RELR-relocated slot. The result is the same whether the relinker was built arm64 or x86_64. - On
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 way test_macos_trace_imports.py does it. That is optional and not a blocker.
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
fabd547 to
7c90e64
Compare
CodeInstructionCollector took code pointers from DT_RELA and DT_JMPREL but not from DT_RELR, which the pipeline has applied since #11463. A function reachable only through a RELR pointer was therefore no entry root, and a Windows TLS rewrite or GS trap could overwrite it without the "would overwrite an executable entry point" refusal that the same pointer as a RELA R_X86_64_RELATIVE triggers. Read the RELR table with ReadRelrRelocations and record its slots like relative relocations.
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 fix(libc): use the default heap for an executable without process parameters #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 fix(libc): use the default heap for an executable without process parameters #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; fix(libc): use the default heap for an executable without process parameters #11979 is no longer reported. The base-conflicting shared files in feat(aot): consolidate native ARM64 compiler, runtime and consumers #5021, fix(libc): use the default heap for an executable without process parameters #6713 and fix(relinker): analyze referenced code beyond SCE scan boundaries #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 feat(aot): consolidate native ARM64 compiler, runtime and consumers #5021, fix(libc): use the default heap for an executable without process parameters #6713, fix(relinker): trap int 0x80 in a software interrupt table instead of refusing the image #10479 and fix(relinker): analyze referenced code beyond SCE scan boundaries #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 fix(relinker): keep embedded data tables out of --to-intel and --to-rosetta conversion #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)