relinker: the two syscall-number paths disagree on sign-extension and on the constant-load forms they recognize #10422
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 KSWORK2001 on 2026-10-23T23:54:48Z.
The refusal message of the syscall scan names the FreeBSD syscall number when a constant load before the pattern establishes it. Two different paths compute that number, and they disagree:
ConstantSyscallNumber(core/relinker/relinker/src/analysis/SyscallScanner.cpp) walks the decoded instructions before the pattern throughConstantRaxLoad, andConstantSyscallNumberInBytes/ConstantRaxSetEndingAtscan the raw bytes back from the pattern when unwind functions exist and the pattern lies outside them.Measured on
main999e612599, relinker-only build, with the fixture style oftest_syscall_number.py(no unwind table, decodable stream → first path) andtest_sce_code_gaps.py(pattern in a gap after undecodable bytes → second path):syscall48 C7 C0 FF FF FF FF(mov rax, imm32, -1)0xFFFFFFFFFFFFFFFFsyscall number 4294967295syscall number 1844674407370955161548 B8 imm64(mov rax, imm64)31 C0(xor eax, eax)syscall number 0So the same instruction sequence names a different number depending on where it sits,
mov rax, imm32reports the raw immediate where the register holds the sign-extended value (ConstantRaxSetEndingAtalready sign-extends;ConstantRaxLoaddoes not), andmov rax, imm64orxor eax, eaximmediately before a syscall establish a number that the decodable path never reports. TheB8 imm32form (mov eax, imm32) is reported zero-extended by both, which is correct.Both paths end in the same refusal, so conversion results do not differ; the number in the message is the only divergence. That message is the primary diagnostic for the most common homebrew conversion failure, and the project's reports quote it verbatim.
Reproduction (decodable path): an executable whose code begins
48 C7 C0 FF FF FF FF 49 89 CA 0F 05 C3fails withForbidden syscall instruction at code offset 0xa: syscall number 4294967295; the same load in a gap after undecodable bytes fails withsyscall number 18446744073709551615.48 B8 09 00 00 00 00 00 00 00 49 89 CA 0F 05 C3fails with no number, where the byte window names 9.Direction: make
ConstantRaxLoadrecognize the same forms asConstantRaxSetEndingAtwith the same extension:48 C7 C0 imm32sign-extended,48 B8 imm64,B8 imm32zero-extended, and31/33 C0zeroing (an operand-size prefix excludes the xor forms, since66 31 C0clears only AX).AI-assisted: yes