Skip to content

fix(relinker): reject Linux relocations into non-writable PT_LOAD segments - #13977

Merged
oneandonlydean merged 4 commits into
boykopovar:mainfrom
roboterspinne:fix/relinker-linux-relocations-writable-load
Nov 22, 2026
Merged

oneandonlydean merged 4 commits into
boykopovar:mainfrom
roboterspinne:fix/relinker-linux-relocations-writable-load

Conversation

@roboterspinne

@roboterspinne roboterspinne commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

What

On 60bdb06 (line numbers below refer to it) the Linux patcher checks every DT_RELA and DT_JMPREL r_offset with RequireLoaded (LinuxElfPatcher.cpp:115-120) but passes no required flags (line 427), so a relocation may target a PT_LOAD without PF_W. The rebuilt Linux dynamic section never declares text relocations: it takes only DT_NEEDED from the input, so an input DT_TEXTREL is dropped, and its DT_FLAGS is DF_BIND_NOW without --lazy-binding and absent with it. The gABI allows a relocation to modify a non-writable segment only when DT_TEXTREL is present, and glibc's _dl_relocate_object (elf/dl-reloc.c) makes such segments writable only for an object with DT_TEXTREL; this comes from reading the glibc source, not from running an output. For a R_X86_64_RELATIVE, R_X86_64_64 or R_X86_64_GLOB_DAT in DT_RELA or an R_X86_64_JUMP_SLOT in DT_JMPREL whose r_offset lies in the fixture's PF_R | PF_X PT_LOAD, Linux and --lazy-binding output were written with exit 0; a RELATIVE case with DT_TEXTREL in the input converted the same way, without the tag in the output. The same holds for the lazy DT_PLTGOT, where ld.so stores its link map and resolver (elf_machine_runtime_setup): RequireLoaded checks it with no required flags as well (line 429), so a DT_PLTGOT inside code converted with --lazy-binding. The other targets already refuse most of these: --macos refuses all four (Mach-O fixup target is not in a writable segment, MacOsImage.cpp:227, or Runtime import target is not writable), and --windows refuses the three that bind imports (WindowsLoadImage.cpp:154) and accepts only the RELATIVE, which becomes a PE base relocation that the Windows loader applies to read-only pages itself. The guest image reader already refuses DT_TEXTREL and DF_TEXTREL in bundled modules (GuestImageReader.cpp:87-90).

  • Rule. RequireLoaded now gets PF_W for every DT_RELA and DT_JMPREL entry the patcher writes, and for DT_PLTGOT under --lazy-binding, so such an input fails at relink time with RELA r_offset 0x300 (8 bytes) does not fit inside a writable PT_LOAD segment (or JMPREL …, DT_PLTGOT …) instead of in the dynamic loader. R_X86_64_NONE entries never reach the patcher (RelinkerPipeline.cpp:395-396), and without --lazy-binding DT_PLTGOT still only has to lie in a PT_LOAD. A PT_LOAD whose p_flags is 0 still passes, as it does for e_entry (line 117): the Linux output maps it PF_R | PF_W | PF_X (_fixLoadFlags, ProgramHeaderLayoutBuilder.cpp:126-127, from bc14e47), so the kernel's make_prot gives the relocation target a writable page; entry-in-flagless-load checks those output flags. The message for an r_offset outside every PT_LOAD, and for a lazy DT_PLTGOT there, now also names a writable segment.
  • Why reject and not pass DT_TEXTREL through. Passing it through would make ld.so remap code pages writable at load, while macOS output and bundled modules already refuse the same inputs. On fix(relinker): reject macOS fixups outside writable segments #11045 wachi35676 mapped all 129,623 RELATIVE, R_X86_64_64, GLOB_DAT and JUMP_SLOT targets of 24 PS5 ELF files (the homebrew eboots of PPSA99005, PPSA47402, PPSA99581 and PPSA99995, their sce_module PRX files and 16 wine PRX modules of PPSA99995) to their PT_LOAD and found every one in a PF_W segment.
  • Tests. linux_load_bounds gains cases for RELATIVE and R_X86_64_32 into a PF_R | PF_X PT_LOAD, a RELA into a read-only .bss-like PT_LOAD, a JMPREL into code, and accepted cases for RELATIVE into an RWX and a flagless PT_LOAD, each for the default, --linux-fixed-base 0x800000 and --lazy-binding, plus a DT_PLTGOT inside code that converts eagerly and fails with --lazy-binding; it and unused_filter_indirect expect the new message text. Six existing tests placed GOT slots or relocation targets in the single PF_R | PF_X PT_LOAD of main_fixture or of the C++ executable fixture and now fail by design; their fixtures give these targets a writable segment. importing_executable in test_guest_symbol_names.py sets PF_W on its single PT_LOAD, which becomes PF_R | PF_W | PF_X (only when it has imports, because init_array_roots counts the code regions of the import-free fixture), as test_game_patches.py and RelocTableBoundsTests.cpp do on theirs. strict_fixture in test_duplicate_relocations.py instead splits its copy into PF_R | PF_X at 0x4000 and PF_R | PF_W at 0x4800, because the strict filter refuses a writable code segment (StrictNidFilter.cpp, unsupported executable segment layout), and the separate helper of the same name in test_import_symbol_types.py keeps that split. Both halves of the split lie in one 4 KiB page, and neither image is run. main_fixture itself is unchanged.
  • Correction in 7487bb1. The earlier head 50b37bb split the shared importing_executable the same way. agc_driver_guest_memory_lifetime_converted and linux_guest_qualified_imports take that helper, set its first PT_LOAD to PF_R | PF_W | PF_X and run the converted executable on Linux, where the kernel maps every later PT_LOAD over its page-aligned range with MAP_FIXED (fs/binfmt_elf.c, elf_map and load_elf_binary; read in the kernel source, not run here). The PF_R | PF_W half then replaced the page that holds the guest code, and the code lost execute permission; oneandonlydean reported both tests failing on Linux. With the single PF_R | PF_W | PF_X PT_LOAD both tests get the same input as on main.

