Index: MCInstrAnalysis.cpp =================================================================== --- MCInstrAnalysis.cpp (revision 183906) +++ MCInstrAnalysis.cpp (working copy) @@ -16,7 +16,20 @@ Info->get(Inst.getOpcode()).OpInfo[0].OperandType != MCOI::OPERAND_PCREL) return false; - int64_t Imm = Inst.getOperand(0).getImm(); - Target = Addr+Size+Imm; + int64_t Imm; + + // If the first operand within Inst is an immediate, use the immediate + // in the computation of the branch destination. If the operand is an + // expression, only use the expression in the computation if it can be + // evaluated as an immediate value. + if (Inst.getOperand(0).isImm()) { + Imm = Inst.getOperand(0).getImm(); + } + else if(Inst.getOperand(0).isExpr()) { + if(!Inst.getOperand(0).getExpr()->EvaluateAsAbsolute(Imm)) + return false; + } + + Target = Addr + Size + Imm; return true; }