fix(relinker): report a NONE entry in DT_JMPREL as an unsupported PLT relocation #11041

Merged
harisibrar1 merged 4 commits from upstream-pr/11041 into main 2026-10-28 23:15:57 +00:00
harisibrar1 commented 2026-10-25 14:54:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-25T14:54:48Z.


What

An R_X86_64_NONE entry in DT_JMPREL fails with a misleading error. The same happens when DT_JMPREL points at zeroed bytes:

Original .rela.plt slot has no corresponding JUMP_SLOT relocation; PLT thunks cannot be filtered without patching their hard-coded reloc index

That message appears at unused-filter levels 0 and 1, on Linux, Windows and macOS output, even when nothing is being filtered.

In RelinkerPipeline.cpp's relocation reader, the R_X86_64_NONE continue runs before the plt && relType != R_X86_64_JUMP_SLOT check. So the NONE entry is skipped, its PLT slot is left without a JUMP_SLOT, and the dynamic section builder fails later with the filtering message. Every other non-JUMP_SLOT type in DT_JMPREL is already rejected at its entry with "Unsupported PLT relocation type (offset …)".

This moves the PLT check above the NONE continue, so a NONE entry in DT_JMPREL is reported at its offset like any other non-JUMP_SLOT type. A NONE entry in DT_RELA is still skipped, as before; the existing -data-symbol-none cases cover that.

This also changes what unused-filter=2 accepts, as @thepoppfish found: on main, strict filtering could compact away an unused DT_JMPREL table that held only NONE entries (or zeroed bytes) and then convert the file. Now the type check runs while the table is read, before any filtering, so that input is rejected at every filter level. That's intended: FreeBSD 11.4's loader refuses any PLT relocation that isn't R_X86_64_JUMP_SLOT or R_X86_64_IRELATIVE, NONE included, in both reloc_plt and reloc_jmpslots, whether or not the slot is ever called. So a binary with such a table wouldn't load there either; the relinker now says so instead of converting it.

Tested

Windows 11, WinLibs GCC 15.2.0 r7, relinker-only Release build (-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON) of d008392c54 (current main merged in).

  • test_jmprel_table_bounds.py gains -none-in-plt cases for Linux and Windows output: a NONE entry in DT_JMPREL must fail with "Unsupported PLT relocation type" at the default filter level and with unused-filter=1 and unused-filter=2. The ordinary DT_RELA NONE (-data-symbol-none) and valid JUMP_SLOT (-plt-symbol-valid) controls in the same file still convert. jmprel_table_bounds passes in 2 runs.
  • Negative control: with main's RelinkerPipeline.cpp, jmprel_table_bounds fails on the new case.
  • On this head, none_relocations, overlapping_relocations, optional_plt, optional_rela and null_symbol_relocations couldn't run here: Smart App Control blocked their freshly built fixtures (WinError 4551), no assertion failures. @thepoppfish's native run of the previous head passed those groups 10/10, and this push only adds test cases and merges main.
  • tools/check_conventions.py --base origin/main passes.
  • Not tested: Linux and macOS hosts. The check is target-independent.

Overlap

