fix(relinker): resolve BND and NOTRACK call sites #10647
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10647"
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 Bram910 on 2026-10-24T14:53:58Z.
What
The call-site resolver skips REX prefixes but stops at
F2(BND/REPNE) or3E(NOTRACK/DS). Valid prefixed indirect calls and tail jumps therefore produce emptycallSitesandcallSitesResolved: falsein the import registry, despite referring to the same GOT slots as unprefixed instructions.Skip these two legacy prefixes when locating the opcode and RIP displacement. Clear the accumulated REX.W state when either appears, so an earlier REX cannot incorrectly widen a subsequent pointer load. This changes registry analysis only; it does not rewrite instructions or emulate BND/CET behavior. Instructions with F3, 66, 67, F0, 2E/26/36, FS/GS prefixes, and
8Bloads without REX.W remain unclassified; these limits are recorded beside the registry entry indocs/dev/debt/relinker.md.Add 22 regression scenarios covering individual and combined hints, both prefix orders, REX placement, pointer loads, and negative controls for narrow loads, segment/address overrides, register transfers and unrelated memory operations. GNU binutils' NOTRACK prefix tests also cover combined BND/NOTRACK forms and their prefix ordering.
Tested
mainat1e740a23a3; implementation commit16eb32f20ef6f9b481a5056d783c67fc2f7c884e. The negative control and first round of testing usedd098eca3d6/00897f4b47. The intervening merge changes only unrelated AGC tests; the implementation retains the same stable patch ID (e28cdac41e62502b22c672f67e3ffc8d49ebe720) across that rebase.BND indirect call, then passes with this fix.0x200to the GOT slot at0x300on both the Windows and native Linux relinkers (40 successful fixed conversions). No title was used.call_site_resolverandcall_site_indexCTests pass five consecutive runs each.ANYPS5_RELINKER_ONLY=ON:cmake --build build-relinker --parallel 4succeeds, andctest --test-dir build-relinker --output-on-failure --parallel 4passes 241/241 tests on the final rebased head (169.97 seconds). The initial pre-rebase full run also passed 241/241.-Wall -Wextra -Werror, in Release and ASan/UBSan builds, and pass five consecutive runs each per build (20 successful component runs). Sanitizer options:detect_leaks=1:halt_on_error=1andhalt_on_error=1:print_stacktrace=1.python tools/check_conventions.py --base origin/mainandgit diff --checkpass.python tools/pr_overlap.py --repo boykopovar/AnyPS5 --branch fix/call-site-hint-prefixes --jobs 4reports no overlap with open pull requests, against the final base1e740a23a3.16eb32f20e, merged with the newer main for CI: Ubuntu 246/246, Windows 243/243, macOS arm64 237/237, macOS x86-64 237/237, and ASan 33/33 passed. Both call-site CTests pass in the four OS jobs; the ASan job builds them but runs only the 33 tests labeledtls_function_coverage. Conventions, labels, intake and eligibility also passed. Full-product jobs were skipped, not executed.7151c6c0907f7440c724c68652846df29d709e67only documents remaining registry-analysis limits and renames one test label. The production resolver is byte-identical to16eb32f20e. Both call-site CTests were rebuilt and passed five consecutive runs each on Windows and Linux (20 successful CTest runs), and conventions and whitespace checks pass. The full-suite results above belong to the implementation head; no full local suite was rerun for the documentation/label-only follow-up.Main integration refresh
mainata5a780eaaa7f187fe8f5c7f2ef244f6a6dab2762into headc265e51abf3d747b67d768fec79f6defc9905419on 2026-10-25, preserving published history.docs/dev/debt/relinker.md: retained this PR's resolver-limit note and main's updated Windows preferred-base documentation. The resolver implementation and regression file are byte-identical to reviewed head7151c6c0907f7440c724c68652846df29d709e67; the diff against the refreshed base remains the same three files.-Wall -Wextra -Werror: both resolver and index tests pass five repetitions each in Release and ASan/UBSan builds (20 successful component runs), with leak detection and halt-on-error enabled. Windows registered resolver/index CTests pass five repetitions each; 20 actual Windows relinker registry conversions pass.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-24T15:00:54Z.
Review: APPROVED
Reviewed exact head
16eb32f20ef6f9b481a5056d783c67fc2f7c884e. The resolver now skips the BND/REPNE and DS/NOTRACK legacy prefixes while scanning the instruction and clears an earlier REX.W when a legacy prefix follows it; the added cases cover both call/jump forms, combined-prefix orderings, REX placement, pointer loads, and negative controls for FS/GS, address-size override, register operands, and unrelated memory operations. The Linux, Windows, macOS ARM64, and macOS x86_64 relinker jobs and relinker ASan all pass; conventions, eligibility, intake, and labels pass. Product-specific jobs were skipped by eligibility. The author reports extensive direct CLI, CTest, and native instruction checks in the PR body; I did not independently rerun those local checks. No blocking issue found.Imported from boykopovar/AnyPS5. Originally posted by roboterspinne on 2026-10-24T15:39:44Z.
Review: COMMENTED
Reviewed head
16eb32f20merged ontoupstream/main3ca5b17655(2026-10-24); the merge is clean,check_conventions.pypasses andpr_overlap.pyreports no overlap.Environment: Windows 11 Home 10.0.26200, Intel i9-12900H, WinLibs GCC 15.2.0 UCRT, CMake 4.3.1, Ninja 1.13.2, Python 3.13.9,
-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON, Release.Results
long_pathsskipped. The one failure,patch_advisor_unit, ismain's:test_uppercase_digest_and_conversion_optionsasserts--sce-module-path <root>unquoted whilesuggest_patches.pyquotes a path that contains a space (subprocess.list2cmdline), and my temp root does; it fails identically on plainmain3ca5b17655and enteredmainwith #8900 today. Not this PR.main's resolver fail atBND indirect call; against this branchcall_site_resolver,call_site_index,call_registry_writerandcall_registrypass.--registryon thetest_call_registryfixture, Linux and Windows output:mainleavesf2 ff 15,3e ff 15,3e f2 ff 15,f2 3e ff 25,f2 48 ff 15,3e ff 25and3e 48 8b 05with emptycallSitesandcallSitesResolved: false; this branch resolves each to0x200.48 3e 8b 05(narrow load) and3e 67 ff 15stay unresolved on both, and64 f2 ff 15is refused by the Windows output on both (Unsupported Windows guest TLS instruction), so nothing outside the registry changes.[rip+disp]): every BND, NOTRACK, combined and REX-prefixedff 15/ff 25form transfers through the slot;48 3e 8b 05and48 f2 8b 05load 32 bits,3e 48 8b 05,f2 48 8b 05and48 3e 48 8b 05load 64 bits,3e 48 40 8b 05loads 32 bits. That is exactly thehasRexWreset and last-REX rule the resolver implements, and it matches the project's own decoder (X64InstructionDecoder.cpp:42-43,:380) andobjdump's reading of every row.0x1100with displacementsf9/f8/f7ifInstructionMatch.Lengthincludes the prefix bytes, soinstrEndatCallSiteResolver.cpp:85is right;X64InstructionDecoder::Decodeconsumes F2, 3E, F3, 66, 67 and segment prefixes before the opcode.CallSites/CallSitesResolvedare read only byCallRegistryWriter(RelinkerPipeline.cpp:579-581,CallRegistryWriter.cpp:90-96); no patcher reads them.GotAccessIndex(unused-NID filter) already counted these prefixed forms as GOT accesses onmain, so the PR narrows a gap between the filter and the registry rather than opening one.1e740a23a3, patch ide28cdac41e), the binutils thread (both prefix orders) and thepr_overlapinvocation check out.Nits
CallSiteResolver.cpp:33: of the four segment overrides that 64-bit mode ignores (2E, 26, 36, 3E) only 3E is skipped, so2e ff 15or26 48 8b 05stay unresolved while the same instruction with 3E resolves. Conservative, and no compiler emits them; the set that stays unclassified after this PR (F3, 66, 67, F0, 2E/26/36, FS/GS, and8bwithout REX.W) is wider than the body's "address-size and FS/GS overrides", and only the body records it. A sentence indocs/dev/debt/relinker.mdnext to the registry entry would keep it findable; your call.relinker-asan, which runs--label-regex '^tls_function_coverage$'(33 tests); the two call-site tests are built there but not run. True for the four OS jobs.CallSiteResolverTests.cpp:44: "DS-prefixed pointer load" names the accepted3e 48 8b 05as a DS override while the same inert override via 2E/26/36 is rejected; "NOTRACK-prefixed pointer load" would say why this one is in.Notes, nothing to change here:
ripRelativeDispOffsetis a third prefix walker next toX64InstructionDecoder::DecodeandDecodeInstruction, andDecodedInstructionInfoalready exposesRexPrefixwith the same reset rule,SegmentPrefix,AddressSize32andRipRelativeDispOffset; the loop predates this PR and a swap would have to re-add the rejections the new tests pin, so follow-up material at most.call_site_resolverhas noTIMEOUTproperty wherecall_site_indexhas 20 (pre-existing).Not checked: AMD hardware (the console's Zen 2 and the author's probes were not run here; the probe above is Intel), macOS and Linux execution, the WSL ASan/UBSan runs, the pre-rebase head
00897f4b47.I found no blocking issue: the two prefixes do not take part in the address match, the REX reset models the documented placement rule and the CPU, the registry is the only consumer, and the counter-check holds. For disclosure: I have open relinker PRs (#10646, #10607, #10564, #10403, #10402, #10401, #10391, #10390); none touches these files.
Written with AI assistance (Claude Code). I ran the builds, tests, registry conversions and native checks above on my Windows 11 machine.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T16:14:03Z.
Review: COMMENTED
Reviewed the follow-up head
7151c6c0907f7440c724c68652846df29d709e67. Production resolver code is unchanged; the debt entry now lists the remaining unclassified instruction prefixes and narrow loads, and the test label is clearer. I builtcall_site_resolver_testsandcall_site_index_testswith the relinker-only Release configuration and ran both CTests five times (all passed); conventions, diff checks, and the current-main merge tree pass. Hosted Ubuntu and ASan checks pass; Windows and macOS jobs are still running, while product jobs are skipped by policy. The previous approval was on the implementation head, so I’ll recheck the remaining matrix before approving this follow-up head.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T16:19:42Z.
Review: APPROVED
Reviewed the follow-up documentation change at
7151c6c090. It documents the resolver's unclassified-prefix behavior and narrow-load rule; the implementation remains the previously reviewed call-site resolver. Local focused CTests and passed five repetitions each, as did conventions and ; merge tree against current main is clean. Hosted eligibility, labels, and all four relinker platform/sanitizer jobs passed (a duplicate conventions run was cancelled and the replacement passed). Product builds were skipped by repository policy.