美文网首页
[arm64]6、OC反编译

[arm64]6、OC反编译

作者: 史记_d5da | 来源:发表于2021-12-14 23:26 被阅读0次

1、OC汇编

1.1、分析Person类的汇编过程
int main(int argc, char * argv[]) {
    Person * p = [Person new];
    return 0;
}
    0x102b022d0 <+0>:  sub    sp, sp, #0x30             ; =0x30 
    0x102b022d4 <+4>:  stp    x29, x30, [sp, #0x20]
    0x102b022d8 <+8>:  add    x29, sp, #0x20            ; =0x20 
    0x102b022dc <+12>: stur   wzr, [x29, #-0x4]
    0x102b022e0 <+16>: stur   w0, [x29, #-0x8]
    0x102b022e4 <+20>: str    x1, [sp, #0x10]
    0x102b022e8 <+24>: adrp   x8, 6
// x0存放的是p的指针
    0x102b022ec <+28>: ldr    x0, [x8, #0xd68]
    0x102b022f0 <+32>: adrp   x8, 6
// x1存放的是new SEL
    0x102b022f4 <+36>: ldr    x1, [x8, #0xd60]
->  0x102b022f8 <+40>: bl     0x102b02704               ; symbol stub for: objc_msgSend
    0x102b022fc <+44>: mov    x8, x0
    0x102b02300 <+48>: add    x0, sp, #0x8              ; =0x8 
    0x102b02304 <+52>: str    x8, [sp, #0x8]
    0x102b02308 <+56>: stur   wzr, [x29, #-0x4]
    0x102b0230c <+60>: mov    x1, #0x0
    0x102b02310 <+64>: bl     0x102b02728               ; symbol stub for: objc_storeStrong
    0x102b02314 <+68>: ldur   w0, [x29, #-0x4]
    0x102b02318 <+72>: ldp    x29, x30, [sp, #0x20]
    0x102b0231c <+76>: add    sp, sp, #0x30             ; =0x30 
    0x102b02320 <+80>: ret   

person类方法分析

+ (instancetype) person {
    return [[Person alloc]init];
}
    0x10248a2f0 <+0>:  sub    sp, sp, #0x20             ; =0x20 
    0x10248a2f4 <+4>:  stp    x29, x30, [sp, #0x10]
    0x10248a2f8 <+8>:  add    x29, sp, #0x10            ; =0x10 
    0x10248a2fc <+12>: str    x0, [sp, #0x8]
    0x10248a300 <+16>: str    x1, [sp]
    0x10248a304 <+20>: adrp   x8, 6
    0x10248a308 <+24>: ldr    x0, [x8, #0xd78]
    0x10248a30c <+28>: bl     0x10248a6bc               ; symbol stub for: objc_alloc
->  0x10248a310 <+32>: adrp   x8, 6
    0x10248a314 <+36>: ldr    x1, [x8, #0xd70]
    0x10248a318 <+40>: bl     0x10248a6e0               ; symbol stub for: objc_msgSend
    0x10248a31c <+44>: ldp    x29, x30, [sp, #0x10]
    0x10248a320 <+48>: add    sp, sp, #0x20             ; =0x20 
    0x10248a324 <+52>: b      0x10248a6c8               ; symbol stub for: objc_autoreleaseReturnValue
1.2、block反汇编
void (^block)(void) = ^() {
        NSLog(@"block");
};
block();
    0x10083e260 <+0>:  sub    sp, sp, #0x30             ; =0x30 
    0x10083e264 <+4>:  stp    x29, x30, [sp, #0x20]
    0x10083e268 <+8>:  add    x29, sp, #0x20            ; =0x20 
    0x10083e26c <+12>: stur   wzr, [x29, #-0x4]
    0x10083e270 <+16>: stur   w0, [x29, #-0x8]
    0x10083e274 <+20>: str    x1, [sp, #0x10]
// x0存放block的对象地址isa
    0x10083e278 <+24>: adrp   x0, 2
// x0存放invoke的实现地址
    0x10083e27c <+28>: add    x0, x0, #0x28             ; =0x28 
->  0x10083e280 <+32>: bl     0x10083e6f0               ; symbol stub for: objc_retainBlock
    0x10083e284 <+36>: add    x8, sp, #0x8              ; =0x8 
    0x10083e288 <+40>: str    x8, [sp]
    0x10083e28c <+44>: str    x0, [sp, #0x8]
    0x10083e290 <+48>: ldr    x0, [sp, #0x8]
    0x10083e294 <+52>: ldr    x8, [x0, #0x10]
    0x10083e298 <+56>: blr    x8
    0x10083e29c <+60>: ldr    x0, [sp]
    0x10083e2a0 <+64>: stur   wzr, [x29, #-0x4]
    0x10083e2a4 <+68>: mov    x1, #0x0
    0x10083e2a8 <+72>: bl     0x10083e708               ; symbol stub for: objc_storeStrong
    0x10083e2ac <+76>: ldur   w0, [x29, #-0x4]
    0x10083e2b0 <+80>: ldp    x29, x30, [sp, #0x20]
    0x10083e2b4 <+84>: add    sp, sp, #0x30             ; =0x30 
    0x10083e2b8 <+88>: ret  

相关文章

网友评论

      本文标题:[arm64]6、OC反编译

      本文链接:https://www.haomeiwen.com/subject/xcyrfrtx.html