On 18 November 2026 pr_overlap.py --branch on 7487bb1 reported no overlap with the open pull requests and none that it could not compare (main 28c4880). #15903, which it could not compare earlier because that pull request conflicted with main, has since been updated (head bdd07bb) and can be merged into that main; it still shares only RelocTableBoundsTests.cpp with this pull request, and a trial merge of the two on that main is clean. #10917 and #11487, named here before, have been merged.

Tested

Windows 11, WinLibs GCC 15.2.0, relinker-only build (-DANYPS5_RELINKER_ONLY=ON, Ninja, Release), on 7487bb1 (main ef4b938 merged in 4fef80c), compared with the same build of main ef4b938:

  • ctest --test-dir build-relinker -j 6 --timeout 300: 949 tests on both. The same 9 fail on both, select_tests and its four parts, the three check_compile_test_* tests and patch_advisor_json_integration, which fail on this machine without this change; long_paths is skipped on both. The relinker tests that take importing_executable or that this pull request changes pass, 15 in all, among them linux_guest_qualified_imports and duplicate_relocations.
  • Not run on Linux: there is no Linux machine here. agc_driver_guest_memory_lifetime_converted is registered on Linux x86-64 only and did not run, and linux_guest_qualified_imports ran its conversions but not its executions, which are Linux-only. What was checked instead: the input that agc_driver_guest_memory_lifetime_converted converts (importing_executable with its imports and PT_LOAD[0] set to 7) has the same SHA-256 on this head as on main (8bbffd524cb38ba3…), and a different one with 50b37bb merged onto main. For the executable-two-providers case of linux_guest_qualified_imports, this head and main write byte-identical files (6 of 6, including input.elf and output.elf). Mapping the PT_LOADs of that output.elf page by page, a later one replacing an earlier one, leaves the guest code page 0x404000 PF_R | PF_W | PF_X on this head and on main, and PF_R | PF_W with 50b37bb merged onto main.
  • guest_deferred_dependencies also takes importing_executable with imports and runs its output on Linux, but does not set PF_W | PF_X itself. Its converted code page stays executable with the split of 50b37bb (the PF_R | PF_W half lands on its own page) and with this head, where output.elf differs from main in one byte, that p_flags.
  • python tools/check_conventions.py --base upstream/main with this title and description passed on 7487bb1.

