summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/ARM/AsmParser
diff options
context:
space:
mode:
authorPrakhar Bahuguna <prakhar.bahuguna@arm.com>2016-08-16 10:41:52 +0000
committerPrakhar Bahuguna <prakhar.bahuguna@arm.com>2016-08-16 10:41:52 +0000
commit15ed7ec5aab8de283b2cfc9b674b5382024c1da1 (patch)
tree48c40b51ab3f6bf481f75f0c99a6844dc58f80b1 /llvm/lib/Target/ARM/AsmParser
parentf16cd361d41135d7f261fd407d74fff38de9dfcb (diff)
downloadbcm5719-llvm-15ed7ec5aab8de283b2cfc9b674b5382024c1da1.tar.gz
bcm5719-llvm-15ed7ec5aab8de283b2cfc9b674b5382024c1da1.zip
[Thumb] Validate branch target for CBZ/CBNZ instructions.
Summary: The assembler currently does not check the branch target for CBZ/CBNZ instructions, which only permit branching forwards with a positive offset. This adds validation for the branch target to ensure negative PC-relative offsets are not encoded into the instruction, whether specified as a literal or as an assembler symbol. Reviewers: rengolin, t.p.northover Subscribers: llvm-commits, rengolin Differential Revision: https://reviews.llvm.org/D23312 llvm-svn: 278788
Diffstat (limited to 'llvm/lib/Target/ARM/AsmParser')
-rw-r--r--llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
index b9b665fc1ea..c011c792bff 100644
--- a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
+++ b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
@@ -6684,6 +6684,12 @@ bool ARMAsmParser::validateInstruction(MCInst &Inst,
return Error(Operands[Op]->getStartLoc(), "branch target out of range");
break;
}
+ case ARM::tCBZ:
+ case ARM::tCBNZ: {
+ if (!static_cast<ARMOperand &>(*Operands[2]).isUnsignedOffset<6, 1>())
+ return Error(Operands[2]->getStartLoc(), "branch target out of range");
+ break;
+ }
case ARM::MOVi16:
case ARM::t2MOVi16:
case ARM::t2MOVTi16:
OpenPOWER on IntegriCloud