Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArchPPC32 has incorrect PC register number #27

Closed
jeffball55 opened this issue Jan 31, 2016 · 6 comments
Closed

ArchPPC32 has incorrect PC register number #27

jeffball55 opened this issue Jan 31, 2016 · 6 comments

Comments

@jeffball55
Copy link

I'm attempting to obtain the Intermediate Representation for the PPC32 architecture (little endian), however when parsing the output, I'm getting an incorrect register number for what appears to be the PC register. The output is shown below. The register number 1168 is returned instead of the correct 1160.
I'm running python 2.7.10 on Ubuntu 15.10 and installed pyvex using the recommended "pip install pyvex".

>>> import archinfo,pyvex
>>> pyvex.IRSB('\x20\x00\x80\x4e', 0x80000, archinfo.ArchPPC32()).pp()
IRSB {
   t0:Ity_I32 t1:Ity_I32 t2:Ity_I32 t3:Ity_I32 t4:Ity_I32 t5:Ity_I32 t6:Ity_I32 t7:Ity_I32 t8:Ity_I32 t9:Ity_I1 t10:Ity_I32

   00 | IR-NoOp
   01 | IR-NoOp
   02 | IR-NoOp
   03 | IR-NoOp
   04 | IR-NoOp
   05 | IR-NoOp
   06 | IR-NoOp
   07 | IR-NoOp
   08 | IR-NoOp
   09 | IR-NoOp
   10 | IR-NoOp
   11 | IR-NoOp
   12 | IR-NoOp
   13 | IR-NoOp
   14 | IR-NoOp
   15 | ------ IMark(0x80000, 4, 0) ------
   16 | t4 = 0xffffffff
   17 | t1 = t4
   18 | t5 = 0x00000001
   19 | t2 = t5
   20 | t0 = And32(t2,t1)
   21 | t8 = GET:I32(lr)
   22 | t7 = And32(t8,0xfffffffc)
   23 | t3 = t7
   24 | t9 = CmpEQ32(t0,0x00000000)
   25 | if (t9) { PUT(1168) = 0x80004; Ijk_Boring }
   26 | PUT(1168) = t3
   27 | t10 = GET:I32(1168)
   NEXT: PUT(1168) = t10; Ijk_Ret
}
>>> archinfo.ArchPPC32().translate_register_name(1168)
'1168'
>>> archinfo.ArchPPC32().registers['pc']
(1160, 4)
>>> archinfo.ArchPPC32().registers['ip']
(1160, 4)
@zardus
Copy link
Member

zardus commented Feb 1, 2016

Hi jeffball,

Sorry for the laggy response. I was at SECCON, and didn't have a chance to look into this. You've definitely triggered a "how did this ever work" moment. I'll look into this a bit further and get back to you.

@rhelmot
Copy link
Member

rhelmot commented Feb 1, 2016

Can we have whatever sample binary you're working with that's little-endian 32 bit powerpc? As far as I know, code of this type has never been tested with angr, and might not actually exist?

@zardus
Copy link
Member

zardus commented Feb 2, 2016

Ah, I should have mentioned, from my testing, it looks like this holds for
big-endian PPC (fauxware) as well.

I have a vague half-memory of running into this before for some reason, but
can't remember the details...
On Feb 2, 2016 8:51 AM, "Andrew Dutcher" notifications@github.com wrote:

Can we have whatever sample binary you're working with that's
little-endian 32 bit powerpc? As far as I know, code of this type has never
been tested with angr, and might not actually exist?


Reply to this email directly or view it on GitHub
#27 (comment).

@rhelmot
Copy link
Member

rhelmot commented Feb 2, 2016

The vex source comments indicate that yes, it is in fact at that offset. I have no idea where this bug is introduced, and since this source has been copied around since before I was on this project it's impossible to tell when it was introduced, but I'll push a fix. :+)

@rhelmot
Copy link
Member

rhelmot commented Feb 2, 2016

Fix pushed to the archinfo repository. Can you verify it resolves your issue?

@jeffball55
Copy link
Author

Yep, after upgrading archinfo from the archinfo github repository, this does fix the issue. Thanks!

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

No branches or pull requests

3 participants