mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:50:51 +01:00
[PR #1249] recomp_census: fix UNW_FLAG_CHAININFO/CountOfCodes and decode .xdata unwind ops (RECOMP-CENSUS-XDATA-UNWIND) #1280
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1280
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1249
Author: @IlyassRS3
Created: 11/24/2026
Status: 🔄 Open
Base:
main← Head:feat/recomp-census-xdata-unwind📝 Commits (1)
db3ea85recomp_census: fix UNW_FLAG_CHAININFO/CountOfCodes and decode .xdata unwind ops📊 Changes
2 files changed (+686 additions, -6 deletions)
View changed files
➕
tests/test_recomp_census_unwind.py(+371 -0)📝
tools/recomp_census.py(+315 -6)📄 Description
What changed
Fixes two x64
.xdataUNWIND_INFOheader bugs intools/recomp_census.pyand adds fullUNWIND_CODEdecoding andUNW_FLAG_CHAININFOchain walking to report the SEH / frame-layout breakdown needed bydocs/mobile.mdNext Step #3 (arm64 SEH / unwind translation):Bug fixes in
tools/recomp_census.pyUNW_FLAG_*bitmask (UNW_FLAG_NAMES):UNW_FLAG_CHAININFOis0x4(per Microsoft x64 exception handling / LLVMWin64EH.h), not0x8(0x4was previously mislabelledFHANDLER, so real chained unwind entries were misreported asFHANDLERandCHAINEDwas never reported).CountOfCodes(unwind_flags):UNWIND_INFObyte 1 isSizeOfPrologand byte 2 isCountOfCodes;unwind_flags()previously returned byte 1 ascode_count..xdataunwind decoder & census (tools/recomp_census.py)parse_unwind_info(img, unwind_rva)decoding all 11 x64UNWIND_CODEopcodes (0..10:UWOP_PUSH_NONVOL,UWOP_ALLOC_LARGE2- and 3-slot forms,UWOP_ALLOC_SMALL,UWOP_SET_FPREG,UWOP_SAVE_NONVOL,UWOP_SAVE_NONVOL_FAR, v2UWOP_EPILOG,UWOP_SPARE_CODE,UWOP_SAVE_XMM128,UWOP_SAVE_XMM128_FAR,UWOP_PUSH_MACHFRAME), verified against LLVMWin64EH.h/Win64EHDumper.cppand Microsoft CoreCLRamd64/unwinder.cpp.((CountOfCodes + 1) & ~1) * 2before trailingExceptionHandlerRVA or chainedRUNTIME_FUNCTION.UNW_FLAG_CHAININFOchains with cycle detection and bounded depth (MAX_UNWIND_CHAIN = 64), aggregating fixed stack allocation, saved nonvolatile GPRs/XMMs, frame register/offset, epilog counts, and primary handler RVA..xdatarecords cleanly viaerrorwithout crashing."unwind"breakdown tocensus()JSON output and an## Unwind (.xdata) detailssection toto_markdown()while keeping all existing JSON keys and Markdown headings backwards-compatible.tests/test_recomp_census_unwind.py(17 unit tests using synthetic byte-built PE32+ fixtures, no game data).main(), the file docstring, andtests/test_recomp_census.pyuntouched so this merges cleanly with open PR #1088 (RECOMP-CENSUS-WRONG-INPUT).Item ID
RECOMP-CENSUS-XDATA-UNWINDVerification
Tested on macOS 27.2.1 (Apple M5 arm64), Python 3.14 (no game files, no GPU, standard library only):
python3 -I tests/test_recomp_census.py -v-> 7/7 OKpython3 -I tests/test_recomp_census_unwind.py -v-> 17/17 OKtools/recomp_census.pytoupstream/mainwhile keepingtests/test_recomp_census_unwind.py) -> FAILED (3 failures, 23 errors), directly provingFHANDLER != CHAINED,12 != 0(SizeOfPrologvsCountOfCodes), and0x8falsely flagged asCHAINEDonmain.RECOMP-CENSUS-WRONG-INPUT): auto-merged with 0 conflicts, running 11/11test_recomp_census.py+ 17/17test_recomp_census_unwind.py(28/28 OK).python3 -m compileall -q tools/recomp_census.py tests/test_recomp_census.py tests/test_recomp_census_unwind.py-> OKpython3 -I scripts/check_no_game_data.py tools/recomp_census.py tests/test_recomp_census_unwind.py-> OKpython3 -I tests/test_ci_registration.py-> 15/15 OK (new test file selected by CI stdlib loop)python3 -I tests/test_text_write_line_endings.py-> 3/3 OKChecklist
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.