Skip to content

Commit e2b8a62

Browse files
committed
better
1 parent c98b982 commit e2b8a62

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ jobs:
6666
with:
6767
name: a.out
6868
path: a.out*
69-
- name: upload dyld cache
69+
- name: upload vg artifacts
7070
if: always()
7171
uses: actions/upload-artifact@v4
7272
with:
73-
name: dyld_cache
74-
path: /System/Volumes/Preboot/Cryptexes/OS/System/Library/dyld/dyld_shared_cache_x86_64h*
73+
name: vg
74+
path: memcheck/vgpreload_memcheck-amd64-darwin.so

coregrind/m_mach/dyld_cache.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,19 +208,22 @@ Addr VG_(dyld_cache_get_slide)(void) {
208208
return dyld_cache.slide;
209209
}
210210

211-
void VG_(dyld_cache_init)(void) {
211+
void VG_(dyld_cache_init)(Bool is_dynamic) {
212212
if (!try_to_init()) {
213213
VG_(dmsg)(
214214
"WARNING: could not read from dyld shared cache (DSC)\n"
215215
"Some reports (especially memory leaks) might be missing or incorrect (false-positives)\n"
216216
);
217217
return;
218218
}
219-
// We currently detect if dyld is loading/using a library by checking if stat64 fails.
220-
// However, dyld doesn't seem to call stat64 for all of them anymore.
221-
VG_(dyld_cache_load_library)("/usr/lib/system/libsystem_kernel.dylib");
222-
VG_(dyld_cache_load_library)("/usr/lib/system/libsystem_pthread.dylib");
223-
VG_(dyld_cache_load_library)("/usr/lib/system/libsystem_platform.dylib");
219+
if (is_dynamic) {
220+
// We currently detect if dyld is loading/using a library by checking if stat64 fails.
221+
// However, dyld doesn't seem to call stat64 for all of them anymore.
222+
// All arm64 binaries are executables but some x86 ones might not be so let's avoid them just to be safe.
223+
VG_(dyld_cache_load_library)("/usr/lib/system/libsystem_kernel.dylib");
224+
VG_(dyld_cache_load_library)("/usr/lib/system/libsystem_pthread.dylib");
225+
VG_(dyld_cache_load_library)("/usr/lib/system/libsystem_platform.dylib");
226+
}
224227
}
225228

226229
int VG_(dyld_cache_might_be_in)(const HChar* path) {

coregrind/m_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1951,7 +1951,7 @@ Int valgrind_main ( Int argc, HChar **argv, HChar **envp )
19511951
// p: none
19521952
//--------------------------------------------------------------
19531953
# if defined(VGO_darwin) && DARWIN_VERS >= DARWIN_11_00
1954-
VG_(dyld_cache_init)();
1954+
VG_(dyld_cache_init)(the_iicii.dynamic);
19551955
# endif
19561956

19571957
//--------------------------------------------------------------

coregrind/pub_core_mach.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ extern void VG_(mach_record_system_memory)(void);
7272
#if DARWIN_VERS >= DARWIN_11_00
7373
// Dyld shared cache (DSC) parsing, which is required as system libraries are not provided on disk
7474
// starting with macOS 11.0 (Big Sur)
75-
extern void VG_(dyld_cache_init)(void);
75+
extern void VG_(dyld_cache_init)(Bool is_dynamic);
7676
extern int VG_(dyld_cache_might_be_in)(const HChar*);
7777
extern int VG_(dyld_cache_load_library)(const HChar*);
7878
extern Addr VG_(dyld_cache_get_slide)(void);

0 commit comments

Comments
 (0)