-
Notifications
You must be signed in to change notification settings - Fork 23
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
Add PowerPC arch. #29
Conversation
Looks good!
Yeah, that's oftentimes the case ;-).
Ok, is it used for e.g. param passing, or is it callee-saved register? Because otherwise, param filter would deal with it (i.e. it won't be treated as a param), and the difference seems to boil down just to naming - "r2" vs "rtoc". I guess you very well know that r2 can be used as rtoc, then using adhoc naming isn't of much benefit, and both cases above could be covered with just one SABl "arch", with "r2" as naming. But well, ultimately, it's up to you how to name - I don't have experience with PowerPC, so can't suggest much there. (On a calm day it would be interesting to dig into PPC calling conv, but I'm not sure how soon I'd have that ;-) ). |
@maximumspatium, Of related note, I wonder if you might be interested in trying to enable PowerPC support in my another tool, ScratchABit: pfalcon/ScratchABit#39 . No hurries, just wonder if you're remotely interested, or have all your PowerPC disassembly needs covered. Thanks. |
|
||
|
||
def call_ret(addr): | ||
return {REG("r3")} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, how longlong's and double's are returned?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Apple's specs, any value larger than 4 bytes must be returned via memory. For that purpose, the left-most parameter (in other words, R3) must point to a memory location where the return value will be stored to.
The same rule is valid for more than 8 params and variadic functions. Params[8:] as well as variadic args must be passed on the stack.
Float & doubles will be returned in dedicated floating-point registers. I assume that floating-point isn't currently supported so I omitted them for the moment being.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, sounds good.
I assume that floating-point isn't currently supported
Yes, there's no any special support it.
@maximumspatium : Let me know if you'd like to make any changes before this merged. Otherwise, I'd merge this, further changes can go later if needed. |
Okay to merge. |
Merged, thanks! |
Below my first attempt at the PowerPC arch descriptor. It has some limitations described in the source.
The most difficult decision is the proper name for this arch. For the moment being, it describes the calling convention Apple borrowed from IBM and used in Mac OS until 2002.
Mac OS X, introduced around 2000, uses a similar calling convention in its Mach-O format. The most notably difference between them is the usage of R2:
What's the best solution to this problem? Two different archs ("ppc32-peff" and "ppc32-macho")?
Moreover, there is Linux PPC. I have no clue which calling convention is used there...