Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 10, 2025

The reverseRegistersOperations set was incomplete, causing register order mismatches between DEX bytecode and Smali text parsing for operations like or-int/2addr.

Root cause: Dalvik 12x format stores registers as B|A (nibbles), but Smali syntax is op vA, vB. The nibbles parser returns [B, A], requiring reversal to match Smali's [A, B] order.

Changes:

  • Added all missing /2addr operations: or-int/2addr, xor-int/2addr, shl-int/2addr, shr-int/2addr, ushr-int/2addr, rem-int/2addr, and-int/2addr, and long/double variants
  • Added unary operations: neg-*, not-*
  • Added type conversion operations: int-to-*, long-to-*, float-to-*, double-to-*
  • Added rsub-long
  • Documented why 12x operations require register reversal
// Before: incomplete set
const reverseRegistersOperations = new Set([
  'move', 'move-wide', 'move-object',
  'add-int/2addr', 'sub-int/2addr', 'mul-int/2addr', 'div-int/2addr',
  // ... only partial coverage
]);

// After: complete 12x format coverage
const reverseRegistersOperations = new Set([
  'move', 'move-wide', 'move-object',
  'neg-int', 'not-int', /* all unary ops */
  'int-to-long', /* all conversion ops */
  'add-int/2addr', /* all /2addr ops */
  'rsub-long',
]);
Original prompt

This section details on the original issue you should resolve

<issue_title>Fix this failing test</issue_title>
<issue_description>```
dalvikExecutableParserAgainstSmaliParser › parse(dex) against parse(smali(dex)) bafybeiebe27ylo53trgitu6fqfbmba43c4ivxj3nt4kumsilkucpbdxtqq a0/p isolated

            {
              operation: 'or-int/2addr',
              registers: [
  •             3,
                4,
    
  •             3,
              ],
            },
    

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Add missing operations to reverseRegistersOperations set to fix or-int/2addr and other 12x format instructions

Co-authored-by: futpib <4330357+futpib@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix failing test for dalvikExecutableParser Complete reverseRegistersOperations set for 12x format Dalvik bytecode operations Nov 10, 2025
Copilot AI requested a review from futpib November 10, 2025 18:15
Copilot finished work on behalf of futpib November 10, 2025 18:15
@futpib futpib marked this pull request as ready for review November 10, 2025 18:21
@futpib futpib merged commit 74cb5b4 into master Nov 10, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix this failing test

2 participants