From: Simon Atanasyan Date: Sat, 29 Dec 2018 10:10:02 +0000 (+0000) Subject: [mips] Show an error on attempt to use 64-bit PC-relative relocation X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f667513b65f0112c5ff3212e69868666b0a87f89;p=llvm [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 --- 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