No preference rule for p-code languages that no ELF header field distinguishes
- Dominant language
- Python
- Stars
- 485
- Forks
- 135
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 15
Description
THIS MESSAGE WAS GENERATED BY AN AUTOMATED PROCESS
With the header-field matching in angr/cle#740 in place, a good deal of p-code language selection resolves on evidence — 11,069 objects in a large corpus get a demonstrably better answer, and the ambiguous population halves. What remains is genuinely ambiguous, and picking among it needs a policy nobody has written down.
Three groups account for almost all of it. RISC-V splits between `RISCV:LE:32:default` and `RISCV:LE:32:AndeStar_v5` for 1,873 objects; 68000 has four candidate variants for 7,327; avr8 has four for 3,857. None of the Ghidra ELF opinions covering these carries a `secondary` attribute, so there is no header field to distinguish them — the ambiguity is in the opinion, not in the code that reads it. The RISC-V opinion says as much in a comment: it must choose between the `default` and `AndeStar` variants.
Today the choice falls out of `pypcode.Arch.enumerate()`, which yields in directory order, so for RISC-V it is not even stable between installations: creating the language directory repeatedly with identical contents produced both orders roughly evenly, which means a `pip install` of pypcode can change how a binary decodes. The two RISC-V languages are not interchangeable — 905 of 20,000 random 32-bit words decode differently, and one raises where the other decodes.
The obvious repair makes it worse rather than better. Sorting `Arch.enumerate()` gives determinism, but `andestar_v5.ldefs` sorts before `riscv.ldefs`, so every plain RV32 ELF would deterministically get the vendor superset. Objects observed in this group declare `.riscv.attributes` of `rv32i2p1_m2p0_a2p1_c2p0` with no Andes extension, so `default` is the correct answer for them.
So the decision is a preference rule for the remaining ambiguity — preferring a `default` variant over vendor extensions would cover RISC-V, but 68000 and avr8 want their own answer. Once that exists, sorting the enumeration is safe and worth doing for reproducibility.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.