]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dyld_get_image_versions.dtest/main.c
71f6bc262e599f7e547f661f9528c4ac4dd1ab6f
2 // BUILD: $CC main.c -o $BUILD_DIR/dyld_get_image_versions.exe
4 // RUN: ./dyld_get_image_versions.exe
8 #include <mach-o/dyld_priv.h>
10 extern struct mach_header __dso_handle
;
14 printf("[BEGIN] dyld_get_image_versions\n");
17 dyld_get_image_versions(&__dso_handle
, ^(dyld_platform_t platform
, uint32_t sdkVersion
, uint32_t minOS
) {
18 printf("main binary: platform=%d, sdk=0x%08X, minOS-0x%08X\n", platform
, sdkVersion
, minOS
);
21 uint8_t badFile
[4096];
22 struct mach_header
* mh
= (struct mach_header
*)badFile
;
23 mh
->magic
= MH_MAGIC_64
;
25 mh
->filetype
= MH_DYLIB
;
28 struct load_command
* lc
= (struct load_command
*)&badFile
[32];
30 lc
->cmdsize
= 4000; // bad load command size
32 // should detect the mh is bad and not crash or call the callback
33 dyld_get_image_versions(mh
, ^(dyld_platform_t platform
, uint32_t sdkVersion
, uint32_t minOS
) {
34 printf("bad binary: platform=%d, sdk=0x%08X, minOS-0x%08X\n", platform
, sdkVersion
, minOS
);
38 printf("[PASS] dyld_get_image_versions\n");