]> granicus.if.org Git - llvm/commitdiff
[mips] Show an error on attempt to use 64-bit PC-relative relocation
authorSimon Atanasyan <simon@atanasyan.com>
Sat, 29 Dec 2018 10:10:02 +0000 (10:10 +0000)
committerSimon Atanasyan <simon@atanasyan.com>
Sat, 29 Dec 2018 10:10:02 +0000 (10:10 +0000)
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
test/MC/Mips/unsupported-relocation.s

index 7e367b755c1402f5476e3c4c2d3bf46b085fa785..8ace2895d6813358288cf7bd16f821e4525bca27 100644 (file)
@@ -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;
index 311c0c7d60f20b0ae46d49d88dd91405124fcaf6..258b48399873133ceb1d0eb1fd3ae708a856db06 100644 (file)
@@ -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