11import dataclasses
22import enum
33import struct
4- from typing import Iterator
4+ from typing import Iterator , List , Tuple , Dict
55
66from DyldExtractor .extraction_context import ExtractionContext
77from DyldExtractor .file_context import FileContext
@@ -61,7 +61,7 @@ def __init__(self, extractionCtx: ExtractionContext) -> None:
6161 self ._enumerateSymbols ()
6262 pass
6363
64- def symbolizeAddr (self , addr : int ) -> list [bytes ]:
64+ def symbolizeAddr (self , addr : int ) -> List [bytes ]:
6565 """Get the name of a function at the address.
6666
6767 Args:
@@ -79,8 +79,8 @@ def symbolizeAddr(self, addr: int) -> list[bytes]:
7979 def _enumerateExports (self ) -> None :
8080 # process the dependencies iteratively,
8181 # skipping ones already processed
82- depsQueue : list [_DependencyInfo ] = []
83- depsProcessed : list [bytes ] = []
82+ depsQueue : List [_DependencyInfo ] = []
83+ depsProcessed : List [bytes ] = []
8484
8585 # load commands for all dependencies
8686 DEP_LCS = (
@@ -179,7 +179,7 @@ def _getDepInfo(self, dylib: dylib_command) -> _DependencyInfo:
179179 def _readDepExports (
180180 self ,
181181 depInfo : _DependencyInfo
182- ) -> list [dyld_trie .ExportInfo ]:
182+ ) -> List [dyld_trie .ExportInfo ]:
183183 exportOff = None
184184 exportSize = None
185185
@@ -215,7 +215,7 @@ def _readDepExports(
215215 def _cacheDepExports (
216216 self ,
217217 depInfo : _DependencyInfo ,
218- exports : list [dyld_trie .ExportInfo ]
218+ exports : List [dyld_trie .ExportInfo ]
219219 ) -> None :
220220 for export in exports :
221221 if not export .address :
@@ -331,7 +331,7 @@ def getResolverTarget(address):
331331 )
332332
333333 # A cache of resolved stub chains
334- self ._resolveCache : dict [int , int ] = {}
334+ self ._resolveCache : Dict [int , int ] = {}
335335 pass
336336
337337 def generateStubNormal (self , stubAddress : int , ldrAddress : int ) -> bytes :
@@ -421,7 +421,7 @@ def resolveStubChain(self, address: int) -> int:
421421 self ._resolveCache [address ] = target
422422 return target
423423
424- def resolveStub (self , address : int ) -> tuple [int , _StubFormat ]:
424+ def resolveStub (self , address : int ) -> Tuple [int , _StubFormat ]:
425425 """Get the stub and its format.
426426
427427 Args:
@@ -464,7 +464,7 @@ def getStubHelperData(self, address: int) -> int:
464464
465465 return data
466466
467- def getResolverData (self , address : int ) -> tuple [int , int ]:
467+ def getResolverData (self , address : int ) -> Tuple [int , int ]:
468468 """Get the data of a resolver.
469469
470470 This is a stub helper that branches to a function
@@ -1015,17 +1015,17 @@ def run(self):
10151015 self ._fixIndirectSymbols (symbolPtrs , stubMap )
10161016 pass
10171017
1018- def _enumerateSymbolPointers (self ) -> dict [bytes , tuple [int ]]:
1018+ def _enumerateSymbolPointers (self ) -> Dict [bytes , Tuple [int ]]:
10191019 """Generate a mapping between a pointer's symbol and its address.
10201020 """
10211021
10221022 # read all the bind records as they're a source of symbolic info
1023- bindRecords : dict [int , _BindRecord ] = {}
1023+ bindRecords : Dict [int , _BindRecord ] = {}
10241024 dyldInfo : dyld_info_command = self ._machoCtx .getLoadCommand (
10251025 (LoadCommands .LC_DYLD_INFO , LoadCommands .LC_DYLD_INFO_ONLY )
10261026 )
10271027 if dyldInfo :
1028- records : list [_BindRecord ] = []
1028+ records : List [_BindRecord ] = []
10291029 try :
10301030 if dyldInfo .weak_bind_size :
10311031 # usually contains records for c++ symbols like "new"
@@ -1067,7 +1067,7 @@ def _enumerateSymbolPointers(self) -> dict[bytes, tuple[int]]:
10671067 pass
10681068
10691069 # enumerate all symbol pointers
1070- symbolPtrs : dict [bytes , list [int ]] = {}
1070+ symbolPtrs : Dict [bytes , List [int ]] = {}
10711071
10721072 def _addToMap (ptrSymbol : bytes , ptrAddr : int , section : section_64 ):
10731073 if ptrSymbol in symbolPtrs :
@@ -1210,12 +1210,12 @@ def _fixStubHelpers(self) -> None:
12101210
12111211 def _fixStubs (
12121212 self ,
1213- symbolPtrs : dict [bytes , tuple [int ]]
1214- ) -> dict [bytes , tuple [int ]]:
1213+ symbolPtrs : Dict [bytes , Tuple [int ]]
1214+ ) -> Dict [bytes , Tuple [int ]]:
12151215 """Relink stubs to their symbol pointers
12161216 """
12171217
1218- stubMap : dict [bytes , list [int ]] = {}
1218+ stubMap : Dict [bytes , List [int ]] = {}
12191219
12201220 def _addToMap (stubName : bytes , stubAddr : int ):
12211221 if stubName in stubMap :
@@ -1360,7 +1360,7 @@ def _addToMap(stubName: bytes, stubAddr: int):
13601360
13611361 return stubMap
13621362
1363- def _fixCallsites (self , stubMap : dict [bytes , tuple [int ]]) -> None :
1363+ def _fixCallsites (self , stubMap : Dict [bytes , Tuple [int ]]) -> None :
13641364 if (
13651365 b"__TEXT" not in self ._machoCtx .segments
13661366 or b"__text" not in self ._machoCtx .segments [b"__TEXT" ].sects
@@ -1443,8 +1443,8 @@ def _fixCallsites(self, stubMap: dict[bytes, tuple[int]]) -> None:
14431443
14441444 def _fixIndirectSymbols (
14451445 self ,
1446- symbolPtrs : dict [bytes , tuple [int ]],
1447- stubMap : dict [bytes , tuple [int ]]
1446+ symbolPtrs : Dict [bytes , Tuple [int ]],
1447+ stubMap : Dict [bytes , Tuple [int ]]
14481448 ) -> None :
14491449 """Fix indirect symbols.
14501450
0 commit comments