<div dir="ltr">Oh nice. Thanks Juergen. :)</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jul 29, 2014 at 12:57 PM, Juergen Ributzka <span dir="ltr"><<a href="mailto:juergen@apple.com" target="_blank">juergen@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ributzka<br>
Date: Tue Jul 29 14:57:11 2014<br>
New Revision: 214204<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=214204&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=214204&view=rev</a><br>
Log:<br>
[RuntimeDyld][AArch64] Make encode/decodeAddend more typesafe by using the relocation enum type. NFCI.<br>
<br>
Modified:<br>
    llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp<br>
    llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h<br>
    llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h<br>
<br>
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp?rev=214204&r1=214203&r2=214204&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp?rev=214204&r1=214203&r2=214204&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp (original)<br>
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp Tue Jul 29 14:57:11 2014<br>
@@ -28,7 +28,7 @@ using namespace llvm::object;<br>
 namespace llvm {<br>
<br>
 int64_t RuntimeDyldMachO::decodeAddend(uint8_t *LocalAddress, unsigned NumBytes,<br>
-                                       uint32_t RelType) const {<br>
+                                       MachO::RelocationInfoType) const {<br>
   int64_t Addend = 0;<br>
   memcpy(&Addend, LocalAddress, NumBytes);<br>
   return Addend;<br>
<br>
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h?rev=214204&r1=214203&r2=214204&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h?rev=214204&r1=214203&r2=214204&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h (original)<br>
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h Tue Jul 29 14:57:11 2014<br>
@@ -54,7 +54,7 @@ protected:<br>
<br>
   /// Extract the addend encoded in the instruction.<br>
   int64_t decodeAddend(uint8_t *LocalAddress, unsigned NumBytes,<br>
-                       uint32_t RelType) const;<br>
+                       MachO::RelocationInfoType RelType) const;<br>
<br>
   /// Construct a RelocationValueRef representing the relocation target.<br>
   /// For Symbols in known sections, this will return a RelocationValueRef<br>
@@ -138,7 +138,8 @@ protected:<br>
     RI->getOffset(Offset);<br>
     uint8_t *LocalAddress = Section.Address + Offset;<br>
     unsigned NumBytes = 1 << Size;<br>
-    uint32_t RelType = Obj.getAnyRelocationType(RelInfo);<br>
+    MachO::RelocationInfoType RelType =<br>
+      static_cast<MachO::RelocationInfoType>(Obj.getAnyRelocationType(RelInfo));<br>
     int64_t Addend = impl().decodeAddend(LocalAddress, NumBytes, RelType);<br>
<br>
     return RelocationEntry(SectionID, Offset, RelType, Addend, IsPCRel, Size);<br>
<br>
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h?rev=214204&r1=214203&r2=214204&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h?rev=214204&r1=214203&r2=214204&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h (original)<br>
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h Tue Jul 29 14:57:11 2014<br>
@@ -28,7 +28,7 @@ public:<br>
<br>
   /// Extract the addend encoded in the instruction / memory location.<br>
   int64_t decodeAddend(uint8_t *LocalAddress, unsigned NumBytes,<br>
-                       uint32_t RelType) const {<br>
+                       MachO::RelocationInfoType RelType) const {<br>
     int64_t Addend = 0;<br>
     // Verify that the relocation has the correct size and alignment.<br>
     switch (RelType) {<br>
@@ -120,7 +120,7 @@ public:<br>
   }<br>
<br>
   /// Extract the addend encoded in the instruction.<br>
-  void encodeAddend(uint8_t *LocalAddress, uint32_t RelType,<br>
+  void encodeAddend(uint8_t *LocalAddress, MachO::RelocationInfoType RelType,<br>
                     int64_t Addend) const {<br>
     // Verify that the relocation has the correct alignment.<br>
     switch (RelType) {<br>
@@ -285,8 +285,10 @@ public:<br>
<br>
     const SectionEntry &Section = Sections[RE.SectionID];<br>
     uint8_t *LocalAddress = Section.Address + RE.Offset;<br>
+    MachO::RelocationInfoType RelType =<br>
+      static_cast<MachO::RelocationInfoType>(RE.RelType);<br>
<br>
-    switch (RE.RelType) {<br>
+    switch (RelType) {<br>
     default:<br>
       llvm_unreachable("Invalid relocation type!");<br>
     case MachO::ARM64_RELOC_UNSIGNED: {<br>
@@ -304,7 +306,7 @@ public:<br>
       // Check if branch is in range.<br>
       uint64_t FinalAddress = Section.LoadAddress + RE.Offset;<br>
       int64_t PCRelVal = Value - FinalAddress + RE.Addend;<br>
-      encodeAddend(LocalAddress, RE.RelType, PCRelVal);<br>
+      encodeAddend(LocalAddress, RelType, PCRelVal);<br>
       break;<br>
     }<br>
     case MachO::ARM64_RELOC_GOT_LOAD_PAGE21:<br>
@@ -314,7 +316,7 @@ public:<br>
       uint64_t FinalAddress = Section.LoadAddress + RE.Offset;<br>
       int64_t PCRelVal =<br>
         ((Value + RE.Addend) & (-4096)) - (FinalAddress & (-4096));<br>
-      encodeAddend(LocalAddress, RE.RelType, PCRelVal);<br>
+      encodeAddend(LocalAddress, RelType, PCRelVal);<br>
       break;<br>
     }<br>
     case MachO::ARM64_RELOC_GOT_LOAD_PAGEOFF12:<br>
@@ -324,7 +326,7 @@ public:<br>
       Value += RE.Addend;<br>
       // Mask out the page address and only use the lower 12 bits.<br>
       Value &= 0xFFF;<br>
-      encodeAddend(LocalAddress, RE.RelType, Value);<br>
+      encodeAddend(LocalAddress, RelType, Value);<br>
       break;<br>
     }<br>
     case MachO::ARM64_RELOC_SUBTRACTOR:<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>