Resolve p-code architectures from arch_from_id - #365
Conversation
ArchPcode derived the initial stack pointer with an expression that assumed a stack pointer at least 16 bits wide, so an architecture with a narrower one -- the 8051's stack pointer is a single byte -- raised "ValueError: negative shift count" during construction. Derive the value from the stack pointer's own width instead; it is unchanged for every wider architecture. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
THIS MESSAGE WAS GENERATED BY AN AUTOMATED PROCESS Validation record for head
Resolver comparison, baseline against head, over 500 identifiers x 7 endness/width hint combinations = 3500 resolutions. The identifiers are every
End to end on
For an ELF machine this can name, it now answers before cle's own opinion-file fallback. Comparing the two paths on synthesized ELF headers covering every
Every sleigh language pypcode ships constructs on head — 187 of 187, none raising — so any language this can select is one Caveats:
|
|
Corpus decompilation diffs can be found at angr/dec-snapshots@master...angr/archinfo_365 |
arch_from_id could only return one of the fourteen hand-written architecture classes, because arch_id_map is populated by register_arch, which builds an architecture from an endness while ArchPcode is built from a sleigh language. Every loader that names an architecture from a file header goes through arch_from_id, so the 187 languages pypcode ships were unreachable and loading a PA-RISC, Xtensa, LoongArch or TriCore image failed outright. Look the identifier up among the sleigh languages when no registered class claims it, matching a full language id first and then the processor a language describes, and honouring the endness and width the caller passed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
0dcc46e to
08c021f
Compare
THIS MESSAGE WAS GENERATED BY AN AUTOMATED PROCESS
arch_from_idonly returns architectures registered inarch_id_map, whichArchPcodecannot join:register_archbuilds an architecture from an endness, a p-code architecture from a sleigh language. Every loader that reads an architecture out of a header calls it, so PA-RISC, Xtensa and LoongArch images did not load.When nothing registered claims the identifier, look it up among the sleigh languages instead — a full language id first, then the processor a language describes — honouring the endness and width the caller passed. Anything no language covers still raises
ArchNotFound. The regression resolves the machine names the ELF and PE loaders pass.Parked on #363: resolving now reaches the 8051, whose one-byte stack pointer needs that fix, so this branch carries its commit; I will rebase and mark it ready once it merges.
Validation: #365 (comment)