2 // BUILD: $CC main.c -o $BUILD_DIR/libdsc-test.exe -ldsc
4 // RUN: ./libdsc-test.exe
9 #include <mach-o/dyld_priv.h>
12 #include "test_support.h"
13 #include "shared-cache/dsc_iterator.h"
15 // This program links libdsc.a and verifies that dyld_shared_cache_iterate() works
17 int main(int argc
, const char* argv
[], const char* envp
[], const char* apple
[])
20 const void* cacheStart
= _dyld_get_shared_cache_range(&cacheLen
);
22 if ( cacheStart
!= NULL
) {
23 dyld_shared_cache_iterate(cacheStart
, cacheLen
, ^(const dyld_shared_cache_dylib_info
* dylibInfo
, const dyld_shared_cache_segment_info
* segInfo
) {
25 printf("%p %s\n", dylibInfo
->machHeader
, dylibInfo
->path
);
26 printf(" dylib.version=%d\n", dylibInfo
->version
);
27 printf(" dylib.isAlias=%d\n", dylibInfo
->isAlias
);
28 printf(" dylib.inode=%lld\n", dylibInfo
->inode
);
29 printf(" dylib.modTime=%lld\n", dylibInfo
->modTime
);
30 printf(" segment.name= %s\n", segInfo
->name
);
31 printf(" segment.fileOffset= 0x%08llX\n", segInfo
->fileOffset
);
32 printf(" segment.fileSize= 0x%08llX\n", segInfo
->fileSize
);
33 printf(" segment.address= 0x%08llX\n", segInfo
->address
);
34 printf(" segment.addressOffset=0x%08llX\n", segInfo
->addressOffset
);