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

Back to the origin project by LGPerson:

// .h
#import 

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 

@implementation LGStudent

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

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

@end

The NSObject+LG:

// .h
#import 
#import 

NS_ASSUME_NONNULL_BEGIN

@interface NSObject (LG)

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

@end

NS_ASSUME_NONNULL_END

// .m
#import "NSObject+LG.h"
#import 
#import 

@implementation NSObject (LG)

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

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

@end

Then in main.m

#import 
#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.

你可能感兴趣的:(The Third chance Apple gives you to fix the error - Assembly)