MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / LiftConditionalBranch

Function LiftConditionalBranch

arch/powerpc/il.cpp:200–243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

198
199
200static bool LiftConditionalBranch(LowLevelILFunction& il, uint8_t bo, uint8_t bi, BNLowLevelILLabel& takenLabel, BNLowLevelILLabel& falseLabel, size_t addressSize_a=4)
201{
202 bool testsCtr = !(bo & 4);
203 bool testsCrBit = !(bo & 0x10);
204 bool isConditional = testsCtr || testsCrBit;
205
206 if (testsCtr)
207 {
208 ExprId cond, left, right;
209
210 il.AddInstruction(
211 il.SetRegister(addressSize_a, PPC_REG_CTR,
212 il.Sub(addressSize_a,
213 il.Register(addressSize_a, PPC_REG_CTR),
214 il.Const(addressSize_a, 1))));
215
216 left = il.Register(addressSize_a, PPC_REG_CTR);
217 right = il.Const(addressSize_a, 0);
218
219 if (bo & 2)
220 cond = il.CompareEqual(addressSize_a, left, right);
221 else
222 cond = il.CompareNotEqual(addressSize_a, left, right);
223
224 if (!testsCrBit)
225 {
226 il.AddInstruction(il.If(cond, takenLabel, falseLabel));
227 }
228 else
229 {
230 LowLevelILLabel trueLabel;
231 il.AddInstruction(il.If(cond, trueLabel, falseLabel));
232 il.MarkLabel(trueLabel);
233 }
234 }
235
236 if (testsCrBit)
237 {
238 ExprId cond = ExtractConditionClause(il, bi, !(bo & 8));
239 il.AddInstruction(il.If(cond, takenLabel, falseLabel));
240 }
241
242 return isConditional;
243}
244
245static bool LiftBranches(Architecture* arch, LowLevelILFunction &il, const uint8_t* data, uint64_t addr, bool le)
246{

Callers 1

LiftBranchesFunction · 0.85

Calls 10

ExtractConditionClauseFunction · 0.85
SetRegisterMethod · 0.80
AddInstructionMethod · 0.45
SubMethod · 0.45
RegisterMethod · 0.45
ConstMethod · 0.45
CompareEqualMethod · 0.45
CompareNotEqualMethod · 0.45
IfMethod · 0.45
MarkLabelMethod · 0.45

Tested by

no test coverage detected