]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/_dyld_get_image_slide.dtest/main.c
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>
13 #include "test_support.h"
15 int main(int argc
, const char* argv
[], const char* envp
[], const char* apple
[]) {
16 int count
= _dyld_image_count();
17 for (int i
=0; i
< count
; ++i
) {
18 const struct mach_header
* mh
= _dyld_get_image_header(i
);
19 const char* name
= _dyld_get_image_name(i
);
20 intptr_t slide
= _dyld_get_image_slide(mh
);
21 intptr_t vmaddrSlide
= _dyld_get_image_vmaddr_slide(i
);
22 if ( slide
!= vmaddrSlide
) {
23 FAIL("%lld != %lld in %s", (uint64_t)slide
, (uint64_t)vmaddrSlide
, name
);
28 // Check that garbage values return 0
29 uintptr_t notMagic
= 0;
30 intptr_t slide
= _dyld_get_image_slide((const struct mach_header
*)¬Magic
);
32 FAIL("slide value %lld for bad magic", (uint64_t)slide
);
35 intptr_t vmaddrSlide
= _dyld_get_image_vmaddr_slide(count
+ 1);
36 if (vmaddrSlide
!= 0) {
37 FAIL("vmaddr slide value %lld for index %d", (uint64_t)vmaddrSlide
, count
+ 1);