]> granicus.if.org Git - llvm/commitdiff
[Assembler] Fix crash when assembling .quad for AArch32.
authorChad Rosier <mcrosier@codeaurora.org>
Wed, 18 Jan 2017 15:02:54 +0000 (15:02 +0000)
committerChad Rosier <mcrosier@codeaurora.org>
Wed, 18 Jan 2017 15:02:54 +0000 (15:02 +0000)
A 64-bit relocation does not exist in 32-bit ARMELF. Report an error
instead of crashing.

PR23870
Patch by Sanne Wouda (sanwou01).
Differential Revision: https://reviews.llvm.org/D28851

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292373 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
test/MC/ARM/quad-relocation.s [new file with mode: 0644]

index a58d5b34131b3c4a4948663cca0fa055d05ed07c..469c47d236dab08a604740fbe7287cc7afeb0319 100644 (file)
@@ -363,7 +363,8 @@ unsigned ARMAsmBackend::adjustFixupValue(const MCFixup &Fixup, uint64_t Value,
   unsigned Kind = Fixup.getKind();
   switch (Kind) {
   default:
-    llvm_unreachable("Unknown fixup kind!");
+    if (Ctx) Ctx->reportError(Fixup.getLoc(), "bad relocation fixup type");
+    return 0;
   case FK_Data_1:
   case FK_Data_2:
   case FK_Data_4:
diff --git a/test/MC/ARM/quad-relocation.s b/test/MC/ARM/quad-relocation.s
new file mode 100644 (file)
index 0000000..83d312b
--- /dev/null
@@ -0,0 +1,9 @@
+@ RUN: not llvm-mc -triple arm-arm-none-eabi -filetype obj < %s -o /dev/null 2>&1 | FileCheck %s
+
+       .align 3
+symbol:
+  .quad(symbol)
+
+@ CHECK: error: bad relocation fixup type
+@ CHECK-NEXT:   .quad(symbol)
+@ CHECK-NEXT:        ^