Re: Finding the selector used in calls objc_msgSend in otool output...
Re: Finding the selector used in calls objc_msgSend in otool output...
- Subject: Re: Finding the selector used in calls objc_msgSend in otool output...
- From: Shawn Erickson <email@hidden>
- Date: Mon, 10 Jan 2005 14:45:34 -0800
On Jan 10, 2005, at 2:36 PM, Bob Ippolito wrote:
On Jan 10, 2005, at 17:18, Kevin Ballard wrote:
On Jan 10, 2005, at 5:08 PM, Shawn Erickson wrote:
Not sure that works for todays code... because of PIC / none-PIC,
etc.
Still trying to connect the dots.
What's PIC / none-PIC?
He meant PIC / non-PIC. PIC means Position Independent Code, and it
describes what the load/store opcodes are going to look like coming
out of the compiler (the opcodes to load $r4 will look different in
this case). Using -fast will turn off PIC unless explicitly turned on
by -fPIC, otherwise -fPIC is on by default. PIC must be on for dylibs
and bundles, but may be off for an executable.
Yeah, sorry for the typo.
The following is an example. The code generated by GCC 3.3 doesn't do
it the same way that the "better" otool scripts expect from what I can
see. Currently the offset isn't directly related to the load of r4 but
happens before it. Luckily the PIC / non-PIC case doesn't affect things
greatly. Also who knows how the optimizer would play around with things
(the following is not optimized)... likely why otool doesn't list this
information.
- (void)changeState:(int)newState
{
state = newState;
[self advanceState];
}
Not using PIC (-mdynamic-no-pic)...
-[PGAppDelegate changeState:]:
0000a820 mfspr r0,lr
0000a824 stmw r30,0xfff8(r1)
0000a828 stw r0,0x8(r1)
0000a82c stwu r1,0xffb0(r1)
0000a830 or r30,r1,r1
0000a834 stw r3,0x68(r30)
0000a838 stw r4,0x6c(r30)
0000a83c stw r5,0x70(r30)
0000a840 lwz r2,0x68(r30)
0000a844 lwz r0,0x70(r30)
0000a848 stw r0,0x4c(r2)
0000a84c lis r2,0xa
0000a850 addi r2,r2,0xb040
0000a854 lwz r3,0x68(r30) << isa pointer, in this case self
0000a858 lwz r4,0x0(r2) << selector parameter
0000a85c bl 0x26718 ; symbol stub for: _objc_msgSend
0000a860 lwz r1,0x0(r1)
0000a864 lwz r0,0x8(r1)
0000a868 mtspr lr,r0
0000a86c l mw r30,0xfff8(r1)
0000a870 blr
Using PIC...
-[PGAppDelegate changeState:]:
0000a85c mfspr r0,lr
0000a860 stmw r30,0xfff8(r1)
0000a864 or r31,r12,r12 << I guess target in terms of indirect
addressing? what is this offset/pointer?
0000a868 stw r0,0x8(r1)
0000a86c stwu r1,_authPackGAME_CAPACITY(r1)
0000a870 or r30,r1,r1
0000a874 stw r3,0x68(r30)
0000a878 stw r4,0x6c(r30)
0000a87c stw r5,0x70(r30)
0000a880 lwz r2,0x68(r30)
0000a884 lwz r0,0x70(r30)
0000a888 stw r0,0x4c(r2)
0000a88c addis r2,r31,0x9 << I think it is actually "addis r2,r31,0"
not 0x9 based on debugger use
0000a890 addi r2,r2,0x7e4
0000a894 lwz r3,0x68(r30) << isa pointer, in this case self
0000a898 lwz r4,0x0(r2) << selector parameter
0000a89c bl 0x26368 ; symbol stub for: _objc_msgSend
0000a8a0 lwz r1,0x0(r1)
0000a8a4 lwz r0,0x8(r1)
0000a8a8 mtspr lr,r0
0000a8ac lmw r30,0xfff8(r1)
0000a8b0 blr
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden