[llvm] r322266 - [Mips] Handle one byte unsupported relocations

Stefan Maksimovic via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 11 02:07:47 PST 2018


Author: smaksimovic
Date: Thu Jan 11 02:07:47 2018
New Revision: 322266

URL: http://llvm.org/viewvc/llvm-project?rev=322266&view=rev
Log:
[Mips] Handle one byte unsupported relocations

Fail gracefully instead of crashing upon encountering
this type of relocation.

Differential revision: https://reviews.llvm.org/D41857

Added:
    llvm/trunk/test/MC/Mips/unsupported-relocation.s
Modified:
    llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp

Modified: llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp?rev=322266&r1=322265&r2=322266&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp Thu Jan 11 02:07:47 2018
@@ -225,6 +225,8 @@ unsigned MipsELFObjectWriter::getRelocTy
   switch (Kind) {
   case Mips::fixup_Mips_NONE:
     return ELF::R_MIPS_NONE;
+  case FK_Data_1:
+    report_fatal_error("MIPS does not support one byte relocations");
   case Mips::fixup_Mips_16:
   case FK_Data_2:
     return IsPCRel ? ELF::R_MIPS_PC16 : ELF::R_MIPS_16;

Added: llvm/trunk/test/MC/Mips/unsupported-relocation.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/unsupported-relocation.s?rev=322266&view=auto
==============================================================================
--- llvm/trunk/test/MC/Mips/unsupported-relocation.s (added)
+++ llvm/trunk/test/MC/Mips/unsupported-relocation.s Thu Jan 11 02:07:47 2018
@@ -0,0 +1,13 @@
+# RUN: not llvm-mc -triple mips-unknown-linux -filetype=obj %s 2>%t
+# RUN: FileCheck %s < %t
+
+# Check that we emit an error for unsupported relocations instead of crashing.
+
+        .globl x
+
+        .data
+foo:
+        .byte   x
+        .byte   x+1
+
+# CHECK: LLVM ERROR: MIPS does not support one byte relocations




More information about the llvm-commits mailing list