Skip to content

Commit e621f43

Browse files
authored
Merge pull request #64735 from mikeash/weak-dyld-lookup-section-info2
[Runtime] Redeclare _dyld_lookup_section_info as weak.
2 parents 1fea84e + e439d27 commit e621f43

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

stdlib/public/runtime/ImageInspectionMachO.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,17 @@ enum _dyld_section_location_kind {
5858
#define _dyld_section_location_text_swift5_replace2 4
5959
#define _dyld_section_location_text_swift5_ac_funcs 5
6060

61-
#if !OBJC_ADDLOADIMAGEFUNC2_DEFINED
61+
#if OBJC_ADDLOADIMAGEFUNC2_DEFINED
62+
// Redefine _dyld_lookup_section_info as weak so we can build against it but
63+
// still run when it's not present at runtime. Note that we don't have to check
64+
// for its presence at runtime, as it's guaranteed to be available if we get
65+
// the callbacks from objc_addLoadImageFunc2.
66+
LLVM_ATTRIBUTE_WEAK
67+
struct _dyld_section_info_result
68+
_dyld_lookup_section_info(const struct mach_header *mh,
69+
_dyld_section_location_info_t locationHandle,
70+
enum _dyld_section_location_kind kind);
71+
#else
6272
// If we don't have objc_addLoadImageFunc2, fall back to objc_addLoadImageFunc.
6373
// Use a #define so we don't have to conditionalize the calling code below.
6474
#define objc_addLoadImageFunc2 objc_addLoadImageFunc

0 commit comments

Comments
 (0)