[llvm] r205240 - Don't relocate with sections if there might be a paired relocation.

Rafael Espindola rafael.espindola at gmail.com
Mon Mar 31 12:00:23 PDT 2014


Author: rafael
Date: Mon Mar 31 14:00:23 2014
New Revision: 205240

URL: http://llvm.org/viewvc/llvm-project?rev=205240&view=rev
Log:
Don't relocate with sections if there might be a paired relocation.

Modified:
    llvm/trunk/include/llvm/Support/ELF.h
    llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
    llvm/trunk/test/MC/Mips/xgot.s

Modified: llvm/trunk/include/llvm/Support/ELF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ELF.h?rev=205240&r1=205239&r2=205240&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/ELF.h (original)
+++ llvm/trunk/include/llvm/Support/ELF.h Mon Mar 31 14:00:23 2014
@@ -880,6 +880,9 @@ enum {
   R_MIPS_TLS_TPREL_HI16    = 49,
   R_MIPS_TLS_TPREL_LO16    = 50,
   R_MIPS_GLOB_DAT          = 51,
+  R_MIPS16_GOT16           = 102,
+  R_MIPS16_HI16            = 104,
+  R_MIPS16_LO16            = 105,
   R_MIPS_COPY              = 126,
   R_MIPS_JUMP_SLOT         = 127,
   R_MICROMIPS_26_S1        = 133,

Modified: llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp?rev=205240&r1=205239&r2=205240&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp Mon Mar 31 14:00:23 2014
@@ -206,9 +206,25 @@ MipsELFObjectWriter::needsRelocateWithSy
   default:
     return true;
 
-  case ELF::R_MIPS_26:
-  case ELF::R_MIPS_LO16:
+  case ELF::R_MIPS_GOT16:
+  case ELF::R_MIPS16_GOT16:
+  case ELF::R_MICROMIPS_GOT16:
+    llvm_unreachable("Should have been handled already");
+
+  // These relocations might be paired with another relocation. The pairing is
+  // done by the static linker by matching the symbol. Since we only see one
+  // relocation at a time, we have to force them to relocate with a symbol to
+  // avoid ending up with a pair where one points to a section and another
+  // points to a symbol.
   case ELF::R_MIPS_HI16:
+  case ELF::R_MIPS16_HI16:
+  case ELF::R_MICROMIPS_HI16:
+  case ELF::R_MIPS_LO16:
+  case ELF::R_MIPS16_LO16:
+  case ELF::R_MICROMIPS_LO16:
+    return true;
+
+  case ELF::R_MIPS_26:
   case ELF::R_MIPS_32:
   case ELF::R_MIPS_64:
   case ELF::R_MIPS_GPREL16:

Modified: llvm/trunk/test/MC/Mips/xgot.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/xgot.s?rev=205240&r1=205239&r2=205240&view=diff
==============================================================================
--- llvm/trunk/test/MC/Mips/xgot.s (original)
+++ llvm/trunk/test/MC/Mips/xgot.s Mon Mar 31 14:00:23 2014
@@ -11,7 +11,7 @@
 // CHECK:   0x24 R_MIPS_CALL_HI16 printf
 // CHECK:   0x2C R_MIPS_GOT16 $.str
 // CHECK:   0x30 R_MIPS_CALL_LO16 printf
-// CHECK:   0x38 R_MIPS_LO16 .rodata.str1.1
+// CHECK:   0x38 R_MIPS_LO16 $.str
 // CHECK: ]
 
 	.text





More information about the llvm-commits mailing list