fix(relinker): wrap address-size LEA roots #20900
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/20900"
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 Queuse on 2026-11-15T17:50:23Z.
What
A
67haddress-size override on a REX.W RIP-relative LEA computes a 32-bit effective address and zero-extends it into the 64-bit destination. The collector currently retains the high bits of the instruction address, so it can discard a callable low-address target and retain an unrelated high-address decoy. Truncate the effective address before the existing code/data classification; ordinary 64-bit LEAs keep their full address.The production change is two lines. The regression suite covers positive/negative displacement, wrap across 4 GiB and below zero, ordinary 64-bit LEA, unwind functions, data targets, known function interiors and an SCE gap target.
Tested
Windows / WinLibs GCC 15.2 / Python 3.12, relinker-only build based on
mainb7aeb6f40619: four focused CTests passed (code_instruction_collector_address_size,code_analysis_address_data,strict_nid_filter,control_flow_graph). A control compiled from this exact main'sCodeInstructionCollector.cpp, linked with the same test and remaining library objects, fails with67h LEA failed to wrap effective address to 32-bit low callback. The changed collector passes.Linux WSL / GCC 15.2: an actual assembled static ELF executes the address-size LEA and indirect call successfully, returning status 42. Feeding that ELF's real program headers and bytes into the collector misses
callbackon main and on #10861 atef92693f7218, and finds it with this change. The full collector regression also fails on both controls and passes with this change. This demonstrates an executable input rather than a malformed-image-only assertion. No PS5 title was tested.Native ELF reproducer (
as --64 native67.s -o native67.o,ld -melf_x86_64 -T native67.ld native67.o -o native67, then./native67; echo $?prints 42):native67.ld:python tools/check_conventions.py --base origin/mainandgit diff --checkpassed. The required overlap scan failed closed on 19 older branches. All reported shared-file patches were compared at their current heads: #6149, #7531, #10861, #11628, #11661, #11689, #11698, #12678, #13486, #13716, #15245, #15642, #15896, #15903, #17451, #17473, #17557, #17558, #18432. Their CMake changes introduce other targets; none implements this callable 32-bit effective-address case.There is a genuine shared-hunk integration point with #10861: its broader classifier treats address-size-32 LEAs as data even with REX.W. In an isolated temporary composition, allowing REX.W through its code classification and truncating its target before classification makes both the native ELF probe and this regression suite pass. #10861 alone fails both. If that branch lands first, this small correction needs to be carried through its classifier, retaining the regression test. #13716 changes pointer/code classification without wrapping this LEA operand; #15903 changes hash bounds; #18432 changes decoder reuse. The other conflicting branches were compared manually, not built in combination. No performance claim.
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 PrivacyOnion on 2026-11-16T01:48:38Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
af78ab9a82:tools/check_conventions.pypassed;git diff --checkclean.code_instruction_collector_address_size_testsbuilt cleanly.code_instruction_collector_address_size):core/relinker/relinker/src/analysis/CodeInstructionCollector.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.addAddressTakenRoottruncatestargetviastatic_cast<std::uint32_t>(target)wheninfo.AddressSize32is true, matching x86-6467haddress-size override semantics (32-bit EIP-relative effective address calculation with zero-extension) beforeisCode,inTable,inFunction, andaddPointerRootclassification.REX.W LEA(info.AddressSize32 == false) preserves all 64 bits oftargetwithout alteration.CheckAddressSize32WrapsHighInstructionToLowCallback), ordinary 64-bit LEA (CheckOrdinary64BitLeaPreservesHighBits), negative displacement and 32-bit wrap boundary cases (CheckNegativeDisplacementAnd32BitWrap), and.eh_frame/SCE branch interactions (CheckEhFrameAndSceBranchesHonorAddressSize32).std::uint64_t,std::uint32_t,std::int32_t,std::size_tusage) and strict AGENTS.md compliance.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-18T12:25:16Z.
Review: COMMENTED
Reviewed — no blocking findings
The reviewed change wraps address-size-32 LEA targets before classification; no blocking defect was verified, but I could not run the reported checks in this review environment.
What I ran
af78ab9a82fff70d12f26221743a070efaabd048against the prepared diff; no merged-preview check was run.core/relinker/CMakeLists.txt,core/relinker/relinker/src/analysis/CodeInstructionCollector.cpp, andcore/relinker/relinker/tests/CodeInstructionCollectorAddressSizeTests.cpp.Results
Negative control
I could not run a negative control. The description reports that a control built from
mainfailed on the new wrapping assertion.Findings
Blocking
None.
Non-blocking
Sources
Not verified
No build or test execution, PS5 title, or console behavior was verified by me. The prepared manifest lists three changed files, all included; I read the added lines in each. No changed files were excluded.
To get this to a good state
Nothing is required. If #10861 lands first, retain the address-size-32 target wrapping and regression coverage when integrating its classifier.