[llvm] r241440 - Fix handling of ELF::R_MIPS_32 on Mips64.

Rafael Espindola rafael.espindola at gmail.com
Mon Jul 6 05:18:45 PDT 2015


Author: rafael
Date: Mon Jul  6 07:18:44 2015
New Revision: 241440

URL: http://llvm.org/viewvc/llvm-project?rev=241440&view=rev
Log:
Fix handling of ELF::R_MIPS_32 on Mips64.

Thanks to Aboud, Amjad for reporting the regression and providing the testcase.

Added:
    llvm/trunk/test/Object/Inputs/elf-mip64-reloc.o
    llvm/trunk/test/Object/Mips/reloc-visit.test
Modified:
    llvm/trunk/include/llvm/Object/RelocVisitor.h

Modified: llvm/trunk/include/llvm/Object/RelocVisitor.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/RelocVisitor.h?rev=241440&r1=241439&r2=241440&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/RelocVisitor.h (original)
+++ llvm/trunk/include/llvm/Object/RelocVisitor.h Mon Jul  6 07:18:44 2015
@@ -100,9 +100,9 @@ private:
       case Triple::mips64:
         switch (RelocType) {
         case llvm::ELF::R_MIPS_32:
-          return visitELF_MIPS_32(R, Value);
+          return visitELF_MIPS64_32(R, Value);
         case llvm::ELF::R_MIPS_64:
-          return visitELF_MIPS_64(R, Value);
+          return visitELF_MIPS64_64(R, Value);
         default:
           HasError = true;
           return RelocToApply();
@@ -313,11 +313,18 @@ private:
 
   /// MIPS ELF
   RelocToApply visitELF_MIPS_32(RelocationRef R, uint64_t Value) {
-    uint32_t Res = (Value)&0xFFFFFFFF;
+    uint32_t Res = Value & 0xFFFFFFFF;
+    return RelocToApply(Res, 4);
+  }
+
+  /// MIPS64 ELF
+  RelocToApply visitELF_MIPS64_32(RelocationRef R, uint64_t Value) {
+    int64_t Addend = getELFAddend(R);
+    uint32_t Res = (Value + Addend) & 0xFFFFFFFF;
     return RelocToApply(Res, 4);
   }
 
-  RelocToApply visitELF_MIPS_64(RelocationRef R, uint64_t Value) {
+  RelocToApply visitELF_MIPS64_64(RelocationRef R, uint64_t Value) {
     int64_t Addend = getELFAddend(R);
     uint64_t Res = (Value + Addend);
     return RelocToApply(Res, 8);

Added: llvm/trunk/test/Object/Inputs/elf-mip64-reloc.o
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/Inputs/elf-mip64-reloc.o?rev=241440&view=auto
==============================================================================
Binary files llvm/trunk/test/Object/Inputs/elf-mip64-reloc.o (added) and llvm/trunk/test/Object/Inputs/elf-mip64-reloc.o Mon Jul  6 07:18:44 2015 differ

Added: llvm/trunk/test/Object/Mips/reloc-visit.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/Mips/reloc-visit.test?rev=241440&view=auto
==============================================================================
--- llvm/trunk/test/Object/Mips/reloc-visit.test (added)
+++ llvm/trunk/test/Object/Mips/reloc-visit.test Mon Jul  6 07:18:44 2015
@@ -0,0 +1,6 @@
+RUN: llvm-dwarfdump -debug-dump=info %p/../Inputs/elf-mip64-reloc.o 2>&1 | \
+RUN:   FileCheck %s
+
+CHECK: DW_AT_name [DW_FORM_strp]	( .debug_str[0x00000037] = "<stdin>")
+CHECK: DW_AT_name [DW_FORM_strp]	( .debug_str[0x00000054] = "foo")
+CHECK: DW_AT_name [DW_FORM_strp]	( .debug_str[0x00000058] = "int")





More information about the llvm-commits mailing list