This repository was archived by the owner on Dec 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +22
-6
lines changed
Expand file tree Collapse file tree 3 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ def _getArguments():
7878
7979
8080def _openSubCaches (
81- mainCachePath : str ,
81+ mainCachePath : pathlib . Path ,
8282 numSubCaches : int
8383) -> Tuple [List [DyldContext ], List [BinaryIO ]]:
8484 """Create DyldContext objects for each sub cache.
@@ -92,10 +92,10 @@ def _openSubCaches(
9292 Returns:
9393 A list of subcaches, and their file objects, which must be closed!
9494 """
95- subCaches = []
96- subCachesFiles = []
95+ subCaches : List [ DyldContext ] = []
96+ subCachesFiles : List [ BinaryIO ] = []
9797
98- subCacheSuffixes = [i for i in range (1 , numSubCaches + 1 )]
98+ subCacheSuffixes = [str ( i ) for i in range (1 , numSubCaches + 1 )]
9999 subCacheSuffixes .append ("symbols" )
100100 for cacheSuffix in subCacheSuffixes :
101101 subCachePath = f"{ mainCachePath } .{ cacheSuffix } "
Original file line number Diff line number Diff line change @@ -251,6 +251,10 @@ def copyLocalSymbols(self, newLinkedit: bytearray) -> None:
251251 self .statusBar .update (status = "Copy Local Symbols" )
252252
253253 symbolsCache = self .dyldCtx .getSymbolsCache ()
254+ if symbolsCache .header .localSymbolsOffset == 0 :
255+ self .logger .error ("Symbols Cache doesn't contain local symbols." )
256+ return
257+
254258 localSymbolsInfo = dyld_cache_local_symbols_info (
255259 symbolsCache .file ,
256260 symbolsCache .header .localSymbolsOffset
Original file line number Diff line number Diff line change @@ -97,12 +97,24 @@ def headerContainsField(self, field: str) -> bool:
9797
9898 def hasSubCaches (self ) -> bool :
9999 """Check if the dyld cache has sub caches.
100+
101+ Returns:
102+ If the cache has subcaches or not. The symbols cache is factored
103+ into this calculation, but the symbols cache is not counted in
104+ numSubCaches. It is implicitly included.
100105 """
101106
102107 if self .headerContainsField ("numSubCaches" ) and self .header .numSubCaches :
103108 return True
104- else :
105- return False
109+
110+ emptyUUID = b"\x00 " * len (self .header .symbolSubCacheUUID )
111+ if (
112+ self .headerContainsField ("symbolSubCacheUUID" )
113+ and bytes (self .header .symbolSubCacheUUID ) != emptyUUID
114+ ):
115+ return True
116+
117+ return False
106118
107119 def addSubCaches (self , subCacheCtxs : List ["DyldContext" ]) -> None :
108120 for ctx in subCacheCtxs :
You can’t perform that action at this time.
0 commit comments