PE: Read the ARM64 and ARMNT exception directory - #756
Conversation
|
THIS MESSAGE WAS GENERATED BY AN AUTOMATED PROCESS Validation record for head
Corpus A/B, 1,557 PE objects, one process per object per side, with the
The issue proposed masking that bit off. Measured, keeping it is better on every
Both images are Thumb only, so an ARM-mode node at a hint address is a CFG effect of the hints themselves.
That gain is ARM64, and it concentrates: the four largest are ARM64 images whose On ARMNT the hints are close to neutral for Nine of the 22 lose at most four blocks or six functions, which is a hint at a
Caveats: the corpus is a private dataset, so objects are named by machine type and count rather than by path; angr/binaries#183 reproduces both architectures publicly. CI on this PR: every job that resolves the referenced sibling pull request is |
|
Corpus decompilation diffs can be found at angr/dec-snapshots@master...angr/cle_756 |
_handle_seh took the exception directory from pefile, which parses it for x86-64 and Itanium only, so an ARM64 or ARMNT image produced no function hints at all even though its ABI requires an unwind entry for every non-leaf function. Read the eight-byte record for those two machines directly: the function's start RVA, then either an .xdata RVA or unwind data packed into the second word, which is where the function length comes from. Records that describe a fragment of a function beginning elsewhere are not function starts and are skipped, and an ARMNT start address keeps its Thumb bit, which is what selects the decoder.
e4169b6 to
b205ac2
Compare
THIS MESSAGE WAS GENERATED BY AN AUTOMATED PROCESS
_handle_sehreads the exception directory through pefile, which parses it forx86-64 and Itanium only, so an ARM64 or ARMNT image gives CFGFast no function
hints even though its ABI requires an unwind entry for every non-leaf function.
The entries are in the file; only the parse was missing.
CLE now reads the eight-byte ARM64 and ARMNT record itself, taking the length
from the packed word or the
.xdataheader and skipping records that describe afragment of a function beginning elsewhere. An ARMNT start address keeps its
Thumb bit, as an ARM function address does everywhere else in CLE, because that
bit selects the decoder; masking it off measurably costs recovery.
tests/test_pe_function_hints.pycovers both, and checks that the x86-64 hintsstill match pefile's own parse.
Fixes #753. Needs angr/binaries#183 for the fixtures. Validation: #756 (comment)