@@ -1680,7 +1680,7 @@ static void printBB(const BinaryContext &BC, const BinaryBasicBlock *BB,
1680
1680
MCInstReference Inst (BB, I);
1681
1681
if (BC.MIB ->isCFI (Inst))
1682
1682
continue ;
1683
- BC.printInstruction (outs (), Inst, Inst.getAddress (), BF);
1683
+ BC.printInstruction (outs (), Inst, Inst.computeAddress (), BF);
1684
1684
}
1685
1685
}
1686
1686
@@ -1700,14 +1700,15 @@ void Diagnostic::printBasicInfo(raw_ostream &OS, const BinaryContext &BC,
1700
1700
StringRef IssueKind) const {
1701
1701
const BinaryBasicBlock *BB = Location.getBasicBlock ();
1702
1702
const BinaryFunction *BF = Location.getFunction ();
1703
+ const uint64_t Address = Location.computeAddress ();
1703
1704
1704
1705
OS << " \n GS-PAUTH: " << IssueKind;
1705
1706
OS << " in function " << BF->getPrintName ();
1706
1707
if (BB)
1707
1708
OS << " , basic block " << BB->getName ();
1708
- OS << " , at address " << llvm::format (" %x" , Location. getAddress () ) << " \n " ;
1709
+ OS << " , at address " << llvm::format (" %x" , Address ) << " \n " ;
1709
1710
OS << " The instruction is " ;
1710
- BC.printInstruction (OS, Location, Location. getAddress () , BF);
1711
+ BC.printInstruction (OS, Location, Address , BF);
1711
1712
}
1712
1713
1713
1714
void GadgetDiagnostic::generateReport (raw_ostream &OS,
@@ -1721,15 +1722,17 @@ static void printRelatedInstrs(raw_ostream &OS, const MCInstReference Location,
1721
1722
const BinaryContext &BC = BF.getBinaryContext ();
1722
1723
1723
1724
// Sort by address to ensure output is deterministic.
1724
- SmallVector<MCInstReference> RI (RelatedInstrs);
1725
- llvm::sort (RI, [](const MCInstReference &A, const MCInstReference &B) {
1726
- return A.getAddress () < B.getAddress ();
1727
- });
1725
+ SmallVector<std::pair<uint64_t , MCInstReference>> RI;
1726
+ for (auto &InstRef : RelatedInstrs)
1727
+ RI.push_back (std::make_pair (InstRef.computeAddress (), InstRef));
1728
+ llvm::sort (RI, [](auto A, auto B) { return A.first < B.first ; });
1729
+
1728
1730
for (unsigned I = 0 ; I < RI.size (); ++I) {
1729
- MCInstReference InstRef = RI[I];
1731
+ auto [Address, InstRef] = RI[I];
1730
1732
OS << " " << (I + 1 ) << " . " ;
1731
- BC.printInstruction (OS, InstRef, InstRef.getAddress (), &BF);
1733
+ BC.printInstruction (OS, InstRef, InstRef.computeAddress (), &BF);
1732
1734
};
1735
+
1733
1736
if (RelatedInstrs.size () == 1 ) {
1734
1737
const MCInstReference RelatedInst = RelatedInstrs[0 ];
1735
1738
// Printing the details for the MCInstReference::FunctionParent case
0 commit comments