diff options
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/MC/MCObjectStreamer.cpp | 5 | ||||
| -rw-r--r-- | llvm/test/MC/AArch64/label-arithmetic-diags-elf.s | 9 |
2 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp index f7f2253256e..174397e2739 100644 --- a/llvm/lib/MC/MCObjectStreamer.cpp +++ b/llvm/lib/MC/MCObjectStreamer.cpp @@ -133,6 +133,11 @@ void MCObjectStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size, // Avoid fixups when possible. int64_t AbsValue; if (Value->evaluateAsAbsolute(AbsValue, getAssembler())) { + if (!isUIntN(8 * Size, AbsValue) && !isIntN(8 * Size, AbsValue)) { + getContext().reportError( + Loc, "value evaluated as " + Twine(AbsValue) + " is out of range."); + return; + } EmitIntValue(AbsValue, Size); return; } diff --git a/llvm/test/MC/AArch64/label-arithmetic-diags-elf.s b/llvm/test/MC/AArch64/label-arithmetic-diags-elf.s index e9d92d591fa..dbfdd24f8dc 100644 --- a/llvm/test/MC/AArch64/label-arithmetic-diags-elf.s +++ b/llvm/test/MC/AArch64/label-arithmetic-diags-elf.s @@ -1,5 +1,14 @@ // RUN: not llvm-mc -triple aarch64-elf -filetype=obj %s -o /dev/null 2>&1 | FileCheck %s + .data +b: + .fill 300 +e: + .byte e - b + // CHECK: error: value evaluated as 300 is out of range. + // CHECK-NEXT: .byte e - b + // CHECK-NEXT: ^ + .section sec_x start: .space 5000 |

