fix(relinker): tolerate unwind ranges that split an instruction #1326
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1326"
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 gjonn on 2026-10-07T23:37:52Z.
What
Some unwind ranges in a title (version 01.710) start or end inside an instruction: of 156,935 FDEs, 3 begin and 10 end mid-instruction relative to a linear decode. Relinking with
--windows --to-intelfailed twice because of this.Code analysis: branch into skipped range tail (offset 0xba1812). The range[0xba1790, 0xba1813)ends one byte into4c 0f a3 eb(bt rbx, r13). The per-range sweep cannot decode it and records the byte as a skipped tail, thenjb 0xba1812from the next range is rejected. A static branch target inside a skipped tail is now accepted when an instruction decodes there within its executable segment; the CFG pass then collects it with the segment as its bound. Targets that do not decode are still rejected.Unsupported Windows guest TLS instruction (bytes: 65 2e 62 69 6e 00 00 48 89) (offset 0xb10000). An FDE begins at0xb0c000, two bytes intomovabs rax, "ve.bin\0\0"at0xb0bffd. Decoding from the FDE start gives a GS-prefixed instruction that overlaps the real one. The collector already tolerates overlaps that involve no FS prefix; the TLS builder now skips a non-FS segment-prefixed instruction that starts inside an earlier collected instruction instead of treating it as a TLS access. FS accesses and GS instructions that do not overlap anything behave as before.Tested
tls_function_coveragecases:branch-into-cut-tail-unwind,branch-into-cut-tail-symbolandfunction-begins-inside-instructionfail onmainwith the two errors above and pass with this change.branch-into-undecodable-tail(a branch one byte into anextrqthat the range end cuts, where0f 78without its prefix does not decode) is still rejected.--windows --to-intel, starts, and reaches its first file reads.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by hashaam1217 on 2026-10-08T02:12:45Z.
Checked on Linux: Ubuntu 24.04.5, GCC 13.3.0, Release build, Python 3.12.3.
tls_function_coverage,tls_diagnostics,empty_tls,guest_tls,elf_offsetsandelf_headerpass.WindowsTlsBuilder.cppandCodeInstructionCollector.cppreverted to main but the new tests kept,tls_function_coveragefails atbranch-into-cut-tail-unwind, as described.WindowsTlsBuilder.cpploop and test file as my #1233 and #1234. All three merge into main without conflicts in any order. With all three stacked, the six tests above pass.#1234 runs every converted image on x86-64 Linux through
windows_image_runner.py, and each must exit with 42. So in the stacked run, the three new cases that convert successfully (branch-into-cut-tail-unwind,branch-into-cut-tail-symbol,function-begins-inside-instruction) were also executed on the host, and they return 42.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T11:26:32Z.
Checked: build + ctest green on the PR head; the new
tls_function_coveragecases fail with the two source changes reverted and pass with them;branch-into-undecodable-tailis still rejected. Conflicts with main were adjacency only inCodeInstructionCollector.cpp(both blocks kept), rebased onto main with build + ctest green (442/442); merging.