Skip to content

fix(IRSB): removed wrong instruction_addresses calculaion from lift…#521

Open
DanielBotnik wants to merge 1 commit intoangr:masterfrom
DanielBotnik:fix_wrong_instruction_addresses_assignment
Open

fix(IRSB): removed wrong instruction_addresses calculaion from lift…#521
DanielBotnik wants to merge 1 commit intoangr:masterfrom
DanielBotnik:fix_wrong_instruction_addresses_assignment

Conversation

@DanielBotnik
Copy link

@DanielBotnik DanielBotnik commented Feb 7, 2026

I had one of the weirds bug while using pyvex on one of my binaries, I found out that the irsb don't count addresses after empty IMark for some reason, but letting it recalcualtes it works fine.

In [1]: import pyvex

# MOV R0, 0
# SEV
# SEV
# MOV R1, 3
In [2]: opcodes = b"\x03\x00\xa0\xe3\x04\xf0\x20\xe3\x04\xf0\x20\xe3\x03\x10\xa0\xe3\xfa\x0b\x00\xea"

In [3]: irsb = pyvex.IRSB(data=opcodes, mem_addr=0x2000, arch=pyvex.ARCH_ARM_LE)

In [4]: [hex(i) for i in irsb.instruction_addresses]
Out[4]: ['0x2000', '0x2004']

In [5]: irsb.pp()
IRSB {
   t0:Ity_I32 t1:Ity_I32 t2:Ity_I32

   00 | ------ IMark(0x2000, 4, 0) ------
   01 | PUT(r0) = 0x00000003
   02 | ------ IMark(0x2004, 0, 0) ------
   03 | ------ IMark(0x2004, 4, 0) ------
   04 | ------ IMark(0x2008, 4, 0) ------
   05 | ------ IMark(0x200c, 4, 0) ------
   06 | PUT(r1) = 0x00000003
   07 | ------ IMark(0x2010, 4, 0) ------
   NEXT: PUT(r15t) = 0x00005000; Ijk_Boring
}

In [6]: irsb._instruction_addresses = None

In [7]: [hex(i) for i in irsb.instruction_addresses]
Out[7]: ['0x2000', '0x2004', '0x2004', '0x2008', '0x200c', '0x2010']

Now I also noticed that there was multiple addresses, so I made sure only to include IMARK with len greater than 0. this seemed to solve the problem

@DanielBotnik DanielBotnik force-pushed the fix_wrong_instruction_addresses_assignment branch 4 times, most recently from 172457c to ad16eb8 Compare February 7, 2026 19:24
@DanielBotnik DanielBotnik force-pushed the fix_wrong_instruction_addresses_assignment branch from ad16eb8 to 9f1b597 Compare February 7, 2026 19:26
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.

1 participant