File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -176,7 +176,7 @@ void MemoryMappingLayout::Reset() {
176176// The dyld load address should be unchanged throughout process execution,
177177// and it is expensive to compute once many libraries have been loaded,
178178// so cache it here and do not reset.
179- static mach_header * dyld_hdr = 0 ;
179+ static const mach_header* dyld_hdr = 0 ;
180180static const char kDyldPath [] = " /usr/lib/dyld" ;
181181static const int kDyldImageIdx = -1 ;
182182
@@ -244,14 +244,18 @@ extern intptr_t _dyld_get_image_slide(const struct mach_header* mh);
244244extern int dyld_shared_cache_iterate_text (
245245 const uuid_t cacheUuid,
246246 void (^callback)(const dyld_shared_cache_dylib_text_info *info));
247+ SANITIZER_WEAK_IMPORT const struct mach_header * _dyld_get_dyld_header (void );
247248} // extern "C"
248249
249- static mach_header * GetDyldImageHeaderViaSharedCache () {
250+ static const mach_header* GetDyldImageHeaderViaSharedCache () {
250251 uuid_t uuid;
251252 bool hasCache = _dyld_get_shared_cache_uuid (uuid);
252253 if (!hasCache)
253254 return nullptr ;
254255
256+ if (&_dyld_get_dyld_header != nullptr )
257+ return _dyld_get_dyld_header ();
258+
255259 size_t cacheLength;
256260 __block uptr cacheStart = (uptr)_dyld_get_shared_cache_range (&cacheLength);
257261 CHECK (cacheStart && cacheLength);
Original file line number Diff line number Diff line change @@ -10,3 +10,4 @@ ___sanitizer_symbolize_demangle
1010___sanitizer_symbolize_flush
1111___sanitizer_symbolize_set_demangle
1212___sanitizer_symbolize_set_inline_frames
13+ __dyld_get_dyld_header
Original file line number Diff line number Diff line change @@ -165,7 +165,7 @@ elif [ "$GOOS" = "netbsd" ]; then
165165 "
166166elif [ " $GOOS " = " darwin" ]; then
167167 OSCFLAGS=" -fPIC -Wno-unused-const-variable -Wno-unknown-warning-option -mmacosx-version-min=10.7"
168- OSLDFLAGS=" -lpthread -fPIC -fpie -mmacosx-version-min=10.7"
168+ OSLDFLAGS=" -lpthread -fPIC -fpie -mmacosx-version-min=10.7 -Wl,-U,__dyld_get_dyld_header "
169169 SRCS="
170170 $SRCS
171171 ../rtl/tsan_platform_mac.cpp
You can’t perform that action at this time.
0 commit comments