pr_overlap reports #10971 (@roboterspinne) at the end of the same test loop (test_jmprel_table_bounds.py L131); whichever lands second needs a small text merge. #8076 shares RelinkerPipeline.cpp but conflicts with main and doesn't touch these lines.

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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5005804651 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11041). Originally posted by [harisibrar1](https://github.com/harisibrar1) on 2026-10-25T14:54:48Z. --- ### What An `R_X86_64_NONE` entry in DT_JMPREL fails with a misleading error. The same happens when DT_JMPREL points at zeroed bytes: ``` Original .rela.plt slot has no corresponding JUMP_SLOT relocation; PLT thunks cannot be filtered without patching their hard-coded reloc index ``` That message appears at `unused-filter` levels 0 and 1, on Linux, Windows and macOS output, even when nothing is being filtered. In `RelinkerPipeline.cpp`'s relocation reader, the `R_X86_64_NONE` `continue` runs before the `plt && relType != R_X86_64_JUMP_SLOT` check. So the NONE entry is skipped, its PLT slot is left without a JUMP_SLOT, and the dynamic section builder fails later with the filtering message. Every other non-JUMP_SLOT type in DT_JMPREL is already rejected at its entry with "Unsupported PLT relocation type (offset …)". This moves the PLT check above the NONE `continue`, so a NONE entry in DT_JMPREL is reported at its offset like any other non-JUMP_SLOT type. A NONE entry in DT_RELA is still skipped, as before; the existing `-data-symbol-none` cases cover that. **This also changes what `unused-filter=2` accepts**, as @thepoppfish found: on main, strict filtering could compact away an unused DT_JMPREL table that held only NONE entries (or zeroed bytes) and then convert the file. Now the type check runs while the table is read, before any filtering, so that input is rejected at every filter level. That's intended: FreeBSD 11.4's loader refuses any PLT relocation that isn't `R_X86_64_JUMP_SLOT` or `R_X86_64_IRELATIVE`, NONE included, in both [`reloc_plt`](https://github.com/freebsd/freebsd-src/blob/release/11.4.0/libexec/rtld-elf/amd64/reloc.c#L322-L346) and [`reloc_jmpslots`](https://github.com/freebsd/freebsd-src/blob/release/11.4.0/libexec/rtld-elf/amd64/reloc.c#L353-L388), whether or not the slot is ever called. So a binary with such a table wouldn't load there either; the relinker now says so instead of converting it. ### Tested Windows 11, WinLibs GCC 15.2.0 r7, relinker-only Release build (`-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON`) of d008392c54 (current `main` merged in). - `test_jmprel_table_bounds.py` gains `-none-in-plt` cases for Linux and Windows output: a NONE entry in DT_JMPREL must fail with "Unsupported PLT relocation type" at the default filter level and with `unused-filter=1` and `unused-filter=2`. The ordinary DT_RELA NONE (`-data-symbol-none`) and valid JUMP_SLOT (`-plt-symbol-valid`) controls in the same file still convert. `jmprel_table_bounds` passes in 2 runs. - Negative control: with main's `RelinkerPipeline.cpp`, `jmprel_table_bounds` fails on the new case. - On this head, `none_relocations`, `overlapping_relocations`, `optional_plt`, `optional_rela` and `null_symbol_relocations` couldn't run here: Smart App Control blocked their freshly built fixtures (`WinError 4551`), no assertion failures. @thepoppfish's native run of the previous head passed those groups 10/10, and this push only adds test cases and merges `main`. - `tools/check_conventions.py --base origin/main` passes. - Not tested: Linux and macOS hosts. The check is target-independent. ### Overlap `pr_overlap` reports #10971 (@roboterspinne) at the end of the same test loop (`test_jmprel_table_bounds.py` L131); whichever lands second needs a small text merge. #8076 shares `RelinkerPipeline.cpp` but conflicts with main and doesn't touch these lines. ### 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] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-10-25 15:10:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T15:10:01Z.

Review: APPROVED


Reviewed exact head e38c2e1e7a4b5989d31d2a82aeb47f53cc05c4e1. Moving the DT_JMPREL type guard before the NONE skip makes NONE entries fail at the same validation point as other unsupported PLT relocations while preserving the DT_RELA skip. The added Linux/Windows output cases exercise that distinction. Hosted Linux, Windows, macOS arm64/x86_64, ASan and conventions checks pass; product-specific jobs are skipped by path policy. The noted test-file overlap with #10971 is limited to adjacent assertions and does not block this change.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5643804610 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11041#pullrequestreview-5643804610). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T15:10:01Z. **Review:** APPROVED --- Reviewed exact head `e38c2e1e7a4b5989d31d2a82aeb47f53cc05c4e1`. Moving the DT_JMPREL type guard before the NONE skip makes NONE entries fail at the same validation point as other unsupported PLT relocations while preserving the DT_RELA skip. The added Linux/Windows output cases exercise that distinction. Hosted Linux, Windows, macOS arm64/x86_64, ASan and conventions checks pass; product-specific jobs are skipped by path policy. The noted test-file overlap with #10971 is limited to adjacent assertions and does not block this change.
thepoppfish commented 2026-10-25 15:22:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by thepoppfish on 2026-10-25T15:22:59Z.

Review: COMMENTED


Additional native Windows validation and one scope clarification for exact head e38c2e1e7a4b5989d31d2a82aeb47f53cc05c4e1 against main 3a2c51afd2ee6a824cd3a294912c65e6bbf2b768. The relocated guard gives the intended early diagnostic, and the ordinary DT_RELA NONE skip remains intact. This is a comment review because the matrix also found an acceptance change that is worth stating explicitly.

Strict-filter scope: with unused-filter=2, an immutable code segment returning immediately and an unused NONE-only DT_JMPREL table, main succeeds and emits an output; this head exits 2 with Unsupported PLT relocation type before filtering. This happens for both the ordinary NONE entry and a completely zeroed 24-byte entry, using standard/SCE table tags and Linux/Windows/macOS output (12 paired acceptance changes). Main's strict-filter PLT compaction removes the unused table, so those inputs do not reach its later missing-JUMP_SLOT error. With filter levels 0 and 1, the same inputs do fail on main with the misleading message, as described in the PR (24 paired diagnostic improvements).

Is rejecting the previously accepted strict-filter case intentional? If so, please include it in What/Tested and add a strict-filter regression, so the PR is described as enforcing the DT_JMPREL type rule before compaction as well as correcting diagnostics. This observation does not establish that NONE entries in DT_JMPREL must be supported; it distinguishes the actual old/new behavior from a diagnostic-only change.

Validation on Windows 11 build 26200, GCC 16.2.0-6 UCRT, CMake 4.3.1/Ninja 1.13.2, Python 3.14.7:

  • Two fresh, separate exact-commit checkouts and Release relinker-only builds with ANYPS5_RELINKER_ONLY=ON, BUILD_TESTING=ON, target relinker: 88 build steps each, both successful. No source substitution or mixed binary was used.
  • Ten selected registered CTest groups pass on each build: rela_size, none_relocations, guest_none_relocations, guest_relative_section_symbols, overlapping_relocations, optional_plt, optional_rela, null_symbol_relocations, jmprel_table_bounds, copy_relocations. Head 10/10 passed, 42.07 s total; base 10/10 passed, 41.90 s total, each at -j2. These are separate local results, not a speed comparison. The tests include native Windows fixture execution and inspection of other output formats. I did not reproduce the author's Windows security-blocking failure on these selected tests, and changed no security settings.
  • Running this head's test_jmprel_table_bounds.py against the exact main executable gives the expected assertion failure at the first new linux-plt-symbol-none-in-plt case: return 2 and the old missing-JUMP_SLOT message, rather than the new expected message. The head's registered version passes.
  • A separate 144-invocation matrix covers three output formats, standard/SCE table tags and all filter levels 0/1/2. Every head PLT-NONE rejection is at the actual entry offset 0x1400 in this fixture. Both ordinary DT_RELA NONE entries (including an out-of-range ignored symbol index) and valid canonical JUMP_SLOT controls continue to convert successfully, with 36 complete output files byte-for-byte identical between base and head. The 12 acceptance changes and 24 corrected errors above are recorded separately; the baseline is not falsely reported as rejecting every NONE case.
  • The matrix uses separate RX code and RW data segments and canonical PLT bytes, so strict-filter layout/thunk checks are satisfied before observing this distinction. Its generated Linux/macOS files are inspected only; no matrix output is executed. No Linux/macOS host execution, full product build, game, console, GPU, sanitizer or full CTest/hosted-CI result is claimed for this review.
  • Conventions and whitespace checks pass; both source checkouts stay clean. The existing #10971 test-file adjacency conflict has already been acknowledged by its author; I did not merge or validate that separate implementation.

Tested executable SHA-256 values:

main 780886a3c066ec7055d6a37e0b3cab8e27e85f3d70abe9b29149650599c16489
head 9f2cd9c703af2ba4016bdc63b182db8dcb51b7d3bef89061903c16e7a3cfdfe9
Complete native before/after matrix replay

Prepare checkouts at the two exact commits above and build each separately:

cmake -S <checkout> -B <build> -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DBUILD_TESTING=ON -DANYPS5_RELINKER_ONLY=ON
cmake --build <build> --target relinker --parallel 2
ctest --test-dir <build> -R "^(jmprel_table_bounds|none_relocations|guest_none_relocations|overlapping_relocations|rela_size|guest_relative_section_symbols|optional_plt|optional_rela|copy_relocations|null_symbol_relocations)$" --output-on-failure -j2

Save the script below in a separate scratch directory and run with native Git and the selected compiler's runtime directory on PATH:

python probe-jmprel-none.py <absolute-head-checkout> <absolute-main-relinker.exe> <absolute-head-relinker.exe>
python <head-checkout>/core/relinker/relinker/tests/test_jmprel_table_bounds.py <main-relinker.exe>

The first command asserts all 144 results and writes a JSON record including executable hashes; expected summary is 24 corrected errors, 12 strict-filter acceptance changes and 36 identical valid pairs. The second is the expected failing negative control. The script uses the committed fixture builder, constructs the segment layout needed for strict filtering, and runs real converter subprocesses in a disposable scratch directory. It does not edit either checkout or fetch anything.

import hashlib
import importlib.util
import itertools
import json
from pathlib import Path
import struct
import subprocess
import sys
import tempfile

work = Path(__file__).resolve().parent
repo = Path(sys.argv[1]).resolve() if len(sys.argv) > 1 else work / 'review-11041'
executables = [Path(value).resolve() for value in sys.argv[2:4]] if len(sys.argv) > 2 else [
    work / 'build-relinker-11041-base/core/relinker/relinker.exe',
    work / 'build-relinker-11041/core/relinker/relinker.exe']
assert len(executables) == 2 and all(path.is_file() for path in executables)
assert subprocess.check_output(['git', '-C', str(repo), 'rev-parse', 'HEAD'], text=True).strip() == 'e38c2e1e7a4b5989d31d2a82aeb47f53cc05c4e1'
spec = importlib.util.spec_from_file_location('jmprel_fixture', repo / 'core/relinker/relinker/tests/test_jmprel_table_bounds.py')
fixtures = importlib.util.module_from_spec(spec)
spec.loader.exec_module(fixtures)
rows = []
with tempfile.TemporaryDirectory(prefix='jmprel-none-review-', dir=work) as directory:
    root = Path(directory).resolve()
    assert root.is_relative_to(work)
    for target, os_tags, level, kind in itertools.product(('linux', 'windows', 'macos'), (False, True), range(3),
                                                         ('plt-none', 'plt-none-zeroed', 'data-none', 'plt-valid')):
        name = f'{target}-{os_tags}-{level}-{kind}'
        source, output = root / (name + '.elf'), root / (name + '.out')
        options = {'linux': target == 'linux', 'os_tags': os_tags}
        if kind.startswith('plt-none'):
            image = fixtures.fixture(relocation_type=0, symbol_index=0, **options)
        elif kind == 'data-none':
            image = fixtures.fixture(relocation_type=0, symbol_index=0xffffffff, symbol_bytes=0,
                                     data_relocations=True, **options)
        else:
            image = fixtures.fixture(**options)
        original = image
        image = bytearray(0x2000)
        image[:0x300] = original[:0x300]
        image[0x1000:0x1d00] = original[0x300:]
        if target != 'linux':
            struct.pack_into('<H', image, 56, 4)
        struct.pack_into('<IIQQQQQQ', image, 64, 1, 5, 0, 0, 0, 0x300, 0x300, 0x1000)
        struct.pack_into('<IIQQQQQQ', image, 64 + 3 * 56, 1, 6, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000)
        struct.pack_into('<QQQ', image, 128, 0x1100, 0x1100, 0x1100)
        struct.pack_into('<QQ', image, 216, 0x2000, 0x2000)
        addresses = {fixtures.DT_STRTAB, fixtures.DT_SYMTAB, fixtures.DT_RELA,
                     fixtures.DT_PLTGOT, fixtures.DT_JMPREL, fixtures.DT_OS_PLTGOT, fixtures.DT_OS_JMPREL}
        for offset in range(0x1100, 0x1200, 16):
            tag, value = struct.unpack_from('<qQ', image, offset)
            if not tag:
                break
            if tag in addresses:
                struct.pack_into('<Q', image, offset + 8, value + 0xd00)
        struct.pack_into('<Q', image, 0x1400, 0x1000)
        if kind == 'plt-none-zeroed':
            image[0x1400:0x1418] = bytes(24)
        struct.pack_into('<i', image, 0x202, 0x1000 - 0x206)
        if kind != 'plt-valid':
            image[0x200:0x206] = bytes.fromhex('b82a000000c3')
        else:
            image[0x206:0x210] = bytes.fromhex('6800000000e900000000')
        source.write_bytes(image)
        flags = ['--windows'] if target == 'windows' else ['--macos'] if target == 'macos' else []
        pair = []
        for version, executable in zip(('base', 'head'), executables):
            output.unlink(missing_ok=True)
            result = subprocess.run([str(executable), '--skip-sce-module', *flags, f'unused-filter={level}',
                                     str(source), str(output)], capture_output=True, text=True, timeout=20)
            digest = hashlib.sha256(output.read_bytes()).hexdigest() if output.exists() else None
            row = {'case': name, 'version': version, 'exit': result.returncode, 'output_sha256': digest,
                   'stderr': result.stderr.strip()}
            rows.append(row)
            pair.append(row)
            if kind.startswith('plt-none'):
                if version == 'head':
                    assert result.returncode == 2 and not output.exists(), row
                    assert 'Unsupported PLT relocation type (offset 0x1400)' in result.stderr, row
                elif level == 2:
                    assert result.returncode == 0 and output.exists(), row
                else:
                    assert result.returncode == 2 and not output.exists(), row
                    assert 'Original .rela.plt slot has no corresponding JUMP_SLOT relocation' in result.stderr, row
            else:
                assert result.returncode == 0 and output.exists(), row
        if not kind.startswith('plt-none'):
            assert pair[0]['output_sha256'] == pair[1]['output_sha256'], pair
data = {'head': 'e38c2e1e7a4b5989d31d2a82aeb47f53cc05c4e1',
        'base': '3a2c51afd2ee6a824cd3a294912c65e6bbf2b768', 'cases': len(rows),
        'corrected_rejection_pairs': 24, 'parent_acceptance_changed': 12,
        'head_none_rejections': 36, 'identical_valid_pairs': 36, 'rows': rows,
        'executables': [{'path': str(path), 'sha256': hashlib.sha256(path.read_bytes()).hexdigest()} for path in executables],
        'converted_outputs_executed': False}
target = Path(sys.argv[4]).resolve() if len(sys.argv) > 4 else work / 'jmprel-none-matrix.json'
target.write_text(json.dumps(data, indent=2), encoding='utf-8')
print(f'PASS: {len(rows)} native invocations, 24 corrected errors, 12 strict-filter acceptance changes, 36 identical valid pairs')

AI-assisted review and scratch fixture: yes (OpenAI Codex).

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5643847208 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11041#pullrequestreview-5643847208). Originally posted by [thepoppfish](https://github.com/thepoppfish) on 2026-10-25T15:22:59Z. **Review:** COMMENTED --- Additional native Windows validation and one scope clarification for exact head `e38c2e1e7a4b5989d31d2a82aeb47f53cc05c4e1` against main `3a2c51afd2ee6a824cd3a294912c65e6bbf2b768`. The relocated guard gives the intended early diagnostic, and the ordinary DT_RELA NONE skip remains intact. This is a comment review because the matrix also found an acceptance change that is worth stating explicitly. **Strict-filter scope:** with `unused-filter=2`, an immutable code segment returning immediately and an unused NONE-only DT_JMPREL table, main succeeds and emits an output; this head exits 2 with `Unsupported PLT relocation type` before filtering. This happens for both the ordinary NONE entry and a completely zeroed 24-byte entry, using standard/SCE table tags and Linux/Windows/macOS output (**12 paired acceptance changes**). Main's strict-filter PLT compaction removes the unused table, so those inputs do not reach its later missing-JUMP_SLOT error. With filter levels 0 and 1, the same inputs do fail on main with the misleading message, as described in the PR (**24 paired diagnostic improvements**). Is rejecting the previously accepted strict-filter case intentional? If so, please include it in What/Tested and add a strict-filter regression, so the PR is described as enforcing the DT_JMPREL type rule before compaction as well as correcting diagnostics. This observation does not establish that NONE entries in DT_JMPREL must be supported; it distinguishes the actual old/new behavior from a diagnostic-only change. Validation on Windows 11 build 26200, GCC 16.2.0-6 UCRT, CMake 4.3.1/Ninja 1.13.2, Python 3.14.7: - Two fresh, separate exact-commit checkouts and Release relinker-only builds with `ANYPS5_RELINKER_ONLY=ON`, `BUILD_TESTING=ON`, target `relinker`: **88 build steps each, both successful**. No source substitution or mixed binary was used. - Ten selected registered CTest groups pass on each build: `rela_size`, `none_relocations`, `guest_none_relocations`, `guest_relative_section_symbols`, `overlapping_relocations`, `optional_plt`, `optional_rela`, `null_symbol_relocations`, `jmprel_table_bounds`, `copy_relocations`. **Head 10/10 passed, 42.07 s total; base 10/10 passed, 41.90 s total**, each at `-j2`. These are separate local results, not a speed comparison. The tests include native Windows fixture execution and inspection of other output formats. I did not reproduce the author's Windows security-blocking failure on these selected tests, and changed no security settings. - Running this head's `test_jmprel_table_bounds.py` against the exact main executable gives the expected assertion failure at the first new `linux-plt-symbol-none-in-plt` case: return 2 and the old missing-JUMP_SLOT message, rather than the new expected message. The head's registered version passes. - A separate **144-invocation** matrix covers three output formats, standard/SCE table tags and all filter levels 0/1/2. Every head PLT-NONE rejection is at the actual entry offset `0x1400` in this fixture. Both ordinary DT_RELA NONE entries (including an out-of-range ignored symbol index) and valid canonical JUMP_SLOT controls continue to convert successfully, with **36 complete output files byte-for-byte identical** between base and head. The 12 acceptance changes and 24 corrected errors above are recorded separately; the baseline is not falsely reported as rejecting every NONE case. - The matrix uses separate RX code and RW data segments and canonical PLT bytes, so strict-filter layout/thunk checks are satisfied before observing this distinction. Its generated Linux/macOS files are inspected only; no matrix output is executed. No Linux/macOS host execution, full product build, game, console, GPU, sanitizer or full CTest/hosted-CI result is claimed for this review. - Conventions and whitespace checks pass; both source checkouts stay clean. The existing #10971 test-file adjacency conflict has already been acknowledged by its author; I did not merge or validate that separate implementation. Tested executable SHA-256 values: ```text main 780886a3c066ec7055d6a37e0b3cab8e27e85f3d70abe9b29149650599c16489 head 9f2cd9c703af2ba4016bdc63b182db8dcb51b7d3bef89061903c16e7a3cfdfe9 ``` <details> <summary>Complete native before/after matrix replay</summary> Prepare checkouts at the two exact commits above and build each separately: ```text cmake -S <checkout> -B <build> -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DBUILD_TESTING=ON -DANYPS5_RELINKER_ONLY=ON cmake --build <build> --target relinker --parallel 2 ctest --test-dir <build> -R "^(jmprel_table_bounds|none_relocations|guest_none_relocations|overlapping_relocations|rela_size|guest_relative_section_symbols|optional_plt|optional_rela|copy_relocations|null_symbol_relocations)$" --output-on-failure -j2 ``` Save the script below in a separate scratch directory and run with native Git and the selected compiler's runtime directory on PATH: ```text python probe-jmprel-none.py <absolute-head-checkout> <absolute-main-relinker.exe> <absolute-head-relinker.exe> python <head-checkout>/core/relinker/relinker/tests/test_jmprel_table_bounds.py <main-relinker.exe> ``` The first command asserts all 144 results and writes a JSON record including executable hashes; expected summary is 24 corrected errors, 12 strict-filter acceptance changes and 36 identical valid pairs. The second is the expected failing negative control. The script uses the committed fixture builder, constructs the segment layout needed for strict filtering, and runs real converter subprocesses in a disposable scratch directory. It does not edit either checkout or fetch anything. ```python import hashlib import importlib.util import itertools import json from pathlib import Path import struct import subprocess import sys import tempfile work = Path(__file__).resolve().parent repo = Path(sys.argv[1]).resolve() if len(sys.argv) > 1 else work / 'review-11041' executables = [Path(value).resolve() for value in sys.argv[2:4]] if len(sys.argv) > 2 else [ work / 'build-relinker-11041-base/core/relinker/relinker.exe', work / 'build-relinker-11041/core/relinker/relinker.exe'] assert len(executables) == 2 and all(path.is_file() for path in executables) assert subprocess.check_output(['git', '-C', str(repo), 'rev-parse', 'HEAD'], text=True).strip() == 'e38c2e1e7a4b5989d31d2a82aeb47f53cc05c4e1' spec = importlib.util.spec_from_file_location('jmprel_fixture', repo / 'core/relinker/relinker/tests/test_jmprel_table_bounds.py') fixtures = importlib.util.module_from_spec(spec) spec.loader.exec_module(fixtures) rows = [] with tempfile.TemporaryDirectory(prefix='jmprel-none-review-', dir=work) as directory: root = Path(directory).resolve() assert root.is_relative_to(work) for target, os_tags, level, kind in itertools.product(('linux', 'windows', 'macos'), (False, True), range(3), ('plt-none', 'plt-none-zeroed', 'data-none', 'plt-valid')): name = f'{target}-{os_tags}-{level}-{kind}' source, output = root / (name + '.elf'), root / (name + '.out') options = {'linux': target == 'linux', 'os_tags': os_tags} if kind.startswith('plt-none'): image = fixtures.fixture(relocation_type=0, symbol_index=0, **options) elif kind == 'data-none': image = fixtures.fixture(relocation_type=0, symbol_index=0xffffffff, symbol_bytes=0, data_relocations=True, **options) else: image = fixtures.fixture(**options) original = image image = bytearray(0x2000) image[:0x300] = original[:0x300] image[0x1000:0x1d00] = original[0x300:] if target != 'linux': struct.pack_into('<H', image, 56, 4) struct.pack_into('<IIQQQQQQ', image, 64, 1, 5, 0, 0, 0, 0x300, 0x300, 0x1000) struct.pack_into('<IIQQQQQQ', image, 64 + 3 * 56, 1, 6, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000) struct.pack_into('<QQQ', image, 128, 0x1100, 0x1100, 0x1100) struct.pack_into('<QQ', image, 216, 0x2000, 0x2000) addresses = {fixtures.DT_STRTAB, fixtures.DT_SYMTAB, fixtures.DT_RELA, fixtures.DT_PLTGOT, fixtures.DT_JMPREL, fixtures.DT_OS_PLTGOT, fixtures.DT_OS_JMPREL} for offset in range(0x1100, 0x1200, 16): tag, value = struct.unpack_from('<qQ', image, offset) if not tag: break if tag in addresses: struct.pack_into('<Q', image, offset + 8, value + 0xd00) struct.pack_into('<Q', image, 0x1400, 0x1000) if kind == 'plt-none-zeroed': image[0x1400:0x1418] = bytes(24) struct.pack_into('<i', image, 0x202, 0x1000 - 0x206) if kind != 'plt-valid': image[0x200:0x206] = bytes.fromhex('b82a000000c3') else: image[0x206:0x210] = bytes.fromhex('6800000000e900000000') source.write_bytes(image) flags = ['--windows'] if target == 'windows' else ['--macos'] if target == 'macos' else [] pair = [] for version, executable in zip(('base', 'head'), executables): output.unlink(missing_ok=True) result = subprocess.run([str(executable), '--skip-sce-module', *flags, f'unused-filter={level}', str(source), str(output)], capture_output=True, text=True, timeout=20) digest = hashlib.sha256(output.read_bytes()).hexdigest() if output.exists() else None row = {'case': name, 'version': version, 'exit': result.returncode, 'output_sha256': digest, 'stderr': result.stderr.strip()} rows.append(row) pair.append(row) if kind.startswith('plt-none'): if version == 'head': assert result.returncode == 2 and not output.exists(), row assert 'Unsupported PLT relocation type (offset 0x1400)' in result.stderr, row elif level == 2: assert result.returncode == 0 and output.exists(), row else: assert result.returncode == 2 and not output.exists(), row assert 'Original .rela.plt slot has no corresponding JUMP_SLOT relocation' in result.stderr, row else: assert result.returncode == 0 and output.exists(), row if not kind.startswith('plt-none'): assert pair[0]['output_sha256'] == pair[1]['output_sha256'], pair data = {'head': 'e38c2e1e7a4b5989d31d2a82aeb47f53cc05c4e1', 'base': '3a2c51afd2ee6a824cd3a294912c65e6bbf2b768', 'cases': len(rows), 'corrected_rejection_pairs': 24, 'parent_acceptance_changed': 12, 'head_none_rejections': 36, 'identical_valid_pairs': 36, 'rows': rows, 'executables': [{'path': str(path), 'sha256': hashlib.sha256(path.read_bytes()).hexdigest()} for path in executables], 'converted_outputs_executed': False} target = Path(sys.argv[4]).resolve() if len(sys.argv) > 4 else work / 'jmprel-none-matrix.json' target.write_text(json.dumps(data, indent=2), encoding='utf-8') print(f'PASS: {len(rows)} native invocations, 24 corrected errors, 12 strict-filter acceptance changes, 36 identical valid pairs') ``` </details> AI-assisted review and scratch fixture: yes (OpenAI Codex).
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!11041
No description provided.