Skip to content

Commit d01e768

Browse files
committed
[idb_import] Probe enum altval directly instead of gating on operand flag
The previous pass only considered an operand for enum display when its operand-representation flag read back as Enum. IDA records the referenced enumeration in a separate altval, independent of that nibble, so operands such as the immediate of `orr w8, w8, #imm` carry an enum reference the flag does not reflect and were skipped. Probe op_enum_type for operands 0 and 1 directly; it resolves to None when no enum is referenced, so the probe is self-gating and now recovers every enum-displayed operand.
1 parent 6edeedb commit d01e768

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

plugins/idb_import/src/parse.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -439,23 +439,25 @@ impl IDBFileParser {
439439
id2: Option<&ID2Section<K>>,
440440
til: &TILSection,
441441
) -> anyhow::Result<Vec<OperandEnumInfo>> {
442-
use idb_rs::id1::{ByteOp, ByteType};
442+
use idb_rs::id1::ByteType;
443443

444444
let root_info = id0.ida_info(id0.root_node()?)?;
445445
let netdelta = root_info.netdelta();
446446

447447
let mut operand_enums = Vec::new();
448448
for (address, byte_info, _size) in id1.all_bytes_no_tails() {
449-
let ByteType::Code(code) = byte_info.byte_type() else {
449+
if !matches!(byte_info.byte_type(), ByteType::Code(_)) {
450+
continue;
451+
}
452+
// Probe the enum altval directly for operands 0 and 1 rather than gating on the
453+
// operand-representation flag: IDA records the referenced enum independently of that
454+
// nibble, so instructions like `orr w8, w8, #imm` carry the enum altval even when the
455+
// flag does not read back as `Enum`. `op_enum_type` returns `None` when there is no
456+
// enum reference, so the probe is self-gating.
457+
let Some(info) = AddressInfo::new(id0, id1, id2, netdelta, address) else {
450458
continue;
451459
};
452-
for (operand, op) in [(0u8, code.operand0()), (1u8, code.operand1())] {
453-
if !matches!(op, Ok(Some(ByteOp::Enum))) {
454-
continue;
455-
}
456-
let Some(info) = AddressInfo::new(id0, id1, id2, netdelta, address) else {
457-
continue;
458-
};
460+
for operand in 0u8..2 {
459461
if let Some(enum_ty) = info.op_enum_type(operand, til) {
460462
operand_enums.push(OperandEnumInfo {
461463
address: address.into_raw().into_u64(),

0 commit comments

Comments
 (0)