Earlier, Windows 11, WinLibs GCC 15.2.0, relinker-only build (-DANYPS5_RELINKER_ONLY=ON, Ninja, Release), on 50b37bb (based on 60bdb06; main at 73f4f7e changed none of these files and merges cleanly):

  • Built with the LinuxElfPatcher.cpp of 60bdb06, the four relocation types above into a PF_R | PF_X PT_LOAD convert with exit 0 for Linux and --lazy-binding, and the RELATIVE case with a DT_TEXTREL in the input converts without DT_TEXTREL in the output and with DT_FLAGS 0x8; with this change all of them fail with the new message, --windows and --macos behave as described above, and the same input with an RWX PT_LOAD still converts.
  • Without the fixture changes the rule fails guest_symbol_names, guest_registry, import_symbol_types, duplicate_relocations, game_patches and reloc_table_bounds with does not fit inside a writable PT_LOAD segment; with them these six, linux_load_bounds, unused_filter_indirect, init_array_roots, needed_libraries, guest_deferred_dependencies, sce_code_gaps and sce_module_code_extent pass.
  • ctest --test-dir build-relinker -j 5 on 50b37bb: 543 tests, 537 passed, long_paths skipped; annotate_module, a Python test of tools/annotate_module.py that does not run the relinker, timed out under the parallel load and passed alone in 15.5 to 16 s in three of four runs on this machine; select_tests and its three parts select_tests_SelectGraphStateTests, select_tests_SelectBuildTests and select_tests_SelectArgumentTests fail with the Windows symlink fixture's FileExistsError, as on main on this machine; this change touches nothing under tools/.
  • python tools/check_conventions.py --base 60bdb06135 with this title and description passed on 50b37bb.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code)

…ments

A Linux relink accepted a RELA or JMPREL entry whose r_offset lies in a
PT_LOAD without PF_W and wrote an output that keeps the segment
read-only without DT_TEXTREL, so ld.so writes into a read-only mapping.
The check over relocation offsets now requires a writable PT_LOAD, as
the gABI does for objects without DT_TEXTREL; a PT_LOAD without flags
still counts as writable, and an R_X86_64_NONE entry, which writes
nothing, only has to lie inside a PT_LOAD as before. Test fixtures that
placed GOT slots or relocation targets in their read-execute PT_LOAD
now give them a writable one.
…able R_X86_64_NONE exception

With --lazy-binding ld.so stores its link map and resolver in the first
slots at DT_PLTGOT, so that range now has to lie in a writable PT_LOAD
like every relocation target. The pipeline never passes R_X86_64_NONE
entries to the Linux patcher, so the patcher needs no exception for
them.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — changes requested

At head 50b37bb1a98edde1d306775c870a20440fd26814 on base 73f4f7e06e4f210a8c6570e335fd654dc0a86134, the new writable-segment check still accepts a PT_LOAD with p_flags == 0 as writable.

What I ran

Linux x86_64, Python 3.11.2, GCC 12.2.0, Git 2.39.5. The dependency/merge preview and source checks were run; I did not build or run C++ tests locally. Relinker CI was still running when checked.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13977
gh pr checks 13977 -R boykopovar/AnyPS5

Results

Check Result
Diff check Passed
Conventions and PR template Passed
Dependency and merge preview Passed
Hosted conventions, intake, eligibility, labels Passed
Hosted relinker platform jobs and ASAN In progress/queued
Local C++ tests Not run
Precheck output
All conventions checks passed.

Negative control

Assertion Change to code under test Did the new test fail?
A relocation into a segment without PF_W is rejected The new relative-in-flagless case sets p_flags to zero and expects success Not run locally; source inspection shows the case is accepted by the current guard.

Findings

