The Third chance Apple gives you to fix the error - Assembly

Back to the origin project by LGPerson:

// .h
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface LGPerson : NSObject

- (void)saySomething;
+ (void)sayLove;

@end

NS_ASSUME_NONNULL_END

// .m
#import "LGPerson.h"

@implementation LGPerson

- (void)sayAwesome {
    NSLog(@"%s",__func__);
}

+ (void)sayHappay {
    NSLog(@"%s",__func__);
}

@end

The LGStudent:

// .h
#import "LGPerson.h"

NS_ASSUME_NONNULL_BEGIN

@interface LGStudent : LGPerson

- (void)sayHello;
+ (void)sayObject;

@end

NS_ASSUME_NONNULL_END

// .m
#import "LGStudent.h"
#import <objc/message.h>

@implementation LGStudent

- (void)sayHello {
    NSLog(@"%s",__func__);
}

+ (void)sayObject {
    NSLog(@"%s",__func__);
}

@end

The NSObject+LG:

// .h
#import <AppKit/AppKit.h>
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface NSObject (LG)

- (void)sayMaster;
+ (void)sayEasy;

@end

NS_ASSUME_NONNULL_END

// .m
#import "NSObject+LG.h"
#import <objc/message.h>
#import <AppKit/AppKit.h>

@implementation NSObject (LG)

- (void)sayMaster {
    NSLog(@"%s",__func__);
}

+ (void)sayEasy {
    NSLog(@"%s",__func__);
}

@end

Then in main.m

#import <Foundation/Foundation.h>
#import "LGStudent.h"

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        LGStudent *student = [[LGStudent alloc] init];
        [student saySomething];
    }
    return 0;
}

Run and crash. But watch carefully here:

stack_info_forwarding.png
CoreFoundation`___forwarding___:
...
0x7fff3c7df605 <+185>:  movq   0x58dacdc4(%rip), %r14    ; "forwardingTargetForSelector:"
...
0x7fff3c7df6a9 <+349>:  movq   0x58dacce8(%rip), %rbx    ; "methodSignatureForSelector:"
...
0x7fff3c7df76d <+545>:  movq   0x58dacc64(%rip), %rsi    ; "_forwardStackInvocation:"
...
0x7fff3c7df826 <+730>:  movq   0x58dacbab(%rip), %rsi    ; "_forwardStackInvocation:"
...
0x7fff3c7df840 <+756>:  movq   0x58dacba9(%rip), %r15    ; "forwardInvocation:"
...
0x7fff3c7dfaa6 <+1370>: movq   0x58dab7c3(%rip), %rbx    ; "doesNotRecognizeSelector:"

If you want to check the code in CoreFoundation here:

core_foundation.png

Nothing can be found. Now it's time for Hopper / IDA and try path like (I use the Hopper here):

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/CoreFoundation.framework

We will compare with each other:

hopper_1.png
hopper_2.png
hopper_3.png
hopper_4.png
hopper_5.png

That's another way to check the Slow Path.

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • two Last login: Tue Aug 4 17:09:57 on ttys000 yushengyang...
    aofeilin阅读 1,060评论 1 9
  • Tutorials Videos Podcast Forums Store LOGIN / SIGN UPBECO...
    0x4d4746h阅读 636评论 0 1
  • 试营业第一天,好多会员宝宝来上课,大家都好棒,一起合作让今天课程都顺利结束,会员们也很开心,期待明天会更好。
    孟凡玲珑阅读 150评论 0 0
  • 因为信息不完整,所以运气有了一席之地,人类很难发明一个超超级计算机,把影响下一刻命运的东西都计算出来,包括刚才有一...
    军绿色的鱼阅读 331评论 0 0
  • 我们总是过分依赖他人,从而导致了自己的失败。往往是到了需要背水一战,没人可以依赖时,人们才会发奋图强,走向成功! ...
    Viki的计划阅读 269评论 0 3