[BOLT] Fixes for scanExternalRefs()

Summary:
In my previous commit, I've accidentally reverted the condition while
evaluating a branch target.

Also, do not emit instruction for relocation purposes in
scanExternalRefs() if there was no TargetSymbol set and we have not
produced new relocations.

(cherry picked from FBD22169317)
This commit is contained in:
Maksim Panchenko 2020-06-22 12:50:49 -07:00
parent 8374e8e3fe
commit 0403adde32
1 changed files with 3 additions and 3 deletions

View File

@ -1463,8 +1463,8 @@ bool BinaryFunction::scanExternalRefs() {
IsPCRel = true;
}
} else if (BC.MIB->isCall(Instruction) || BC.MIB->isBranch(Instruction)) {
if (!BC.MIB->evaluateBranch(Instruction, AbsoluteInstrAddr, Size,
TargetAddress)) {
if (BC.MIB->evaluateBranch(Instruction, AbsoluteInstrAddr, Size,
TargetAddress)) {
IsBranch = true;
}
}
@ -1525,7 +1525,7 @@ bool BinaryFunction::scanExternalRefs() {
HasRel = true;
}
if (!IsBranch && !IsPCRel && !HasRel)
if (!TargetSymbol && !HasRel)
continue;
// Emit the instruction using temp emitter and generate relocations.