2 * Copyright (c) 2015 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
23 #include <stdlib.h> // EXIT_SUCCESS
25 #include <mach-o/dyld.h>
26 #include <mach-o/dyld_images.h>
27 #include <mach-o/dyld_priv.h>
28 #include <mach/mach.h>
29 #include <Availability.h>
30 #include <mach/shared_region.h>
33 #include "dyld_cache_format.h"
40 _dyld_get_shared_cache_uuid(curUuid
);
42 int __block imageCount
= 0;
43 int result
= dyld_shared_cache_iterate_text(curUuid
, ^(const dyld_shared_cache_dylib_text_info
* info
) {
45 //printf(" cur: 0x%09llX -> 0x%09llX off=0x%0llX %s\n", info->loadAddressUnslid, info->loadAddressUnslid + info->textSegmentSize, info->textSegmentOffset, info->path);
48 FAIL("dyld_shared_cache_iterate_text: dyld_shared_cache_iterate_text() failed");
52 if ( imageCount
< 500 ) {
53 FAIL("dyld_shared_cache_iterate_text: dyld_shared_cache_iterate_text() iterated less than 500 dylibs (%d)", imageCount
);
57 //uuid_t fixedUUID = {0x3E, 0xDE, 0x37, 0x05, 0x81, 0x68, 0x33, 0xEF, 0xBF, 0x97, 0xC0, 0xF6, 0xD2, 0x4D, 0x93, 0xEC};
58 uuid_t fixedUUID
= {0xD4, 0x3B, 0x31, 0x2B, 0xA5, 0xA7, 0x3C, 0x55, 0x90, 0xA0, 0x9A, 0x37, 0x60, 0x7D, 0x70, 0xAF};
59 result
= dyld_shared_cache_iterate_text(fixedUUID
, ^(const dyld_shared_cache_dylib_text_info
* info
) {
60 printf(" my: 0x%09llX -> 0x%09llX %s\n", info
->loadAddressUnslid
, info
->loadAddressUnslid
+ info
->textSegmentSize
, info
->path
);
64 PASS("dyld_shared_cache_iterate_text");