From f667513b65f0112c5ff3212e69868666b0a87f89 Mon Sep 17 00:00:00 2001 From: Simon Atanasyan Date: Sat, 29 Dec 2018 10:10:02 +0000 Subject: [PATCH] [mips] Show an error on attempt to use 64-bit PC-relative relocation The following code requests 64-bit PC-relative relocations unsupported by MIPS ABI. Now it triggers an assertion. It's better to show an error message. ``` foo: .quad bar - foo ``` git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350152 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp | 4 ++++ test/MC/Mips/unsupported-relocation.s | 2 ++ 2 files changed, 6 insertions(+) diff --git a/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp b/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp index 7e367b755c1..8ace2895d68 100644 --- a/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp +++ b/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp @@ -239,6 +239,10 @@ unsigned MipsELFObjectWriter::getRelocType(MCContext &Ctx, if (IsPCRel) { switch (Kind) { + case FK_Data_8: + Ctx.reportError(Fixup.getLoc(), + "MIPS does not support 64-bit PC-relative relocations"); + return ELF::R_MIPS_NONE; case Mips::fixup_Mips_Branch_PCRel: case Mips::fixup_Mips_PC16: return ELF::R_MIPS_PC16; diff --git a/test/MC/Mips/unsupported-relocation.s b/test/MC/Mips/unsupported-relocation.s index 311c0c7d60f..258b4839987 100644 --- a/test/MC/Mips/unsupported-relocation.s +++ b/test/MC/Mips/unsupported-relocation.s @@ -11,3 +11,5 @@ foo: # CHECK: :[[@LINE-1]]:17: error: MIPS does not support one byte relocations .byte x+1 # CHECK: :[[@LINE-1]]:17: error: MIPS does not support one byte relocations + .quad x-foo +# CHECK: :[[@LINE-1]]:17: error: MIPS does not support 64-bit PC-relative relocations -- 2.50.1