File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 28
28
#include < objc/message.h>
29
29
#include < TargetConditionals.h>
30
30
31
+ #if __has_include(<mach-o/dyld_priv.h>)
32
+ #include < mach-o/dyld_priv.h>
33
+ #define APPLE_OS_SYSTEM 1
34
+ #else
35
+ #define APPLE_OS_SYSTEM 0
36
+ #endif
37
+
31
38
// Note: There are more #includes below under "Function patching machinery".
32
39
// Those are only relevant to the function patching machinery.
33
40
@@ -69,11 +76,17 @@ typedef BOOL (*objc_hook_getImageName)(
69
76
const void *descriptor = classAsMetadata->getDescription ();
70
77
assert (descriptor &&
71
78
" all non-artificial Swift classes should have a descriptor" );
79
+ #if APPLE_OS_SYSTEM
80
+ // Use a more efficient internal API when building the system libraries
81
+ // for Apple OSes.
82
+ *outImageName = dyld_image_path_containing_address (descriptor);
83
+ #else
72
84
Dl_info imageInfo = {};
73
85
if (!dladdr (descriptor, &imageInfo))
74
86
return NO ;
75
87
*outImageName = imageInfo.dli_fname ;
76
- return imageInfo.dli_fname != nullptr ;
88
+ #endif
89
+ return *outImageName != nullptr ;
77
90
}
78
91
79
92
return NO ;
You can’t perform that action at this time.
0 commit comments