diff options
author | iximeow <me@iximeow.net> | 2023-07-08 13:56:17 -0700 |
---|---|---|
committer | iximeow <me@iximeow.net> | 2023-07-08 13:56:17 -0700 |
commit | 8e199827b62ab79676c17c48efde19c485e5e301 (patch) | |
tree | 2509eabe2d054023c6f11f99fec9376f561c6f3b | |
parent | 3ca85e2bbe9bb0ada387c2ffdeb1b5e29227d6fe (diff) |
move rip-rel check to a slightly colder spot...
-rw-r--r-- | src/long_mode/mod.rs | 106 |
1 files changed, 54 insertions, 52 deletions
diff --git a/src/long_mode/mod.rs b/src/long_mode/mod.rs index a84dbd9..3b2f23f 100644 --- a/src/long_mode/mod.rs +++ b/src/long_mode/mod.rs @@ -6172,51 +6172,6 @@ fn read_M< .with_id(modrm_start + 2) ); return read_sib(words, instr, modrm, sink); - } else if mmm == 5 && modbits == 0b00 { - sink.record( - modrm_start + 6, - modrm_start + 7, - InnerDescription::Misc("rip-relative reference") - .with_id(modrm_start + 0) - ); - sink.record( - modrm_start + 0, - modrm_start + 2, - InnerDescription::Misc("rip-relative reference") - .with_id(modrm_start + 0) - ); - if instr.prefixes.address_size() { - sink.record( - modrm_start + 6, - modrm_start + 7, - InnerDescription::Misc("address-size override selects `eip` instead") - .with_id(modrm_start + 1) - ); - sink.record( - modrm_start + 0, - modrm_start + 2, - InnerDescription::Misc("address-size override selects `eip` instead") - .with_id(modrm_start + 1) - ); - } - - let disp = read_num(words, 4)? as i32; - - sink.record( - modrm_start + 8, - modrm_start + 8 + 32, - InnerDescription::Number("displacement", disp as i64) - .with_id(modrm_start + 3) - ); - - instr.regs[1] = - if !instr.prefixes.address_size() { RegSpec::rip() } else { RegSpec::eip() }; - if disp == 0 { - OperandSpec::Deref - } else { - instr.disp = disp as i64 as u64; - OperandSpec::RegDisp - } } else { let mut r = 0; if instr.prefixes.rex_unchecked().b() { @@ -6231,13 +6186,60 @@ fn read_M< ); if modbits == 0b00 { - sink.record( - modrm_start + 6, - modrm_start + 7, - InnerDescription::Misc("memory operand is [reg] with no displacement, register selected by `mmm` (mod bits: 00)") - .with_id(modrm_start + 0) - ); - OperandSpec::Deref + if mmm == 5 { + sink.record( + modrm_start + 6, + modrm_start + 7, + InnerDescription::Misc("rip-relative reference") + .with_id(modrm_start + 0) + ); + sink.record( + modrm_start + 0, + modrm_start + 2, + InnerDescription::Misc("rip-relative reference") + .with_id(modrm_start + 0) + ); + if instr.prefixes.address_size() { + sink.record( + modrm_start + 6, + modrm_start + 7, + InnerDescription::Misc("address-size override selects `eip` instead") + .with_id(modrm_start + 1) + ); + sink.record( + modrm_start + 0, + modrm_start + 2, + InnerDescription::Misc("address-size override selects `eip` instead") + .with_id(modrm_start + 1) + ); + } + + let disp = read_num(words, 4)? as i32; + + sink.record( + modrm_start + 8, + modrm_start + 8 + 32, + InnerDescription::Number("displacement", disp as i64) + .with_id(modrm_start + 3) + ); + + instr.regs[1] = + if !instr.prefixes.address_size() { RegSpec::rip() } else { RegSpec::eip() }; + if disp == 0 { + OperandSpec::Deref + } else { + instr.disp = disp as i64 as u64; + OperandSpec::RegDisp + } + } else { + sink.record( + modrm_start + 6, + modrm_start + 7, + InnerDescription::Misc("memory operand is [reg] with no displacement, register selected by `mmm` (mod bits: 00)") + .with_id(modrm_start + 0) + ); + OperandSpec::Deref + } } else { let disp_start = words.offset(); let disp = if modbits == 0b01 { |