#import
int main (int argc, const char * argv[])
{
NSLog ( @"HelloWorld" );
return (0);
}
我们先编译成可执行文件,然后再用OTOOL工具反汇编:
$ arm-apple-darwin9-otool -tVv ./HelloWorld >HelloWorld.S
反汇编文件如下:
_main:
00001f34 e92d4080 stmdb sp!, {r7, lr}
00001f38 e28d7000 add r7, sp, #0 ; 0x0
00001f3c e24dd008 sub sp, sp, #8 ; 0x8
00001f40 e58d0004 str r0, [sp, #4]
00001f44 e58d1000 str r1, [sp]
00001f48 e59f3018 ldr r3, [pc, #24] ; 0x1f68
00001f4c e08f3003 add r3, pc, r3
00001f50 e1a00003 mov r0, r3
00001f54 eb000022 bl 0x1fe4 ; symbol stub for: _NSLog
00001f58 e3a03000 mov r3, #0 ; 0x0
00001f5c e1a00003 mov r0, r3
00001f60 e247d000 sub sp, r7, #0 ; 0x0
00001f64 e8bd8080 ldmia sp!, {r7, pc}
00001f48 e59f3018 ldr r3, [pc, #24] ; 0x1f68
上面地址0x1f68指向的数据:(0xd4)
00000F60 00 D0 47 E2 80 80 BD E8 D4 00 00 00 5F 5F 64 79 ..G.........__dy
00001f4c e08f3003 add r3, pc, r3
上面一条指令就是:(r3)0xd4 + PC(0x1f54) = 0x2028
0x2028指向数据,NSLog的参数为NSString类型:
@interface NSString : NSObject
/* NSString primitive (funnel) methods. A minimal subclass of NSString just needs to implement these, although we also recommend getCharacters:range:. See below for the other methods.
*/
- (NSUInteger)length;
- (unichar)characterAtIndex:(NSUInteger)index;
@end:
00001020 00 00 00 00 00 00 00 00 00 00 00 00 C8 07 00 00 ................
00001030 B4 1F 00 00 0A 00 00 00 00 00 00 00 00 00 00 00 ................
0x1FB4指向字符串数据:
00000FB0 73 00 00 00 48 65 6C 6C 6F 57 6F 72 6C 64 00 00 s...HelloWorld..
00000FC0 00 C0 9F E5 00 F0 9C E4 0C 20 00 00 00 C0 9F E5 ......... ......
00000FB0 73 00 00 00 48 65 6C 6C 6F 57 6F 72 6C 64 00 00 s...HelloWorld..
00000FC0 00 C0 9F E5 00 F0 9C E4 0C 20 00 00 00 C0 9F E5 ......... ......
没有评论:
发表评论