Skip to content

Commit

Permalink
Merging r322266:
Browse files Browse the repository at this point in the history
------------------------------------------------------------------------
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
  • Loading branch information
tstellar committed May 18, 2018
1 parent 083bcf8 commit a6d704f
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 a6d704f

Please sign in to comment.