@@ -19,7 +19,7 @@ def __init__(self, context: common.Context, vromStart: int, vromEnd: int, inFile
19
19
20
20
self .instrAnalyzer = analysis .InstrAnalyzer (self .vram , context )
21
21
22
- self .branchesTaken : set [int ] = set ()
22
+ self .branchesTaken : set [tuple [ int , bool ] ] = set ()
23
23
24
24
self .pointersOffsets : set [int ] = set ()
25
25
self .pointersRemoved : bool = False
@@ -40,7 +40,7 @@ def sizew(self) -> int:
40
40
def isFunction (self ) -> bool :
41
41
return True
42
42
43
- def _lookAheadSymbolFinder (self , instr : rabbitizer .Instruction , prevInstr : rabbitizer .Instruction , instructionOffset : int , trackedRegistersOriginal : rabbitizer .RegistersTracker ) -> None :
43
+ def _lookAheadSymbolFinder (self , instr : rabbitizer .Instruction , prevInstr : rabbitizer .Instruction , instructionOffset : int , trackedRegistersOriginal : rabbitizer .RegistersTracker , prev_is_likely : bool ) -> None :
44
44
if not prevInstr .isBranch () and not prevInstr .isUnconditionalBranch ():
45
45
return
46
46
@@ -58,9 +58,9 @@ def _lookAheadSymbolFinder(self, instr: rabbitizer.Instruction, prevInstr: rabbi
58
58
59
59
self .instrAnalyzer .processInstr (regsTracker , instr , instructionOffset , currentVram , None )
60
60
61
- if instructionOffset in self .branchesTaken :
61
+ if ( instructionOffset , prev_is_likely ) in self .branchesTaken :
62
62
return
63
- self .branchesTaken .add (instructionOffset )
63
+ self .branchesTaken .add (( instructionOffset , prev_is_likely ) )
64
64
65
65
sizew = len (self .instructions )* 4
66
66
while branch < sizew :
@@ -69,7 +69,7 @@ def _lookAheadSymbolFinder(self, instr: rabbitizer.Instruction, prevInstr: rabbi
69
69
70
70
self .instrAnalyzer .processInstr (regsTracker , targetInstr , branch , self .getVramOffset (branch ), prevTargetInstr )
71
71
72
- self ._lookAheadSymbolFinder (targetInstr , prevTargetInstr , branch , regsTracker )
72
+ self ._lookAheadSymbolFinder (targetInstr , prevTargetInstr , branch , regsTracker , prev_is_likely or prevTargetInstr . isBranchLikely () )
73
73
74
74
if prevTargetInstr .isUnconditionalBranch ():
75
75
# Since we took the branch on the previous _lookAheadSymbolFinder
@@ -129,7 +129,7 @@ def _runInstructionAnalyzer(self) -> None:
129
129
self .instrAnalyzer .processInstr (regsTracker , instr , instructionOffset , currentVram , prevInstr )
130
130
131
131
# look-ahead symbol finder
132
- self ._lookAheadSymbolFinder (instr , prevInstr , instructionOffset , regsTracker )
132
+ self ._lookAheadSymbolFinder (instr , prevInstr , instructionOffset , regsTracker , prevInstr . isBranchLikely () )
133
133
134
134
if prevInstr .isJumpWithAddress () and not prevInstr .doesLink ():
135
135
targetVram = prevInstr .getBranchVramGeneric ()
@@ -380,6 +380,8 @@ def _generateRelocsFromInstructionAnalyzer(self) -> None:
380
380
self .relocs [instrOffset ] = common .RelocationInfo (relocType , "_gp_disp" )
381
381
382
382
for instrOffset , gpInfo in self .instrAnalyzer .gpSets .items ():
383
+ if gpInfo is None :
384
+ continue
383
385
hiInstrOffset = gpInfo .hiOffset
384
386
hiInstr = self .instructions [hiInstrOffset // 4 ]
385
387
instr = self .instructions [instrOffset // 4 ]
0 commit comments