e4f1b9d2e5f6f005524e2b33de9fbdfee5b6a9dd
2 // BUILD: $CC main.c -o $BUILD_DIR/_dyld_get_image_slide-test.exe
4 // RUN: ./_dyld_get_image_slide-test.exe
10 #include <mach-o/dyld.h>
11 #include <mach-o/dyld_priv.h>
16 printf("[BEGIN] _dyld_get_image_slide-test\n");
18 int count
= _dyld_image_count();
19 for (int i
=0; i
< count
; ++i
) {
20 const struct mach_header
* mh
= _dyld_get_image_header(i
);
21 const char* name
= _dyld_get_image_name(i
);
22 intptr_t slide
= _dyld_get_image_slide(mh
);
23 intptr_t vmaddrSlide
= _dyld_get_image_vmaddr_slide(i
);
24 if ( slide
!= vmaddrSlide
) {
25 printf("[FAIL] _dyld_get_image_slide-test: %lld != %lld in %s\n",
26 (uint64_t)slide
, (uint64_t)vmaddrSlide
, name
);
31 // Check that garbage values return 0
32 uintptr_t notMagic
= 0;
33 intptr_t slide
= _dyld_get_image_slide((const struct mach_header
*)¬Magic
);
35 printf("[FAIL] _dyld_get_image_slide-test: slide value %lld for bad magic\n",
39 intptr_t vmaddrSlide
= _dyld_get_image_vmaddr_slide(count
+ 1);
40 if (vmaddrSlide
!= 0) {
41 printf("[FAIL] _dyld_get_image_slide-test: vmaddr slide value %lld for index %d\n",
42 (uint64_t)vmaddrSlide
, count
+ 1);
45 printf("[PASS] _dyld_get_image_slide-test\n");