[MCJIT] Rewrite RuntimeDyldMachO and its derived classes to use the 'Offset'
authorLang Hames <lhames@gmail.com>
Sun, 7 Sep 2014 04:03:32 +0000 (04:03 +0000)
committerLang Hames <lhames@gmail.com>
Sun, 7 Sep 2014 04:03:32 +0000 (04:03 +0000)
field of RelocationValueRef, rather than the 'Addend' field.

This is consistent with RuntimeDyldELF's use of RelocationValueRef, and more
consistent with the semantics of the data being stored (the offset from the
start of a section or symbol).

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

lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h
lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h
lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOI386.h
lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOX86_64.h

index b3c740188119e8cab6d0fbdd77e1fe3d2d5eee38..49234f59b0bac8be1ac6f2aab2bff9e8c3c839d5 100644 (file)
@@ -883,7 +883,7 @@ void RuntimeDyldCheckerImpl::registerStubMap(
       for (auto &GSTEntry : getRTDyld().GlobalSymbolTable) {
         if (GSTEntry.second.first == StubMapEntry.first.SectionID &&
             GSTEntry.second.second ==
-                static_cast<uint64_t>(StubMapEntry.first.Addend)) {
+                static_cast<uint64_t>(StubMapEntry.first.Offset)) {
           SymbolName = GSTEntry.first();
           break;
         }
index 803e5cb781cc033965de2d2b87811138ffa9c061..30c849ea9496b2b49a1c147f9f6f78f92379023e 100644 (file)
@@ -1034,11 +1034,11 @@ relocation_iterator RuntimeDyldELF::processRelocationRef(
           createStubFunction(Section.Address + Section.StubOffset);
 
       RelocationEntry REmovz_g3(SectionID, StubTargetAddr - Section.Address,
-                                ELF::R_AARCH64_MOVW_UABS_G3, Value.Addend);
+                                ELF::R_AARCH64_MOVW_UABS_G3, Value.Offset + Addend);
       RelocationEntry REmovk_g2(SectionID, StubTargetAddr - Section.Address + 4,
-                                ELF::R_AARCH64_MOVW_UABS_G2_NC, Value.Addend);
+                                ELF::R_AARCH64_MOVW_UABS_G2_NC, Value.Offset + Addend);
       RelocationEntry REmovk_g1(SectionID, StubTargetAddr - Section.Address + 8,
-                                ELF::R_AARCH64_MOVW_UABS_G1_NC, Value.Addend);
+                                ELF::R_AARCH64_MOVW_UABS_G1_NC, Value.Offset + Addend);
       RelocationEntry REmovk_g0(SectionID,
                                 StubTargetAddr - Section.Address + 12,
                                 ELF::R_AARCH64_MOVW_UABS_G0_NC, Value.Addend);
index 14bcbeb1ec5b511a8a8cfc9f78a1a002753104fc..8e78317669a7a53c2b7d9e5dc62af719ebabb820 100644 (file)
@@ -53,15 +53,15 @@ RelocationValueRef RuntimeDyldMachO::getRelocationValueRef(
     SymbolTableMap::const_iterator SI = Symbols.find(TargetName.data());
     if (SI != Symbols.end()) {
       Value.SectionID = SI->second.first;
-      Value.Addend = SI->second.second + RE.Addend;
+      Value.Offset = SI->second.second + RE.Addend;
     } else {
       SI = GlobalSymbolTable.find(TargetName.data());
       if (SI != GlobalSymbolTable.end()) {
         Value.SectionID = SI->second.first;
-        Value.Addend = SI->second.second + RE.Addend;
+        Value.Offset = SI->second.second + RE.Addend;
       } else {
         Value.SymbolName = TargetName.data();
-        Value.Addend = RE.Addend;
+        Value.Offset = RE.Addend;
       }
     }
   } else {
@@ -71,7 +71,7 @@ RelocationValueRef RuntimeDyldMachO::getRelocationValueRef(
     Value.SectionID = findOrEmitSection(ObjImg, Sec, IsCode, ObjSectionToID);
     uint64_t Addr;
     Sec.getAddress(Addr);
-    Value.Addend = RE.Addend - Addr;
+    Value.Offset = RE.Addend - Addr;
   }
 
   return Value;
@@ -90,7 +90,7 @@ void RuntimeDyldMachO::makeValueAddendPCRel(RelocationValueRef &Value,
   if (IsPCRel) {
     uint64_t RelocAddr = 0;
     RI->getAddress(RelocAddr);
-    Value.Addend += RelocAddr + OffsetToNextPC;
+    Value.Offset += RelocAddr + OffsetToNextPC;
   }
 }
 
index ab20113f2588522c84c8062f4baf519613180eb8..980daaaf62524f214f5bd4dcbf1d75a792c33e8a 100644 (file)
@@ -277,14 +277,14 @@ public:
       "ARM64_RELOC_ADDEND and embedded addend in the instruction.");
     if (ExplicitAddend) {
       RE.Addend = ExplicitAddend;
-      Value.Addend = ExplicitAddend;
+      Value.Offset = ExplicitAddend;
     }
 
     bool IsExtern = Obj.getPlainRelocationExternal(RelInfo);
     if (!IsExtern && RE.IsPCRel)
       makeValueAddendPCRel(Value, ObjImg, RelI, 1 << RE.Size);
 
