summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Stellard <tstellar@redhat.com>2018-05-18 20:43:04 +0000
committerTom Stellard <tstellar@redhat.com>2018-05-18 20:43:04 +0000
commita6d704f4d039804d1d4a2c7a80f7eb09e6e43aed (patch)
tree646ca470a8b6f8a36d38504e67b9f71f00a5b550
parent083bcf84eb133b661454ed9e3396e29b257ace8a (diff)
downloadllvm-a6d704f4d039804d1d4a2c7a80f7eb09e6e43aed.tar.gz
Merging r322266:
------------------------------------------------------------------------ r322266 | smaksimovic | 2018-01-11 02:07:47 -0800 (Thu, 11 Jan 2018) | 7 lines [Mips] Handle one byte unsupported relocations Fail gracefully instead of crashing upon encountering this type of relocation. Differential revision: https://reviews.llvm.org/D41857 ------------------------------------------------------------------------ llvm-svn: 332765
-rw-r--r--llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp2
-rw-r--r--llvm/test/MC/Mips/unsupported-relocation.s13
2 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
index 6d2f098a6b32..3c67743947cb 100644
--- a/llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
+++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
@@ -225,6 +225,8 @@ unsigned MipsELFObjectWriter::getRelocType(MCContext &Ctx,
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;
diff --git a/llvm/test/MC/Mips/unsupported-relocation.s b/llvm/test/MC/Mips/unsupported-relocation.s
new file mode 100644
index 000000000000..151a559671fb
--- /dev/null
+++ b/llvm/test/MC/Mips/unsupported-relocation.s
@@ -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