Skip to content

Commit 85a7989

Browse files
authored
MIPS: Adding a check for JAL argument in PIC mode to prevent crashing on getExpr (#120356)
Only an Expr is supported by JAL. Let's check it before getExpr. #80535 --------- Co-authored-by: Renat Idrisov <[email protected]>
1 parent 4f7ff6b commit 85a7989

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2108,6 +2108,10 @@ bool MipsAsmParser::processInstruction(MCInst &Inst, SMLoc IDLoc,
21082108
if ((Opcode == Mips::JAL || Opcode == Mips::JAL_MM) && inPicMode()) {
21092109
warnIfNoMacro(IDLoc);
21102110

2111+
if (!Inst.getOperand(0).isExpr()) {
2112+
return Error(IDLoc, "unsupported constant in relocation");
2113+
}
2114+
21112115
const MCExpr *JalExpr = Inst.getOperand(0).getExpr();
21122116

21132117
// We can do this expansion if there's only 1 symbol in the argument

0 commit comments

Comments
 (0)