-    RE.Addend = Value.Addend;
+    RE.Addend = Value.Offset;
 
     if (RE.RelType == MachO::ARM64_RELOC_GOT_LOAD_PAGE21 ||
         RE.RelType == MachO::ARM64_RELOC_GOT_LOAD_PAGEOFF12)
@@ -384,7 +384,7 @@ private:
       assert(((StubAddress % getStubAlignment()) == 0) &&
              "GOT entry not aligned");
       RelocationEntry GOTRE(RE.SectionID, StubOffset,
-                            MachO::ARM64_RELOC_UNSIGNED, Value.Addend,
+                            MachO::ARM64_RELOC_UNSIGNED, Value.Offset,
                             /*IsPCRel=*/false, /*Size=*/3);
       if (Value.SymbolName)
         addRelocationForSymbol(GOTRE, Value.SymbolName);
index f1b6ebebb507d58779740d7b3acaf133003a5cd5..e29b8dc5091496675cb8090d2ad669daa08f7663 100644 (file)
@@ -71,7 +71,7 @@ public:
     if ((RE.RelType & 0xf) == MachO::ARM_RELOC_BR24)
       processBranchRelocation(RE, Value, Stubs);
     else {
-      RE.Addend = Value.Addend;
+      RE.Addend = Value.Offset;
       if (Value.SymbolName)
         addRelocationForSymbol(RE, Value.SymbolName);
       else
@@ -152,7 +152,7 @@ private:
       uint8_t *StubTargetAddr =
           createStubFunction(Section.Address + Section.StubOffset);
       RelocationEntry StubRE(RE.SectionID, StubTargetAddr - Section.Address,
-                             MachO::GENERIC_RELOC_VANILLA, Value.Addend, false,
+                             MachO::GENERIC_RELOC_VANILLA, Value.Offset, false,
                              2);
       if (Value.SymbolName)
         addRelocationForSymbol(StubRE, Value.SymbolName);
index 6e8318906495682aa5406ced26bb2b6c8eadaf4b..a743ec69717185590143381c804074a2dc970a41 100644 (file)
@@ -68,7 +68,7 @@ public:
     if (RE.IsPCRel)
       makeValueAddendPCRel(Value, ObjImg, RelI, 1 << RE.Size);
 
-    RE.Addend = Value.Addend;
+    RE.Addend = Value.Offset;
 
     if (Value.SymbolName)
       addRelocationForSymbol(RE, Value.SymbolName);
index 6a8e99747fa94ea878bb0bb7744a11f074a0ce09..84d9e809a17594447d9040ffa893e17034a1a7d6 100644 (file)
@@ -54,7 +54,7 @@ public:
         RE.RelType == MachO::X86_64_RELOC_GOT_LOAD)
       processGOTRelocation(RE, Value, Stubs);
     else {
-      RE.Addend = Value.Addend;
+      RE.Addend = Value.Offset;
       if (Value.SymbolName)
         addRelocationForSymbol(RE, Value.SymbolName);
       else
@@ -106,7 +106,7 @@ private:
     SectionEntry &Section = Sections[RE.SectionID];
     assert(RE.IsPCRel);
     assert(RE.Size == 2);
-    Value.Addend -= RE.Addend;
+    Value.Offset -= RE.Addend;
     RuntimeDyldMachO::StubMap::const_iterator i = Stubs.find(Value);
     uint8_t *Addr;
     if (i != Stubs.end()) {
@@ -115,7 +115,7 @@ private:
       Stubs[Value] = Section.StubOffset;
       uint8_t *GOTEntry = Section.Address + Section.StubOffset;
       RelocationEntry GOTRE(RE.SectionID, Section.StubOffset,
-                            MachO::X86_64_RELOC_UNSIGNED, Value.Addend, false,
+                            MachO::X86_64_RELOC_UNSIGNED, Value.Offset, false,
                             3);
       if (Value.SymbolName)
         addRelocationForSymbol(GOTRE, Value.SymbolName);