Skip to content

Commit

Permalink
[Mips] Handle one byte unsupported relocations
Browse files Browse the repository at this point in the history
Fail gracefully instead of crashing upon encountering
this type of relocation.

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

llvm-svn: 322266
  • Loading branch information
Stefan Maksimovic committed Jan 11, 2018
1 parent ba5fd77 commit 5481c21
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
Expand Up @@ -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;
Expand Down
13 changes: 13 additions & 0 deletions 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

0 comments on commit 5481c21

Please sign in to comment.