]> git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/libdsc.dtest/main.c
dyld-851.27.tar.gz
[apple/dyld.git] / testing / test-cases / libdsc.dtest / main.c
1
2 // BUILD: $CC main.c -o $BUILD_DIR/libdsc-test.exe -ldsc
3
4 // RUN: ./libdsc-test.exe
5
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <mach-o/dyld_priv.h>
10 #include <dlfcn.h>
11
12 #include "test_support.h"
13 #include "shared-cache/dsc_iterator.h"
14
15 // This program links libdsc.a and verifies that dyld_shared_cache_iterate() works
16
17 int main(int argc, const char* argv[], const char* envp[], const char* apple[])
18 {
19 size_t cacheLen;
20 const void* cacheStart = _dyld_get_shared_cache_range(&cacheLen);
21
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) {
24 if ( false ) {
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);
35 }
36 });
37 }
38
39 PASS("Success");
40 }