[mips][mcjit] Add support for R_MIPS_PC32.
authorDaniel Sanders <daniel.sanders@imgtec.com>
Tue, 2 Jun 2015 15:28:29 +0000 (15:28 +0000)
committerDaniel Sanders <daniel.sanders@imgtec.com>
Tue, 2 Jun 2015 15:28:29 +0000 (15:28 +0000)
Summary:
This allows us to resolve relocations for DW_EH_PE_pcrel TType encodings
in the exception handling LSDA.

Also fixed a nearby typo.

Reviewers: petarj, vkalintiris

Reviewed By: vkalintiris

Subscribers: vkalintiris, llvm-commits

Differential Revision: http://reviews.llvm.org/D10127

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238844 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
test/ExecutionEngine/RuntimeDyld/Mips/ELF_O32_PIC_relocations.s

index 8679368d7736b93b92b82c98dcbd43a75ab7b960..3bd8a47711206a1a34c1a4b860c49bba903305ed 100644 (file)
@@ -480,7 +480,7 @@ void RuntimeDyldELF::resolveMIPSRelocation(const SectionEntry &Section,
   uint32_t *TargetPtr = (uint32_t *)(Section.Address + Offset);
   Value += Addend;
 
-  DEBUG(dbgs() << "resolveMipselocation, LocalAddress: "
+  DEBUG(dbgs() << "resolveMIPSRelocation, LocalAddress: "
                << Section.Address + Offset << " FinalAddress: "
                << format("%p", Section.LoadAddress + Offset) << " Value: "
                << format("%x", Value) << " Type: " << format("%x", Type)
@@ -504,6 +504,10 @@ void RuntimeDyldELF::resolveMIPSRelocation(const SectionEntry &Section,
   case ELF::R_MIPS_LO16:
     *TargetPtr = ((*TargetPtr) & 0xffff0000) | (Value & 0xffff);
     break;
+  case ELF::R_MIPS_PC32:
+    uint32_t FinalAddress = (Section.LoadAddress + Offset);
+    writeBytesUnaligned(Value + Addend - FinalAddress, (uint8_t *)TargetPtr, 4);
+    break;
   }
 }
 
index c9f9e1fb7b2236e3ed8adaeef5c32438c68c655b..d92164806714bf1cee53836bade1af4bbc2c211c 100644 (file)
@@ -8,6 +8,12 @@ R_MIPS_32:
         .word foo
 # rtdyld-check: *{4}(R_MIPS_32+4) = foo
         .4byte foo
+# rtdyld-check: *{4}(R_MIPS_PC32) = foo - R_MIPS_PC32
+R_MIPS_PC32:
+        .word foo-.
+# rtdyld-check: *{4}(R_MIPS_PC32 + 4) = foo - tmp1
+tmp1:
+        .4byte foo-tmp1
 
        .text
        .abicalls