Skip to content

Commit ffd7083

Browse files
committed
fixup! [BOLT] Add symbolizer for AArch64 disassembler. NFCI
1 parent 74cec63 commit ffd7083

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,6 +1327,22 @@ Error BinaryFunction::disassemble() {
13271327
BC.printInstruction(BC.errs(), Instruction, AbsoluteInstrAddr);
13281328
BC.errs() << '\n';
13291329
}
1330+
1331+
// Verify that we've symbolized an operand if the instruction has a
1332+
// relocation against it.
1333+
if (getRelocationInRange(Offset, Offset + Size)) {
1334+
bool HasSymbolicOp = false;
1335+
for (MCOperand &Op : Instruction) {
1336+
if (Op.isExpr()) {
1337+
HasSymbolicOp = true;
1338+
break;
1339+
}
1340+
}
1341+
if (!HasSymbolicOp)
1342+
return createFatalBOLTError(
1343+
"expected symbolized operand for instruction at 0x" +
1344+
Twine::utohexstr(AbsoluteInstrAddr));
1345+
}
13301346
}
13311347

13321348
// Special handling for AVX-512 instructions.

bolt/lib/Target/AArch64/AArch64MCSymbolizer.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include "bolt/Core/MCPlusBuilder.h"
1313
#include "bolt/Core/Relocation.h"
1414
#include "llvm/MC/MCInst.h"
15-
#include "llvm/MC/MCRegisterInfo.h"
1615
#include "llvm/Support/Debug.h"
1716

1817
#define DEBUG_TYPE "bolt-symbolizer"

bolt/lib/Target/AArch64/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
set(LLVM_LINK_COMPONENTS
22
MC
3+
MCDisassembler
34
Support
45
AArch64Desc
56
)

llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,10 @@ static DecodeStatus DecodeMoveImmInstruction(MCInst &Inst, uint32_t insn,
744744
Inst.getOpcode() == AArch64::MOVKXi)
745745
Inst.addOperand(Inst.getOperand(0));
746746

747-
Inst.addOperand(MCOperand::createImm(imm));
747+
if (!Decoder->tryAddingSymbolicOperand(Inst, imm, Addr, /*IsBranch*/ false, 0,
748+
0, 4))
749+
Inst.addOperand(MCOperand::createImm(imm));
750+
748751
Inst.addOperand(MCOperand::createImm(shift));
749752
return Success;
750753
}

0 commit comments

Comments
 (0)