/macosx-10.10/dyld-353.2.1/include/ |
H A D | dlfcn.h | 31 #define _DLFCN_H_ macro 45 typedef struct dl_info { struct 46 const char *dli_fname; /* Pathname of shared object */ member in struct:dl_info 47 void *dli_fbase; /* Base address of shared object */ member in struct:dl_info 48 const char *dli_sname; /* Name of nearest symbol */ member in struct:dl_info 49 void *dli_saddr; /* Address of nearest symbol */ member in struct:dl_info 50 } Dl_info; typedef in typeref:struct:dl_info 65 #define RTLD_LAZY macro 66 #define RTLD_NOW macro 67 #define RTLD_LOCAL macro 68 #define RTLD_GLOBAL macro 71 #define RTLD_NOLOAD macro 72 #define RTLD_NODELETE macro 73 #define RTLD_FIRST macro 78 #define RTLD_NEXT macro 79 #define RTLD_DEFAULT macro 80 #define RTLD_SELF macro 81 #define RTLD_MAIN_ONLY macro [all...] |
H A D | objc-shared-cache.h | 76 #define _OBJC_SELOPT_H macro 93 # define STATIC_ASSERT macro 94 # define _STATIC_ASSERT2 macro 95 # define _STATIC_ASSERT3 macro 101 #define SELOPT_DEBUG macro 103 #define S32 macro 104 #define S64 macro 106 namespace objc_opt { namespace 108 typedef int32_t objc_stringhash_offset_t; typedef in namespace:objc_opt 109 typedef uint8_t objc_stringhash_check_t; typedef in namespace:objc_opt 117 struct perfect_hash { struct in namespace:objc_opt 118 uint32_t capacity; member in struct:objc_opt::perfect_hash 119 uint32_t occupied; member in struct:objc_opt::perfect_hash 120 uint32_t shift; member in struct:objc_opt::perfect_hash 121 uint32_t mask; member in struct:objc_opt::perfect_hash 122 uint64_t salt; member in struct:objc_opt::perfect_hash 124 uint32_t scramble[256]; member in struct:objc_opt::perfect_hash 125 uint8_t *tab; // count == mask+1; free with delete[] member in struct:objc_opt::perfect_hash 127 perfect_hash() : tab(0) { } function in struct:objc_opt::perfect_hash 129 ~perfect_hash() { if (tab) delete[] tab; } function in struct:objc_opt::perfect_hash 132 struct eqstr { struct in namespace:objc_opt 133 operator ()(const char* s1, const char* s2) const argument 138 struct hashstr { struct in namespace:objc_opt 139 operator ()(const char *s) const argument 146 typedef std::unordered_map<const char *, uint64_t, hashstr, eqstr> string_map; typedef in namespace:objc_opt 149 typedef std::unordered_multimap<const char *, std::pair<uint64_t, uint64_t>, hashstr, eqstr> class_map; typedef in namespace:objc_opt 159 struct objc_stringhash_t { struct in namespace:objc_opt 160 uint32_t capacity; member in struct:objc_opt::objc_stringhash_t 161 uint32_t occupied; member in struct:objc_opt::objc_stringhash_t 162 uint32_t shift; member in struct:objc_opt::objc_stringhash_t 163 uint32_t mask; member in struct:objc_opt::objc_stringhash_t 164 uint32_t zero; member in struct:objc_opt::objc_stringhash_t 165 uint32_t unused; // alignment pad member in struct:objc_opt::objc_stringhash_t 166 uint64_t salt; member in struct:objc_opt::objc_stringhash_t 168 uint32_t scramble[256]; member in struct:objc_opt::objc_stringhash_t 169 uint8_t tab[0]; /* tab[mask+1] (always power-of-2) */ member in struct:objc_opt::objc_stringhash_t 173 objc_stringhash_check_t *checkbytes() { return (objc_stringhash_check_t *)&tab[mask+1]; } function in struct:objc_opt::objc_stringhash_t 174 checkbytes() const argument 176 objc_stringhash_offset_t *offsets() { return (objc_stringhash_offset_t *)&checkbytes()[capacity]; } function in struct:objc_opt::objc_stringhash_t 177 offsets() const argument 179 hash(const char *key, size_t keylen) const argument 181 uint64_t val = lookup8((uint8_t*)key, keylen, salt); local 182 uint32_t index = (uint32_t)(val>>shift) ^ scramble[tab[val&mask]]; local 186 hash(const char *key) const argument 195 checkbyte(const char *key, size_t keylen) const argument 203 checkbyte(const char *key) const argument 209 #define INDEX_NOT_FOUND macro 211 getIndex(const char *key) const argument 213 size_t keylen = strlen(key); local 214 uint32_t h = hash(key, keylen); local 217 objc_stringhash_check_t h_check = checkbytes()[h]; local 218 objc_stringhash_check_t key_check = checkbyte(key, keylen); local 219 bool check_fail = (h_check != key_check); local 227 const char *result = (const char *)this + offset; local 239 size_t size() function in struct:objc_opt::objc_stringhash_t 247 byteswap(bool little_endian) argument 253 objc_stringhash_offset_t *o = offsets(); local 266 write(uint64_t base, size_t remaining, string_map& strings) argument 277 perfect_hash phash = make_perfect(strings); local 314 # define SHIFT macro 315 string_map::const_iterator s; local 317 int64_t offset = s->second - base; local 322 uint32_t h = hash(s->first); local 326 # undef SHIFT macro 338 struct objc_selopt_t : objc_stringhash_t { struct in namespace:objc_opt 339 get(const char *key) const argument 341 uint32_t h = getIndex(key); local 351 struct objc_classheader_t { struct in namespace:objc_opt 352 objc_stringhash_offset_t clsOffset; member in struct:objc_opt::objc_classheader_t 353 objc_stringhash_offset_t hiOffset; member in struct:objc_opt::objc_classheader_t 358 isDuplicate() const argument 359 duplicateCount() const argument 360 duplicateIndex() const argument 364 struct objc_clsopt_t : objc_stringhash_t { struct in namespace:objc_opt 370 objc_classheader_t *classOffsets() { return (objc_classheader_t *)&offsets()[capacity]; } function in struct:objc_opt::objc_clsopt_t 371 classOffsets() const argument 373 uint32_t& duplicateCount() { return *(uint32_t *)&classOffsets()[capacity]; } function in struct:objc_opt::objc_clsopt_t 374 duplicateCount() const argument 376 objc_classheader_t *duplicateOffsets() { return (objc_classheader_t *)(&duplicateCount()+1); } function in struct:objc_opt::objc_clsopt_t 377 duplicateOffsets() const argument 382 getClassAndHeader(const char *key, void*& cls, void*& hi) const argument 384 uint32_t h = getIndex(key); local 391 const objc_classheader_t& clshi = classOffsets()[h]; local 406 getClassesAndHeaders(const char *key, void **cls, void **hi) const argument 408 uint32_t h = getIndex(key); local 411 const objc_classheader_t& clshi = classOffsets()[h]; local 419 uint32_t count = clshi.duplicateCount(); local 420 const objc_classheader_t *list = local 431 size_t size() function in struct:objc_opt::objc_clsopt_t 440 byteswap(bool little_endian) argument 442 objc_classheader_t *o; local 461 write(uint64_t base, size_t remaining, string_map& strings, class_map& classes, bool verbose) argument 464 const char *err; local 473 objc_stringhash_offset_t zeroOffset = local 481 # define SHIFT macro 482 class_map::const_iterator c; local 484 uint32_t h = getIndex(c->first); local 494 uint32_t count = classes.count(c->first); local 498 int64_t coff = c->second.first - base; local 499 int64_t hoff = c->second.second - base; local 516 uint32_t dest = duplicateCount(); local 527 duplicates = classes.equal_range(c->first); local 528 class_map::const_iterator dup; local 530 int64_t coff = dup->second.first - base; local 531 int64_t hoff = dup->second.second - base; local 545 # undef SHIFT macro 561 enum { VERSION = 12 }; enumerator in enum:objc_opt::__anon8 565 struct objc_opt_t { struct in namespace:objc_opt 566 uint32_t version; member in struct:objc_opt::objc_opt_t 567 int32_t selopt_offset; member in struct:objc_opt::objc_opt_t 568 int32_t headeropt_offset; member in struct:objc_opt::objc_opt_t 569 int32_t clsopt_offset; member in struct:objc_opt::objc_opt_t 571 selopt() const argument 575 objc_selopt_t* selopt() { function in struct:objc_opt::objc_opt_t 580 headeropt() const argument 585 clsopt() const argument 595 #define X8 macro 596 #define X64 macro 597 #define X256 macro 598 #define OPT_INITIALIZER macro 627 #define mix64 macro 672 lookup8( uint8_t *k, size_t length, uint64_t level) argument 677 uint64_t a,b,c; local 678 size_t len; local 778 typedef uint64_t ub8; typedef in namespace:objc_opt 779 #define UB8MAXVAL macro 780 #define UB8BITS macro 781 typedef uint32_t ub4; typedef in namespace:objc_opt 782 #define UB4MAXVAL macro 783 #define UB4BITS macro 784 typedef uint16_t ub2; typedef in namespace:objc_opt 785 #define UB2MAXVAL macro 786 #define UB2BITS macro 787 typedef uint8_t ub1; typedef in namespace:objc_opt 788 #define UB1MAXVAL macro 789 #define UB1BITS macro 791 #define TRUE macro 792 #define FALSE macro 794 #define SCRAMBLE_LEN macro 795 #define RETRY_INITKEY macro 796 #define RETRY_PERFECT macro 800 struct key struct in namespace:objc_opt 802 ub1 *name_k; /* the actual key */ member in struct:objc_opt::key 803 ub4 len_k; /* the length of the actual key */ member in struct:objc_opt::key 804 ub4 hash_k; /* the initial hash value for this key */ member in struct:objc_opt::key 806 ub4 a_k; /* a, of the key maps to (a,b) */ member in struct:objc_opt::key 807 ub4 b_k; /* b, of the key maps to (a,b) */ member in struct:objc_opt::key 808 struct key *nextb_k; /* next key with this b */ member in struct:objc_opt::key 810 typedef struct key key; typedef in namespace:objc_opt 813 struct bstuff struct in namespace:objc_opt 815 ub2 val_b; /* hash=a^tabb[b].val_b */ member in struct:objc_opt::bstuff 816 key *list_b; /* tabb[i].list_b is list of keys with b==i */ member in struct:objc_opt::bstuff 817 ub4 listlen_b; /* length of list_b */ member in struct:objc_opt::bstuff 818 ub4 water_b; /* high watermark of who has visited this map node */ member in struct:objc_opt::bstuff 820 typedef struct bstuff bstuff; typedef in namespace:objc_opt 823 struct hstuff struct in namespace:objc_opt 825 key *key_h; /* tabh[i].key_h is the key with a hash of i */ member in struct:objc_opt::hstuff 827 typedef struct hstuff hstuff; typedef in namespace:objc_opt 830 struct qstuff struct in namespace:objc_opt 832 bstuff *b_q; /* b that currently occupies this hash */ member in struct:objc_opt::qstuff 833 ub4 parent_q; /* queue position of parent that could use this hash */ member in struct:objc_opt::qstuff 834 ub2 newval_q; /* what to change parent tab[b] to to use this hash */ member in struct:objc_opt::qstuff 835 ub2 oldval_q; /* original value of tab[b] */ member in struct:objc_opt::qstuff 837 typedef struct qstuff qstuff; typedef in namespace:objc_opt 847 log2u(ub4 val) argument 849 ub4 i; local 857 permute(ub4 x, ub4 nbits) argument 861 int i; local 862 int mask = ((ub4)1<<nbits)-1; /* all ones */ local 863 int const2 = 1+nbits/2; local 864 int const3 = 1+nbits/3; local 865 int const4 = 1+nbits/4; local 866 int const5 = 1+nbits/5; local 878 scrambleinit(ub4 *scramble, ub4 smax) argument 882 ub4 i; local 896 inittab(bstuff *tabb, ub4 blen, key *keys, ub4 nkeys, int complete) argument 902 int nocollision = TRUE; local 903 ub4 i; local 909 key *mykey = keys+i; local 910 key *otherkey; local 934 initnorm(key *keys, ub4 nkeys, ub4 alen, ub4 blen, ub4 smax, ub8 salt) argument 942 ub4 loga = log2u(alen); /* log based 2 of blen */ local 943 ub4 i; local 945 key *mykey = keys+i; local 946 ub8 hash = lookup8(mykey->name_k, mykey->len_k, salt); local 954 apply(bstuff *tabb, hstuff *tabh, qstuff *tabq, ub4 blen, ub4 *scramble, ub4 tail, int rollback) argument 963 ub4 hash; local 964 key *mykey; local 965 bstuff *pb; local 966 ub4 child; local 967 ub4 parent; local 968 ub4 stabb; /* scramble[tab[b]] */ local 1031 augment(bstuff *tabb, hstuff *tabh, qstuff *tabq, ub4 blen, ub4 *scramble, ub4 smax, bstuff *item, ub4 nkeys, ub4 highwater) argument 1043 ub4 q; /* current position walking through the queue */ local 1044 ub4 tail; /* tail of the queue. 0 is the head of the queue. */ local 1045 ub4 limit=UB1MAXVAL+1; local 1046 ub4 highhash = smax; local 1055 bstuff *myb = tabq[q].b_q; /* the b for this node */ local 1056 ub4 i; /* possible value for myb->val_b */ local 1063 bstuff *childb = (bstuff *)0; /* the b that this i maps to */ local 1064 key *mykey; /* for walking through myb's keys */ local 1068 key *childkey; local 1069 ub4 hash = mykey->a_k^scramble[i]; local 1076 bstuff *hitb = &tabb[childkey->b_k]; local 1114 perfect(bstuff *tabb, hstuff *tabh, qstuff *tabq, ub4 blen, ub4 smax, ub4 *scramble, ub4 nkeys) argument 1116 ub4 maxkeys; /* maximum number of keys for any b */ local 1117 ub4 i, j; local 1147 initalen(ub4 *alen, ub4 *blen, ub4 smax, ub4 nkeys) argument 1204 findhash(bstuff **tabb, ub4 *alen, ub4 *blen, ub8 *salt, ub4 *scramble, ub4 smax, key *keys, ub4 nkeys) argument 1215 ub4 bad_initkey; /* how many times did initkey fail? */ local 1216 ub4 bad_perfect; /* how many times did perfect fail? */ local 1217 ub4 si; /* trial initializer for initial hash */ local 1218 ub4 maxalen; local 1219 hstuff *tabh; /* table of keys indexed by hash value */ local 1220 qstuff *tabq; /* table of stuff indexed by queue value, used by augment */ local 1240 ub4 rslinit; local 1309 getkeys(key **keys, ub4 *nkeys, const string_map& strings) argument 1311 key *buf = new key[strings.size()]; local 1312 size_t i; local 1313 string_map::const_iterator s; local 1315 key *mykey = buf+i; local 1325 make_perfect(const string_map& strings) argument 1327 ub4 nkeys; /* number of keys */ local 1328 key *keys; /* head of list of keys */ local 1329 bstuff *tab; /* table indexed by b */ local 1330 ub4 smax; /* scramble[] values in 0..smax-1, a power of 2 */ local 1331 ub4 alen; /* a in 0..alen-1, a power of 2 */ local 1332 ub4 blen; /* b in 0..blen-1, a power of 2 */ local 1333 ub8 salt; /* a parameter to the hash function */ local 1334 ub4 scramble[SCRAMBLE_LEN]; /* used in final hash function */ local 1335 int ok; local 1336 int i; local 1337 perfect_hash result; local 1382 #undef S32 macro 1383 #undef S64 macro [all...] |
/macosx-10.10/dyld-353.2.1/include/mach-o/ |
H A D | dyld-interposing.h | 25 #define _DYLD_INTERPOSING_H_ macro 43 #define DYLD_INTERPOSE macro [all...] |
H A D | dyld.h | 24 #define _MACH_O_DYLD_H_ macro 118 #define ENUM_DYLD_BOOL macro 119 #undef FALSE macro 120 #undef TRUE macro 121 enum DYLD_BOOL { FALSE, TRUE }; enumerator in enum:DYLD_BOOL 127 NSObjectFileImageFailure, /* for this a message is printed on stderr */ enumerator in enum:__anon1 128 NSObjectFileImageSuccess, enumerator in enum:__anon1 129 NSObjectFileImageInappropriateFile, enumerator in enum:__anon1 130 NSObjectFileImageArch, enumerator in enum:__anon1 131 NSObjectFileImageFormat, /* for this a message is printed on stderr */ enumerator in enum:__anon1 132 NSObjectFileImageAccess enumerator in enum:__anon1 133 } NSObjectFileImageReturnCode; typedef in typeref:enum:__anon1 135 typedef struct __NSObjectFileImage* NSObjectFileImage; typedef in typeref:struct:__NSObjectFileImage 150 typedef struct __NSModule* NSModule; typedef in typeref:struct:__NSModule 155 #define NSLINKMODULE_OPTION_NONE macro 156 #define NSLINKMODULE_OPTION_BINDNOW macro 157 #define NSLINKMODULE_OPTION_PRIVATE macro 158 #define NSLINKMODULE_OPTION_RETURN_ON_ERROR macro 159 #define NSLINKMODULE_OPTION_DONT_CALL_MOD_INIT_ROUTINES macro 160 #define NSLINKMODULE_OPTION_TRAILING_PHYS_NAME macro 163 #define NSUNLINKMODULE_OPTION_NONE macro 164 #define NSUNLINKMODULE_OPTION_KEEP_MEMORY_MAPPED macro 165 #define NSUNLINKMODULE_OPTION_RESET_LAZY_REFERENCES macro 168 typedef struct __NSSymbol* NSSymbol; typedef in typeref:struct:__NSSymbol 176 #define NSLOOKUPSYMBOLINIMAGE_OPTION_BIND macro 177 #define NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW macro 178 #define NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_FULLY macro 179 #define NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR macro 186 NSLinkEditFileAccessError, enumerator in enum:__anon2 187 NSLinkEditFileFormatError, enumerator in enum:__anon2 188 NSLinkEditMachResourceError, enumerator in enum:__anon2 189 NSLinkEditUnixResourceError, enumerator in enum:__anon2 190 NSLinkEditOtherError, enumerator in enum:__anon2 191 NSLinkEditWarningError, enumerator in enum:__anon2 192 NSLinkEditMultiplyDefinedError, enumerator in enum:__anon2 193 NSLinkEditUndefinedError enumerator in enum:__anon2 194 } NSLinkEditErrors; typedef in typeref:enum:__anon2 203 NSOtherErrorRelocation, enumerator in enum:__anon3 204 NSOtherErrorLazyBind, enumerator in enum:__anon3 205 NSOtherErrorIndrLoop, enumerator in enum:__anon3 206 NSOtherErrorLazyInit, enumerator in enum:__anon3 207 NSOtherErrorInvalidArgs enumerator in enum:__anon3 208 } NSOtherErrorNumbers; typedef in typeref:enum:__anon3 213 void (*undefined)(const char* symbolName); member in struct:__anon4 214 NSModule (*multiple)(NSSymbol s, NSModule oldModule, NSModule newModule); member in struct:__anon4 215 void (*linkEdit)(NSLinkEditErrors errorClass, int errorNumber, member in struct:__anon4 217 } NSLinkEditErrorHandlers; typedef in typeref:struct:__anon4 224 #define NSADDIMAGE_OPTION_NONE macro 225 #define NSADDIMAGE_OPTION_RETURN_ON_ERROR macro 226 #define NSADDIMAGE_OPTION_WITH_SEARCHING macro 227 #define NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED macro 228 #define NSADDIMAGE_OPTION_MATCH_FILENAME_BY_INSTALLNAME macro [all...] |
H A D | dyld_gdb.h | 24 #define _DYLD_GDB_ macro [all...] |
H A D | dyld_images.h | 24 #define _DYLD_IMAGES_ macro 66 enum dyld_image_mode { dyld_image_adding=0, dyld_image_removing=1, dyld_image_info_change=2 }; enumerator in enum:dyld_image_mode 68 struct dyld_image_info { struct 69 const struct mach_header* imageLoadAddress; /* base address image is mapped into */ member in struct:dyld_image_info 70 const char* imageFilePath; /* path dyld used to load the image */ member in struct:dyld_image_info 71 uintptr_t imageFileModDate; /* time_t of image file */ member in struct:dyld_image_info 76 struct dyld_uuid_info { struct 77 const struct mach_header* imageLoadAddress; /* base address image is mapped into */ member in struct:dyld_uuid_info 78 uuid_t imageUUID; /* UUID of image */ member in struct:dyld_uuid_info 81 typedef void (*dyld_image_notifier)(enum dyld_image_mode mode, uint32_t infoCount, const struct dyld_image_info info[]); typedef 84 enum { dyld_error_kind_none=0, enumerator in enum:__anon5 85 dyld_error_kind_dylib_missing=1, enumerator in enum:__anon5 86 dyld_error_kind_dylib_wrong_arch=2, enumerator in enum:__anon5 87 dyld_error_kind_dylib_version=3, enumerator in enum:__anon5 88 dyld_error_kind_symbol_missing=4 enumerator in enum:__anon5 92 struct dyld_all_image_infos { struct 93 uint32_t version; /* 1 in Mac OS X 10.4 and 10.5 */ member in struct:dyld_all_image_infos 94 uint32_t infoArrayCount; member in struct:dyld_all_image_infos 95 const struct dyld_image_info* infoArray; member in struct:dyld_all_image_infos 96 dyld_image_notifier notification; member in struct:dyld_all_image_infos 97 bool processDetachedFromSharedRegion; member in struct:dyld_all_image_infos 99 bool libSystemInitialized; member in struct:dyld_all_image_infos 100 const struct mach_header* dyldImageLoadAddress; member in struct:dyld_all_image_infos 102 void* jitInfo; member in struct:dyld_all_image_infos 104 const char* dyldVersion; member in struct:dyld_all_image_infos 105 const char* errorMessage; member in struct:dyld_all_image_infos 106 uintptr_t terminationFlags; member in struct:dyld_all_image_infos 108 void* coreSymbolicationShmPage; member in struct:dyld_all_image_infos 110 uintptr_t systemOrderFlag; member in struct:dyld_all_image_infos 112 uintptr_t uuidArrayCount; member in struct:dyld_all_image_infos 113 const struct dyld_uuid_info* uuidArray; /* only images not in dyld shared cache */ member in struct:dyld_all_image_infos 115 struct dyld_all_image_infos* dyldAllImageInfosAddress; member in struct:dyld_all_image_infos 117 uintptr_t initialImageCount; member in struct:dyld_all_image_infos 119 uintptr_t errorKind; member in struct:dyld_all_image_infos 120 const char* errorClientOfDylibPath; member in struct:dyld_all_image_infos 121 const char* errorTargetDylibPath; member in struct:dyld_all_image_infos 122 const char* errorSymbol; member in struct:dyld_all_image_infos 124 uintptr_t sharedCacheSlide; member in struct:dyld_all_image_infos 126 uint8_t sharedCacheUUID[16]; member in struct:dyld_all_image_infos 128 uintptr_t reserved[16]; member in struct:dyld_all_image_infos 143 struct dyld_shared_cache_ranges { struct 144 uintptr_t sharedRegionsCount; /* how many ranges follow */ member in struct:dyld_shared_cache_ranges 146 uintptr_t start; member in struct:dyld_shared_cache_ranges::__anon6 147 uintptr_t length; member in struct:dyld_shared_cache_ranges::__anon6 148 } ranges[4]; /* max regions */ member in struct:dyld_shared_cache_ranges [all...] |
H A D | dyld_priv.h | 25 #define _MACH_O_DYLD_PRIV_H_ macro 52 enum dyld_image_states enum 54 dyld_image_state_mapped = 10, // No batch notification for this enumerator in enum:dyld_image_states 55 dyld_image_state_dependents_mapped = 20, // Only batch notification for this enumerator in enum:dyld_image_states 56 dyld_image_state_rebased = 30, enumerator in enum:dyld_image_states 57 dyld_image_state_bound = 40, enumerator in enum:dyld_image_states 58 dyld_image_state_dependents_initialized = 45, // Only single notification for this enumerator in enum:dyld_image_states 59 dyld_image_state_initialized = 50, enumerator in enum:dyld_image_states 60 dyld_image_state_terminated = 60 // Only single notification for this enumerator in enum:dyld_image_states 69 typedef const char* (*dyld_image_state_change_handler)(enum dyld_image_states state, uint32_t infoCount, const struct dyld_image_info info[]); typedef 87 enum dyld_tlv_states { enum 88 dyld_tlv_state_allocated = 10, // TLV range newly allocated enumerator in enum:dyld_tlv_states 89 dyld_tlv_state_deallocated = 20 // TLV range about to be deallocated enumerator in enum:dyld_tlv_states 96 size_t info_size; // sizeof(dyld_tlv_info) member in struct:__anon7 97 void * tlv_addr; // Base address of TLV storage member in struct:__anon7 98 size_t tlv_size; // Byte size of TLV storage member in struct:__anon7 99 } dyld_tlv_info; typedef in typeref:struct:__anon7 106 typedef void (^dyld_tlv_state_change_handler)(enum dyld_tlv_states state, const dyld_tlv_info *info); variable 145 struct dyld_unwind_sections struct 147 const struct mach_header* mh; member in struct:dyld_unwind_sections 148 const void* dwarf_section; member in struct:dyld_unwind_sections 149 uintptr_t dwarf_section_length; member in struct:dyld_unwind_sections 150 const void* compact_unwind_section; member in struct:dyld_unwind_sections 151 uintptr_t compact_unwind_section_length; member in struct:dyld_unwind_sections 176 #define DYLD_MACOSX_VERSION_10_4 macro 177 #define DYLD_MACOSX_VERSION_10_5 macro 178 #define DYLD_MACOSX_VERSION_10_6 macro 179 #define DYLD_MACOSX_VERSION_10_7 macro 180 #define DYLD_MACOSX_VERSION_10_8 macro 181 #define DYLD_MACOSX_VERSION_10_9 macro 182 #define DYLD_MACOSX_VERSION_10_10 macro 184 #define DYLD_IOS_VERSION_2_0 macro 185 #define DYLD_IOS_VERSION_2_1 macro 186 #define DYLD_IOS_VERSION_2_2 macro 187 #define DYLD_IOS_VERSION_3_0 macro 188 #define DYLD_IOS_VERSION_3_1 macro 189 #define DYLD_IOS_VERSION_3_2 macro 190 #define DYLD_IOS_VERSION_4_0 macro 191 #define DYLD_IOS_VERSION_4_1 macro 192 #define DYLD_IOS_VERSION_4_2 macro 193 #define DYLD_IOS_VERSION_4_3 macro 194 #define DYLD_IOS_VERSION_5_0 macro 195 #define DYLD_IOS_VERSION_5_1 macro 196 #define DYLD_IOS_VERSION_6_0 macro 197 #define DYLD_IOS_VERSION_6_1 macro 198 #define DYLD_IOS_VERSION_7_0 macro 199 #define DYLD_IOS_VERSION_7_1 macro 200 #define DYLD_IOS_VERSION_8_0 macro 260 #define NSLINKMODULE_OPTION_CAN_UNLOAD macro 270 struct dyld_interpose_tuple { struct 271 const void* replacement; member in struct:dyld_interpose_tuple 272 const void* replacee; member in struct:dyld_interpose_tuple [all...] |
/macosx-10.10/dyld-353.2.1/launch-cache/ |
H A D | Architectures.hpp | 26 #define __ARCHITECTURES__ macro 34 struct x86 struct 36 typedef Pointer32<LittleEndian> P; typedef in struct:x86 40 struct x86_64 struct 42 typedef Pointer64<LittleEndian> P; typedef in struct:x86_64 45 struct arm struct 47 typedef Pointer32<LittleEndian> P; typedef in struct:arm 51 struct arm64 struct 53 typedef Pointer64<LittleEndian> P; typedef in struct:arm64 [all...] |
H A D | CacheFileAbstraction.hpp | 25 #define __DYLD_CACHE_ABSTRACTION__ macro 33 class dyldCacheHeader { class 75 dyld_cache_header fields; member in class:dyldCacheHeader 80 class dyldCacheFileMapping { class 98 dyld_cache_mapping_info fields; member in class:dyldCacheFileMapping 103 class dyldCacheImageInfo { class 118 dyld_cache_image_info fields; member in class:dyldCacheImageInfo 122 class dyldCacheSlideInfo { class 146 dyld_cache_slide_info fields; member in class:dyldCacheSlideInfo 150 struct dyldCacheSlideInfoEntry { struct 151 uint8_t bits[4096/(8*4)]; // 128-byte bitmap member in struct:dyldCacheSlideInfoEntry 157 class dyldCacheLocalSymbolsInfo { class 178 dyld_cache_local_symbols_info fields; member in class:dyldCacheLocalSymbolsInfo 183 class dyldCacheLocalSymbolEntry { class 195 dyld_cache_local_symbols_entry fields; member in class:dyldCacheLocalSymbolEntry [all...] |
H A D | FileAbstraction.hpp | 25 #define __FILE_ABSTRACTION__ macro 33 #define INLINE macro 35 #define INLINE macro 58 class BigEndian class 76 uint8_t firstBit, uint8_t bitCount) INLINE { uint32_t temp = get32(into); setBitsRaw(temp, value, firstBit, bitCount); set32(into, temp); } variable 81 uint8_t firstBit, uint8_t bitCount) INLINE { uint32_t temp = into; variable 82 const uint32_t mask = ((1<<bitCount)-1); variable 86 enum { little_endian = 0 }; enumerator in enum:BigEndian::__anon9 90 class LittleEndian class 108 uint8_t firstBit, uint8_t bitCount) INLINE { uint32_t temp = get32(into); setBitsRaw(temp, value, firstBit, bitCount); set32(into, temp); } variable 113 uint8_t firstBit, uint8_t bitCount) INLINE { uint32_t temp = into; variable 114 const uint32_t mask = ((1<<bitCount)-1); variable 118 enum { little_endian = 1 }; enumerator in enum:LittleEndian::__anon10 123 class Pointer32 class 126 typedef uint32_t uint_t; typedef in class:Pointer32 127 typedef _E E; typedef in class:Pointer32 134 round_up(T value) argument 136 round_down(T value) argument 141 class Pointer64 class 144 typedef uint64_t uint_t; typedef in class:Pointer64 145 typedef _E E; typedef in class:Pointer64 152 round_up(T value) argument 154 round_down(T value) argument [all...] |
H A D | MachOBinder.hpp | 26 #define __MACHO_BINDER__ macro 53 #define EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER macro 57 #define EXPORT_SYMBOL_FLAGS_KIND_ABSOLUTE macro 62 class Binder : public Rebaser<A> class in inherits:Rebaser 65 class CStringHash { class in class:Binder 67 operator ()(const char* __s) const argument 68 size_t __h = 0; local 74 struct CStringEquals { struct in class:Binder 75 operator ()(const char* left, const char* right) const argument 77 typedef std::unordered_map<const char*, class Binder<A>*, CStringHash, CStringEquals> Map; typedef in class:Binder 81 virtual ~Binder() {} function in class:Binder 89 typedef typename A::P P; typedef in class:Binder 90 typedef typename A::P::E E; typedef in class:Binder 91 typedef typename A::P::uint_t pint_t; typedef in class:Binder 92 struct BinderAndReExportFlag { Binder<A>* binder; bool reExport; }; member in struct:Binder::BinderAndReExportFlag 93 struct SymbolReExport { const char* exportName; int dylibOrdinal; const char* importName; }; member in struct:Binder::SymbolReExport 94 typedef std::unordered_map<const char*, pint_t, CStringHash, CStringEquals> NameToAddrMap; typedef in class:Binder 95 typedef std::unordered_set<const char*, CStringHash, CStringEquals> NameSet; typedef in class:Binder 96 struct ClientAndSymbol { Binder<A>* client; const char* symbolName; }; member in struct:Binder::ClientAndSymbol 97 struct SymbolAndLazyPointer { const char* symbolName; pint_t lpVMAddr; }; member in struct:Binder::SymbolAndLazyPointer 126 std::vector<BinderAndReExportFlag> fDependentDylibs; member in class:Binder 127 NameToAddrMap fHashTable; member in class:Binder 128 NameSet fSymbolResolvers; member in class:Binder 129 NameSet fAbsoluteSymbols; member in class:Binder 130 std::vector<SymbolReExport> fReExportedSymbols; member in class:Binder 131 uint64_t fDyldBaseAddress; member in class:Binder 132 const macho_nlist<P>* fSymbolTable; member in class:Binder 133 const char* fStrings; member in class:Binder 134 const macho_dysymtab_command<P>* fDynamicInfo; member in class:Binder 135 const macho_segment_command<P>* fFristWritableSegment; member in class:Binder 136 const macho_dylib_command<P>* fDylibID; member in class:Binder 137 const macho_dylib_command<P>* fParentUmbrella; member in class:Binder 138 const macho_dyld_info_command<P>* fDyldInfo; member in class:Binder 139 bool fOriginallyPrebound; member in class:Binder 140 bool fReExportedSymbolsResolved; member in class:Binder 141 std::vector<ClientAndSymbol> fClientAndSymbols; member in class:Binder 142 NameToAddrMap fResolverLazyPointers; member in class:Binder 146 runtimeAddressFromNList(const macho_nlist<Pointer32<LittleEndian> >* sym) argument 155 runtimeAddressFromNList(const macho_nlist<P>* sym) argument 162 Binder(const MachOLayoutAbstraction& layout, uint64_t dyldBaseAddress) argument 173 const macho_symtab_command<P>* symtab; local 174 const macho_load_command<P>* const cmds = (macho_load_command<P>*)((uint8_t*)this->fHeader + sizeof(macho_header<P>)); local 175 const uint32_t cmd_count = this->fHeader->ncmds(); local 176 const macho_load_command<P>* cmd = cmds; local 220 std::vector<mach_o::trie::Entry> exports; local 221 const uint8_t* exportsStart = layout.getDyldInfoExports(); local 222 const uint8_t* exportsEnd = &exportsStart[fDyldInfo->export_size()]; local 224 pint_t baseAddress = layout.getSegments()[0].newAddress(); local 233 SymbolReExport sym; local 262 const macho_nlist<P>* start = &fSymbolTable[fDynamicInfo->iextdefsym()]; local 263 const macho_nlist<P>* end = &start[fDynamicInfo->nextdefsym()]; local 266 const char* name = &fStrings[sym->n_strx()]; local 272 int32_t count = fDynamicInfo->ntoc(); local 274 const struct dylib_table_of_contents* toc = (dylib_table_of_contents*)&this->fLinkEditBase[fDynamicInfo->tocoff()]; local 276 const uint32_t index = E::get32(toc[i].symbol_index); local 277 const macho_nlist<P>* sym = &fSymbolTable[index]; local 278 const char* name = &fStrings[sym->n_strx()]; local 286 template <> uint8_t Binder<x86>::pointerRelocSize() { return 2; } function in class:Binder 287 template <> uint8_t Binder<x86_64>::pointerRelocSize() { return 3; } function in class:Binder 288 template <> uint8_t Binder<arm>::pointerRelocSize() { return 2; } function in class:Binder 289 template <> uint8_t Binder<arm64>::pointerRelocSize() { return 3; } function in class:Binder 291 template <> uint8_t Binder<x86>::pointerRelocType() { return GENERIC_RELOC_VANILLA; } function in class:Binder 292 template <> uint8_t Binder<x86_64>::pointerRelocType() { return X86_64_RELOC_UNSIGNED; } function in class:Binder 293 template <> uint8_t Binder<arm>::pointerRelocType() { return ARM_RELOC_VANILLA; } function in class:Binder 294 template <> uint8_t Binder<arm64>::pointerRelocType() { return ARM64_RELOC_UNSIGNED; } function in class:Binder 298 getDylibID() const argument 307 const char* Binder<A>::parentUmbrella() function in class:Binder 317 isPublicLocation(const char* pth) argument 325 const char* frameworkDot = strchr(&pth[27], '.'); local 332 int frameworkNameLen = frameworkDot - &pth[27]; local 342 setDependentBinders(const Map& map) argument 345 const macho_load_command<P>* const cmds = (macho_load_command<P>*)((uint8_t*)this->fHeader + sizeof(macho_header<P>)); local 346 const uint32_t cmd_count = this->fHeader->ncmds(); local 347 const macho_load_command<P>* cmd = cmds; local 354 const char* path = ((struct macho_dylib_command<P>*)cmd)->name(); local 355 typename Map::const_iterator pos = map.find(path); local 357 BinderAndReExportFlag entry; local 368 bool found = false; local 369 char targetPath[PATH_MAX]; local 372 char aPath[PATH_MAX]; local 375 BinderAndReExportFlag entry; local 389 BinderAndReExportFlag entry; local 408 const char* dylibBaseName; local 409 const char* frameworkLeafName; local 415 const char* dylibName = it->binder->getDylibID(); local 416 const char* lastSlash = strrchr(dylibName, '/'); local 417 const char* leafStart = &lastSlash[1]; local 420 const char* firstDot = strchr(leafStart, '.'); local 421 int len = strlen(leafStart); local 431 const char* dylibName = it->binder->getDylibID(); local 432 const char* lastSlash = strrchr(dylibName, '/'); local 441 const char* thisName = this->getDylibID(); local 443 const char* thisLeafName = strrchr(thisName, '/'); local 448 Binder<A>* dep = it->binder; local 450 const char* parentUmbrellaName = dep->parentUmbrella(); local 464 ordinalOfDependentBinder(Binder<A>* dep) argument 474 void Binder<A>::hoistPrivateRexports() function in class:Binder 476 std::vector<Binder<A>*> privateReExportedDylibs; local 483 const uint8_t* exportsStart = this->fLayout.getDyldInfoExports(); local 484 const uint8_t* exportsEnd = &exportsStart[fDyldInfo->export_size()]; local 485 std::vector<mach_o::trie::Entry> exports; local 491 Binder<A>* binder = *it; local 492 int ordinal = ordinalOfDependentBinder(binder); local 493 const uint8_t* aDylibsExportsStart = binder->fLayout.getDyldInfoExports(); local 494 const uint8_t* aDylibsExportsEnd = &aDylibsExportsStart[binder->fDyldInfo->export_size()]; local 495 std::vector<mach_o::trie::Entry> aDylibsExports; local 499 mach_o::trie::Entry entry = *eit; local 507 std::vector<uint8_t> newExportTrieBytes; local 513 uint32_t newExportsSize = newExportTrieBytes.size(); local 514 uint8_t* sideTrie = new uint8_t[newExportsSize]; local 524 bind(std::vector<void*>& pointersInData) argument 542 void Binder<A>::doSetUpDyldSection() function in class:Binder 545 const macho_load_command<P>* const cmds = (macho_load_command<P>*)((uint8_t*)this->fHeader + sizeof(macho_header<P>)); local 546 const uint32_t cmd_count = this->fHeader->ncmds(); local 547 const macho_load_command<P>* cmd = cmds; local 550 const macho_segment_command<P>* seg = (macho_segment_command<P>*)cmd; local 552 const macho_section<P>* const sectionsStart = (macho_section<P>*)((uint8_t*)seg + sizeof(macho_segment_command<P>)); local 553 const macho_section<P>* const sectionsEnd = §ionsStart[seg->nsects()]; local 557 pint_t* lazyBinder = this->mappedAddressForNewAddress(sect->addr()); local 558 pint_t* dyldFuncLookup = this->mappedAddressForNewAddress(sect->addr()+sizeof(pint_t)); local 570 bindDyldInfoAt(uint8_t segmentIndex, uint64_t segmentOffset, uint8_t type, int libraryOrdinal, int64_t addend, const char* symbolName, bool lazyPointer, bool weakImport, std::vector<void*>& pointersInData) argument 574 const std::vector<MachOLayoutAbstraction::Segment>& segments = this->fLayout.getSegments(); local 590 Binder<A>* binder; local 595 pint_t targetSymbolAddress; local 596 bool isResolverSymbol = false; local 597 bool isAbsolute = false; local 598 Binder<A>* foundIn; local 619 const MachOLayoutAbstraction::Segment& seg = segments[segmentIndex]; local 620 uint8_t* mappedAddr = (uint8_t*)seg.mappedAddress() + segmentOffset; local 621 pint_t* mappedAddrP = (pint_t*)mappedAddr; local 622 uint32_t* mappedAddr32 = (uint32_t*)mappedAddr; local 623 int32_t svalue32new; local 648 doBindDyldLazyInfo(std::vector<void*>& pointersInData) argument 650 const uint8_t* p = &this->fLinkEditBase[fDyldInfo->lazy_bind_off()]; local 651 const uint8_t* end = &p[fDyldInfo->lazy_bind_size()]; local 653 uint8_t type = BIND_TYPE_POINTER; local 654 uint64_t segmentOffset = 0; local 655 uint8_t segmentIndex = 0; local 656 const char* symbolName = NULL; local 657 int libraryOrdinal = 0; local 658 int64_t addend = 0; local 659 bool weakImport = false; local 661 uint8_t immediate = *p & BIND_IMMEDIATE_MASK; local 662 uint8_t opcode = *p & BIND_OPCODE_MASK; local 679 int8_t signExtended = BIND_OPCODE_MASK | immediate; local 715 doBindDyldInfo(std::vector<void*>& pointersInData) argument 717 const uint8_t* p = &this->fLinkEditBase[fDyldInfo->bind_off()]; local 718 const uint8_t* end = &p[fDyldInfo->bind_size()]; local 720 uint8_t type = 0; local 721 uint64_t segmentOffset = 0; local 722 uint8_t segmentIndex = 0; local 723 const char* symbolName = NULL; local 724 int libraryOrdinal = 0; local 725 int64_t addend = 0; local 726 uint32_t count; local 727 uint32_t skip; local 728 bool weakImport = false; local 729 bool done = false; local 731 uint8_t immediate = *p & BIND_IMMEDIATE_MASK; local 732 uint8_t opcode = *p & BIND_OPCODE_MASK; local 749 int8_t signExtended = BIND_OPCODE_MASK | immediate; local 804 void Binder<A>::doSetPreboundUndefines() function in class:Binder 806 const macho_dysymtab_command<P>* dysymtab = NULL; local 807 macho_nlist<P>* symbolTable = NULL; local 810 const macho_load_command<P>* const cmds = (macho_load_command<P>*)((uint8_t*)this->fHeader + sizeof(macho_header<P>)); local 811 const uint32_t cmd_count = this->fHeader->ncmds(); local 812 const macho_load_command<P>* cmd = cmds; local 817 const macho_symtab_command<P>* symtab = (macho_symtab_command<P>*)cmd; local 829 macho_nlist<P>* const lastUndefine = &symbolTable[dysymtab->iundefsym()+dysymtab->nundefsym()]; local 834 pint_t pbaddr = this->resolveUndefined(entry); local 842 void Binder<A>::doBindExternalRelocations() function in class:Binder 847 pint_t firstWritableSegmentBaseAddress = 0; local 848 const std::vector<MachOLayoutAbstraction::Segment>& segments = this->fLayout.getSegments(); local 850 const MachOLayoutAbstraction::Segment& seg = *it; local 858 const macho_relocation_info<P>* const relocsStart = (macho_relocation_info<P>*)(&this->fLinkEditBase[fDynamicInfo->extreloff()]); local 859 const macho_relocation_info<P>* const relocsEnd = &relocsStart[fDynamicInfo->nextrel()]; local 868 const macho_nlist<P>* undefinedSymbol = &fSymbolTable[reloc->r_symbolnum()]; local 869 pint_t* location; local 876 pint_t addend = P::getP(*location); local 888 pint_t symbolAddr = this->resolveUndefined(undefinedSymbol); local 898 bindStub(uint8_t elementSize, uint8_t* location, pint_t vmlocation, pint_t value) argument 905 bindStub(uint8_t elementSize, uint8_t* location, pint_t vmlocation, pint_t value) argument 909 uint32_t rel32 = value - (vmlocation + 5); local 919 void Binder<A>::doBindIndirectSymbols() function in class:Binder 921 const uint32_t* const indirectTable = (uint32_t*)&this->fLinkEditBase[fDynamicInfo->indirectsymoff()]; local 922 const macho_load_command<P>* const cmds = (macho_load_command<P>*)((uint8_t*)this->fHeader + sizeof(macho_header<P>)); local 923 const uint32_t cmd_count = this->fHeader->ncmds(); local 924 const macho_load_command<P>* cmd = cmds; local 928 const macho_segment_command<P>* seg = (macho_segment_command<P>*)cmd; local 929 const macho_section<P>* const sectionsStart = (macho_section<P>*)((uint8_t*)seg + sizeof(macho_segment_command<P>)); local 930 const macho_section<P>* const sectionsEnd = §ionsStart[seg->nsects()]; local 932 uint8_t elementSize = 0; local 933 uint8_t sectionType = sect->flags() & SECTION_TYPE; local 944 uint32_t elementCount = sect->size() / elementSize; local 945 const uint32_t indirectTableOffset = sect->reserved1(); local 946 uint8_t* location = NULL; local 949 pint_t vmlocation = sect->addr(); local 951 uint32_t symbolIndex = E::get32(indirectTable[indirectTableOffset + j]); local 957 const macho_nlist<P>* undefinedSymbol = &fSymbolTable[symbolIndex]; local 959 pint_t symbolAddr = this->resolveUndefined(undefinedSymbol); local 983 resolveUndefined(const macho_nlist<P>* undefinedSymbol) argument 995 const char* symbolName = &fStrings[undefinedSymbol->n_strx()]; local 1001 uint8_t ordinal = GET_LIBRARY_ORDINAL(undefinedSymbol->n_desc()); local 1002 Binder<A>* binder = NULL; local 1015 pint_t addr; local 1016 bool isResolver; local 1017 bool isAbsolute; local 1018 Binder<A>* foundIn; local 1026 findExportedSymbolAddress(const char* name, pint_t* result, Binder<A>** foundIn, bool* isResolverSymbol, bool* isAbsolute) argument 1035 pint_t targetSymbolAddress; local 1036 bool isResolver; local 1037 bool isAb; local 1042 Binder<A>* binder = fDependentDylibs[it->dylibOrdinal-1].binder; local 1063 typename NameToAddrMap::iterator pos = fHashTable.find(name); local 1085 addResolverClient(Binder<A>* clientDylib, const char* symbolName) argument 1087 ClientAndSymbol x; local 1095 findLazyPointerFor(const char* symbolName) argument 1097 static const bool log = false; local 1100 typename NameToAddrMap::iterator pos = fResolverLazyPointers.find(symbolName); local 1107 const uint32_t* const indirectTable = (uint32_t*)&this->fLinkEditBase[fDynamicInfo->indirectsymoff()]; local 1108 const macho_load_command<P>* const cmds = (macho_load_command<P>*)((uint8_t*)this->fHeader + sizeof(macho_header<P>)); local 1109 const uint32_t cmd_count = this->fHeader->ncmds(); local 1110 const macho_load_command<P>* cmd = cmds; local 1113 const macho_segment_command<P>* seg = (macho_segment_command<P>*)cmd; local 1114 const macho_section<P>* const sectionsStart = (macho_section<P>*)((uint8_t*)seg + sizeof(macho_segment_command<P>)); local 1115 const macho_section<P>* const sectionsEnd = §ionsStart[seg->nsects()]; local 1117 uint8_t sectionType = sect->flags() & SECTION_TYPE; local 1119 uint32_t elementCount = sect->size() / sizeof(pint_t); local 1120 const uint32_t indirectTableOffset = sect->reserved1(); local 1121 pint_t vmlocation = sect->addr(); local 1123 uint32_t symbolIndex = E::get32(indirectTable[indirectTableOffset + j]); local 1129 const macho_nlist<P>* aSymbol = &fSymbolTable[symbolIndex]; local 1130 const char* aName = &fStrings[aSymbol->n_strx()]; local 1154 Binder<A>* binder = fDependentDylibs[it->dylibOrdinal-1].binder; local 1161 pint_t result = it->binder->findLazyPointerFor(symbolName); local 1173 void Binder<A>::optimize() function in class:Binder 1176 pint_t lpVMAddr = findLazyPointerFor(it->symbolName); local 1188 optimizeStub(uint8_t* stubMappedAddress, pint_t stubVMAddress, uint32_t stubSize, pint_t lpVMAddr) argument 1194 uint32_t* instructions = (uint32_t*)stubMappedAddress; local 1204 uint32_t betterOffset = lpVMAddr - (stubVMAddress + 12); local 1210 optimizeStub(uint8_t* stubMappedAddress, pint_t stubVMAddress, uint32_t stubSize, pint_t lpVMAddr) argument 1222 uint32_t betterOffset = lpVMAddr - (stubVMAddress + 6); local 1227 optimizeStub(uint8_t* stubMappedAddress, pint_t stubVMAddress, uint32_t stubSize, pint_t lpVMAddress) argument 1235 optimizeStub(const char* stubName, pint_t lpVMAddr) argument 1238 const uint32_t* const indirectTable = (uint32_t*)&this->fLinkEditBase[fDynamicInfo->indirectsymoff()]; local 1239 const macho_load_command<P>* const cmds = (macho_load_command<P>*)((uint8_t*)this->fHeader + sizeof(macho_header<P>)); local 1240 const uint32_t cmd_count = this->fHeader->ncmds(); local 1241 const macho_load_command<P>* cmd = cmds; local 1244 macho_segment_command<P>* seg = (macho_segment_command<P>*)cmd; local 1245 macho_section<P>* const sectionsStart = (macho_section<P>*)((char*)seg + sizeof(macho_segment_command<P>)); local 1246 macho_section<P>* const sectionsEnd = §ionsStart[seg->nsects()]; local 1249 pint_t stubsVMStart = sect->addr(); local 1250 uint8_t* stubsMappingStart = (uint8_t*)this->mappedAddressForNewAddress(stubsVMStart); local 1251 const uint32_t indirectTableOffset = sect->reserved1(); local 1252 const uint32_t stubSize = sect->reserved2(); local 1253 uint32_t elementCount = sect->size() / stubSize; local 1254 pint_t stubVMAddr = stubsVMStart; local 1255 uint8_t* stubMappedAddr = stubsMappingStart; local 1257 uint32_t symbolIndex = E::get32(indirectTable[indirectTableOffset + j]); local 1264 const macho_nlist<P>* sym = &this->fSymbolTable[symbolIndex]; local 1265 const char* symName = &fStrings[sym->n_strx()]; local [all...] |
H A D | MachOFileAbstraction.hpp | 25 #define __MACH_O_FILE_ABSTRACTION__ macro 34 #define LC_UUID macro 35 struct uuid_command { struct 36 uint32_t cmd; /* LC_UUID */ member in struct:uuid_command 37 uint32_t cmdsize; /* sizeof(struct uuid_command) */ member in struct:uuid_command 38 uint8_t uuid[16]; /* the 128-bit uuid */ member in struct:uuid_command 43 #define S_16BYTE_LITERALS macro 47 #define CPU_SUBTYPE_ARM_V5TEJ macro 50 #define CPU_SUBTYPE_ARM_XSCALE macro 53 #define CPU_SUBTYPE_ARM_V7 macro 56 #define CPU_SUBTYPE_ARM_V7F macro 59 #define CPU_SUBTYPE_ARM_V7K macro 62 #define CPU_SUBTYPE_ARM_V7S macro 65 #define CPU_SUBTYPE_ARM64_ALL macro 68 #define CPU_TYPE_ARM64 macro 71 #define ARM64_RELOC_UNSIGNED macro 75 #define LC_LOAD_UPWARD_DYLIB macro 79 #define EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER macro 82 #define EXPORT_SYMBOL_FLAGS_REEXPORT macro 86 #define LC_FUNCTION_STARTS macro 90 #define LC_DATA_IN_CODE macro 94 #define LC_DYLIB_CODE_SIGN_DRS macro 98 #define CPU_SUBTYPE_X86_64_H macro 106 struct ArchPair struct 108 uint32_t arch; member in struct:ArchPair 109 uint32_t subtype; member in struct:ArchPair 111 ArchPair(uint32_t cputype, uint32_t cpusubtype) argument 113 operator <(const ArchPair& other) const argument 129 class macho_load_command { class 137 typedef typename P::E E; typedef in class:macho_load_command 139 load_command command; member in class:macho_load_command 146 template <typename P> struct macho_segment_content {}; struct 147 template <> struct macho_segment_content<Pointer32<BigEndian> > { segment_command fields; enum { CMD = LC_SEGMENT }; }; enumerator in enum:macho_segment_content::__anon11 148 template <> struct macho_segment_content<Pointer64<BigEndian> > { segment_command_64 fields; enum { CMD = LC_SEGMENT_64 }; }; enumerator in enum:macho_segment_content::__anon12 149 template <> struct macho_segment_content<Pointer32<LittleEndian> > { segment_command fields; enum { CMD = LC_SEGMENT }; }; enumerator in enum:macho_segment_content::__anon13 150 template <> struct macho_segment_content<Pointer64<LittleEndian> > { segment_command_64 fields; enum { CMD = LC_SEGMENT_64 }; }; enumerator in enum:macho_segment_content::__anon14 153 class macho_segment_command { class 189 CMD = macho_segment_content<P>::CMD enumerator in enum:macho_segment_command::__anon15 192 typedef typename P::E E; typedef in class:macho_segment_command 194 macho_segment_content<P> segment; member in class:macho_segment_command 201 template <typename P> struct macho_section_content {}; struct 202 template <> struct macho_section_content<Pointer32<BigEndian> > { section fields; }; member in struct:macho_section_content 203 template <> struct macho_section_content<Pointer64<BigEndian> > { section_64 fields; }; member in struct:macho_section_content 204 template <> struct macho_section_content<Pointer32<LittleEndian> > { section fields; }; member in struct:macho_section_content 205 template <> struct macho_section_content<Pointer64<LittleEndian> > { section_64 fields; }; member in struct:macho_section_content 208 class macho_section { class 243 typedef typename P::E E; typedef in class:macho_section 245 macho_section_content<P> section; member in class:macho_section 253 class macho_dylib_command { class 276 typedef typename P::E E; typedef in class:macho_dylib_command 278 dylib_command fields; member in class:macho_dylib_command 286 class macho_dylinker_command { class 300 typedef typename P::E E; typedef in class:macho_dylinker_command 302 dylinker_command fields; member in class:macho_dylinker_command 310 class macho_sub_framework_command { class 324 typedef typename P::E E; typedef in class:macho_sub_framework_command 326 sub_framework_command fields; member in class:macho_sub_framework_command 334 class macho_sub_client_command { class 348 typedef typename P::E E; typedef in class:macho_sub_client_command 350 sub_client_command fields; member in class:macho_sub_client_command 358 class macho_sub_umbrella_command { class 372 typedef typename P::E E; typedef in class:macho_sub_umbrella_command 374 sub_umbrella_command fields; member in class:macho_sub_umbrella_command 382 class macho_sub_library_command { class 396 typedef typename P::E E; typedef in class:macho_sub_library_command 398 sub_library_command fields; member in class:macho_sub_library_command 406 class macho_uuid_command { class 417 typedef typename P::E E; typedef in class:macho_uuid_command 419 uuid_command fields; member in class:macho_uuid_command 426 template <typename P> struct macho_routines_content {}; struct 427 template <> struct macho_routines_content<Pointer32<BigEndian> > { routines_command fields; enum { CMD = LC_ROUTINES }; }; enumerator in enum:macho_routines_content::__anon16 428 template <> struct macho_routines_content<Pointer64<BigEndian> > { routines_command_64 fields; enum { CMD = LC_ROUTINES_64 }; }; enumerator in enum:macho_routines_content::__anon17 429 template <> struct macho_routines_content<Pointer32<LittleEndian> > { routines_command fields; enum { CMD = LC_ROUTINES }; }; enumerator in enum:macho_routines_content::__anon18 430 template <> struct macho_routines_content<Pointer64<LittleEndian> > { routines_command_64 fields; enum { CMD = LC_ROUTINES_64 }; }; enumerator in enum:macho_routines_content::__anon19 433 class macho_routines_command { class 465 typedef typename P::E E; typedef in class:macho_routines_command 467 CMD = macho_routines_content<P>::CMD enumerator in enum:macho_routines_command::__anon20 470 macho_routines_content<P> routines; member in class:macho_routines_command 478 class macho_symtab_command { class 499 typedef typename P::E E; typedef in class:macho_symtab_command 501 symtab_command fields; member in class:macho_symtab_command 509 class macho_dysymtab_command { class 571 typedef typename P::E E; typedef in class:macho_dysymtab_command 573 dysymtab_command fields; member in class:macho_dysymtab_command 581 class macho_twolevel_hints_command { class 595 typedef typename P::E E; typedef in class:macho_twolevel_hints_command 597 twolevel_hints_command fields; member in class:macho_twolevel_hints_command 605 class macho_thread_command { class 622 typedef typename P::E E; typedef in class:macho_thread_command 623 typedef typename P::uint_t pint_t; typedef in class:macho_thread_command 625 struct thread_command fields; member in class:macho_thread_command 626 uint32_t fields_flavor; member in class:macho_thread_command 627 uint32_t fields_count; member in class:macho_thread_command 628 pint_t thread_registers[1]; member in class:macho_thread_command 636 class macho_linkedit_data_command { class 651 typedef typename P::E E; typedef in class:macho_linkedit_data_command 653 linkedit_data_command fields; member in class:macho_linkedit_data_command 660 template <typename P> struct macho_nlist_content {}; struct 661 template <> struct macho_nlist_content<Pointer32<BigEndian> > { struct nlist fields; }; member in struct:macho_nlist_content 662 template <> struct macho_nlist_content<Pointer64<BigEndian> > { struct nlist_64 fields; }; member in struct:macho_nlist_content 663 template <> struct macho_nlist_content<Pointer32<LittleEndian> > { struct nlist fields; }; member in struct:macho_nlist_content 664 template <> struct macho_nlist_content<Pointer64<LittleEndian> > { struct nlist_64 fields; }; member in struct:macho_nlist_content 667 class macho_nlist { class 684 typedef typename P::E E; typedef in class:macho_nlist 686 macho_nlist_content<P> entry; member in class:macho_nlist 695 class macho_relocation_info { class 717 typedef typename P::E E; typedef in class:macho_relocation_info 719 uint32_t address; member in class:macho_relocation_info 720 uint32_t other; member in class:macho_relocation_info 729 class macho_scattered_relocation_info { class 732 void set_r_scattered(bool x) INLINE { uint32_t temp = E::get32(other); BigEndian::setBitsRaw(temp, x, 0, 1); E::set32(other, temp); } variable 735 void set_r_pcrel(bool x) INLINE { uint32_t temp = E::get32(other); BigEndian::setBitsRaw(temp, x, 1, 1); E::set32(other, temp); } variable 738 void set_r_length(uint8_t x) INLINE { uint32_t temp = E::get32(other); BigEndian::setBitsRaw(temp, x, 2, 2); E::set32(other, temp); } variable 741 void set_r_type(uint8_t x) INLINE { uint32_t temp = E::get32(other); BigEndian::setBitsRaw(temp, x, 4, 4); E::set32(other, temp); } variable 744 void set_r_address(uint32_t x) INLINE { uint32_t temp = E::get32(other); BigEndian::setBitsRaw(temp, x, 8, 24); E::set32(other, temp); } variable 751 typedef typename P::E E; typedef in class:macho_scattered_relocation_info 753 uint32_t other; member in class:macho_scattered_relocation_info 754 uint32_t value; member in class:macho_scattered_relocation_info 761 template <typename P> struct macho_header_content {}; struct 762 template <> struct macho_header_content<Pointer32<BigEndian> > { mach_header fields; }; member in struct:macho_header_content 763 template <> struct macho_header_content<Pointer64<BigEndian> > { mach_header_64 fields; }; member in struct:macho_header_content 764 template <> struct macho_header_content<Pointer32<LittleEndian> > { mach_header fields; }; member in struct:macho_header_content 765 template <> struct macho_header_content<Pointer64<LittleEndian> > { mach_header_64 fields; }; member in struct:macho_header_content 768 class macho_header { class 794 getSegment(const char *segname) const argument 796 const macho_load_command<P>* cmds = (macho_load_command<P>*)((uint8_t*)this + sizeof(macho_header<P>)); local 797 uint32_t cmd_count = this->ncmds(); local 798 const macho_load_command<P>* cmd = cmds; local 801 const macho_segment_command<P>* segcmd = (macho_segment_command<P>*)cmd; local 811 getSection(const char *segname, const char *sectname) const argument 813 const macho_segment_command<P>* segcmd = getSegment(segname); local 816 const macho_section<P>* sectcmd = (macho_section<P>*)(segcmd+1); local 817 uint32_t section_count = segcmd->nsects(); local 827 getLoadCommand(int query) const argument 829 const macho_load_command<P>* cmds = (macho_load_command<P>*)((uint8_t*)this + sizeof(macho_header<P>)); local 830 uint32_t cmd_count = this->ncmds(); local 831 const macho_load_command<P>* cmd = cmds; local 841 typedef typename P::E E; typedef in class:macho_header 843 macho_header_content<P> header; member in class:macho_header 852 class macho_dyld_info_command { class 891 typedef typename P::E E; typedef in class:macho_dyld_info_command 893 dyld_info_command fields; member in class:macho_dyld_info_command 897 read_uleb128(const uint8_t*& p, const uint8_t* end) argument 898 uint64_t result = 0; local 899 int bit = 0; local 904 uint64_t slice = *p & 0x7f; local 918 read_sleb128(const uint8_t*& p, const uint8_t* end) argument 920 int64_t result = 0; local 921 int bit = 0; local 922 uint8_t byte; local [all...] |
H A D | MachOLayout.hpp | 26 #define __MACHO_LAYOUT__ macro 53 throwf(const char* format, ...) argument 55 va_list list; local 56 char* p; local 61 const char* t = p; local 66 class MachOLayoutAbstraction class 69 struct Segment struct in class:MachOLayoutAbstraction 72 Segment(uint64_t addr, uint64_t vmsize, uint64_t offset, uint64_t file_size, uint64_t align, uint32_t prot, const char* segName) argument 80 address() const argument 81 size() const argument 82 fileOffset() const argument 83 fileSize() const argument 84 permissions() const argument 85 readable() const argument 86 writable() const argument 87 executable() const argument 88 alignment() const argument 89 name() const argument 90 newAddress() const argument 91 mappedAddress() const argument 92 setNewAddress(uint64_t addr) argument 93 setMappedAddress(void* addr) argument 94 setSize(uint64_t new_size) argument 95 setFileOffset(uint64_t new_off) argument 96 setFileSize(uint64_t new_size) argument 97 setWritable(bool w) argument 98 void reset() { fSize=fOrigSize; fFileOffset=fOrigFileOffset; fFileSize=fOrigFileSize; fPermissions=fOrigPermissions; } function in struct:MachOLayoutAbstraction::Segment 100 uint64_t fOrigAddress; member in struct:MachOLayoutAbstraction::Segment 101 uint64_t fOrigSize; member in struct:MachOLayoutAbstraction::Segment 102 uint64_t fOrigFileOffset; member in struct:MachOLayoutAbstraction::Segment 103 uint64_t fOrigFileSize; member in struct:MachOLayoutAbstraction::Segment 104 uint32_t fOrigPermissions; member in struct:MachOLayoutAbstraction::Segment 105 char fOrigName[16]; member in struct:MachOLayoutAbstraction::Segment 106 uint64_t fSize; member in struct:MachOLayoutAbstraction::Segment 107 uint64_t fFileOffset; member in struct:MachOLayoutAbstraction::Segment 108 uint64_t fFileSize; member in struct:MachOLayoutAbstraction::Segment 109 uint64_t fAlignment; member in struct:MachOLayoutAbstraction::Segment 110 uint32_t fPermissions; member in struct:MachOLayoutAbstraction::Segment 111 uint64_t fNewAddress; member in struct:MachOLayoutAbstraction::Segment 112 void* fMappedAddress; member in struct:MachOLayoutAbstraction::Segment 115 struct Library struct in class:MachOLayoutAbstraction 117 const char* name; member in struct:MachOLayoutAbstraction::Library 118 uint32_t currentVersion; member in struct:MachOLayoutAbstraction::Library 119 uint32_t compatibilityVersion; member in struct:MachOLayoutAbstraction::Library 120 bool weakImport; member in struct:MachOLayoutAbstraction::Library 165 class MachOLayout : public MachOLayoutAbstraction class in inherits:MachOLayoutAbstraction 170 virtual ~MachOLayout() {} function in class:MachOLayout 172 getArchPair() const argument 173 getFilePath() const argument 174 getOffsetInUniversalFile() const argument 175 getFileType() const argument 176 getFlags() const argument 177 getID() const argument 178 isDylib() const argument 180 hasSplitSegInfo() const argument 181 isRootOwned() const argument 182 inSharableLocation() const argument 183 hasDynamicLookupLinkage() const argument 184 hasMainExecutableLookupLinkage() const argument 185 isTwoLevelNamespace() const argument 186 hasDyldInfo() const argument 187 hasMultipleReadWriteSegments() const argument 188 getNameFileOffset() const argument 189 getLastModTime() const argument 190 getInode() const argument 191 virtual std::vector<Segment>& getSegments() { return fSegments; } function in class:MachOLayout 192 getSegments() const argument 194 getLibraries() const argument 195 getBaseAddress() const argument 196 getVMSize() const argument 197 getBaseExecutableAddress() const argument 198 getBaseWritableAddress() const argument 199 getBaseReadOnlyAddress() const argument 200 getExecutableVMSize() const argument 201 getWritableVMSize() const argument 202 getReadOnlyVMSize() const argument 203 getDyldInfoExports() const argument 204 setDyldInfoExports(const uint8_t* newExports) const argument 205 uuid(uuid_t u) const argument 208 typedef typename A::P P; typedef in class:MachOLayout 209 typedef typename A::P::E E; typedef in class:MachOLayout 210 typedef typename A::P::uint_t pint_t; typedef in class:MachOLayout 219 const char* fPath; member in class:MachOLayout 220 uint64_t fOffset; member in class:MachOLayout 221 uint32_t fFileType; member in class:MachOLayout 222 ArchPair fArchPair; member in class:MachOLayout 223 uint32_t fFlags; member in class:MachOLayout 224 std::vector<Segment> fSegments; member in class:MachOLayout 225 std::vector<Library> fLibraries; member in class:MachOLayout 226 const Segment* fLowSegment; member in class:MachOLayout 227 const Segment* fLowExecutableSegment; member in class:MachOLayout 228 const Segment* fLowWritableSegment; member in class:MachOLayout 229 const Segment* fLowReadOnlySegment; member in class:MachOLayout 230 Library fDylibID; member in class:MachOLayout 231 uint32_t fNameFileOffset; member in class:MachOLayout 232 time_t fMTime; member in class:MachOLayout 233 ino_t fInode; member in class:MachOLayout 234 uint64_t fVMSize; member in class:MachOLayout 235 uint64_t fVMExecutableSize; member in class:MachOLayout 236 uint64_t fVMWritablSize; member in class:MachOLayout 237 uint64_t fVMReadOnlySize; member in class:MachOLayout 238 bool fHasSplitSegInfo; member in class:MachOLayout 239 bool fRootOwned; member in class:MachOLayout 240 bool fShareableLocation; member in class:MachOLayout 241 bool fDynamicLookupLinkage; member in class:MachOLayout 242 bool fMainExecutableLookupLinkage; member in class:MachOLayout 243 bool fIsDylib; member in class:MachOLayout 244 bool fHasDyldInfo; member in class:MachOLayout 245 bool fHasTooManyWritableSegments; member in class:MachOLayout 246 mutable const uint8_t* fDyldInfoExports; member in class:MachOLayout 247 uuid_t fUUID; member in class:MachOLayout 252 class UniversalMachOLayout class 256 ~UniversalMachOLayout() {} function in class:UniversalMachOLayout 260 allLayouts() const argument 263 class CStringHash { class in class:UniversalMachOLayout 265 operator ()(const char* __s) const argument 266 size_t __h = 0; local 272 struct CStringEquals { struct in class:UniversalMachOLayout 273 operator ()(const char* left, const char* right) const argument 275 typedef std::unordered_map<const char*, const UniversalMachOLayout*, CStringHash, CStringEquals> PathToNode; typedef in class:UniversalMachOLayout 279 static PathToNode fgLayoutCache; member in class:UniversalMachOLayout 280 const char* fPath; member in class:UniversalMachOLayout 281 std::vector<MachOLayoutAbstraction*> fLayouts; member in class:UniversalMachOLayout 284 UniversalMachOLayout::PathToNode UniversalMachOLayout::fgLayoutCache; member in class:UniversalMachOLayout 289 getSlice(ArchPair ap) const argument 293 const MachOLayoutAbstraction* layout = *it; local 315 find(const char* path, const std::set<ArchPair>* onlyArchs) argument 318 PathToNode::iterator pos = fgLayoutCache.find(path); local 323 const UniversalMachOLayout* result = new UniversalMachOLayout(path, onlyArchs); local 332 requestedSlice(const std::set<ArchPair>* onlyArchs, cpu_type_t cpuType, cpu_subtype_t cpuSubType) argument 338 ArchPair anArch = *it; local 354 UniversalMachOLayout(const char* path, const std::set<ArchPair>* onlyArchs) argument 358 int fd = ::open(path, O_RDONLY, 0); local 360 int err = errno; local 366 struct stat stat_buf; local 371 uint8_t* p = (uint8_t*)::mmap(NULL, stat_buf.st_size, PROT_READ, MAP_FILE | MAP_PRIVATE, fd, 0); local 378 const fat_header* fh = (fat_header*)p; local 379 const mach_header* mh = (mach_header*)p; local 382 const struct fat_arch* slices = (struct fat_arch*)(p + sizeof(struct fat_header)); local 383 const uint32_t sliceCount = OSSwapBigToHostInt32(fh->nfat_arch); local 386 uint32_t fileOffset = OSSwapBigToHostInt32(slices[i].offset); local 454 segmentSize(const macho_segment_command<typename A::P>* segCmd) const argument 458 const macho_section<P>* const sectionsStart = (macho_section<P>*)((uint8_t*)segCmd + sizeof(macho_segment_command<P>)); local 459 const macho_section<P>* const lastSection = §ionsStart[segCmd->nsects()-1]; local 460 uint64_t endSectAddr = lastSection->addr() + lastSection->size(); local 461 uint64_t endSectAddrPage = (endSectAddr + 4095) & (-4096); local 463 uint64_t size = endSectAddrPage - segCmd->vmaddr(); local 474 segmentAlignment(const macho_segment_command<typename A::P>* segCmd) const argument 476 int p2align = 12; local 478 const macho_section<P>* const sectionsStart = (macho_section<P>*)((uint8_t*)segCmd + sizeof(macho_segment_command<P>)); local 479 const macho_section<P>* const sectionsEnd = §ionsStart[segCmd->nsects()-1]; local 489 segmentFileSize(const macho_segment_command<typename A::P>* segCmd) const argument 493 uint64_t endOffset = segCmd->fileoff(); local 494 const macho_section<P>* const sectionsStart = (macho_section<P>*)((uint8_t*)segCmd + sizeof(macho_segment_command<P>)); local 495 const macho_section<P>* const sectionsEnd = §ionsStart[segCmd->nsects()]; local 500 uint64_t size = (endOffset - segCmd->fileoff() + 4095) & (-4096); local 511 MachOLayout(const void* machHeader, uint64_t offset, const char* path, ino_t inode, time_t modTime, uid_t uid) argument 521 const macho_header<P>* mh = (const macho_header<P>*)machHeader; local 541 const macho_dyld_info_command<P>* dyldInfo = NULL; local 542 const macho_symtab_command<P>* symbolTableCmd = NULL; local 543 const macho_dysymtab_command<P>* dynamicSymbolTableCmd = NULL; local 544 const macho_load_command<P>* const cmds = (macho_load_command<P>*)((uint8_t*)mh + sizeof(macho_header<P>)); local 545 const uint32_t cmd_count = mh->ncmds(); local 546 const macho_load_command<P>* cmd = cmds; local 551 macho_dylib_command<P>* dylib = (macho_dylib_command<P>*)cmd; local 564 macho_dylib_command<P>* dylib = (macho_dylib_command<P>*)cmd; local 565 Library lib; local 578 const macho_segment_command<P>* segCmd = (macho_segment_command<P>*)cmd; local 596 const macho_uuid_command<P>* uc = (macho_uuid_command<P>*)cmd; local 612 const Segment* highSegment = NULL; local 614 const Segment& seg = *it; local 643 const macho_nlist<P>* symbolTable = (macho_nlist<P>*)((uint8_t*)machHeader + symbolTableCmd->symoff()); local 644 const uint32_t startUndefs = dynamicSymbolTableCmd->iundefsym(); local 645 const uint32_t endUndefs = startUndefs + dynamicSymbolTableCmd->nundefsym(); local 647 uint8_t ordinal = GET_LIBRARY_ORDINAL(symbolTable[i].n_desc()); local 663 template <> cpu_type_t MachOLayout<x86>::arch() { return CPU_TYPE_I386; } function in class:MachOLayout 664 template <> cpu_type_t MachOLayout<x86_64>::arch() { return CPU_TYPE_X86_64; } function in class:MachOLayout 665 template <> cpu_type_t MachOLayout<arm>::arch() { return CPU_TYPE_ARM; } function in class:MachOLayout 666 template <> cpu_type_t MachOLayout<arm64>::arch() { return CPU_TYPE_ARM64; } function in class:MachOLayout 669 validReadWriteSeg(const Segment& seg) const argument 675 validReadWriteSeg(const Segment& seg) const argument 682 isSplitSeg() const argument 688 isSplitSeg() const argument 694 isSplitSeg() const argument 700 getSegment(const char* name) const argument 703 const Segment& seg = *it; local [all...] |
H A D | MachORebaser.hpp | 26 #define __MACHO_REBASER__ macro 53 class AbstractRebaser class 64 class Rebaser : public AbstractRebaser class in inherits:AbstractRebaser 68 virtual ~Rebaser() {} function in class:Rebaser 76 typedef typename A::P P; typedef in class:Rebaser 77 typedef typename A::P::E E; typedef in class:Rebaser 78 typedef typename A::P::uint_t pint_t; typedef in class:Rebaser 106 const macho_header<P>* fHeader; member in class:Rebaser 107 uint8_t* fLinkEditBase; // add file offset to this to get linkedit content member in class:Rebaser 108 const MachOLayoutAbstraction& fLayout; member in class:Rebaser 110 pint_t fOrignalVMRelocBaseAddress; // add reloc address to this to get original address reloc referred to member in class:Rebaser 111 const macho_symtab_command<P>* fSymbolTable; member in class:Rebaser 112 const macho_dysymtab_command<P>* fDynamicSymbolTable; member in class:Rebaser 113 const macho_dyld_info_command<P>* fDyldInfo; member in class:Rebaser 114 bool fSplittingSegments; member in class:Rebaser 115 bool fOrignalVMRelocBaseAddressValid; member in class:Rebaser 116 pint_t fSkipSplitSegInfoStart; member in class:Rebaser 117 pint_t fSkipSplitSegInfoEnd; member in class:Rebaser 123 Rebaser(const MachOLayoutAbstraction& layout) argument 137 const std::vector<MachOLayoutAbstraction::Segment>& segments = fLayout.getSegments(); local 139 const MachOLayoutAbstraction::Segment& seg = *it; local 149 const macho_load_command<P>* const cmds = (macho_load_command<P>*)((uint8_t*)fHeader + sizeof(macho_header<P>)); local 150 const uint32_t cmd_count = fHeader->ncmds(); local 151 const macho_load_command<P>* cmd = cmds; local 173 getArchitecture() const argument 174 getArchitecture() const argument 175 getArchitecture() const argument 176 getArchitecture() const argument 179 unequalSlides() const argument 181 const std::vector<MachOLayoutAbstraction::Segment>& segments = fLayout.getSegments(); local 182 uint64_t slide = segments[0].newAddress() - segments[0].address(); local 184 const MachOLayoutAbstraction::Segment& seg = *it; local 192 getBaseAddress() const argument 198 getVMSize() const argument 200 uint64_t highestVMAddress = 0; local 201 const std::vector<MachOLayoutAbstraction::Segment>& segments = fLayout.getSegments(); local 203 const MachOLayoutAbstraction::Segment& seg = *it; local 213 rebase(std::vector<void*>& pointersInData) argument 242 adjustSegmentLoadCommand(macho_segment_command<P>* seg) argument 250 adjustSegmentLoadCommand(macho_segment_command<P>* seg) argument 256 void Rebaser<A>::adjustLoadCommands() function in class:Rebaser 258 const macho_load_command<P>* const cmds = (macho_load_command<P>*)((uint8_t*)fHeader + sizeof(macho_header<P>)); local 259 const uint32_t cmd_count = fHeader->ncmds(); local 260 const macho_load_command<P>* cmd = cmds; local 266 macho_dylib_command<P>* dylib = (macho_dylib_command<P>*)cmd; local 276 macho_dylib_command<P>* dylib = (macho_dylib_command<P>*)cmd; local 283 struct macho_routines_command<P>* routines = (struct macho_routines_command<P>*)cmd; local 290 macho_segment_command<P>* seg = (macho_segment_command<P>*)cmd; local 292 pint_t slide = this->getSlideForVMAddress(seg->vmaddr()); local 294 macho_section<P>* const sectionsStart = (macho_section<P>*)((char*)seg + sizeof(macho_segment_command<P>)); local 295 macho_section<P>* const sectionsEnd = §ionsStart[seg->nsects()]; local 307 maskedVMAddress(pint_t vmaddress) argument 313 maskedVMAddress(pint_t vmaddress) argument 320 getSlideForVMAddress(pint_t vmaddress) argument 322 pint_t vmaddr = this->maskedVMAddress(vmaddress); local 323 const std::vector<MachOLayoutAbstraction::Segment>& segments = fLayout.getSegments(); local 325 const MachOLayoutAbstraction::Segment& seg = *it; local 335 mappedAddressForVMAddress(pint_t vmaddress) argument 337 pint_t vmaddr = this->maskedVMAddress(vmaddress); local 338 const std::vector<MachOLayoutAbstraction::Segment>& segments = fLayout.getSegments(); local 340 const MachOLayoutAbstraction::Segment& seg = *it; local 349 mappedAddressForNewAddress(pint_t vmaddress) argument 351 const std::vector<MachOLayoutAbstraction::Segment>& segments = fLayout.getSegments(); local 353 const MachOLayoutAbstraction::Segment& seg = *it; local 362 getSlideForNewAddress(pint_t newAddress) argument 364 const std::vector<MachOLayoutAbstraction::Segment>& segments = fLayout.getSegments(); local 366 const MachOLayoutAbstraction::Segment& seg = *it; local 375 mappedAddressForRelocAddress(pint_t r_address) argument 385 makeNoPicStub(uint8_t* stub, pint_t logicalAddress) argument 387 uint32_t* instructions = (uint32_t*)stub; local 391 uint32_t lazyPtrAddress = instructions[3] + logicalAddress + 12; local 439 void Rebaser<A>::optimzeStubs() function in class:Rebaser 445 void Rebaser<A>::adjustSymbolTable() function in class:Rebaser 447 macho_nlist<P>* symbolTable = (macho_nlist<P>*)(&fLinkEditBase[fSymbolTable->symoff()]); local 450 macho_nlist<P>* lastExport = &symbolTable[fDynamicSymbolTable->iextdefsym()+fDynamicSymbolTable->nextdefsym()]; local 457 macho_nlist<P>* lastLocal = &symbolTable[fDynamicSymbolTable->ilocalsym()+fDynamicSymbolTable->nlocalsym()]; local 465 void Rebaser<A>::adjustExportInfo() function in class:Rebaser 473 const uint8_t* start = fLayout.getDyldInfoExports(); local 474 const uint8_t* end = &start[fDyldInfo->export_size()]; local 475 std::vector<mach_o::trie::Entry> originalExports; local 483 std::vector<mach_o::trie::Entry> newExports; local 485 pint_t baseAddress = this->getBaseAddress(); local 486 pint_t baseAddressSlide = this->getSlideForVMAddress(baseAddress); local 503 std::vector<uint8_t> newExportTrieBytes; local 511 uint32_t newExportsSize = newExportTrieBytes.size(); local 512 uint8_t* sideTrie = new uint8_t[newExportsSize]; local 522 doCodeUpdate(uint8_t kind, uint64_t address, int64_t codeToDataDelta, int64_t codeToImportDelta) argument 526 uint8_t* p = (uint8_t*)mappedAddressForVMAddress(address); local 535 uint32_t* p; local 536 uint32_t instruction; local 537 uint32_t value; local 538 uint64_t value64; local 595 uint32_t i = ((instruction & 0x00000400) >> 10); local 596 uint32_t imm4 = (instruction & 0x0000000F); local 597 uint32_t imm3 = ((instruction & 0x70000000) >> 28); local 598 uint32_t imm8 = ((instruction & 0x00FF0000) >> 16); local 599 uint32_t imm16 = (imm4 << 12) | (i << 11) | (imm3 << 8) | imm8; local 601 uint32_t targetValue = (imm16 << 16) | ((kind & 0xF) << 12); local 602 uint32_t newTargetValue = targetValue + codeToDataDelta; local 604 uint32_t imm4_ = (newTargetValue & 0xF0000000) >> 28; local 605 uint32_t i_ = (newTargetValue & 0x08000000) >> 27; local 606 uint32_t imm3_ = (newTargetValue & 0x07000000) >> 24; local 607 uint32_t imm8_ = (newTargetValue & 0x00FF0000) >> 16; local 609 uint32_t newInstruction = (instruction & 0x8F00FBF0) | imm4_ | (i_ << 10) | (imm3_ << 28) | (imm8_ << 16); local 634 uint32_t imm4 = ((instruction & 0x000F0000) >> 16); local 635 uint32_t imm12 = (instruction & 0x00000FFF); local 636 uint32_t imm16 = (imm4 << 12) | imm12; local 638 uint32_t targetValue = (imm16 << 16) | ((kind & 0xF) << 12); local 639 uint32_t newTargetValue = targetValue + codeToDataDelta; local 641 uint32_t imm4_ = (newTargetValue & 0xF0000000) >> 28; local 642 uint32_t imm12_ = (newTargetValue & 0x0FFF0000) >> 16; local 644 uint32_t newInstruction = (instruction & 0xFFF0F000) | (imm4_ << 16) | imm12_; local 665 doCodeUpdateForEachULEB128Address(const uint8_t* p, uint8_t kind, uint64_t orgBaseAddress, int64_t codeToDataDelta, int64_t codeToImportDelta) argument 667 uint64_t address = 0; local 668 uint64_t delta = 0; local 669 uint32_t shift = 0; local 670 bool more = true; local 672 uint8_t byte = *p++; local 691 void Rebaser<A>::adjustCode() function in class:Rebaser 695 const uint8_t* infoStart = NULL; local 696 const uint8_t* infoEnd = NULL; local 697 const macho_segment_command<P>* seg; local 698 const macho_load_command<P>* const cmds = (macho_load_command<P>*)((uint8_t*)fHeader + sizeof(macho_header<P>)); local 699 const uint32_t cmd_count = fHeader->ncmds(); local 700 const macho_load_command<P>* cmd = cmds; local 705 const macho_linkedit_data_command<P>* segInfo = (macho_linkedit_data_command<P>*)cmd; local 714 const macho_section<P>* const sectionsStart = (macho_section<P>*)((char*)seg + sizeof(macho_segment_command<P>)); local 715 const macho_section<P>* const sectionsEnd = §ionsStart[seg->nsects()]; local 729 const uint64_t orgBaseAddress = this->getBaseAddress(); local 730 int64_t codeToDataDelta = 0; local 731 int64_t codeToImportDelta = 0; local 732 const std::vector<MachOLayoutAbstraction::Segment>& segments = fLayout.getSegments(); local 733 const MachOLayoutAbstraction::Segment& codeSeg = segments[0]; local 735 const MachOLayoutAbstraction::Segment& dataSeg = *it; local 746 uint8_t kind = *p++; local 753 doRebase(int segIndex, uint64_t segOffset, uint8_t type, std::vector<void*>& pointersInData) argument 755 const std::vector<MachOLayoutAbstraction::Segment>& segments = fLayout.getSegments(); local 758 const MachOLayoutAbstraction::Segment& seg = segments[segIndex]; local 759 uint8_t* mappedAddr = (uint8_t*)seg.mappedAddress() + segOffset; local 760 pint_t* mappedAddrP = (pint_t*)mappedAddr; local 761 uint32_t* mappedAddr32 = (uint32_t*)mappedAddr; local 762 pint_t valueP; local 763 pint_t valuePnew; local 764 uint32_t value32; local 765 int32_t svalue32; local 766 int32_t svalue32new; local 800 applyRebaseInfo(std::vector<void*>& pointersInData) argument 802 const uint8_t* p = &fLinkEditBase[fDyldInfo->rebase_off()]; local 803 const uint8_t* end = &p[fDyldInfo->rebase_size()]; local 805 uint8_t type = 0; local 806 int segIndex; local 807 uint64_t segOffset = 0; local 808 uint32_t count; local 809 uint32_t skip; local 810 bool done = false; local 812 uint8_t immediate = *p & REBASE_IMMEDIATE_MASK; local 813 uint8_t opcode = *p & REBASE_OPCODE_MASK; local 864 void Rebaser<A>::adjustDATA() function in class:Rebaser 867 const macho_relocation_info<P>* const relocsStart = (macho_relocation_info<P>*)(&fLinkEditBase[fDynamicSymbolTable->locreloff()]); local 868 const macho_relocation_info<P>* const relocsEnd = &relocsStart[fDynamicSymbolTable->nlocrel()]; local 874 const macho_load_command<P>* const cmds = (macho_load_command<P>*)((uint8_t*)fHeader + sizeof(macho_header<P>)); local 875 const uint32_t cmd_count = fHeader->ncmds(); local 876 const macho_load_command<P>* cmd = cmds; local 879 const macho_segment_command<P>* seg = (macho_segment_command<P>*)cmd; local 880 const macho_section<P>* const sectionsStart = (macho_section<P>*)((char*)seg + sizeof(macho_segment_command<P>)); local 881 const macho_section<P>* const sectionsEnd = §ionsStart[seg->nsects()]; local 882 const uint32_t* const indirectTable = (uint32_t*)(&fLinkEditBase[fDynamicSymbolTable->indirectsymoff()]); local 885 const uint32_t indirectTableOffset = sect->reserved1(); local 886 uint32_t pointerCount = sect->size() / sizeof(pint_t); local 887 pint_t* nonLazyPointerAddr = this->mappedAddressForVMAddress(sect->addr()); local 890 pint_t value = A::P::getP(*nonLazyPointerAddr); local 903 void Rebaser<A>::adjustRelocBaseAddresses() function in class:Rebaser 909 int32_t relocAddressAdjust = 0; local 910 const std::vector<MachOLayoutAbstraction::Segment>& segments = fLayout.getSegments(); local 912 const MachOLayoutAbstraction::Segment& seg = *it; local 920 macho_relocation_info<P>* const relocsStart = (macho_relocation_info<P>*)(&fLinkEditBase[fDynamicSymbolTable->locreloff()]); local 921 macho_relocation_info<P>* const relocsEnd = &relocsStart[fDynamicSymbolTable->nlocrel()]; local 927 macho_relocation_info<P>* const externRelocsStart = (macho_relocation_info<P>*)(&fLinkEditBase[fDynamicSymbolTable->extreloff()]); local 928 macho_relocation_info<P>* const externRelocsEnd = &externRelocsStart[fDynamicSymbolTable->nextrel()]; local 936 void Rebaser<x86_64>::adjustRelocBaseAddresses() function in class:Rebaser 943 doLocalRelocation(const macho_relocation_info<x86_64::P>* reloc) argument 946 pint_t* addr = this->mappedAddressForRelocAddress(reloc->r_address()); local 947 pint_t value = P::getP(*addr); local 956 doLocalRelocation(const macho_relocation_info<P>* reloc) argument 960 pint_t* addr = this->mappedAddressForRelocAddress(reloc->r_address()); local 961 pint_t value = P::getP(*addr); local 966 macho_scattered_relocation_info<P>* sreloc = (macho_scattered_relocation_info<P>*)reloc; local 977 doLocalRelocation(const macho_relocation_info<P>* reloc) argument 981 pint_t* addr = this->mappedAddressForRelocAddress(reloc->r_address()); local 982 pint_t value = P::getP(*addr); local 993 void Rebaser<A>::calculateRelocBase() function in class:Rebaser 995 const std::vector<MachOLayoutAbstraction::Segment>& segments = fLayout.getSegments(); local 999 const MachOLayoutAbstraction::Segment& seg = *it; local 1016 void Rebaser<x86_64>::calculateRelocBase() function in class:Rebaser 1019 const std::vector<MachOLayoutAbstraction::Segment>& segments = fLayout.getSegments(); local 1021 const MachOLayoutAbstraction::Segment& seg = *it; local [all...] |
H A D | MachOTrie.hpp | 25 #define __MACH_O_TRIE__ macro 33 namespace mach_o { namespace 34 namespace trie { namespace in namespace:mach_o 36 struct Edge struct in namespace:mach_o::trie 38 Edge(const char* s, struct Node* n) argument 39 ~Edge() { } function in struct:mach_o::trie::Edge 40 const char* fSubString; member in struct:mach_o::trie::Edge 41 struct Node* fChild; member in struct:mach_o::trie::Edge 45 struct Node struct in namespace:mach_o::trie 47 Node(const char* s) argument 50 ~Node() { } function in struct:mach_o::trie::Node 51 const char* fCummulativeString; member in struct:mach_o::trie::Node 52 std::vector<Edge> fChildren; member in struct:mach_o::trie::Node 53 uint64_t fAddress; member in struct:mach_o::trie::Node 54 uint64_t fFlags; member in struct:mach_o::trie::Node 55 uint64_t fOther; member in struct:mach_o::trie::Node 56 const char* fImportedName; member in struct:mach_o::trie::Node 57 bool fOrdered; member in struct:mach_o::trie::Node 58 bool fHaveExportInfo; member in struct:mach_o::trie::Node 59 uint32_t fTrieOffset; member in struct:mach_o::trie::Node 61 addSymbol(const char* fullStr, uint64_t address, uint64_t flags, uint64_t other, const char* importName) argument 62 const char* partialStr = &fullStr[strlen(fCummulativeString)]; local 64 Edge& e = *it; local 65 int subStringLen = strlen(e.fSubString); local 76 char* bNodeCummStr = strdup(e.fChild->fCummulativeString); local 79 Node* bNode = new Node(bNodeCummStr); local 80 Node* cNode = e.fChild; local 81 char* abEdgeStr = strdup(e.fSubString); local 83 char* bcEdgeStr = strdup(&e.fSubString[i]); local 84 Edge& abEdge = e; local 97 Node* newNode = new Node(strdup(fullStr)); local 98 Edge newEdge(strdup(partialStr), newNode); local 110 addOrderedNodes(const char* name, std::vector<Node*>& orderedNodes) argument 116 const char* partialStr = &name[strlen(fCummulativeString)]; local 118 Edge& e = *it; local 119 int subStringLen = strlen(e.fSubString); local 132 updateOffset(uint32_t& offset) argument 133 uint32_t nodeSize = 1; // length of export info when no export info local 152 Edge& e = *it; local 155 bool result = (fTrieOffset != offset); local 163 appendToStream(std::vector<uint8_t>& out) argument 168 uint32_t nodeSize = uleb128_size(fFlags) + uleb128_size(fOther) + strlen(fImportedName) + 1; local 176 uint32_t nodeSize = uleb128_size(fFlags) + uleb128_size(fOther) + 1; local 185 uint32_t nodeSize = uleb128_size(fFlags) + uleb128_size(fAddress) + uleb128_size(fOther); local 193 uint32_t nodeSize = uleb128_size(fFlags) + uleb128_size(fAddress); local 207 Edge& e = *it; local 214 append_uleb128(uint64_t value, std::vector<uint8_t>& out) argument 215 uint8_t byte; local 226 append_string(const char* str, std::vector<uint8_t>& out) argument 232 uleb128_size(uint64_t value) argument 233 uint32_t result = 0; local 244 read_uleb128(const uint8_t*& p, const uint8_t* end) argument 245 uint64_t result = 0; local 246 int bit = 0; local 254 uint64_t slice = *p & 0x7f; local 273 struct Entry struct in namespace:mach_o::trie 275 const char* name; member in struct:mach_o::trie::Entry 276 uint64_t address; member in struct:mach_o::trie::Entry 277 uint64_t flags; member in struct:mach_o::trie::Entry 278 uint64_t other; member in struct:mach_o::trie::Entry 279 const char* importName; member in struct:mach_o::trie::Entry 284 makeTrie(const std::vector<Entry>& entries, std::vector<uint8_t>& output) argument 294 std::vector<Node*> orderedNodes; local 301 bool more; local 303 uint32_t offset = 0; local 317 struct EntryWithOffset struct in namespace:mach_o::trie 319 uintptr_t nodeOffset; member in struct:mach_o::trie::EntryWithOffset 320 Entry entry; member in struct:mach_o::trie::EntryWithOffset 322 operator <(const EntryWithOffset& other) const argument 327 processExportNode(const uint8_t* const start, const uint8_t* p, const uint8_t* const end, char* cummulativeString, int curStrOffset, std::vector<EntryWithOffset>& output) argument 337 const uint8_t terminalSize = read_uleb128(p, end); local 338 const uint8_t* children = p + terminalSize; local 340 EntryWithOffset e; local 359 const uint8_t childrenCount = *children++; local 360 const uint8_t* s = children; local 362 int edgeStrLen = 0; local 368 uint32_t childNodeOffet = read_uleb128(s, end); local 374 parseTrie(const uint8_t* start, const uint8_t* end, std::vector<Entry>& output) argument 379 char cummulativeString[4000]; local 380 std::vector<EntryWithOffset> entries; local [all...] |
H A D | ObjCLegacyAbstraction.hpp | 25 #define OBJC_IMAGE_SUPPORTS_GC macro 26 #define OBJC_IMAGE_REQUIRES_GC macro 29 struct objc_image_info { struct 30 uint32_t version; member in struct:objc_image_info 31 uint32_t flags; member in struct:objc_image_info 38 void setFlag(uint32_t bits) INLINE { uint32_t old = A::P::E::get32(flags); A::P::E::set32(flags, old | bits); } variable 43 struct objc_method { struct 44 uint32_t method_name; // SEL member in struct:objc_method 45 uint32_t method_types; // char * member in struct:objc_method 46 uint32_t method_imp; // IMP member in struct:objc_method 53 struct objc_method_list { struct 54 enum { OBJC_FIXED_UP = 1771 }; enumerator in enum:objc_method_list::__anon21 55 uint32_t obsolete; // struct objc_method_list * member in struct:objc_method_list 56 uint32_t method_count; // int member in struct:objc_method_list 57 struct objc_method<A> method_list[0]; member in struct:objc_method_list 64 struct objc_class { struct 65 uint32_t isa; // struct objc_class * member in struct:objc_class 66 uint32_t super_class; // struct objc_class * member in struct:objc_class 67 uint32_t name; // const char * member in struct:objc_class 68 uint32_t version; // long member in struct:objc_class 69 uint32_t info; // long member in struct:objc_class 70 uint32_t instance_size; // long member in struct:objc_class 71 uint32_t ivars; // struct objc_ivar_list * member in struct:objc_class 72 uint32_t methodList; // struct objc_method_list * member in struct:objc_class 73 uint32_t method_cache; // struct objc_cache * member in struct:objc_class 74 uint32_t protocols; // objc_protocol_list * member in struct:objc_class 75 uint32_t ivar_layout; // const char * member in struct:objc_class 76 uint32_t ext; // struct objc_class_ext * member in struct:objc_class 83 struct objc_category { struct 84 uint32_t category_name; // char * member in struct:objc_category 85 uint32_t class_name; // char * member in struct:objc_category 86 uint32_t instance_methods; // struct objc_method_list * member in struct:objc_category 87 uint32_t class_methods; // struct objc_method_list * member in struct:objc_category 88 uint32_t protocols; // objc_protocol_list * member in struct:objc_category 89 uint32_t size; // uint32_t member in struct:objc_category 90 uint32_t instance_properties; // struct objc_property_list * member in struct:objc_category 97 struct objc_symtab { struct 98 uint32_t sel_ref_cnt; // unsigned long member in struct:objc_symtab 99 uint32_t refs; // SEL * member in struct:objc_symtab 100 uint16_t cls_def_cnt; // unsigned short member in struct:objc_symtab 101 uint16_t cat_def_cnt; // unsigned short member in struct:objc_symtab 102 uint32_t defs[0]; // void * member in struct:objc_symtab 111 struct objc_module { struct 112 uint32_t version; // unsigned long member in struct:objc_module 113 uint32_t size; // unsigned long member in struct:objc_module 114 uint32_t name; // char* member in struct:objc_module 115 uint32_t symtab; // Symtab member in struct:objc_module 121 struct objc_method_description { struct 122 uint32_t name; // SEL member in struct:objc_method_description 123 uint32_t types; // char * member in struct:objc_method_description 130 struct objc_method_description_list { struct 131 uint32_t count; // int member in struct:objc_method_description_list 132 struct objc_method_description<A> list[0]; member in struct:objc_method_description_list 138 struct objc_protocol { struct 139 uint32_t isa; // danger! contains strange values! member in struct:objc_protocol 140 uint32_t protocol_name; // const char * member in struct:objc_protocol 141 uint32_t protocol_list; // struct objc_protocol_list member in struct:objc_protocol 142 uint32_t instance_methods; // struct objc_method_description_list * member in struct:objc_protocol 143 uint32_t class_methods; // struct objc_method_description_list * member in struct:objc_protocol 151 class LegacySelectorUpdater { class 153 typedef typename A::P P; typedef in class:LegacySelectorUpdater 155 visitMethodList(objc_method_list<A> *mlist, V& visitor) argument 158 uint64_t oldValue = mlist->method_list[m].getName(); local 159 uint64_t newValue = visitor.visit(oldValue); local 165 visitMethodDescriptionList(objc_method_description_list<A> *mlist, V& visitor) argument 168 uint64_t oldValue = mlist->list[m].getName(); local 169 uint64_t newValue = visitor.visit(oldValue); local 176 update(SharedCache<A>* cache, const macho_header<P>* header, V& visitor) argument 182 objc_symtab<A> *symtab = modules.get(m).getSymtab(cache); local 187 objc_class<A> *cls = symtab->getClass(cache, c); local 188 objc_class<A> *isa = cls->getIsa(cache); local 189 objc_method_list<A> *mlist; local 200 objc_category<A> *cat = symtab->getCategory(cache, c); local 201 objc_method_list<A> *mlist; local 215 objc_protocol<A>& protocol = protocols.get(p); local 216 objc_method_description_list<A> *mlist; local 228 uint64_t oldValue = selrefs.getUnmapped(s); local 229 uint64_t newValue = visitor.visit(oldValue); local [all...] |
H A D | ObjCModernAbstraction.hpp | 32 struct entsize_iterator { struct 33 uint32_t entsize; member in struct:entsize_iterator 34 uint32_t index; // keeping track of this saves a divide in operator- member in struct:entsize_iterator 35 T* current; member in struct:entsize_iterator 37 typedef std::random_access_iterator_tag iterator_category; typedef in struct:entsize_iterator 38 typedef T value_type; typedef in struct:entsize_iterator 39 typedef ptrdiff_t difference_type; typedef in struct:entsize_iterator 40 typedef T* pointer; typedef in struct:entsize_iterator 41 typedef T& reference; typedef in struct:entsize_iterator 43 entsize_iterator() { } function in struct:entsize_iterator 45 entsize_iterator(const Tlist& list, uint32_t start = 0) argument 49 operator +=(ptrdiff_t count) argument 54 operator -=(ptrdiff_t count) argument 59 operator +(ptrdiff_t count) const argument 62 operator -(ptrdiff_t count) const argument 66 entsize_iterator<A,T,Tlist>& operator ++ () { *this += 1; return *this; } function in struct:entsize_iterator 67 entsize_iterator<A,T,Tlist>& operator -- () { *this -= 1; return *this; } function in struct:entsize_iterator 68 entsize_iterator<A,T,Tlist> operator ++ (int) { function in struct:entsize_iterator 71 entsize_iterator<A,T,Tlist> operator -- (int) { function in struct:entsize_iterator 75 operator -(const entsize_iterator<A,T,Tlist>& rhs) const argument 79 T& operator * () { return *current; } function in struct:entsize_iterator 80 operator *() const argument 81 T& operator -> () { return *current; } function in struct:entsize_iterator 82 operator ->() const argument 84 operator T&() const argument 86 operator ==(const entsize_iterator<A,T,Tlist>& rhs) argument 89 operator !=(const entsize_iterator<A,T,Tlist>& rhs) argument 93 operator <(const entsize_iterator<A,T,Tlist>& rhs) argument 96 operator >(const entsize_iterator<A,T,Tlist>& rhs) argument 101 overwrite(entsize_iterator<A,T,Tlist>& dst, const Tlist* srcList) argument 103 entsize_iterator<A,T,Tlist> src; local 104 uint32_t ee = srcList->getEntsize(); local 113 class objc_header_info_t { class 115 typedef typename A::P P; typedef in class:objc_header_info_t 116 typedef typename A::P::uint_t pint_t; typedef in class:objc_header_info_t 118 pint_t next; // objc_header_info * member in class:objc_header_info_t 119 pint_t mhdr; // mach_header or mach_header_64 member in class:objc_header_info_t 120 pint_t info; // objc_image_info * member in class:objc_header_info_t 121 pint_t fname; // const char * member in class:objc_header_info_t 122 bool loaded; member in class:objc_header_info_t 123 bool inSharedCache; member in class:objc_header_info_t 124 bool allClassesRealized; member in class:objc_header_info_t 127 objc_header_info_t(SharedCache<A>* cache, const macho_header<P>* mh) argument 136 const macho_section<P>* sect = mh->getSection("__DATA", "__objc_imageinfo"); local 142 addPointers(std::vector<void*>& pointersToAdd) argument 147 header_vmaddr() const argument 153 class objc_method_t { class 154 typename A::P::uint_t name; // SEL member in class:objc_method_t 155 typename A::P::uint_t types; // const char * member in class:objc_method_t 156 typename A::P::uint_t imp; // IMP member in class:objc_method_t 159 getName() const argument 160 setName(typename A::P::uint_t newName) argument 162 struct SortBySELAddress : struct in class:objc_method_t 166 operator ()(const objc_method_t<A>& lhs, const objc_method_t<A>& rhs) argument 175 class objc_method_list_t { class 176 uint32_t entsize; member in class:objc_method_list_t 177 uint32_t count; member in class:objc_method_list_t 178 objc_method_t<A> first; member in class:objc_method_list_t 180 operator new(size_t, void* buf) argument 184 typedef entsize_iterator< A, objc_method_t<A>, objc_method_list_t<A> > method_iterator; typedef in class:objc_method_list_t 186 getCount() const argument 188 getEntsize() const argument 190 get(uint32_t i) const argument 192 byteSize() const argument 196 byteSizeForCount(uint32_t c, uint32_t e = sizeof(objc_method_t<A>)) argument 200 method_iterator begin() { return method_iterator(*this, 0); } function in class:objc_method_list_t 201 method_iterator end() { return method_iterator(*this, getCount()); } function in class:objc_method_list_t 202 begin() const argument 203 end() const argument 205 void setFixedUp() { A::P::E::set32(entsize, getEntsize() | 3); } function in class:objc_method_list_t 207 getPointers(std::set<void*>& pointersToRemove) argument 209 objc_method_t<A>& entry = *it; local 216 addPointers(uint8_t* methodList, std::vector<void*>& pointersToAdd) argument 217 objc_method_list_t<A>* mlist = (objc_method_list_t<A>*)methodList; local 219 objc_method_t<A>& entry = *it; local 226 newMethodList(size_t newCount, uint32_t newEntsize) argument 227 void *buf = ::calloc(byteSizeForCount(newCount, newEntsize), 1); local 231 operator delete(void * p) argument 235 objc_method_list_t(uint32_t newCount, uint32_t newEntsize = sizeof(objc_method_t<A>)) argument 249 class objc_ivar_offset_t { class 250 typedef typename A::P::uint_t pint_t; typedef in class:objc_ivar_offset_t 251 typename A::P::uint_t ptr; // uint32_t * member in class:objc_ivar_offset_t 253 offset(SharedCache<A> *cache) const argument 256 hasOffset() const argument 257 getOffset(SharedCache<A> *cache) const argument 258 void setOffset(SharedCache<A> *cache, pint_t newOffset) { A::P::E::set32(offset(cache), newOffset); } local 262 class objc_ivar_offset_t<x86_64> { class 263 typedef x86_64 A; typedef in class:objc_ivar_offset_t 264 typedef typename A::P::uint_t pint_t; typedef in class:objc_ivar_offset_t 265 typename A::P::uint_t ptr; // uint64_t * member in class:objc_ivar_offset_t 267 offset(SharedCache<A> *cache) const argument 270 hasOffset() const argument 271 getOffset(SharedCache<A> *cache) const argument 272 void setOffset(SharedCache<A> *cache, pint_t newOffset) { A::P::E::set64(offset(cache), newOffset); } local 276 class objc_ivar_t { class 277 typedef typename A::P::uint_t pint_t; typedef in class:objc_ivar_t 278 objc_ivar_offset_t<A> offset; // uint32_t * (uint64_t * on x86_64) member in class:objc_ivar_t 279 typename A::P::uint_t name; // const char * member in class:objc_ivar_t 280 typename A::P::uint_t type; // const char * member in class:objc_ivar_t 281 uint32_t alignment; member in class:objc_ivar_t 282 uint32_t size; member in class:objc_ivar_t 285 getName(SharedCache<A> *cache) const argument 287 hasOffset() const argument 288 getOffset(SharedCache<A> *cache) const argument 289 setOffset(SharedCache<A> *cache, pint_t newOffset) argument 291 uint32_t getAlignment() function in class:objc_ivar_t 293 uint32_t a = A::P::E::get32(alignment); local 299 class objc_ivar_list_t { class 300 typedef typename A::P::uint_t pint_t; typedef in class:objc_ivar_list_t 301 uint32_t entsize; member in class:objc_ivar_list_t 302 uint32_t count; member in class:objc_ivar_list_t 303 objc_ivar_t<A> first; member in class:objc_ivar_list_t 305 operator new(size_t, void* buf) argument 309 typedef entsize_iterator< A, objc_ivar_t<A>, objc_ivar_list_t<A> > ivar_iterator; typedef in class:objc_ivar_list_t 311 getCount() const argument 313 getEntsize() const argument 315 get(pint_t i) const argument 317 byteSize() const argument 321 byteSizeForCount(uint32_t c, uint32_t e = sizeof(objc_ivar_t<A>)) argument 325 ivar_iterator begin() { return ivar_iterator(*this, 0); } function in class:objc_ivar_list_t 326 ivar_iterator end() { return ivar_iterator(*this, getCount()); } function in class:objc_ivar_list_t 327 begin() const argument 328 end() const argument 330 newIvarList(size_t newCount, uint32_t newEntsize) argument 331 void *buf = ::calloc(byteSizeForCount(newCount, newEntsize), 1); local 335 operator delete(void * p) argument 339 objc_ivar_list_t(uint32_t newCount, uint32_t newEntsize = sizeof(objc_ivar_t<A>)) argument 352 class objc_property_t { class 353 typename A::P::uint_t name; member in class:objc_property_t 354 typename A::P::uint_t attributes; member in class:objc_property_t 358 getName(SharedCache<A>* cache) const argument 360 getAttributes(SharedCache<A>* cache) const argument 364 class objc_property_list_t { class 365 uint32_t entsize; member in class:objc_property_list_t 366 uint32_t count; member in class:objc_property_list_t 367 objc_property_t<A> first; member in class:objc_property_list_t 369 operator new(size_t, void* buf) argument 373 typedef entsize_iterator< A, objc_property_t<A>, objc_property_list_t<A> > property_iterator; typedef in class:objc_property_list_t 375 getCount() const argument 377 getEntsize() const argument 379 get(uint32_t i) const argument 381 byteSize() const argument 385 byteSizeForCount(uint32_t c, uint32_t e = sizeof(objc_property_t<A>)) argument 389 property_iterator begin() { return property_iterator(*this, 0); } function in class:objc_property_list_t 390 property_iterator end() { return property_iterator(*this, getCount()); } function in class:objc_property_list_t 391 begin() const argument 392 end() const argument 394 getPointers(std::set<void*>& pointersToRemove) argument 396 objc_property_t<A>& entry = *it; local 402 addPointers(uint8_t* propertyList, std::vector<void*>& pointersToAdd) argument 403 objc_property_list_t<A>* plist = (objc_property_list_t<A>*)propertyList; local 405 objc_property_t<A>& entry = *it; local 411 newPropertyList(size_t newCount, uint32_t newEntsize) argument 412 void *buf = ::calloc(byteSizeForCount(newCount, newEntsize), 1); local 416 operator delete(void * p) argument 420 objc_property_list_t(uint32_t newCount, uint32_t newEntsize = sizeof(objc_property_t<A>)) argument 430 class objc_protocol_t { class 431 typename A::P::uint_t isa; member in class:objc_protocol_t 432 typename A::P::uint_t name; member in class:objc_protocol_t 433 typename A::P::uint_t protocols; member in class:objc_protocol_t 434 typename A::P::uint_t instanceMethods; member in class:objc_protocol_t 435 typename A::P::uint_t classMethods; member in class:objc_protocol_t 436 typename A::P::uint_t optionalInstanceMethods; member in class:objc_protocol_t 437 typename A::P::uint_t optionalClassMethods; member in class:objc_protocol_t 438 typename A::P::uint_t instanceProperties; member in class:objc_protocol_t 441 getInstanceMethods(SharedCache<A>* cache) const argument 443 getClassMethods(SharedCache<A>* cache) const argument 445 getOptionalInstanceMethods(SharedCache<A>* cache) const argument 447 getOptionalClassMethods(SharedCache<A>* cache) const argument 452 class objc_protocol_list_t { class 453 typedef typename A::P::uint_t pint_t; typedef in class:objc_protocol_list_t 454 pint_t count; member in class:objc_protocol_list_t 455 pint_t list[0]; member in class:objc_protocol_list_t 457 operator new(size_t, void* buf) argument 461 getCount() const argument 463 get(SharedCache<A>* cache, pint_t i) argument 467 overwrite(pint_t& index, const objc_protocol_list_t<A>* src) argument 468 pint_t srcCount = src->getCount(); local 473 byteSize() const argument 476 byteSizeForCount(pint_t c) argument 480 getPointers(std::set<void*>& pointersToRemove) argument 486 addPointers(uint8_t* protocolList, std::vector<void*>& pointersToAdd) argument 487 objc_protocol_list_t<A>* plist = (objc_protocol_list_t<A>*)protocolList; local 493 newProtocolList(pint_t newCount) argument 494 void *buf = ::calloc(byteSizeForCount(newCount), 1); local 498 operator delete(void * p) argument 502 objc_protocol_list_t(uint32_t newCount) argument 510 class objc_class_data_t { class 511 uint32_t flags; member in class:objc_class_data_t 512 uint32_t instanceStart; member in class:objc_class_data_t 517 uint32_t instanceSize; member in union:objc_class_data_t::__anon22 518 typename A::P::uint_t pad; member in union:objc_class_data_t::__anon22 519 } instanceSize; member in class:objc_class_data_t 520 typename A::P::uint_t ivarLayout; member in class:objc_class_data_t 521 typename A::P::uint_t name; member in class:objc_class_data_t 522 typename A::P::uint_t baseMethods; member in class:objc_class_data_t 523 typename A::P::uint_t baseProtocols; member in class:objc_class_data_t 524 typename A::P::uint_t ivars; member in class:objc_class_data_t 525 typename A::P::uint_t weakIvarLayout; member in class:objc_class_data_t 526 typename A::P::uint_t baseProperties; member in class:objc_class_data_t 529 bool isMetaClass() { return A::P::E::get32(flags) & 1; } function in class:objc_class_data_t 531 uint32_t getInstanceStart() { return A::P::E::get32(instanceStart); } function in class:objc_class_data_t 532 setInstanceStart(uint32_t newStart) argument 534 uint32_t getInstanceSize() { return A::P::E::get32(instanceSize.instanceSize); } function in class:objc_class_data_t 535 setInstanceSize(uint32_t newSiz) argument 537 getMethodList(SharedCache<A>* cache) const argument 539 getProtocolList(SharedCache<A>* cache) const argument 541 getIvarList(SharedCache<A>* cache) const argument 543 getPropertyList(SharedCache<A>* cache) const argument 545 getName(SharedCache<A>* cache) const argument 547 setMethodList(SharedCache<A>* cache, objc_method_list_t<A>* mlist) argument 551 setProtocolList(SharedCache<A>* cache, objc_protocol_list_t<A>* protolist) argument 555 setPropertyList(SharedCache<A>* cache, objc_property_list_t<A>* proplist) argument 559 addMethodListPointer(std::vector<void*>& pointersToAdd) argument 563 addPropertyListPointer(std::vector<void*>& pointersToAdd) argument 567 addProtocolListPointer(std::vector<void*>& pointersToAdd) argument 573 class objc_class_t { class 574 typename A::P::uint_t isa; member in class:objc_class_t 575 typename A::P::uint_t superclass; member in class:objc_class_t 576 typename A::P::uint_t method_cache; member in class:objc_class_t 577 typename A::P::uint_t vtable; member in class:objc_class_t 578 typename A::P::uint_t data; member in class:objc_class_t 581 isMetaClass(SharedCache<A>* cache) const argument 583 getIsa(SharedCache<A> *cache) const argument 585 getSuperclass(SharedCache<A> *cache) const argument 587 getData(SharedCache<A>* cache) const argument 589 getMethodList(SharedCache<A>* cache) const argument 591 getProtocolList(SharedCache<A>* cache) const argument 593 getPropertyList(SharedCache<A>* cache) const argument 595 getName(SharedCache<A>* cache) const argument 599 setMethodList(SharedCache<A>* cache, objc_method_list_t<A>* mlist) argument 603 setProtocolList(SharedCache<A>* cache, objc_protocol_list_t<A>* protolist) argument 607 setPropertyList(SharedCache<A>* cache, objc_property_list_t<A>* proplist) argument 611 addMethodListPointer(SharedCache<A>* cache, std::vector<void*>& pointersToAdd) argument 615 addPropertyListPointer(SharedCache<A>* cache, std::vector<void*>& pointersToAdd) argument 619 addProtocolListPointer(SharedCache<A>* cache, std::vector<void*>& pointersToAdd) argument 628 class objc_category_t { class 629 typename A::P::uint_t name; member in class:objc_category_t 630 typename A::P::uint_t cls; member in class:objc_category_t 631 typename A::P::uint_t instanceMethods; member in class:objc_category_t 632 typename A::P::uint_t classMethods; member in class:objc_category_t 633 typename A::P::uint_t protocols; member in class:objc_category_t 634 typename A::P::uint_t instanceProperties; member in class:objc_category_t 638 getName(SharedCache<A> *cache) const argument 640 getClass(SharedCache<A> *cache) const argument 642 getInstanceMethods(SharedCache<A>* cache) const argument 644 getClassMethods(SharedCache<A>* cache) const argument 646 getProtocols(SharedCache<A>* cache) const argument 648 getInstanceProperties(SharedCache<A>* cache) const argument 650 getPointers(std::set<void*>& pointersToRemove) argument 663 class objc_message_ref_t { class 664 typename A::P::uint_t imp; member in class:objc_message_ref_t 665 typename A::P::uint_t sel; member in class:objc_message_ref_t 668 getName() const argument 670 setName(typename A::P::uint_t newName) argument 675 class IvarWalker { class 676 typedef typename A::P P; typedef in class:IvarWalker 677 typedef typename A::P::uint_t pint_t; typedef in class:IvarWalker 678 V& ivarVisitor; member in class:IvarWalker 681 IvarWalker(V& visitor) argument 683 walk(SharedCache<A>* cache, const macho_header<P>* header, objc_class_t<A> *cls) argument 685 objc_class_data_t<A> *data = cls->getData(cache); local 686 objc_ivar_list_t<A> *ivars = data->getIvarList(cache); local 689 objc_ivar_t<A>& ivar = ivars->get(i); local 698 visitClass(SharedCache<A>* cache, const macho_header<P>* header, objc_class_t<A> *cls) argument 706 class ClassWalker { class 707 typedef typename A::P P; typedef in class:ClassWalker 708 typedef typename A::P::uint_t pint_t; typedef in class:ClassWalker 709 V& classVisitor; member in class:ClassWalker 712 ClassWalker(V& visitor) argument 714 walk(SharedCache<A>* cache, const macho_header<P>* header) argument 720 objc_class_t<A> *cls = classes.get(i); local 730 class MethodListWalker { class 732 typedef typename A::P P; typedef in class:MethodListWalker 733 typedef typename A::P::uint_t pint_t; typedef in class:MethodListWalker 735 V& mVisitor; member in class:MethodListWalker 739 MethodListWalker(V& visitor) argument 741 walk(SharedCache<A>* cache, const macho_header<P>* header, bool walkProtocols) argument 748 objc_class_t<A> *cls = classes.get(i); local 749 objc_method_list_t<A> *mlist; local 762 objc_category_t<A> *cat = cats.get(i); local 763 objc_method_list_t<A> *mlist; local 777 objc_protocol_t<A> *proto = protocols.get(i); local 778 objc_method_list_t<A> *mlist; local 799 class SelectorOptimizer { class 801 typedef typename A::P P; typedef in class:SelectorOptimizer 802 typedef typename A::P::uint_t pint_t; typedef in class:SelectorOptimizer 804 V& mVisitor; member in class:SelectorOptimizer 807 visitMethodList(objc_method_list_t<A> *mlist) argument 811 pint_t oldValue = mlist->get(m).getName(); local 812 pint_t newValue = mVisitor.visit(oldValue); local 820 SelectorOptimizer(V& visitor) argument 822 optimize(SharedCache<A>* cache, const macho_header<P>* header) argument 832 pint_t oldValue = selrefs.getUnmapped(i); local 833 pint_t newValue = mVisitor.visit(oldValue); local 841 objc_message_ref_t<A>& msg = msgrefs.get(i); local 842 pint_t oldValue = msg.getName(); local 843 pint_t newValue = mVisitor.visit(oldValue); local 852 class IvarOffsetOptimizer { class 853 typedef typename A::P P; typedef in class:IvarOffsetOptimizer 855 uint32_t slide; member in class:IvarOffsetOptimizer 856 uint32_t maxAlignment; member in class:IvarOffsetOptimizer 858 uint32_t fOptimized; member in class:IvarOffsetOptimizer 862 IvarOffsetOptimizer() : fOptimized(0) { } function in class:IvarOffsetOptimizer 864 optimized() const argument 868 visitIvar(SharedCache<A>* cache, const macho_header<P>* , objc_class_t<A> *cls, objc_ivar_t<A> *ivar) argument 871 uint32_t alignment = ivar->getAlignment(); local 876 uint32_t oldOffset = (uint32_t)ivar->getOffset(cache); local 888 visitClass(SharedCache<A>* cache, const macho_header<P>* , objc_class_t<A> *cls) argument 890 objc_class_t<A> *super = cls->getSuperclass(cache); local 896 objc_class_data_t<A> *data = cls->getData(cache); local 897 objc_class_data_t<A> *super_data = super->getData(cache); local 898 int32_t diff = super_data->getInstanceSize() - data->getInstanceStart(); local 908 uint32_t alignMask = maxAlignment - 1; local 924 optimize(SharedCache<A>* cache, const macho_header<P>* header) argument 927 const macho_section<P> *imageInfoSection = header->getSection("__DATA", "__objc_imageinfo"); local 929 objc_image_info<A> *info = (objc_image_info<A> *)cache->mappedAddressForVMAddress(imageInfoSection->addr()); local 943 class MethodListSorter { class 945 typedef typename A::P P; typedef in class:MethodListSorter 946 typedef typename A::P::uint_t pint_t; typedef in class:MethodListSorter 948 uint32_t fOptimized; member in class:MethodListSorter 951 visitMethodList(objc_method_list_t<A> *mlist) argument 953 typename objc_method_t<A>::SortBySELAddress sorter; local 960 MethodListSorter() : fOptimized(0) { } function in class:MethodListSorter 962 optimized() const argument 964 optimize(SharedCache<A>* cache, macho_header<P>* header) argument 973 class HeaderInfoOptimizer { class 975 typedef typename A::P P; typedef in class:HeaderInfoOptimizer 976 typedef typename A::P::uint_t pint_t; typedef in class:HeaderInfoOptimizer 978 objc_header_info_t<A>* fHinfos; member in class:HeaderInfoOptimizer 979 size_t fCount; member in class:HeaderInfoOptimizer 982 HeaderInfoOptimizer() : fHinfos(0), fCount(0) { } function in class:HeaderInfoOptimizer 984 init(size_t count, uint8_t*& buf, size_t& bufSize) argument 992 uint32_t *buf32 = (uint32_t *)buf; local 997 size_t total = sizeof(uint32_t) + count*sizeof(objc_header_info_t<A>); local 1004 update(SharedCache<A>* cache, const macho_header<P>* mh, std::vector<void*>& pointersInData) argument 1006 objc_header_info_t<A>* hi = new(&fHinfos[fCount++]) objc_header_info_t<A>(cache, mh); local 1010 hinfoForHeader(SharedCache<A>* cache, const macho_header<P>* mh) argument 1013 pint_t mh_vmaddr = cache->VMAddressForMappedAddress(mh); local 1015 objc_header_info_t<A>* hi = &fHinfos[i]; local [all...] |
H A D | dsc_extractor.cpp | 41 #define NO_ULEB macro 57 struct seg_info struct 59 seg_info(const char* n, uint64_t o, uint64_t s) argument 61 const char* segName; member in struct:seg_info 62 uint64_t offset; member in struct:seg_info 63 uint64_t sizem; member in struct:seg_info 66 class CStringHash { class 68 operator ()(const char* __s) const argument 69 size_t __h = 0; local 75 class CStringEquals { class 77 operator ()(const char* left, const char* right) const argument 79 typedef std::unordered_map<const char*, std::vector<seg_info>, CStringHash, CStringEquals> NameToSegments; typedef 82 class NotReExportSymbol { class 84 NotReExportSymbol(const std::set<int> &rd) argument 85 operator ()(const mach_o::trie::Entry &entry) const argument 96 const std::set<int> &_reexportDeps; member in class:NotReExportSymbol 101 optimize_linkedit(macho_header<typename A::P>* mh, uint64_t textOffsetInCache, const void* mapped_cache, uint64_t* newSize) argument 103 typedef typename A::P P; typedef 104 typedef typename A::P::E E; typedef 105 typedef typename A::P::uint_t pint_t; typedef 111 uint64_t cumulativeFileSize = 0; local 112 const macho_load_command<P>* const cmds = (macho_load_command<P>*)((uint8_t*)mh + sizeof(macho_header<P>)); local 113 const uint32_t cmd_count = mh->ncmds(); local 114 const macho_load_command<P>* cmd = cmds; local 115 macho_segment_command<P>* linkEditSegCmd = NULL; local 116 macho_symtab_command<P>* symtab = NULL; local 117 macho_dysymtab_command<P>* dynamicSymTab = NULL; local 118 macho_linkedit_data_command<P>* functionStarts = NULL; local 119 macho_linkedit_data_command<P>* dataInCode = NULL; local 120 uint32_t exportsTrieOffset = 0; local 121 uint32_t exportsTrieSize = 0; local 122 std::set<int> reexportDeps; local 123 int depIndex = 0; local 129 macho_segment_command<P>* segCmd = (macho_segment_command<P>*)cmd; local 131 macho_section<P>* const sectionsStart = (macho_section<P>*)((char*)segCmd + sizeof(macho_segment_command<P>)); local 132 macho_section<P>* const sectionsEnd = §ionsStart[segCmd->nsects()]; local 146 macho_dyld_info_command<P>* dyldInfo = (macho_dyld_info_command<P>*)cmd; local 200 const uint64_t newFunctionStartsOffset = linkEditSegCmd->fileoff(); local 201 uint32_t functionStartsSize = 0; local 207 const uint64_t newDataInCodeOffset = (newFunctionStartsOffset + functionStartsSize + sizeof(pint_t) - 1) & (-sizeof(pint_t)); // pointer align local 208 uint32_t dataInCodeSize = 0; local 215 std::vector<mach_o::trie::Entry> exports; local 217 const uint8_t* exportsStart = ((uint8_t*)mapped_cache) + exportsTrieOffset; local 218 const uint8_t* exportsEnd = &exportsStart[exportsTrieSize]; local 224 dyldCacheHeader<E>* header = (dyldCacheHeader<E>*)mapped_cache; local 225 macho_nlist<P>* localNlists = NULL; local 226 uint32_t localNlistCount = 0; local 227 const char* localStrings = NULL; local 228 const char* localStringsEnd = NULL; local 230 dyldCacheLocalSymbolsInfo<E>* localInfo = (dyldCacheLocalSymbolsInfo<E>*)(((uint8_t*)mapped_cache) + header->localSymbolsOffset()); local 231 dyldCacheLocalSymbolEntry<E>* entries = (dyldCacheLocalSymbolEntry<E>*)(((uint8_t*)mapped_cache) + header->localSymbolsOffset() + localInfo->entriesOffset()); local 232 macho_nlist<P>* allLocalNlists = (macho_nlist<P>*)(((uint8_t*)localInfo) + localInfo->nlistOffset()); local 233 const uint32_t entriesCount = localInfo->entriesCount(); local 236 uint32_t localNlistStart = entries[i].nlistStartIndex(); local 246 const macho_nlist<P>* const mergedSymTabStart = (macho_nlist<P>*)(((uint8_t*)mapped_cache) + symtab->symoff()); local 247 const macho_nlist<P>* const mergedSymTabend = &mergedSymTabStart[symtab->nsyms()]; local 248 uint32_t newSymCount = symtab->nsyms(); local 263 const uint64_t newSymTabOffset = (newDataInCodeOffset + dataInCodeSize + sizeof(pint_t) - 1) & (-sizeof(pint_t)); // pointer align local 264 const uint64_t newIndSymTabOffset = newSymTabOffset + newSymCount*sizeof(macho_nlist<P>); local 265 const uint64_t newStringPoolOffset = newIndSymTabOffset + dynamicSymTab->nindirectsyms()*sizeof(uint32_t); local 266 macho_nlist<P>* const newSymTabStart = (macho_nlist<P>*)(((uint8_t*)mh) + newSymTabOffset); local 267 char* const newStringPoolStart = (char*)mh + newStringPoolOffset; local 268 const uint32_t* mergedIndSymTab = (uint32_t*)((char*)mapped_cache + dynamicSymTab->indirectsymoff()); local 269 const char* mergedStringPoolStart = (char*)mapped_cache + symtab->stroff(); local 270 const char* mergedStringPoolEnd = &mergedStringPoolStart[symtab->strsize()]; local 271 macho_nlist<P>* t = newSymTabStart; local 272 int poolOffset = 0; local 273 uint32_t symbolsCopied = 0; local 281 const char* symName = &mergedStringPoolStart[s->n_strx()]; local 297 const char* importName = it->importName; local 312 const char* localName = &localStrings[localNlists[i].n_strx()]; local 333 uint32_t* newIndSymTab = (uint32_t*)((char*)mh + newIndSymTabOffset); local 365 make_dirs(const char* file_path) argument 368 char dirs[strlen(file_path)+1]; local 370 char* lastSlash = strrchr(dirs, '/'); local 374 struct stat stat_buf; local 376 char* afterSlash = &dirs[1]; local 377 char* slash; local 391 dylib_maker(const void* mapped_cache, std::vector<uint8_t> &dylib_data, const std::vector<seg_info>& segments) argument 392 typedef typename A::P P; typedef 394 size_t additionalSize = 0; local 401 uint32_t nfat_archs = 0; local 402 uint32_t offsetInFatFile = 4096; local 403 uint8_t *base_ptr = &dylib_data.front(); local 405 #define FH macro 406 #define FA macro 427 uint64_t totalSize = 0; local 428 uint64_t textOffsetInCache = 0; local 433 const macho_header<P> *textMH = reinterpret_cast<macho_header<P>*>((uint8_t*)mapped_cache+textOffsetInCache); local 439 fat_arch *afa = reinterpret_cast<fat_arch*>(base_ptr+8)+i; local 459 uint64_t newSize = dylib_data.size(); local 466 #undef FH macro 467 #undef FA macro 472 dyld_shared_cache_extract_dylibs_progress(const char* shared_cache_file_path, const char* extraction_root_path, void (^progress)(unsigned current, unsigned total)) argument 475 struct stat statbuf; local 481 int cache_fd = open(shared_cache_file_path, O_RDONLY); local 487 void* mapped_cache = mmap(NULL, statbuf.st_size, PROT_READ, MAP_PRIVATE, cache_fd, 0); local 520 __block NameToSegments map; local 521 __block int result = dyld_shared_cache_iterate(mapped_cache, (uint32_t)statbuf.st_size, ^(const dyld_shared_cache_dylib_info* dylibInfo, const dyld_shared_cache_segment_info* segInfo) { local 532 dispatch_group_t group = dispatch_group_create(); local 533 dispatch_semaphore_t sema = dispatch_semaphore_create(2); local 534 dispatch_queue_t process_queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0); local 535 dispatch_queue_t writer_queue = dispatch_queue_create("dyld writer queue", 0); local 537 __block unsigned count = 0; local 607 dyld_shared_cache_extract_dylibs(const char* shared_cache_file_path, const char* extraction_root_path) argument [all...] |
H A D | dsc_extractor.h | 26 #define _DYLD_SHARED_CACHE_EXTRACTOR_ macro [all...] |
H A D | dsc_iterator.cpp | 32 #define NO_ULEB macro 38 namespace dyld { namespace 43 mappedAddress(const uint8_t* cache, const uint8_t* cacheEnd, uint64_t addr) argument 45 const dyldCacheHeader<E>* header = (dyldCacheHeader<E>*)cache; local 46 const dyldCacheFileMapping<E>* mappings = (dyldCacheFileMapping<E>*)&cache[header->mappingOffset()]; local 49 uint64_t cacheOffset = mappings[i].file_offset() + addr - mappings[i].address(); local 50 const uint8_t* result = &cache[cacheOffset]; local 62 walkSegments(const uint8_t* cache, const uint8_t* cacheEnd, const uint8_t* firstSeg, const char* dylibPath, uint64_t inode,uint64_t modTime, const uint8_t* machHeader, void (^callback)(const dyld_shared_cache_dylib_info* dylibInfo, const dyld_shared_cache_segment_info* segInfo)) argument 65 typedef typename A::P P; typedef 66 typedef typename A::P::E E; typedef 67 dyld_shared_cache_dylib_info dylibInfo; local 68 dyld_shared_cache_segment_info segInfo; local 75 const macho_header<P>* mh = (const macho_header<P>*)machHeader; local 76 const macho_load_command<P>* const cmds = (macho_load_command<P>*)(machHeader + sizeof(macho_header<P>)); local 79 const uint32_t cmd_count = mh->ncmds(); local 80 const macho_load_command<P>* cmd = cmds; local 85 const uuid_command* uc = (const uuid_command*)cmd; local 95 macho_segment_command<P>* segCmd = (macho_segment_command<P>*)cmd; local 96 uint64_t fileOffset = segCmd->fileoff(); local 101 uint64_t sizem = segCmd->vmsize(); local 122 walkImages(const uint8_t* cache, uint32_t size, void (^callback)(const dyld_shared_cache_dylib_info* dylibInfo, const dyld_shared_cache_segment_info* segInfo)) argument 127 typedef typename A::P::E E; typedef 128 typedef typename A::P P; typedef 129 const dyldCacheHeader<E>* header = (dyldCacheHeader<E>*)cache; local 130 const dyldCacheImageInfo<E>* dylibs = (dyldCacheImageInfo<E>*)&cache[header->imagesOffset()]; local 131 const dyldCacheFileMapping<E>* mappings = (dyldCacheFileMapping<E>*)&cache[header->mappingOffset()]; local 132 uint64_t greatestMappingOffset = 0; local 142 const uint8_t* cacheEnd = &cache[size]; local 155 const uint8_t* firstSeg = NULL; local 157 const char* dylibPath = (char*)cache + dylibs[i].pathFileOffset(); local 158 uint64_t inode = dylibs[i].inode(); local 159 uint64_t modTime = dylibs[i].modTime(); local 162 const uint8_t* machHeader = mappedAddress<E>(cache, cacheEnd, dylibs[i].address()); local 169 int result = walkSegments<A>(cache, cacheEnd, firstSeg, dylibPath, inode, modTime, machHeader, callback); local 183 dyld_shared_cache_iterate(const void* shared_cache_file, uint32_t shared_cache_size, void (^callback)(const dyld_shared_cache_dylib_info* dylibInfo, const dyld_shared_cache_segment_info* segInfo)) argument 185 const uint8_t* cache = (uint8_t*)shared_cache_file; local 208 dyld_shared_cache_iterate_segments_with_slide(const void* shared_cache_file, dyld_shared_cache_iterator_slide_t callback) argument [all...] |
H A D | dsc_iterator.h | 28 struct dyld_shared_cache_dylib_info { struct 29 uint32_t version; // current version 2 member in struct:dyld_shared_cache_dylib_info 31 uint32_t isAlias; // this is alternate path (symlink) member in struct:dyld_shared_cache_dylib_info 32 const void* machHeader; // of dylib in mapped cached file member in struct:dyld_shared_cache_dylib_info 33 const char* path; // of dylib member in struct:dyld_shared_cache_dylib_info 34 const uuid_t* uuid; // of dylib, or NULL is missing member in struct:dyld_shared_cache_dylib_info 36 uint64_t inode; // of dylib file or path hash member in struct:dyld_shared_cache_dylib_info 37 uint64_t modTime; // of dylib file member in struct:dyld_shared_cache_dylib_info 39 typedef struct dyld_shared_cache_dylib_info dyld_shared_cache_dylib_info; typedef in typeref:struct:dyld_shared_cache_dylib_info 41 struct dyld_shared_cache_segment_info { struct 42 uint64_t version; // initial version 1 member in struct:dyld_shared_cache_segment_info 43 const char* name; // of segment member in struct:dyld_shared_cache_segment_info 44 uint64_t fileOffset; // of segment in cache file member in struct:dyld_shared_cache_segment_info 45 uint64_t fileSize; // of segment member in struct:dyld_shared_cache_segment_info 46 uint64_t address; // of segment when cache mapped with ASLR (sliding) off member in struct:dyld_shared_cache_segment_info 49 typedef struct dyld_shared_cache_segment_info dyld_shared_cache_segment_info; typedef in typeref:struct:dyld_shared_cache_segment_info 69 typedef void (^dyld_shared_cache_iterator_t)(const char* dylibName, const char* segName, uint64_t offset, uint64_t size, uint64_t mappedddress); variable 70 typedef void (^dyld_shared_cache_iterator_slide_t)(const char* dylibName, const char* segName, uint64_t offset, uint64_t size, uint64_t mappedddress, uint64_t slide); variable 71 typedef void (*dyld_shared_cache_iterator_nb_t)(const char* dylibName, const char* segName, uint64_t offset, uint64_t sizem, uint64_t mappedddress, void* userData); typedef 72 typedef void (*dyld_shared_cache_iterator_slide_nb_t)(const char* dylibName, const char* segName, uint64_t offset, uint64_t sizem, uint64_t mappedddress, uint64_t slide, void* userData); typedef [all...] |
H A D | dyld_cache_format.h | 25 #define __DYLD_CACHE_FORMAT__ macro 32 struct dyld_cache_header struct 34 char magic[16]; // e.g. "dyld_v0 i386" member in struct:dyld_cache_header 35 uint32_t mappingOffset; // file offset to first dyld_cache_mapping_info member in struct:dyld_cache_header 36 uint32_t mappingCount; // number of dyld_cache_mapping_info entries member in struct:dyld_cache_header 37 uint32_t imagesOffset; // file offset to first dyld_cache_image_info member in struct:dyld_cache_header 38 uint32_t imagesCount; // number of dyld_cache_image_info entries member in struct:dyld_cache_header 39 uint64_t dyldBaseAddress; // base address of dyld when cache was built member in struct:dyld_cache_header 40 uint64_t codeSignatureOffset; // file offset of code signature blob member in struct:dyld_cache_header 41 uint64_t codeSignatureSize; // size of code signature blob (zero means to end of file) member in struct:dyld_cache_header 42 uint64_t slideInfoOffset; // file offset of kernel slid info member in struct:dyld_cache_header 43 uint64_t slideInfoSize; // size of kernel slid info member in struct:dyld_cache_header 44 uint64_t localSymbolsOffset; // file offset of where local symbols are stored member in struct:dyld_cache_header 45 uint64_t localSymbolsSize; // size of local symbols information member in struct:dyld_cache_header 46 uint8_t uuid[16]; // unique value for each shared cache file member in struct:dyld_cache_header 49 struct dyld_cache_mapping_info { struct 50 uint64_t address; member in struct:dyld_cache_mapping_info 51 uint64_t size; member in struct:dyld_cache_mapping_info 52 uint64_t fileOffset; member in struct:dyld_cache_mapping_info 53 uint32_t maxProt; member in struct:dyld_cache_mapping_info 54 uint32_t initProt; member in struct:dyld_cache_mapping_info 57 struct dyld_cache_image_info struct 59 uint64_t address; member in struct:dyld_cache_image_info 60 uint64_t modTime; member in struct:dyld_cache_image_info 61 uint64_t inode; member in struct:dyld_cache_image_info 62 uint32_t pathFileOffset; member in struct:dyld_cache_image_info 63 uint32_t pad; member in struct:dyld_cache_image_info 66 struct dyld_cache_slide_info struct 68 uint32_t version; // currently 1 member in struct:dyld_cache_slide_info 69 uint32_t toc_offset; member in struct:dyld_cache_slide_info 70 uint32_t toc_count; member in struct:dyld_cache_slide_info 71 uint32_t entries_offset; member in struct:dyld_cache_slide_info 72 uint32_t entries_count; member in struct:dyld_cache_slide_info 73 uint32_t entries_size; // currently 128 member in struct:dyld_cache_slide_info 79 struct dyld_cache_local_symbols_info struct 81 uint32_t nlistOffset; // offset into this chunk of nlist entries member in struct:dyld_cache_local_symbols_info 82 uint32_t nlistCount; // count of nlist entries member in struct:dyld_cache_local_symbols_info 83 uint32_t stringsOffset; // offset into this chunk of string pool member in struct:dyld_cache_local_symbols_info 84 uint32_t stringsSize; // byte count of string pool member in struct:dyld_cache_local_symbols_info 85 uint32_t entriesOffset; // offset into this chunk of array of dyld_cache_local_symbols_entry member in struct:dyld_cache_local_symbols_info 86 uint32_t entriesCount; // number of elements in dyld_cache_local_symbols_entry array member in struct:dyld_cache_local_symbols_info 89 struct dyld_cache_local_symbols_entry struct 91 uint32_t dylibOffset; // offset in cache file of start of dylib member in struct:dyld_cache_local_symbols_entry 92 uint32_t nlistStartIndex; // start index of locals for this dylib member in struct:dyld_cache_local_symbols_entry 93 uint32_t nlistCount; // number of local symbols for this dylib member in struct:dyld_cache_local_symbols_entry 98 #define MACOSX_DYLD_SHARED_CACHE_DIR macro 99 #define IPHONE_DYLD_SHARED_CACHE_DIR macro 100 #define DYLD_SHARED_CACHE_BASE_NAME macro [all...] |
H A D | dyld_shared_cache_util.cpp | 47 enum Mode { enum 48 modeNone, enumerator in enum:Mode 49 modeList, enumerator in enum:Mode 50 modeMap, enumerator in enum:Mode 51 modeDependencies, enumerator in enum:Mode 52 modeSlideInfo, enumerator in enum:Mode 53 modeLinkEdit, enumerator in enum:Mode 54 modeInfo, enumerator in enum:Mode 55 modeSize enumerator in enum:Mode 58 struct Options { struct 59 Mode mode; member in struct:Options 60 const char* dependentsOfPath; member in struct:Options 61 const void* mappedCache; member in struct:Options 62 bool printUUIDs; member in struct:Options 63 bool printVMAddrs; member in struct:Options 64 bool printDylibVersions; member in struct:Options 65 bool printInodes; member in struct:Options 68 struct TextInfo { struct 69 uint64_t textSize; member in struct:TextInfo 70 const char* path; member in struct:TextInfo 73 struct TextInfoSorter { struct 74 operator ()(const TextInfo& left, const TextInfo& right) argument 79 struct Results { struct 80 std::map<uint32_t, const char*> pageToContent; member in struct:Results 81 uint64_t linkeditBase; member in struct:Results 82 bool dependentTargetFound; member in struct:Results 83 std::vector<TextInfo> textSegments; member in struct:Results 88 void usage() { function 93 static bool isHaswell() function 96 struct host_basic_info info; local 97 mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT; local 98 mach_port_t hostPort = mach_host_self(); local 99 kern_return_t result = host_info(hostPort, HOST_BASIC_INFO, (host_info_t)&info, &count); local 100 mach_port_deallocate(mach_task_self(), hostPort); local 110 static const char* default_shared_cache_path() { function 137 typedef void (*segment_callback_t)(const dyld_shared_cache_dylib_info* dylibInfo, const dyld_shared_cache_segment_info* segInfo, typedef 147 print_dependencies(const dyld_shared_cache_dylib_info* dylibInfo, const dyld_shared_cache_segment_info* segInfo, const Options& options, Results& results) argument 149 typedef typename A::P P; typedef 150 typedef typename A::P::E E; typedef 157 const macho_dylib_command<P>* dylib_cmd; local 158 const macho_header<P>* mh = (const macho_header<P>*)dylibInfo->machHeader; local 159 const macho_load_command<P>* const cmds = (macho_load_command<P>*)((uintptr_t)dylibInfo->machHeader + sizeof(macho_header<P>)); local 160 const uint32_t cmd_count = mh->ncmds(); local 161 const macho_load_command<P>* cmd = cmds; local 171 uint32_t compat_vers = dylib_cmd->compatibility_version(); local 172 uint32_t current_vers = dylib_cmd->current_version(); local 201 print_list(const dyld_shared_cache_dylib_info* dylibInfo, const dyld_shared_cache_segment_info* segInfo, const Options& options, Results& results) argument 213 const uint8_t* uuid = (uint8_t*)dylibInfo->uuid;; local 231 collect_size(const dyld_shared_cache_dylib_info* dylibInfo, const dyld_shared_cache_segment_info* segInfo, const Options& options, Results& results) argument 243 size_t size = segInfo->fileSize; local 249 add_linkedit(uint32_t pageStart, uint32_t pageEnd, const char* message, Results& results) argument 252 std::map<uint32_t, const char*>::iterator pos = results.pageToContent.find(p); local 257 const char* oldMessage = pos->second; local 258 char* newMesssage; local 271 process_linkedit(const dyld_shared_cache_dylib_info* dylibInfo, const dyld_shared_cache_segment_info* segInfo, const Options& options, Results& results) argument 273 typedef typename A::P P; typedef 274 typedef typename A::P::E E; typedef 278 const macho_header<P>* mh = (const macho_header<P>*)dylibInfo->machHeader; local 279 uint32_t ncmds = mh->ncmds(); local 280 const macho_load_command<P>* const cmds = (macho_load_command<P>*)((long)mh + sizeof(macho_header<P>)); local 281 const macho_load_command<P>* cmd = cmds; local 284 macho_dyld_info_command<P>* dyldInfo = (macho_dyld_info_command<P>*)cmd; local 285 char message[1000]; local 286 const char* shortName = strrchr(dylibInfo->path, '/') + 1; local 290 uint32_t exportPageOffsetStart = dyldInfo->export_off() & (-4096); local 291 uint32_t exportPageOffsetEnd = (dyldInfo->export_off() + dyldInfo->export_size()) & (-4096); local 297 uint32_t bindPageOffsetStart = dyldInfo->bind_off() & (-4096); local 298 uint32_t bindPageOffsetEnd = (dyldInfo->bind_off() + dyldInfo->bind_size()) & (-4096); local 304 uint32_t lazybindPageOffsetStart = dyldInfo->lazy_bind_off() & (-4096); local 305 uint32_t lazybindPageOffsetEnd = (dyldInfo->lazy_bind_off() + dyldInfo->lazy_bind_size()) & (-4096); local 311 uint32_t weakbindPageOffsetStart = dyldInfo->weak_bind_off() & (-4096); local 312 uint32_t weakbindPageOffsetEnd = (dyldInfo->weak_bind_off() + dyldInfo->weak_bind_size()) & (-4096); local 326 print_map(const dyld_shared_cache_dylib_info* dylibInfo, const dyld_shared_cache_segment_info* segInfo, const Options& options, Results& results) argument 332 checkMode(Mode mode) argument 340 main(int argc, const char* argv[]) argument 342 const char* sharedCachePath = default_shared_cache_path(); local 344 Options options; local 353 const char* opt = argv[i]; local 435 struct stat statbuf; local 441 int cache_fd = ::open(sharedCachePath, O_RDONLY); local 453 const dyldCacheHeader<LittleEndian>* header = (dyldCacheHeader<LittleEndian>*)options.mappedCache; local 458 const dyldCacheFileMapping<LittleEndian>* mappings = (dyldCacheFileMapping<LittleEndian>*)((char*)options.mappedCache + header->mappingOffset()); local 459 const dyldCacheFileMapping<LittleEndian>* dataMapping = &mappings[1]; local 460 uint64_t dataStartAddress = dataMapping->address(); local 461 uint64_t dataSize = dataMapping->size(); local 462 const dyldCacheSlideInfo<LittleEndian>* slideInfoHeader = (dyldCacheSlideInfo<LittleEndian>*)((char*)options.mappedCache+header->slideInfoOffset()); local 465 const dyldCacheSlideInfoEntry* entries = (dyldCacheSlideInfoEntry*)((char*)slideInfoHeader + slideInfoHeader->entries_offset()); local 468 const dyldCacheSlideInfoEntry* entry = &entries[slideInfoHeader->toc(i)]; local 475 const dyldCacheHeader<LittleEndian>* header = (dyldCacheHeader<LittleEndian>*)options.mappedCache; local 478 const uint8_t* uuid = header->uuid(); local 490 const dyldCacheFileMapping<LittleEndian>* mappings = (dyldCacheFileMapping<LittleEndian>*)((char*)options.mappedCache + header->mappingOffset()); local 500 uint64_t size = statbuf.st_size - header->codeSignatureOffset(); local 501 uint64_t csAddr = mappings[header->mappingCount()-1].address() + mappings[header->mappingCount()-1].size(); local 506 segment_callback_t callback; local 606 __block Results results; local 608 int iterateResult = dyld_shared_cache_iterate(options.mappedCache, (uint32_t)statbuf.st_size, local [all...] |
H A D | update_dyld_shared_cache.cpp | 68 #define SELOPT_WRITE macro 71 #define FIRST_DYLIB_TEXT_OFFSET macro 74 #define LC_FUNCTION_STARTS macro 77 static bool verbose = false; variable 78 static bool progress = false; variable 79 static bool iPhoneOS = false; variable 80 static std::vector<const char*> warnings; variable 83 warn(const char *arch, const char *format, ...) argument 85 char *msg; local 87 va_list args; local 104 class CStringHash { class 106 operator ()(const char* __s) const argument 107 size_t __h = 0; local 113 class CStringEquals class 116 operator ()(const char* left, const char* right) const argument 121 class ArchGraph class 124 typedef std::unordered_map<const char*, const char*, CStringHash, CStringEquals> StringToString; typedef in class:ArchGraph 129 graphForArchPair(ArchPair ap) argument 130 setFileSystemRoot(const char* root) argument 134 ArchPair getArchPair() { return fArchPair; } function in class:ArchGraph 135 std::set<const class MachOLayoutAbstraction*>& getSharedDylibs() { return fSharedDylibs; } function in class:ArchGraph 136 StringToString& getDylibAliases() { return fAliasesMap; } function in class:ArchGraph 137 const char* archName() { return archName(fArchPair); } function in class:ArchGraph 141 class DependencyNode class in class:ArchGraph 147 getPath() const argument 148 getLayout() const argument 149 useCount() const argument 150 allDependentsFound() const argument 152 ArchGraph* fGraph; member in class:ArchGraph::DependencyNode 153 const char* fPath; member in class:ArchGraph::DependencyNode 154 const MachOLayoutAbstraction* fLayout; member in class:ArchGraph::DependencyNode 155 bool fDependenciesLoaded; member in class:ArchGraph::DependencyNode 156 bool fDependentMissing; member in class:ArchGraph::DependencyNode 157 std::set<DependencyNode*> fDependsOn; member in class:ArchGraph::DependencyNode 158 std::set<DependencyNode*> fRootsDependentOnThis; member in class:ArchGraph::DependencyNode 161 typedef std::unordered_map<const char*, class DependencyNode*, CStringHash, CStringEquals> PathToNode; typedef in class:ArchGraph 164 ArchGraph(ArchPair ap) argument 171 static std::map<ArchPair, ArchGraph*> fgPerArchGraph; member in class:ArchGraph 172 static const char* fgFileSystemRoot; member in class:ArchGraph 173 static std::vector<const char*> fgFileSystemOverlays; member in class:ArchGraph 175 ArchPair fArchPair; member in class:ArchGraph 176 std::set<DependencyNode*> fRoots; member in class:ArchGraph 177 PathToNode fNodes; member in class:ArchGraph 178 std::set<const MachOLayoutAbstraction*> fSharedDylibs; // use set to avoid duplicates when installname!=realpath member in class:ArchGraph 179 StringToString fAliasesMap; member in class:ArchGraph 181 std::map<ArchPair, ArchGraph*> ArchGraph::fgPerArchGraph; member in class:ArchGraph 182 const char* ArchGraph::fgFileSystemRoot = ""; member in class:ArchGraph 183 std::vector<const char*> ArchGraph::fgFileSystemOverlays; member in class:ArchGraph 185 addArchPair(ArchPair ap) argument 191 setFileSystemOverlay(const std::vector<const char*>& overlays) argument 197 addRoot(const char* vpath, const std::set<ArchPair>& onlyArchs) argument 200 char completePath[MAXPATHLEN]; local 201 const char* path = NULL; local 206 struct stat stat_buf; local 216 struct stat stat_buf; local 225 const UniversalMachOLayout& uni = UniversalMachOLayout::find(path, &onlyArchs); local 228 const MachOLayoutAbstraction* layout = uni.getSlice(*ait); local 246 addRoot(const char* path, const MachOLayoutAbstraction* layout) argument 250 DependencyNode* node = this->getNode(path); local 252 const MachOLayoutAbstraction* mainExecutableLayout = NULL; local 262 getNodeForVirtualPath(const char* vpath) argument 265 char completePath[MAXPATHLEN]; local 267 const char* overlayPath = *it; local 271 struct stat stat_buf; local 276 const char* pathToSymlink = vpath; local 284 char pathInSymLink[MAXPATHLEN]; local 285 size_t res = readlink(pathToSymlink, pathInSymLink, sizeof(pathInSymLink)); local 289 char symFullPath[MAXPATHLEN]; local 291 char* lastSlash = strrchr(symFullPath, '/'); local 312 getNode(const char* path) argument 316 PathToNode::iterator pos = fNodes.find(path); local 321 char realPath[MAXPATHLEN]; local 329 const char* aliasPath = path; local 343 const UniversalMachOLayout& uni = UniversalMachOLayout::find(realPath); local 344 DependencyNode* node = new DependencyNode(this, realPath, uni.getSlice(fArchPair)); local 356 uuid_t uuid1; local 357 uuid_t uuid2; local 362 char* msg; local 378 const char* aliasPath = realPath; local 384 const char* overlayPath = *it; local 401 loadDependencies(const MachOLayoutAbstraction* mainExecutableLayout) argument 406 const std::vector<MachOLayoutAbstraction::Library>& dependsOn = fLayout->getLibraries(); local 409 const char* dependentPath = it->name; local 414 const char* executablePath = mainExecutableLayout->getFilePath(); local 415 char newPath[strlen(executablePath) + strlen(dependentPath)+2]; local 423 char* addPoint = strrchr(newPath,'/'); local 432 char newPath[strlen(fPath) + strlen(dependentPath)+2]; local 440 char* addPoint = strrchr(newPath,'/'); local 451 bool addDependent = true; local 478 markNeededByRoot(ArchGraph::DependencyNode* rootNode) argument 489 DependencyNode(ArchGraph* graph, const char* path, const MachOLayoutAbstraction* layout) argument 495 findSharedDylibs(ArchPair ap) argument 497 const PathToNode& nodes = fgPerArchGraph[ap]->fNodes; local 498 std::set<const MachOLayoutAbstraction*> possibleLibs; local 501 DependencyNode* node = it->second; local 504 const MachOLayoutAbstraction* layout = node->getLayout(); local 506 char* msg; local 524 std::set<const MachOLayoutAbstraction*>& sharedLibs = fgPerArchGraph[ap]->fSharedDylibs; local 525 std::map<const MachOLayoutAbstraction*,bool> shareableMap; local 532 archName(ArchPair ap) argument 572 sharable(const MachOLayoutAbstraction* layout, ArchPair ap, char** msg) argument 593 canBeShared(const MachOLayoutAbstraction* layout, ArchPair ap, const std::set<const MachOLayoutAbstraction*>& possibleLibs, std::map<const MachOLayoutAbstraction*, bool>& shareableMap) argument 596 std::map<const MachOLayoutAbstraction*, bool>::iterator mapPos = shareableMap.find(layout); local 603 char* msg; local 613 const PathToNode& nodes = fgPerArchGraph[ap]->fNodes; local 614 const std::vector<MachOLayoutAbstraction::Library>& dependents = layout->getLibraries(); local 616 PathToNode::const_iterator pos = nodes.find(dit->name); local 619 char realPath[MAXPATHLEN]; local 628 char* msg; local 638 char* msg; local 652 class StringPool class 663 typedef std::unordered_map<const char*, uint32_t, CStringHash, CStringEquals> StringToOffset; typedef in class:StringPool 665 char* fBuffer; member in class:StringPool 666 uint32_t fBufferAllocated; member in class:StringPool 667 uint32_t fBufferUsed; member in class:StringPool 668 StringToOffset fUniqueStrings; member in class:StringPool 672 StringPool::StringPool() function in class:StringPool 678 add(const char* str) argument 680 uint32_t len = strlen(str); local 686 uint32_t result = fBufferUsed; local 692 addUnique(const char* str) argument 694 StringToOffset::iterator pos = fUniqueStrings.find(str); local 703 uint32_t StringPool::size() function in class:StringPool 708 const char* StringPool::getBuffer() function in class:StringPool 713 stringAtIndex(uint32_t index) const argument 720 struct LocalSymbolInfo struct 722 uint32_t dylibOffset; member in struct:LocalSymbolInfo 723 uint32_t nlistStartIndex; member in struct:LocalSymbolInfo 724 uint32_t nlistCount; member in struct:LocalSymbolInfo 729 class SharedCache class 749 typedef typename A::P P; typedef in class:SharedCache 750 typedef typename A::P::E E; typedef in class:SharedCache 751 typedef typename A::P::uint_t pint_t; typedef in class:SharedCache 773 struct LayoutInfo { struct in class:SharedCache 774 const MachOLayoutAbstraction* layout; member in struct:SharedCache::LayoutInfo 775 std::vector<const char*> aliases; member in struct:SharedCache::LayoutInfo 776 dyld_cache_image_info info; member in struct:SharedCache::LayoutInfo 779 struct ByNameSorter { struct in class:SharedCache 780 operator ()(const LayoutInfo& left, const LayoutInfo& right) argument 784 struct ByAddressSorter { struct in class:SharedCache 785 operator ()(const LayoutInfo& left, const LayoutInfo& right) argument 790 struct ByCStringSectionSizeSorter { struct in class:SharedCache 791 operator ()(const LayoutInfo& left, const LayoutInfo& right) argument 792 const std::vector<MachOLayoutAbstraction::Segment>& segs_l = local 794 const std::vector<MachOLayoutAbstraction::Segment>& segs_r = local 800 const macho_header<P> *mh_l = (macho_header<P>*)segs_l[0].mappedAddress(); local 801 const macho_header<P> *mh_r = (macho_header<P>*)segs_r[0].mappedAddress(); local 802 const macho_section<P> *cstring_l = mh_l->getSection("__TEXT", "__cstring"); local 803 const macho_section<P> *cstring_r = mh_r->getSection("__TEXT", "__cstring"); local 813 struct Sorter { struct in class:SharedCache 814 Sorter(std::map<const MachOLayoutAbstraction*, uint32_t>& map) argument 815 operator ()(const LayoutInfo& left, const LayoutInfo& right) argument 819 std::map<const MachOLayoutAbstraction*, uint32_t>& fMap; member in struct:SharedCache::Sorter 823 ArchGraph* fArchGraph; member in class:SharedCache 824 const bool fVerify; member in class:SharedCache 825 bool fExistingIsNotUpToDate; member in class:SharedCache 826 bool fCacheFileInFinalLocation; member in class:SharedCache 827 const char* fCacheFilePath; member in class:SharedCache 828 uint8_t* fExistingCacheForVerification; member in class:SharedCache 829 std::vector<LayoutInfo> fDylibs; member in class:SharedCache 830 std::vector<LayoutInfo> fDylibAliases; member in class:SharedCache 831 std::vector<shared_file_mapping_np> fMappings; member in class:SharedCache 832 std::vector<macho_nlist<P> > fUnmappedLocalSymbols; member in class:SharedCache 833 StringPool fUnmappedLocalsStringPool; member in class:SharedCache 834 std::vector<LocalSymbolInfo> fLocalSymbolInfos; member in class:SharedCache 835 uint32_t fHeaderSize; member in class:SharedCache 836 uint8_t* fInMemoryCache; member in class:SharedCache 837 uint64_t fDyldBaseAddress; member in class:SharedCache 838 uint64_t fLinkEditsTotalUnoptimizedSize; member in class:SharedCache 839 uint64_t fLinkEditsStartAddress; member in class:SharedCache 840 MachOLayoutAbstraction::Segment* fFirstLinkEditSegment; member in class:SharedCache 841 uint32_t fOffsetOfBindInfoInCombinedLinkedit; member in class:SharedCache 842 uint32_t fOffsetOfWeakBindInfoInCombinedLinkedit; member in class:SharedCache 843 uint32_t fOffsetOfLazyBindInfoInCombinedLinkedit; member in class:SharedCache 844 uint32_t fOffsetOfExportInfoInCombinedLinkedit; member in class:SharedCache 845 uint32_t fOffsetOfOldSymbolTableInfoInCombinedLinkedit; member in class:SharedCache 846 uint32_t fSizeOfOldSymbolTableInfoInCombinedLinkedit; member in class:SharedCache 847 uint32_t fOffsetOfOldExternalRelocationsInCombinedLinkedit; member in class:SharedCache 848 uint32_t fSizeOfOldExternalRelocationsInCombinedLinkedit; member in class:SharedCache 849 uint32_t fOffsetOfOldIndirectSymbolsInCombinedLinkedit; member in class:SharedCache 850 uint32_t fSizeOfOldIndirectSymbolsInCombinedLinkedit; member in class:SharedCache 851 uint32_t fOffsetOfOldStringPoolInCombinedLinkedit; member in class:SharedCache 852 uint32_t fSizeOfOldStringPoolInCombinedLinkedit; member in class:SharedCache 853 uint32_t fOffsetOfFunctionStartsInCombinedLinkedit; member in class:SharedCache 854 uint32_t fSizeOfFunctionStartsInCombinedLinkedit; member in class:SharedCache 855 uint32_t fOffsetOfDataInCodeInCombinedLinkedit; member in class:SharedCache 856 uint32_t fSizeOfDataInCodeInCombinedLinkedit; member in class:SharedCache 857 uint32_t fLinkEditsTotalOptimizedSize; member in class:SharedCache 858 uint32_t fUnmappedLocalSymbolsSize; member in class:SharedCache 864 class PointerSection class 866 typedef typename A::P P; typedef in class:PointerSection 867 typedef typename A::P::uint_t pint_t; typedef in class:PointerSection 869 SharedCache<A>* const fCache; member in class:PointerSection 870 const macho_section<P>* const fSection; member in class:PointerSection 871 pint_t * const fBase; member in class:PointerSection 872 uint64_t fCount; member in class:PointerSection 875 PointerSection(SharedCache<A>* cache, const macho_header<P>* header, const char *segname, const char *sectname) argument 884 count() const argument 886 getUnmapped(uint64_t index) const argument 891 get(uint64_t index) const argument 895 set(uint64_t index, uint64_t value) argument 900 void removeNulls() { function in class:PointerSection 901 uint64_t shift = 0; local 903 pint_t value = fBase[i]; local 917 class ArraySection class 919 typedef typename A::P P; typedef in class:ArraySection 921 SharedCache<A>* const fCache; member in class:ArraySection 922 const macho_section<P>* const fSection; member in class:ArraySection 923 T * const fBase; member in class:ArraySection 924 uint64_t const fCount; member in class:ArraySection 927 ArraySection(SharedCache<A>* cache, const macho_header<P>* header, const char *segname, const char *sectname) argument 936 count() const argument 938 get(uint64_t index) const argument 951 template <> cpu_type_t SharedCache<x86>::arch() { return CPU_TYPE_I386; } function in class:SharedCache 952 template <> cpu_type_t SharedCache<x86_64>::arch() { return CPU_TYPE_X86_64; } function in class:SharedCache 953 template <> cpu_type_t SharedCache<arm>::arch() { return CPU_TYPE_ARM; } function in class:SharedCache 954 template <> cpu_type_t SharedCache<arm64>::arch() { return CPU_TYPE_ARM64; } function in class:SharedCache 956 template <> uint64_t SharedCache<x86>::sharedRegionStartAddress() { return 0x90000000; } function in class:SharedCache 957 template <> uint64_t SharedCache<x86_64>::sharedRegionStartAddress() { return 0x7FFF80000000LL; } function in class:SharedCache 958 template <> uint64_t SharedCache<arm>::sharedRegionStartAddress() { return ARM_SHARED_REGION_START; } function in class:SharedCache 959 template <> uint64_t SharedCache<arm64>::sharedRegionStartAddress() { return ARM64_SHARED_REGION_START; } function in class:SharedCache 961 template <> uint64_t SharedCache<x86>::sharedRegionSize() { return 0x20000000; } function in class:SharedCache 962 template <> uint64_t SharedCache<x86_64>::sharedRegionSize() { return 0x40000000; } function in class:SharedCache 963 template <> uint64_t SharedCache<arm>::sharedRegionSize() { return ARM_SHARED_REGION_SIZE; } function in class:SharedCache 964 template <> uint64_t SharedCache<arm64>::sharedRegionSize() { return ARM64_SHARED_REGION_SIZE; } function in class:SharedCache 966 sharedRegionStartWritableAddress(uint64_t exEnd) argument 967 sharedRegionStartWritableAddress(uint64_t exEnd) argument 968 sharedRegionStartWritableAddress(uint64_t exEnd) argument 969 sharedRegionStartWritableAddress(uint64_t exEnd) argument 971 sharedRegionStartReadOnlyAddress(uint64_t wrEnd, uint64_t exEnd) argument 972 sharedRegionStartReadOnlyAddress(uint64_t wrEnd, uint64_t exEnd) argument 973 sharedRegionStartReadOnlyAddress(uint64_t wrEnd, uint64_t exEnd) argument 974 sharedRegionStartReadOnlyAddress(uint64_t wrEnd, uint64_t exEnd) argument 976 template <> const char* SharedCache<x86>::archName() { return "i386"; } function in class:SharedCache 977 template <> const char* SharedCache<x86_64>::archName() { return "x86_64"; } function in class:SharedCache 978 template <> const char* SharedCache<arm>::archName() { return "arm"; } function in class:SharedCache 979 template <> const char* SharedCache<arm64>::archName() { return "arm64"; } function in class:SharedCache 981 cacheFileSuffix(bool, const char* archName) argument 982 cacheFileSuffix(bool, const char* archName) argument 983 cacheFileSuffix(bool, const char* archName) argument 984 cacheFileSuffix(bool, const char* archName) argument 986 pageAlign(uint64_t addr) argument 987 pageAlign(uint64_t addr) argument 988 pageAlign(uint64_t addr) argument 989 pageAlign(uint64_t addr) argument 991 regionAlign(uint64_t addr) argument 992 regionAlign(uint64_t addr) argument 993 regionAlign(uint64_t addr) argument 994 regionAlign(uint64_t addr) argument 998 pageAlign4KB(uint64_t addr) argument 1001 SharedCache(ArchGraph* graph, const char* rootPath, const std::vector<const char*>& overlayPaths, const char* cacheDir, bool explicitCacheDir, bool alphaSort, bool verify, bool optimize, uint64_t dyldBaseAddress) argument 1019 unsigned int aliasCount = 0; local 1020 std::set<const MachOLayoutAbstraction*>& dylibs = fArchGraph->getSharedDylibs(); local 1021 ArchGraph::StringToString& aliases = fArchGraph->getDylibAliases(); local 1023 const MachOLayoutAbstraction* lib = *it; local 1024 LayoutInfo temp; local 1044 char cachePathCanonical[MAXPATHLEN]; local 1050 char cachePath[MAXPATHLEN]; local 1073 struct stat stat_buf; local 1079 char cachePathRoot[MAXPATHLEN]; local 1103 std::map<const MachOLayoutAbstraction*, uint32_t> map; local 1117 const uint64_t baseHeaderSize = fHeaderSize; local 1122 LayoutInfo temp = *it; local 1124 const char* aliasPath = *ait; local 1147 const dyldCacheHeader<E>* header = (dyldCacheHeader<E>*)fExistingCacheForVerification; local 1148 const dyldCacheImageInfo<E>* cacheEntry = (dyldCacheImageInfo<E>*)(fExistingCacheForVerification + header->imagesOffset()); local 1164 getWritableSegmentNewAddress(uint64_t proposedNewAddress, uint64_t originalAddress, uint64_t executableSlide) argument 1170 pathHash(const char* path) argument 1172 uint64_t sum = 0; local 1180 assignNewBaseAddresses(bool verify) argument 1183 const uint64_t startExecuteAddress = sharedRegionStartAddress(); local 1184 uint64_t currentExecuteAddress = startExecuteAddress + FIRST_DYLIB_TEXT_OFFSET; local 1186 std::vector<MachOLayoutAbstraction::Segment>& segs = ((MachOLayoutAbstraction*)(it->layout))->getSegments(); local 1188 MachOLayoutAbstraction::Segment& seg = segs[i]; local 1205 const uint64_t startWritableAddress = sharedRegionStartWritableAddress(currentExecuteAddress); local 1206 uint64_t currentWritableAddress = startWritableAddress; local 1208 std::vector<MachOLayoutAbstraction::Segment>& segs = ((MachOLayoutAbstraction*)(it->layout))->getSegments(); local 1210 MachOLayoutAbstraction::Segment& seg = segs[i]; local 1226 const uint64_t startReadOnlyAddress = sharedRegionStartReadOnlyAddress(currentWritableAddress, currentExecuteAddress); local 1227 uint64_t currentReadOnlyAddress = startReadOnlyAddress; local 1229 std::vector<MachOLayoutAbstraction::Segment>& segs = ((MachOLayoutAbstraction*)(it->layout))->getSegments(); local 1231 MachOLayoutAbstraction::Segment& seg = segs[i]; local 1245 std::vector<MachOLayoutAbstraction::Segment>& segs = ((MachOLayoutAbstraction*)(it->layout))->getSegments(); local 1247 MachOLayoutAbstraction::Segment& seg = segs[i]; local 1259 uint64_t cacheFileOffset = 0; local 1261 shared_file_mapping_np executeMapping; local 1270 shared_file_mapping_np writableMapping; local 1280 shared_file_mapping_np readOnlyMapping; local 1291 shared_file_mapping_np cacheHeaderMapping; local 1304 cacheFileOffsetForVMAddress(uint64_t vmaddr) const argument 1314 VMAddressForCacheFileOffset(uint64_t offset) const argument 1324 mappedAddressForVMAddress(uint64_t vmaddr) argument 1331 VMAddressForMappedAddress(const void *mapaddr) argument 1340 notUpToDate(const void* cache, unsigned int aliasCount) argument 1342 dyldCacheHeader<E>* header = (dyldCacheHeader<E>*)cache; local 1344 const char* archPairName = fArchGraph->archName(); local 1345 char temp[16]; local 1370 const dyldCacheFileMapping<E>* textMapping = (dyldCacheFileMapping<E>*)((uint8_t*)cache+sizeof(dyldCacheHeader<E>)); local 1371 const uint32_t textSize = textMapping->size(); local 1374 std::map<const MachOLayoutAbstraction*, uint32_t> sortingMap; local 1375 const dyldCacheImageInfo<E>* imagesStart = (dyldCacheImageInfo<E>*)((uint8_t*)cache + header->imagesOffset()); local 1376 const dyldCacheImageInfo<E>* imagesEnd = &imagesStart[header->imagesCount()]; local 1378 bool found = false; local 1440 notUpToDate(const char* path, unsigned int aliasCount) argument 1443 int fd = ::open(path, O_RDONLY); local 1446 struct stat stat_buf; local 1448 uint32_t cacheFileSize = stat_buf.st_size; local 1449 uint32_t cacheAllocatedSize = pageAlign(cacheFileSize); local 1450 uint8_t* mappingAddr = NULL; local 1455 ssize_t readResult = pread(fd, mappingAddr, cacheFileSize, 0); local 1461 bool result = this->notUpToDate(mappingAddr, aliasCount); local 1468 vm_deallocate(mach_task_self(), (vm_address_t)mappingAddr, cacheAllocatedSize); local 1478 class LinkEditOptimizer class 1482 virtual ~LinkEditOptimizer() {} function in class:LinkEditOptimizer 1503 typedef typename A::P P; typedef in class:LinkEditOptimizer 1504 typedef typename A::P::E E; typedef in class:LinkEditOptimizer 1505 typedef typename A::P::uint_t pint_t; typedef in class:LinkEditOptimizer 1509 const SharedCache<A>& fSharedCache; member in class:LinkEditOptimizer 1510 const macho_header<P>* fHeader; member in class:LinkEditOptimizer 1511 uint8_t* fNewLinkEditStart; member in class:LinkEditOptimizer 1512 uint8_t* fLinkEditBase; member in class:LinkEditOptimizer 1513 const MachOLayoutAbstraction& fLayout; member in class:LinkEditOptimizer 1514 macho_dyld_info_command<P>* fDyldInfo; member in class:LinkEditOptimizer 1515 macho_dysymtab_command<P>* fDynamicSymbolTable; member in class:LinkEditOptimizer 1516 macho_linkedit_data_command<P>* fFunctionStarts; member in class:LinkEditOptimizer 1517 macho_linkedit_data_command<P>* fDataInCode; member in class:LinkEditOptimizer 1518 macho_symtab_command<P>* fSymbolTableLoadCommand; member in class:LinkEditOptimizer 1519 const macho_nlist<P>* fSymbolTable; member in class:LinkEditOptimizer 1520 const char* fStrings; member in class:LinkEditOptimizer 1521 StringPool& fNewStringPool; member in class:LinkEditOptimizer 1522 std::map<uint32_t,uint32_t> fOldToNewSymbolIndexes; member in class:LinkEditOptimizer 1523 uint32_t fBindInfoOffsetIntoNewLinkEdit; member in class:LinkEditOptimizer 1524 uint32_t fBindInfoSizeInNewLinkEdit; member in class:LinkEditOptimizer 1525 uint32_t fWeakBindInfoOffsetIntoNewLinkEdit; member in class:LinkEditOptimizer 1526 uint32_t fWeakBindInfoSizeInNewLinkEdit; member in class:LinkEditOptimizer 1527 uint32_t fLazyBindInfoOffsetIntoNewLinkEdit; member in class:LinkEditOptimizer 1528 uint32_t fLazyBindInfoSizeInNewLinkEdit; member in class:LinkEditOptimizer 1529 uint32_t fExportInfoOffsetIntoNewLinkEdit; member in class:LinkEditOptimizer 1530 uint32_t fExportInfoSizeInNewLinkEdit; member in class:LinkEditOptimizer 1531 uint32_t fSymbolTableStartOffsetInNewLinkEdit; member in class:LinkEditOptimizer 1532 uint32_t fLocalSymbolsStartIndexInNewLinkEdit; member in class:LinkEditOptimizer 1533 uint32_t fLocalSymbolsCountInNewLinkEdit; member in class:LinkEditOptimizer 1534 uint32_t fExportedSymbolsStartIndexInNewLinkEdit; member in class:LinkEditOptimizer 1535 uint32_t fExportedSymbolsCountInNewLinkEdit; member in class:LinkEditOptimizer 1536 uint32_t fImportSymbolsStartIndexInNewLinkEdit; member in class:LinkEditOptimizer 1537 uint32_t fImportedSymbolsCountInNewLinkEdit; member in class:LinkEditOptimizer 1538 uint32_t fExternalRelocationsOffsetIntoNewLinkEdit; member in class:LinkEditOptimizer 1539 uint32_t fIndirectSymbolTableOffsetInfoNewLinkEdit; member in class:LinkEditOptimizer 1540 uint32_t fFunctionStartsOffsetInNewLinkEdit; member in class:LinkEditOptimizer 1541 uint32_t fDataInCodeOffsetInNewLinkEdit; member in class:LinkEditOptimizer 1542 uint32_t fUnmappedLocalSymbolsStartIndexInNewLinkEdit; member in class:LinkEditOptimizer 1543 uint32_t fUnmappedLocalSymbolsCountInNewLinkEdit; member in class:LinkEditOptimizer 1549 LinkEditOptimizer(const MachOLayoutAbstraction& layout, const SharedCache<A>& sharedCache, uint8_t* newLinkEdit, StringPool& stringPool) argument 1568 const std::vector<MachOLayoutAbstraction::Segment>& segments = fLayout.getSegments(); local 1570 const MachOLayoutAbstraction::Segment& seg = *it; local 1577 const macho_load_command<P>* const cmds = (macho_load_command<P>*)((uint8_t*)fHeader + sizeof(macho_header<P>)); local 1578 const uint32_t cmd_count = fHeader->ncmds(); local 1579 const macho_load_command<P>* cmd = cmds; local 1613 class SymbolSorter class 1616 typedef typename A::P P; typedef in class:SymbolSorter 1617 SymbolSorter(const StringPool& pool) argument 1618 operator ()(const macho_nlist<P>& left, const macho_nlist<P>& right) argument 1623 const StringPool& fStringPool; member in class:SymbolSorter 1628 copyBindInfo(uint32_t& offset) argument 1639 copyWeakBindInfo(uint32_t& offset) argument 1650 copyLazyBindInfo(uint32_t& offset) argument 1661 copyExportInfo(uint32_t& offset) argument 1673 copyLocalSymbols(uint32_t symbolTableOffset, uint32_t& symbolIndex, bool dontMapLocalSymbols, uint8_t* cacheStart, StringPool& unmappedLocalsStringPool, std::vector<macho_nlist<P> >& unmappedSymbols, std::vector<LocalSymbolInfo>& dylibInfos) argument 1678 LocalSymbolInfo localInfo; local 1683 macho_nlist<P>* const newSymbolTableStart = (macho_nlist<P>*)(fNewLinkEditStart+symbolTableOffset); local 1684 const macho_nlist<P>* const firstLocal = &fSymbolTable[fDynamicSymbolTable->ilocalsym()]; local 1685 const macho_nlist<P>* const lastLocal = &fSymbolTable[fDynamicSymbolTable->ilocalsym()+fDynamicSymbolTable->nlocalsym()]; local 1686 uint32_t oldIndex = fDynamicSymbolTable->ilocalsym(); local 1690 const char* name = &fStrings[entry->n_strx()]; local 1691 macho_nlist<P>* newSymbolEntry = &newSymbolTableStart[symbolIndex]; local 1717 copyExportedSymbols(uint32_t symbolTableOffset, uint32_t& symbolIndex) argument 1720 macho_nlist<P>* const newSymbolTableStart = (macho_nlist<P>*)(fNewLinkEditStart+symbolTableOffset); local 1721 const macho_nlist<P>* const firstExport = &fSymbolTable[fDynamicSymbolTable->iextdefsym()]; local 1722 const macho_nlist<P>* const lastExport = &fSymbolTable[fDynamicSymbolTable->iextdefsym()+fDynamicSymbolTable->nextdefsym()]; local 1723 uint32_t oldIndex = fDynamicSymbolTable->iextdefsym(); local 1727 macho_nlist<P>* newSymbolEntry = &newSymbolTableStart[symbolIndex]; local 1737 macho_nlist<P>* newSymbolsStart = &newSymbolTableStart[fExportedSymbolsStartIndexInNewLinkEdit]; local 1738 macho_nlist<P>* newSymbolsEnd = &newSymbolTableStart[fExportedSymbolsStartIndexInNewLinkEdit+fExportedSymbolsCountInNewLinkEdit]; local 1746 copyImportedSymbols(uint32_t symbolTableOffset, uint32_t& symbolIndex) argument 1749 macho_nlist<P>* const newSymbolTableStart = (macho_nlist<P>*)(fNewLinkEditStart+symbolTableOffset); local 1750 const macho_nlist<P>* const firstImport = &fSymbolTable[fDynamicSymbolTable->iundefsym()]; local 1751 const macho_nlist<P>* const lastImport = &fSymbolTable[fDynamicSymbolTable->iundefsym()+fDynamicSymbolTable->nundefsym()]; local 1752 uint32_t oldIndex = fDynamicSymbolTable->iundefsym(); local 1755 macho_nlist<P>* newSymbolEntry = &newSymbolTableStart[symbolIndex]; local 1772 copyExternalRelocations(uint32_t& offset) argument 1775 const macho_relocation_info<P>* const relocsStart = (macho_relocation_info<P>*)(&fLinkEditBase[fDynamicSymbolTable->extreloff()]); local 1776 const macho_relocation_info<P>* const relocsEnd = &relocsStart[fDynamicSymbolTable->nextrel()]; local 1778 macho_relocation_info<P>* newReloc = (macho_relocation_info<P>*)(&fNewLinkEditStart[offset]); local 1780 uint32_t newSymbolIndex = fOldToNewSymbolIndexes[reloc->r_symbolnum()]; local 1789 copyFunctionStarts(uint32_t& offset) argument 1799 copyDataInCode(uint32_t& offset) argument 1810 copyIndirectSymbolTable(uint32_t& offset) argument 1813 const uint32_t* const indirectTable = (uint32_t*)&this->fLinkEditBase[fDynamicSymbolTable->indirectsymoff()]; local 1814 uint32_t* newIndirectTable = (uint32_t*)&fNewLinkEditStart[offset]; local 1816 uint32_t oldSymbolIndex = E::get32(indirectTable[i]); local 1817 uint32_t newSymbolIndex = oldSymbolIndex; local 1829 updateLoadCommands(uint64_t newVMAddress, uint64_t leSize, uint32_t stringPoolOffset, uint32_t linkEditsFileOffset, bool keepSignatures) argument 1833 const macho_load_command<P>* const cmds = (macho_load_command<P>*)((uint8_t*)fHeader + sizeof(macho_header<P>)); local 1834 const uint32_t cmd_count = fHeader->ncmds(); local 1835 const macho_load_command<P>* cmd = cmds; local 1838 macho_segment_command<P>* seg = (macho_segment_command<P>*)cmd; local 1846 pint_t oldFileOff = seg->fileoff(); local 1852 pint_t fileOffsetDelta = seg->fileoff() - oldFileOff; local 1853 const MachOLayoutAbstraction::Segment* layoutSeg = fLayout.getSegment(seg->segname()); local 1867 macho_section<P>* const sectionsStart = (macho_section<P>*)((char*)seg + sizeof(macho_segment_command<P>)); local 1868 macho_section<P>* const sectionsEnd = §ionsStart[seg->nsects()]; local 1928 const macho_load_command<P>* srcCmd = cmds; local 1929 macho_load_command<P>* dstCmd = (macho_load_command<P>*)cmds; local 1930 int32_t newCount = 0; local 1932 uint32_t cmdSize = srcCmd->cmdsize(); local 1954 macho_header<P>* writableHeader = (macho_header<P>*)fHeader; local 1969 optimizeLINKEDIT(bool keepSignatures, bool dontMapLocalSymbols) argument 1972 uint8_t* newLinkEdit = new uint8_t[fLinkEditsTotalUnoptimizedSize]; local 1976 StringPool stringPool; local 1979 std::vector<LinkEditOptimizer<A>*> optimizers; local 1987 uint32_t offset = 0; local 2013 uint32_t symbolTableOffset = offset; local 2014 uint32_t symbolTableIndex = 0; local 2063 uint32_t linkEditsFileOffset = cacheFileOffsetForVMAddress(fLinkEditsStartAddress); local 2079 std::vector<MachOLayoutAbstraction::Segment>& segs = ((MachOLayoutAbstraction*)(it->layout))->getSegments(); local 2081 MachOLayoutAbstraction::Segment& seg = segs[i]; local 2098 class ObjCSelectorUniquer class 2101 objc_opt::string_map fSelectorStrings; member in class:ObjCSelectorUniquer 2102 SharedCache<A> *fCache; member in class:ObjCSelectorUniquer 2103 size_t fCount; member in class:ObjCSelectorUniquer 2107 ObjCSelectorUniquer(SharedCache<A> *newCache) argument 2113 visit(typename A::P::uint_t oldValue) argument 2116 const char *s = (const char *) local 2118 objc_opt::string_map::iterator element = local 2123 objc_opt::string_map& strings() { function in class:ObjCSelectorUniquer 2127 count() const argument 2132 class ClassListBuilder class 2135 typedef typename A::P P; typedef in class:ClassListBuilder 2137 objc_opt::string_map fClassNames; member in class:ClassListBuilder 2138 objc_opt::class_map fClasses; member in class:ClassListBuilder 2139 size_t fCount; member in class:ClassListBuilder 2140 HeaderInfoOptimizer<A>& fHinfos; member in class:ClassListBuilder 2144 ClassListBuilder(HeaderInfoOptimizer<A>& hinfos) argument 2151 visitClass(SharedCache<A>* cache, const macho_header<P>* header, objc_class_t<A>* cls) argument 2157 const char *name = cls->getName(cache); local 2158 uint64_t name_vmaddr = cache->VMAddressForMappedAddress(name); local 2159 uint64_t cls_vmaddr = cache->VMAddressForMappedAddress(cls); local 2160 uint64_t hinfo_vmaddr = cache->VMAddressForMappedAddress(fHinfos.hinfoForHeader(cache, header)); local 2166 objc_opt::string_map& classNames() { function in class:ClassListBuilder 2170 objc_opt::class_map& classes() { function in class:ClassListBuilder 2174 count() const argument 2178 percent(size_t num, size_t denom) argument 2184 optimizeObjC(std::vector<void*>& pointersInData) argument 2186 const char *err; local 2192 size_t headerSize = P::round_up(sizeof(objc_opt::objc_opt_t)); local 2198 const macho_section<P> *optROSection = NULL; local 2199 const macho_section<P> *optRWSection = NULL; local 2202 const macho_header<P>* mh = (const macho_header<P>*)(*it->layout).getSegments()[0].mappedAddress(); local 2219 uint8_t* optROData = (uint8_t*)mappedAddressForVMAddress(optROSection->addr()); local 2220 size_t optRORemaining = optROSection->size(); local 2222 uint8_t* optRWData = (uint8_t*)mappedAddressForVMAddress(optRWSection->addr()); local 2223 size_t optRWRemaining = optRWSection->size(); local 2229 objc_opt::objc_opt_t* optROHeader = (objc_opt::objc_opt_t *)optROData; local 2242 std::vector<LayoutInfo> objcDylibs; local 2244 macho_header<P> *mh = (macho_header<P>*)(*it->layout).getSegments()[0].mappedAddress(); local 2254 std::vector<LayoutInfo> addressSortedDylibs = objcDylibs; local 2257 uint64_t hinfoVMAddr = optRWSection->addr() + optRWSection->size() - optRWRemaining; local 2258 HeaderInfoOptimizer<A> hinfoOptimizer; local 2261 warn(archName(), err); local 2265 const macho_header<P> *mh = (const macho_header<P>*)(*it->layout).getSegments()[0].mappedAddress(); local 2278 std::vector<LayoutInfo> sizeSortedDylibs = objcDylibs; local 2283 const macho_header<P> *mh = (const macho_header<P>*)(*it->layout).getSegments()[0].mappedAddress(); local 2288 uint64_t seloptVMAddr = optROSection->addr() + optROSection->size() - optRORemaining; local 2289 objc_opt::objc_selopt_t *selopt = new(optROData) objc_opt::objc_selopt_t; local 2292 warn(archName(), err); local 2297 selopt->byteswap(E::little_endian), selopt = NULL; local 2307 const macho_header<P> *mh = (const macho_header<P>*)(*it->layout).getSegments()[0].mappedAddress(); local 2311 uint64_t clsoptVMAddr = optROSection->addr() + optROSection->size() - optRORemaining; local 2312 objc_opt::objc_clsopt_t *clsopt = new(optROData) objc_opt::objc_clsopt_t; local 2316 warn(archName(), err); local 2321 size_t duplicateCount = clsopt->duplicateCount(); local 2322 clsopt->byteswap(E::little_endian), clsopt = NULL; local 2330 MethodListSorter<A> methodSorter; local 2332 macho_header<P> *mh = (macho_header<P>*)(*it->layout).getSegments()[0].mappedAddress(); local 2341 IvarOffsetOptimizer<A> ivarOffsetOptimizer; local 2343 const macho_header<P> *mh = (const macho_header<P>*)(*it->layout).getSegments()[0].mappedAddress(); local 2350 const macho_header<P> *mh = (const macho_header<P>*)(*it->layout).getSegments()[0].mappedAddress(); local 2351 const macho_section<P> *imageInfoSection; local 2357 objc_image_info<A> *info = (objc_image_info<A> *) local 2370 size_t roSize = optROSection->size() - optRORemaining; local 2371 size_t rwSize = optRWSection->size() - optRWRemaining; local 2404 static const char* sCleanupFile = NULL; variable 2405 cleanup(int sig) argument 2418 sync_volume(const char* volumePath) argument 2421 int error = sync_volume_np(volumePath, SYNC_VOLUME_FULLSYNC|SYNC_VOLUME_FULLSYNC); local 2434 adhoc_codesign_share_cache(const char* path) argument 2436 CFURLRef target = ::CFURLCreateFromFileSystemRepresentation(NULL, (const UInt8 *)path, strlen(path), FALSE); local 2441 OSStatus status = ::SecStaticCodeCreateWithPath(target, kSecCSDefaultFlags, &code); local 2448 const void * keys[1] = { (void *)kSecCodeSignerIdentity } ; local 2449 const void * values[1] = { (void *)kCFNull }; local 2450 CFDictionaryRef params = ::CFDictionaryCreate(NULL, keys, values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); local 2456 SecCodeSignerRef signer; local 2481 template <> bool SharedCache<x86_64>::addCacheSlideInfo(){ return true; } function in class:SharedCache 2482 template <> bool SharedCache<arm>::addCacheSlideInfo() { return true; } function in class:SharedCache 2483 template <> bool SharedCache<x86>::addCacheSlideInfo() { return false; } function in class:SharedCache 2484 template <> bool SharedCache<arm64>::addCacheSlideInfo() { return true; } function in class:SharedCache 2488 update(bool force, bool optimize, bool deleteExistingFirst, int archIndex, int archCount, bool keepSignatures, bool dontMapLocalSymbols) argument 2491 bool didUpdate = false; local 2505 uint8_t* inMemoryCache = NULL; local 2506 uint32_t allocatedCacheSize = 0; local 2507 char tempCachePath[strlen(fCacheFilePath)+16]; local 2511 uint32_t cacheFileSize = 0; local 2513 uint32_t end = it->sfm_file_offset + it->sfm_size; local 2523 dyldCacheHeader<E>* header = (dyldCacheHeader<E>*)inMemoryCache; local 2524 const char* archPairName = fArchGraph->archName(); local 2525 char temp[16]; local 2543 dyldCacheFileMapping<E>* mapping = (dyldCacheFileMapping<E>*)&inMemoryCache[sizeof(dyldCacheHeader<E>)]; local 2557 dyldCacheImageInfo<E>* image = (dyldCacheImageInfo<E>*)mapping; local 2578 const int dylibCount = fDylibs.size(); local 2579 int dylibIndex = 0; local 2580 int progressIndex = 0; local 2582 const char* path = it->layout->getFilePath(); local 2583 int src = ::open(path, O_RDONLY, 0); local 2589 struct stat stat_buf; local 2600 const std::vector<MachOLayoutAbstraction::Segment>& segs = it->layout->getSegments(); local 2602 const MachOLayoutAbstraction::Segment& seg = segs[i]; local 2606 const uint64_t segmentSrcStartOffset = it->layout->getOffsetInUniversalFile()+seg.fileOffset(); local 2607 const uint64_t segmentSize = seg.fileSize(); local 2608 const uint64_t segmentDstStartOffset = cacheFileOffsetForVMAddress(seg.newAddress()); local 2609 ssize_t readResult = ::pread(src, &inMemoryCache[segmentDstStartOffset], segmentSize, segmentSrcStartOffset); local 2626 int nextProgressIndex = archIndex*100+(40*dylibIndex)/dylibCount; local 2635 std::vector<MachOLayoutAbstraction::Segment>& segs = ((MachOLayoutAbstraction*)(it->layout))->getSegments(); local 2637 MachOLayoutAbstraction::Segment& seg = segs[i]; local 2645 std::vector<void*> pointersInData; local 2664 typename Binder<A>::Map map; local 2665 std::vector<Binder<A>*> binders; local 2668 Binder<A>* binder = new Binder<A>(*it->layout, fDyldBaseAddress); local 2710 dyldCacheHeader<E>* cacheHeader = (dyldCacheHeader<E>*)inMemoryCache; local 2711 dyldCacheFileMapping<E>* mappings = (dyldCacheFileMapping<E>*)&inMemoryCache[sizeof(dyldCacheHeader<E>)]; local 2712 dyldCacheFileMapping<E>* lastMapping = &mappings[cacheHeader->mappingCount()-1]; local 2733 uint8_t* const dataStart = &inMemoryCache[fMappings[1].sfm_file_offset]; // R/W mapping is always second local 2734 uint8_t* const dataEnd = &inMemoryCache[fMappings[1].sfm_file_offset+fMappings[1].sfm_size]; local 2735 const int bitmapSize = (dataEnd - dataStart)/(4*8); local 2736 uint8_t* bitmap = (uint8_t*)calloc(bitmapSize, 1); local 2737 void* lastPointer = inMemoryCache; local 2740 void* p = *pit; local 2743 long offset = (long)((uint8_t*)p - dataStart); local 2746 long byteIndex = offset / (4*8); local 2747 long bitInByte = (offset % 32) >> 2; local 2754 const int entry_size = 4096/(8*4); // 8 bits per byte, possible pointer every 4 bytes. local 2755 const int toc_count = bitmapSize/entry_size; local 2756 int slideInfoSize = sizeof(dyldCacheSlideInfo<E>) + 2*toc_count + entry_size*(toc_count+1); local 2757 dyldCacheSlideInfo<E>* slideInfo = (dyldCacheSlideInfo<E>*)calloc(slideInfoSize, 1); local 2765 const dyldCacheSlideInfoEntry* bitmapAsEntries = (dyldCacheSlideInfoEntry*)bitmap; local 2766 dyldCacheSlideInfoEntry* const entriesInSlidInfo = (dyldCacheSlideInfoEntry*)((char*)slideInfo+slideInfo->entries_offset()); local 2767 int entry_count = 0; local 2769 const dyldCacheSlideInfoEntry* thisEntry = &bitmapAsEntries[i]; local 2771 bool found = false; local 2788 int slideInfoPageSize = regionAlign(slideInfo->entries_offset() + entry_count*entry_size); local 2792 dyldCacheHeader<E>* cacheHeader = (dyldCacheHeader<E>*)inMemoryCache; local 2793 dyldCacheFileMapping<E>* mappings = (dyldCacheFileMapping<E>*)&inMemoryCache[sizeof(dyldCacheHeader<E>)]; local 2794 dyldCacheFileMapping<E>* lastMapping = &mappings[cacheHeader->mappingCount()-1]; local 2811 uint32_t spaceAtEnd = allocatedCacheSize - cacheFileSize; local 2812 uint32_t localSymbolsOffset = pageAlign(cacheFileSize); local 2813 dyldCacheLocalSymbolsInfo<E>* infoHeader = (dyldCacheLocalSymbolsInfo<E>*)(&inMemoryCache[localSymbolsOffset]); local 2814 const uint32_t entriesOffset = sizeof(dyldCacheLocalSymbolsInfo<E>); local 2815 const uint32_t entriesCount = fLocalSymbolInfos.size(); local 2816 const uint32_t nlistOffset = entriesOffset + entriesCount * sizeof(dyldCacheLocalSymbolEntry<E>); local 2817 const uint32_t nlistCount = fUnmappedLocalSymbols.size(); local 2818 const uint32_t stringsOffset = nlistOffset + nlistCount * sizeof(macho_nlist<P>); local 2819 const uint32_t stringsSize = fUnmappedLocalsStringPool.size(); local 2831 dyldCacheLocalSymbolEntry<E>* entries = (dyldCacheLocalSymbolEntry<E>*)(&inMemoryCache[localSymbolsOffset+entriesOffset]); local 2847 dyldCacheHeader<E>* cacheHeader = (dyldCacheHeader<E>*)inMemoryCache; local 2855 dyldCacheHeader<E>* cacheHeader = (dyldCacheHeader<E>*)inMemoryCache; local 2856 dyldCacheFileMapping<E>* mappings = (dyldCacheFileMapping<E>*)&inMemoryCache[cacheHeader->mappingOffset()]; local 2858 uint32_t estCodeSigSize = regionAlign(cacheFileSize/200); // guess 0.5% for code signature local 2860 uint64_t endAddr = mappings[i].address() + mappings[i].size() + estCodeSigSize; local 2869 uint8_t digest[16]; local 2883 const dyldCacheHeader<E>* newHeader = (dyldCacheHeader<E>*)inMemoryCache; local 2884 const dyldCacheHeader<E>* oldHeader = (dyldCacheHeader<E>*)fExistingCacheForVerification; local 2889 const dyldCacheFileMapping<E>* newMappings = (dyldCacheFileMapping<E>*)&inMemoryCache[newHeader->mappingOffset()]; local 2890 const dyldCacheFileMapping<E>* oldMappings = (dyldCacheFileMapping<E>*)&fExistingCacheForVerification[oldHeader->mappingOffset()]; local 2909 const std::vector<MachOLayoutAbstraction::Segment>& segs = it->layout->getSegments(); local 2911 const MachOLayoutAbstraction::Segment& seg = *sit; local 2945 char dyldDirs[1024]; local 2947 char* lastSlash = strrchr(dyldDirs, '/'); local 2950 struct stat stat_buf; local 2952 const char* afterSlash = &dyldDirs[1]; local 2953 char* slash; local 2963 int fd = ::open(tempCachePath, O_CREAT | O_RDWR | O_TRUNC, 0644); local 2968 fstore_t fcntlSpec = { F_ALLOCATECONTIG|F_ALLOCATEALL, F_PEOFPOSMODE, 0, cacheFileSize, 0 }; local 2982 int result = ::fcntl(fd, F_FULLFSYNC, NULL); local 3000 char tmpDirPath[64]; local 3001 const char* pathLastSlash = strrchr(fCacheFilePath, '/'); local 3033 char mapFilePath[strlen(fCacheFilePath)+16]; local 3035 char tempMapFilePath[strlen(fCacheFilePath)+32]; local 3037 FILE* fmap = ::fopen(tempMapFilePath, "w"); local 3043 const char* prot = "RW"; local 3102 dyldCacheHeader<E>* cacheHeader = (dyldCacheHeader<E>*)inMemoryCache; local 3109 uint64_t endMappingAddr = fMappings[2].sfm_address + fMappings[2].sfm_size; local 3113 uint64_t freeSpace = 256*1024*1024 - fMappings[1].sfm_size; local 3117 uint64_t freeSpace = sharedRegionStartAddress() + sharedRegionSize() - endMappingAddr; local 3125 const std::vector<MachOLayoutAbstraction::Segment>& segs = it->layout->getSegments(); local 3127 const MachOLayoutAbstraction::Segment& seg = segs[i]; local 3143 vm_deallocate(mach_task_self(), (vm_address_t)inMemoryCache, allocatedCacheSize); local 3172 parsePathsFile(const char* filePath, std::vector<const char*>& paths) argument 3175 int fd = open(filePath, O_RDONLY, 0); local 3180 struct stat stat_buf; local 3182 char* p = (char*)malloc(stat_buf.st_size); local 3194 char * const end = &p[stat_buf.st_size]; local 3195 enum { lineStart, inSymbol, inComment } state = lineStart; local 3196 char* symbolStart = NULL; local 3212 char* last = s-1; local 3233 setSharedDylibs(const char* rootPath, const std::vector<const char*>& overlayPaths, const std::set<ArchPair>& onlyArchs, std::vector<const char*> rootsPaths) argument 3253 scanForSharedDylibs(const char* rootPath, const std::vector<const char*>& overlayPaths, const char* dirOfPathFiles, const std::set<ArchPair>& onlyArchs) argument 3255 char rootDirOfPathFiles[strlen(rootPath)+strlen(dirOfPathFiles)+2]; local 3266 std::vector<const char*> rootsPaths; local 3267 DIR* dir = ::opendir(dirOfPathFiles); local 3274 struct stat tmpStatPathsFile; local 3275 char fullPath[strlen(dirOfPathFiles)+entry->d_namlen+2]; local 3301 setSharedDylibs(const char* rootPath, const std::vector<const char*>& overlayPaths, const char* pathsFile, const std::set<ArchPair>& onlyArchs) argument 3303 std::vector<const char*> rootsPaths; local 3314 static void deleteOrphanTempCacheFiles() function 3316 DIR* dir = ::opendir(MACOSX_DYLD_SHARED_CACHE_DIR); local 3318 std::vector<const char*> filesToDelete; local 3323 char fullPath[strlen(MACOSX_DYLD_SHARED_CACHE_DIR)+entry->d_namlen+2]; local 3327 struct stat tmpFileStatInfo; local 3329 int mib[2] = {CTL_KERN, KERN_BOOTTIME}; local 3330 struct timeval boottime; local 3331 size_t size = sizeof(boottime); local 3352 updateSharedeCacheFile(const char* rootPath, const std::vector<const char*>& overlayPaths, const char* cacheDir, bool explicitCacheDir, const std::set<ArchPair>& onlyArchs, bool force, bool alphaSort, bool optimize, bool deleteExistingFirst, bool verify, bool keepSignatures, bool dontMapLocalSymbols) argument 3355 bool didUpdate = false; local 3357 UniversalMachOLayout* dyldLayout = NULL; local 3358 char dyldPath[1024]; local 3361 struct stat stat_buf; local 3368 const int archCount = onlyArchs.size(); local 3369 int index = 0; local 3371 const MachOLayoutAbstraction* dyldLayoutForArch = dyldLayout->getSlice(*a); local 3372 uint64_t dyldBaseAddress = 0; local 3412 static void usage() function 3418 main(int argc, const char* argv[]) argument 3420 std::set<ArchPair> onlyArchs; local 3421 const char* rootPath = ""; local 3422 std::vector<const char*> overlayPaths; local 3423 const char* dylibListFile = NULL; local 3424 bool force = false; local 3425 bool alphaSort = false; local 3426 bool optimize = true; local 3427 bool verify = false; local 3428 bool keepSignatures = false; local 3429 bool explicitCacheDir = false; local 3430 bool dontMapLocalSymbols = false; local 3431 bool relaunchForHaswell = false; local 3432 const char* cacheDir = NULL; local 3437 const char* arg = argv[i]; local 3478 const char* path = argv[++i]; local 3490 const char* arch = argv[++i]; local 3535 char realRootPath[MAXPATHLEN]; local 3543 char realOverlayPath[MAXPATHLEN]; local 3560 int available; local 3561 size_t len = sizeof(int); local 3567 struct host_basic_info info; local 3568 mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT; local 3569 mach_port_t hostPort = mach_host_self(); local 3570 kern_return_t result = host_info(hostPort, HOST_BASIC_INFO, (host_info_t)&info, &count); local 3571 mach_port_deallocate(mach_task_self(), hostPort); local 3593 bool didUpdate = updateSharedeCacheFile(rootPath, overlayPaths, cacheDir, explicitCacheDir, onlyArchs, force, alphaSort, optimize, local 3597 void* handle = dlopen("/usr/lib/libspindump.dylib", RTLD_LAZY); local 3599 typedef bool (*dscsym_proc_t)(const char *root); typedef 3600 dscsym_proc_t proc = (dscsym_proc_t)dlsym(handle, "dscsym_save_nuggets_for_current_caches"); local 3601 const char* nuggetRootPath = "/"; local 3612 char cmd[2048]; local [all...] |
/macosx-10.10/dyld-353.2.1/src/ |
H A D | ImageLoader.cpp | 25 #define __STDC_LIMIT_MACROS macro 42 uint32_t ImageLoader::fgImagesUsedFromSharedCache = 0; member in class:ImageLoader 43 uint32_t ImageLoader::fgImagesWithUsedPrebinding = 0; member in class:ImageLoader 44 uint32_t ImageLoader::fgImagesRequiringCoalescing = 0; member in class:ImageLoader 45 uint32_t ImageLoader::fgImagesHasWeakDefinitions = 0; member in class:ImageLoader 46 uint32_t ImageLoader::fgTotalRebaseFixups = 0; member in class:ImageLoader 47 uint32_t ImageLoader::fgTotalBindFixups = 0; member in class:ImageLoader 48 uint32_t ImageLoader::fgTotalBindSymbolsResolved = 0; member in class:ImageLoader 49 uint32_t ImageLoader::fgTotalBindImageSearches = 0; member in class:ImageLoader 50 uint32_t ImageLoader::fgTotalLazyBindFixups = 0; member in class:ImageLoader 51 uint32_t ImageLoader::fgTotalPossibleLazyBindFixups = 0; member in class:ImageLoader 52 uint32_t ImageLoader::fgTotalSegmentsMapped = 0; member in class:ImageLoader 53 uint64_t ImageLoader::fgTotalBytesMapped = 0; member in class:ImageLoader 54 uint64_t ImageLoader::fgTotalBytesPreFetched = 0; member in class:ImageLoader 55 uint64_t ImageLoader::fgTotalLoadLibrariesTime; member in class:ImageLoader 56 uint64_t ImageLoader::fgTotalRebaseTime; member in class:ImageLoader 57 uint64_t ImageLoader::fgTotalBindTime; member in class:ImageLoader 58 uint64_t ImageLoader::fgTotalWeakBindTime; member in class:ImageLoader 59 uint64_t ImageLoader::fgTotalDOF; member in class:ImageLoader 60 uint64_t ImageLoader::fgTotalInitTime; member in class:ImageLoader 61 uint16_t ImageLoader::fgLoadOrdinal = 0; member in class:ImageLoader 62 std::vector<ImageLoader::InterposeTuple>ImageLoader::fgInterposingTuples; member in class:ImageLoader 63 uintptr_t ImageLoader::fgNextPIEDylibAddress = 0; member in class:ImageLoader 67 ImageLoader(const char* path, unsigned int libCount) argument 85 deleteImage(ImageLoader* image) argument 91 ImageLoader::~ImageLoader() function in class:ImageLoader 99 setFileInfo(dev_t device, ino_t inode, time_t modDate) argument 106 setMapped(const LinkContext& context) argument 112 compare(const ImageLoader* right) const argument 130 setPath(const char* path) argument 141 setPathUnowned(const char* path) argument 151 setPaths(const char* path, const char* realPath) argument 158 getRealPath() const argument 167 hash(const char* path) argument 172 uint32_t h = 0; local 178 matchInstallPath() const argument 183 setMatchInstallPath(bool match) argument 188 statMatch(const struct stat& stat_buf) const argument 193 getShortName() const argument 197 const char* s = strrchr(fPath, '/'); local 204 void ImageLoader::setLeaveMapped() function in class:ImageLoader 209 setHideExports(bool hide) argument 214 hasHiddenExports() const argument 219 isLinked() const argument 224 lastModified() const argument 229 containsAddress(const void* addr) const argument 232 const uint8_t* start = (const uint8_t*)segActualLoadAddress(i); local 233 const uint8_t* end = (const uint8_t*)segActualEndAddress(i); local 240 overlapsWithAddressRange(const void* start, const void* end) const argument 243 const uint8_t* segStart = (const uint8_t*)segActualLoadAddress(i); local 244 const uint8_t* segEnd = (const uint8_t*)segActualEndAddress(i); local 262 getMappedRegions(MappedRegion*& regions) const argument 265 MappedRegion region; local 274 dependsOn(ImageLoader* image) argument 283 notInImgageList(const ImageLoader* image, const ImageLoader** dsiStart, const ImageLoader** dsiCur) argument 293 findExportedSymbolInDependentImagesExcept(const char* name, const ImageLoader** dsiStart, const ImageLoader**& dsiCur, const ImageLoader** dsiEnd, const ImageLoader** foundIn) const argument 296 const ImageLoader::Symbol* sym; local 307 ImageLoader* dependentImage = libImage(i); local 309 const ImageLoader::Symbol* sym = dependentImage->findExportedSymbol(name, false, foundIn); local 317 ImageLoader* dependentImage = libImage(i); local 320 const ImageLoader::Symbol* sym = dependentImage->findExportedSymbolInDependentImagesExcept(name, dsiStart, dsiCur, dsiEnd, foundIn); local 330 findExportedSymbolInDependentImages(const char* name, const LinkContext& context, const ImageLoader** foundIn) const argument 332 unsigned int imageCount = context.imageCount(); local 333 const ImageLoader* dontSearchImages[imageCount]; local 335 const ImageLoader** cur = &dontSearchImages[1]; local 339 findExportedSymbolInImageOrDependentImages(const char* name, const LinkContext& context, const ImageLoader** foundIn) const argument 341 unsigned int imageCount = context.imageCount(); local 342 const ImageLoader* dontSearchImages[imageCount]; local 343 const ImageLoader** cur = &dontSearchImages[0]; local 348 applyInterposing(const LinkContext& context) argument 355 interposedAddress(const LinkContext& context, uintptr_t address, const ImageLoader* inImage, const ImageLoader* onlyInImage) argument 372 addDynamicInterposingTuples(const struct dyld_interpose_tuple array[], size_t count) argument 375 ImageLoader::InterposeTuple tuple; local 391 link(const LinkContext& context, bool forceLazysBound, bool preflightOnly, bool neverUnload, const RPathChain& loaderRPaths) argument 398 uint64_t t0 = mach_absolute_time(); local 410 uint64_t t2 = mach_absolute_time(); local 414 uint64_t t3 = mach_absolute_time(); local 417 uint64_t t4 = mach_absolute_time(); local 420 uint64_t t5 = mach_absolute_time(); local 423 uint64_t t6 = mach_absolute_time(); local 425 std::vector<DOFInfo> dofs; local 428 uint64_t t7 = mach_absolute_time(); local 449 void ImageLoader::printReferenceCounts() function in class:ImageLoader 455 bool ImageLoader::decrementDlopenReferenceCount() function in class:ImageLoader 468 processInitializers(const LinkContext& context, mach_port_t thisThread, InitializerTimingList& timingInfo, ImageLoader::UninitedUpwards& images) argument 471 uint32_t maxImageCount = context.imageCount(); local 472 ImageLoader::UninitedUpwards upsBuffer[maxImageCount]; local 473 ImageLoader::UninitedUpwards& ups = upsBuffer[0]; local 486 runInitializers(const LinkContext& context, InitializerTimingList& timingInfo) argument 488 uint64_t t1 = mach_absolute_time(); local 489 mach_port_t thisThread = mach_thread_self(); local 490 ImageLoader::UninitedUpwards up; local 495 mach_port_deallocate(mach_task_self(), thisThread); local 496 uint64_t t2 = mach_absolute_time(); local 501 bindAllLazyPointers(const LinkContext& context, bool recursive) argument 509 ImageLoader* dependentImage = libImage(i); local 520 allDependentLibrariesAsWhenPreBound() const argument 526 markedUsedRecursive(const std::vector<DynamicReference>& dynamicReferences) argument 535 ImageLoader* dependentImage = libImage(i); local 549 recursiveUpdateDepth(unsigned int maxDepth) argument 559 unsigned int minDependentDepth = maxDepth; local 561 ImageLoader* dependentImage = libImage(i); local 563 unsigned int d = dependentImage->recursiveUpdateDepth(maxDepth); local 577 recursiveLoadLibraries(const LinkContext& context, bool preflightOnly, const RPathChain& loaderRPaths) argument 584 DependentLibraryInfo libraryInfos[fLibraryCount]; local 588 std::vector<const char*> rpathsFromThisImage; local 593 bool canUsePrelinkingInfo = true; local 595 ImageLoader* dependentLib; local 596 bool depLibReExported = false; local 597 bool depLibReRequired = false; local 598 bool depLibCheckSumsMatch = false; local 599 DependentLibraryInfo& requiredLibInfo = libraryInfos[i]; local 623 LibraryInfo actualInfo = dependentLib->doGetLibraryInfo(); local 681 ImageLoader* dependentImage = libImage(i); local 690 ImageLoader* dependentImage = libImage(i); local 700 const char* str = *it; local 707 recursiveRebase(const LinkContext& context) argument 716 ImageLoader* dependentImage = libImage(i); local 736 recursiveApplyInterposing(const LinkContext& context) argument 745 ImageLoader* dependentImage = libImage(i); local 763 recursiveBind(const LinkContext& context, bool forceLazysBound, bool neverUnload) argument 776 ImageLoader* dependentImage = libImage(i); local 800 weakBind(const LinkContext& context) argument 804 uint64_t t1 = mach_absolute_time(); local 806 ImageLoader* imagesNeedingCoalescing[fgImagesRequiringCoalescing]; local 807 int count = context.getCoalescedImages(imagesNeedingCoalescing); local 810 int countNotYetWeakBound = 0; local 811 int countOfImagesWithWeakDefinitions = 0; local 812 int countOfImagesWithWeakDefinitionsNotInSharedCache = 0; local 826 ImageLoader::CoalIterator iterators[count]; local 827 ImageLoader::CoalIterator* sortedIts[count]; local 837 int doneCount = 0; local 847 int result = strcmp(sortedIts[i-1]->symbolName, sortedIts[i]->symbolName); local 852 ImageLoader::CoalIterator* temp = sortedIts[i-1]; local 861 const char* nameToCoalesce = sortedIts[0]->symbolName; local 863 uintptr_t targetAddr = 0; local 864 ImageLoader* targetImage = NULL; local 910 uint64_t t2 = mach_absolute_time(); local 919 recursiveGetDOFSections(const LinkContext& context, std::vector<DOFInfo>& dofs) argument 927 ImageLoader* dependentImage = libImage(i); local 935 void ImageLoader::setNeverUnloadRecursive() { function in class:ImageLoader 942 ImageLoader* dependentImage = libImage(i); local 949 recursiveSpinLock(recursive_lock& rlock) argument 962 void ImageLoader::recursiveSpinUnLock() function in class:ImageLoader 969 recursiveInitialization(const LinkContext& context, mach_port_t this_thread, InitializerTimingList& timingInfo, UninitedUpwards& uninitUps) argument 976 uint8_t oldState = fState; local 982 ImageLoader* dependentImage = libImage(i); local 1000 uint64_t t1 = mach_absolute_time(); local 1006 bool hasInitializers = this->doInitialization(context); local 1014 uint64_t t2 = mach_absolute_time(); local 1032 printTime(const char* msg, uint64_t partTime, uint64_t totalTime) argument 1034 static uint64_t sUnitsPerSecond = 0; local 1036 struct mach_timebase_info timeBaseInfo; local 1042 uint32_t milliSecondsTimesHundred = (uint32_t)((partTime*100000)/sUnitsPerSecond); local 1043 uint32_t milliSeconds = (uint32_t)(milliSecondsTimesHundred/100); local 1044 uint32_t percentTimesTen = (uint32_t)((partTime*1000)/totalTime); local 1045 uint32_t percent = percentTimesTen/10; local 1049 uint32_t secondsTimeTen = (uint32_t)((partTime*10)/sUnitsPerSecond); local 1050 uint32_t seconds = secondsTimeTen/10; local 1051 uint32_t percentTimesTen = (uint32_t)((partTime*1000)/totalTime); local 1052 uint32_t percent = percentTimesTen/10; local 1057 commatize(uint64_t in, char* out) argument 1059 uint64_t div10 = in / 10; local 1060 uint8_t delta = in - div10*10; local 1061 char* s = &out[32]; local 1062 int digitCount = 1; local 1079 printStatistics(unsigned int imageCount, const InitializerTimingList& timingInfo) argument 1081 uint64_t totalTime = fgTotalLoadLibrariesTime + fgTotalRebaseTime + fgTotalBindTime + fgTotalWeakBindTime + fgTotalDOF + fgTotalInitTime; local 1082 char commaNum1[40]; local 1083 char commaNum2[40]; local 1101 uint32_t avgTimesTen = (fgTotalBindImageSearches * 10) / fgTotalBindSymbolsResolved; local 1102 uint32_t avgInt = fgTotalBindImageSearches / fgTotalBindSymbolsResolved; local 1103 uint32_t avgTenths = avgTimesTen - (avgInt*10); local 1128 addSuffix(const char* path, const char* suffix, char* result) argument 1132 char* start = strrchr(result, '/'); local 1138 char* dot = strrchr(start, '.'); local 1149 VECTOR_NEVER_DESTRUCTED_IMPL(ImageLoader::InterposeTuple); variable 1150 VECTOR_NEVER_DESTRUCTED_IMPL(ImagePair); variable [all...] |