Blocking

  • RequireLoaded still accepts header.Flags == 0, and the new relative-in-flagless case expects that relocation to pass. In Linux, the ELF loader derives PROT_WRITE from PF_W; a zero p_flags value therefore does not describe a writable segment. The relocation is accepted by this check despite the PR's stated requirement to reject targets outside writable PT_LOAD segments.

    Keep the zero-flags shortcut only for calls that request no permission check. For example:

    if (header.Type == PT_LOAD && (flags == 0 || (header.Flags & flags) == flags) && address >= header.MappedAddress && address - header.MappedAddress < header.MemorySize && size <= header.MemorySize - (address - header.MappedAddress))
    

    Update the flagless relocation test to expect rejection, and retain a separate containment-only test if that behavior is needed.

Non-blocking

None identified.

Sources

Not verified

No local build or C++ tests. Hosted relinker jobs had not completed. The local precheck's ABI/test-quality helper commands were unavailable from its isolated snapshot; that is a tooling limitation, not a PR test result.

To get this to a good state

Require PF_W for writable relocation targets even when the segment has no flags, and change the flagless case to assert rejection. I will rerun the same checks and inspect the results on the new head.

@roboterspinne

Copy link
Copy Markdown
Contributor Author

make_prot reads the p_flags of the output, and RequireLoaded checks the input headers (originalHeaders). The Linux layout writer rewrites a PT_LOAD whose p_flags is 0 to PF_R | PF_W | PF_X before writing it: ProgramHeaderLayoutBuilder::_fixLoadFlags (ProgramHeaderLayoutBuilder.cpp:126-127, applied to every kept PT_LOAD in WriteLayout, line 264), introduced in bc14e47 (fix(relinker): map zero-flag ps5 load segments as rwx). Nothing between the check and that call changes the flags: SeparateSharedLoadPages only shrinks sizes and moves offsets, RebaseProgramHeaders only rewrites p_vaddr/p_paddr, and SegmentFilter never skips a PT_LOAD. So the kernel maps that segment PROT_READ | PROT_WRITE | PROT_EXEC and ld.so writes into a writable page. entry-in-flagless-load in test_linux_load_bounds.py (from #10402) asserts the output flags [PF_R | PF_W | PF_X] for a PT_LOAD with p_flags 0, and relative-in-flagless relinks the same flagless segment with a RELATIVE into it in all three Linux modes. Requiring the flag on the input would also fail the e_entry check (PF_X) for such an input and revert #10402. I have reworded the description to cite _fixLoadFlags instead of line 117.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-checked — same head, looks good

I’m correcting my earlier change request: zero-flag PT_LOAD segments are normalized to RWX before the Linux output ELF is written, so the relocation case I previously flagged does target a writable output mapping.

What I ran

Reviewed head 50b37bb1a98edde1d306775c870a20440fd26814 against base 73f4f7e06e4f210a8c6570e335fd654dc0a86134; this is the same code head as my earlier review. The live merge preview was clean. Environment: Linux x86_64, Python 3.11.2, GCC 12.2.0. No local build or compilation was run.

git diff --check 73f4f7e06e4f210a8c6570e335fd654dc0a86134...50b37bb1a98edde1d306775c870a20440fd26814
python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13977
python3 -m py_compile core/relinker/relinker/tests/test_game_patches.py core/relinker/relinker/tests/test_guest_symbol_names.py core/relinker/relinker/tests/test_import_symbol_types.py core/relinker/relinker/tests/test_linux_load_bounds.py core/relinker/relinker/tests/test_unused_filter_indirect.py
python3 tools/check_test_registration.py --scripts
python3 /marc/AnyPS5/tools/pr_test_quality.py --root /tmp/anyps5-review-13977 --json core/relinker/relinker/tests/test_linux_load_bounds.py core/relinker/relinker/tests/test_game_patches.py core/relinker/relinker/tests/test_guest_symbol_names.py core/relinker/relinker/tests/test_import_symbol_types.py core/relinker/relinker/tests/test_unused_filter_indirect.py
gh pr checks 13977 --repo boykopovar/AnyPS5

Results

Check Result
Diff check, conventions and test registration Passed.
Python syntax Passed for all five changed Python test modules.
Test-quality heuristic Emitted five generic constant-assertion prompts. They point to assertions outside the changed hunks; manual diff review found no new assertion that only checks a constant.
Precheck runner Partial: the isolated head worktree lacks the local-only pr_test_quality.py helper. The check did not run there; I ran that helper separately against the exact head.
Hosted relinker checks Ubuntu/g++, Windows/g++, macOS/clang++ x86_64, macOS/clang++, and ASAN passed. Generic linux, windows, register-context, and write-watch jobs were skipped.
Source review The RequireLoaded exception for zero flags matches the actual output transformation; the earlier blocking concern is resolved by existing code, not by a new PR commit.
Selected unedited check output
All conventions checks passed.
230 test script(s), each run by an add_test or a workflow
/usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13977-50b37bb1a98e/head-50b37bb1a98e-3dfcc8cc/tools/pr_test_quality.py': [Errno 2] No such file or directory
{
  "findings": [
    {
      "path": "core/relinker/relinker/tests/test_game_patches.py",
      "line": 57,
      "kind": "constant-assertion",
      "message": "Assertion appears to check only a constant; inspect manually"
    },
    {
      "path": "core/relinker/relinker/tests/test_guest_symbol_names.py",
      "line": 208,
      "kind": "constant-assertion",
      "message": "Assertion appears to check only a constant; inspect manually"
    },
    {
      "path": "core/relinker/relinker/tests/test_guest_symbol_names.py",
      "line": 215,
      "kind": "constant-assertion",
      "message": "Assertion appears to check only a constant; inspect manually"
    },
    {
      "path": "core/relinker/relinker/tests/test_guest_symbol_names.py",
      "line": 266,
      "kind": "constant-assertion",
      "message": "Assertion appears to check only a constant; inspect manually"
    },
    {
      "path": "core/relinker/relinker/tests/test_unused_filter_indirect.py",
      "line": 71,
      "kind": "constant-assertion",
      "message": "Assertion appears to check only a constant; inspect manually"
    }
  ],
  "negative_control_candidates": [],
  "limits": [
    "Heuristics can miss weak assertions and can flag valid tests; inspect every finding.",
    "A test that passes against base is not by itself proof that the PR test is inadequate.",
    "Negative controls are only candidates until the test actually runs against base and fails by assertion rather than import/setup error."
  ]
}
conventions	pass	16s	https://github.com/boykopovar/AnyPS5/actions/runs/41214094282/job/124574898848
eligibility	pass	7s	https://github.com/boykopovar/AnyPS5/actions/runs/41209814310/job/124562241307
intake	pass	4s	https://github.com/boykopovar/AnyPS5/actions/runs/41209812774/job/124562236959
labels	pass	12s	https://github.com/boykopovar/AnyPS5/actions/runs/41214094327/job/124574899024
relinker (macos-latest, clang++)	pass	4m34s	https://github.com/boykopovar/AnyPS5/actions/runs/41209814310/job/124562276852
relinker (macos-latest, clang++, x86_64)	pass	5m48s	https://github.com/boykopovar/AnyPS5/actions/runs/41209814310/job/124562276874
relinker (ubuntu-latest, g++)	pass	3m38s	https://github.com/boykopovar/AnyPS5/actions/runs/41209814310/job/124562276878
relinker (windows-latest, g++)	pass	9m5s	https://github.com/boykopovar/AnyPS5/actions/runs/41209814310/job/124562276911
relinker-asan	pass	2m48s	https://github.com/boykopovar/AnyPS5/actions/runs/41209814310/job/124562276808
linux	skipping	0	https://github.com/boykopovar/AnyPS5/actions/runs/41209814310/job/124562277591
register-context	skipping	0	https://github.com/boykopovar/AnyPS5/actions/runs/41209814310/job/124562277957
windows	skipping	0	https://github.com/boykopovar/AnyPS5/actions/runs/41209814310/job/124562277605
write-watch	skipping	0	https://github.com/boykopovar/AnyPS5/actions/runs/41209814310/job/124562277787

Findings

Blocking

None confirmed after reviewing the author’s evidence and the unchanged implementation path.

Non-blocking

I did not run a local negative control. The macOS ARM relinker job passed during this re-check; the previously reviewed CI jobs also passed at the current head.

Sources

Not verified

I did not build or run tests locally. The hosted relinker CI passed on Ubuntu, Windows, macOS x86_64, macOS ARM, and ASAN; generic platform jobs listed above were skipped. No local runtime or title integration was tested.

@JJenkx

JJenkx commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Windows check of head 50b37bb1a9, merged onto main 141cc61132 (a8fe63efa1, clean merge).

Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run these tests on pull requests.

  • game_patches, guest_symbol_names, import_symbol_types, linux_load_bounds, reloc_table_bounds, unused_filter_indirect pass in 3 of 3 runs, none skipped.

AI-assisted: yes.

@gabichuuuuu

Copy link
Copy Markdown
Contributor

Windows check of head 50b37bb1a9, merged onto main 31b4aa91e8 (clean merge, built together with other open PRs that touch different files).

Setup: Windows 11 Pro 10.0.26300, WinLibs GCC 15.2.0 (r7), Ninja, Release, -DANYPS5_RELINKER_ONLY=ON, BUILD_TESTING=ON, Python 3.15.

  • Tests chosen with tools/select_tests.py explain from this PR's test files: game_patches, guest_symbol_names, import_symbol_types, linux_load_bounds, reloc_table_bounds, unused_filter_indirect.
  • All of them pass in 3 of 3 runs.
  • Negative control: with this PR's code reverted to main (files it adds removed) and rebuilt, linux_load_bounds, unused_filter_indirect fail in 2 of 2 runs, so the tests detect the change.

AI-assisted: yes.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

@roboterspinne with this PR (head 50b37bb) merged onto main, agc_driver_guest_memory_lifetime_converted and linux_guest_qualified_imports fail on the 4090. The same main without it passes both, and this PR alone on that main fails both.

Please run those two on your head and fix what they hit, or show why the tests are wrong. Once they pass I will test it again.

importing_executable split its fixture into a PF_R | PF_X load at
0x4000 and a PF_R | PF_W load at 0x4800, which share one 4 KiB page.
agc_driver_guest_memory_lifetime_converted and
linux_guest_qualified_imports set the first load to PF_R | PF_W | PF_X
and run the converted executable on Linux, where the kernel maps the
later PF_R | PF_W load over that page with MAP_FIXED, so the guest code
there loses PF_X. The helper now keeps its single load and makes it
PF_R | PF_W | PF_X, which keeps the import relocations in a writable
PT_LOAD and gives both tests the same input as on main.
strict_fixture in test_duplicate_relocations.py makes the split itself,
because the strict filter refuses a writable code segment; that image
is only converted, never run.
@roboterspinne

Copy link
Copy Markdown
Contributor Author

@oneandonlydean Thanks for the run. The two failures come from this pull request's change to a shared test helper, not from the relinker check. importing_executable in test_guest_symbol_names.py split its fixture into a PF_R | PF_X PT_LOAD at 0x4000 and a PF_R | PF_W one at 0x4800, which share one 4 KiB page. agc_driver_guest_memory_lifetime_converted and linux_guest_qualified_imports set the first one to PF_R | PF_W | PF_X and run the converted executable; as I read fs/binfmt_elf.c, the kernel maps each later PT_LOAD over its page-aligned range with MAP_FIXED, so the PF_R | PF_W one replaced the page that holds the guest code and the code lost execute permission.

7487bb1, on top of a merge of main ef4b938, keeps the helper's single PT_LOAD and makes it PF_R | PF_W | PF_X, so both tests get the same input as on main. Only strict_fixture in test_duplicate_relocations.py, which needs it because the strict filter refuses a writable code segment, and the separate helper of the same name in test_import_symbol_types.py keep the split; both images are converted but never run.

I could not run the two tests as you asked: I have no Linux machine, only Windows, where the AGC test is not registered and linux_guest_qualified_imports runs its conversions but not its executions. What I checked there: the input of the AGC test has the same SHA-256 on this head as on main; for the executable-two-providers case of linux_guest_qualified_imports this head and main write byte-identical files, and mapping the PT_LOADs of that output page by page leaves the guest code page executable on this head and on main but not on the previous head merged onto main. The full relinker suite fails the same nine tests on this head as on main here, tests that fail on this machine without this change. The details are under Tested in the description. Could you run the two again on 7487bb1, and guest_deferred_dependencies, whose converted input now has a PF_R | PF_W | PF_X code load where main has PF_R | PF_X?

@ycbuzi

ycbuzi commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Tested 7487bb1108 merged into main, with the whole ctest suite on each machine below. Nothing fails that does not also fail on main on the same machine.

  • Linux: Debian 13 in ChromeOS's Linux environment on a Pentium Silver N6000 (4 cores, SSE4.2, no AVX), GCC 14.2.0, relinker-only build (-DANYPS5_RELINKER_ONLY=ON): run 1: 99% tests passed, 5 tests failed out of 927; run 2: 99% tests passed, 5 tests failed out of 927; run 3: 99% tests passed, 5 tests failed out of 927. 5 of the failing tests fail on main too.

AI-assisted: yes (Claude Code); the runs are automated, this summary was written from their reports.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

Nothing blocks this change; the checked-in tests and reported runs support the writable-target checks.

What I ran

Reviewed head 7487bb11083f0dc35928124b440e3b4accbff0fd from the prepared diff and pinned repository reader. No tests or builds were run during this review; the Windows test results in the description are author-reported.

Results

Check Result Note
Diff and changed lines passed All eight changed files and added lines reviewed
Tests and build not run Author reports Windows relinker tests passed; not independently verified

Findings

Blocking

None.

Non-blocking

None.

Not verified

No tests or build were run. Linux execution and the Linux-only tests were not independently verified. Read all eight changed files listed in the manifest; no changed files were excluded.

To get this to a good state

Nothing is required.

@github-actions

Copy link
Copy Markdown

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.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 23861 core/relinker/elfpatcher/src/linux/LinuxElfPatcher.cpp L130-134

@kiwe147

kiwe147 commented Nov 20, 2026

Copy link
Copy Markdown

The writable-PT_LOAD check builds on Windows and the relinker tests pass: linux_load_bounds, reloc_table_bounds, duplicate_relocations, game_patches, guest_symbol_names, import_symbol_types (the tests this PR changes).

Setup: tested head 7487bb1108 on main c8f72e9. Windows 11 Pro 10.0.26200, Ryzen 7 9800X3D, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON. The tests below are host-side; the GPU is not involved. For the whole-batch numbers I used an RTX 3080 (driver 621.24) and the Ryzen iGPU (gfx1036, driver 32.0.21036.18).

Whole batch (this PR was one of 11 applied together on main c8f72e9: #10007, #11109, #12184, #14103, #14108, #13804, #10518, #13977, #8041, #8043 (its hunk reverted, see #8043), #12056; #9584 did not apply): the clean main baseline fails 4 of 6505 tests on the RTX 3080 (agc_driver_stencil_plane_memory, agc_driver_msaa_dcc_unwatch, agc_storage_write_back_host_retile, pr_overlap_names) and 1 of 2097 AGC/video tests on the iGPU (agc_driver_stencil_plane_memory). With the batch the RTX 3080 run fails 8 of 6506: those 4, agc_driver_store_over_untracked (known flaky, #22670) and three new ones: guest_pthread_guard_size (does not build, #8041), guest_pthread_timed_locks (abort, caused by #14103) and guest_kernel_rwlockattr_bounds (abort, caused by #14108). On the iGPU agc_storage_write_back_host_retile also failed once and passes 5 of 5 alone (known race, #23708). I isolated the two aborts by reverting the PRs one at a time.

AI-assisted: yes (Claude Code)

@oneandonlydean
oneandonlydean merged commit e4959eb into boykopovar:main Nov 22, 2026
16 of 18 checks passed
@roboterspinne
roboterspinne deleted the fix/relinker-linux-relocations-writable-load branch November 24, 2026 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants