Add support for ARM and AArch64 big endian objects to
[oota-llvm.git] / include / llvm / Object / RelocVisitor.h
index c30699f511e70e61c7d0eb9ece6266fc74e89acc..9eb768daa0a9c521e6f56e8f2a32a78cd00c29c6 100644 (file)
@@ -304,7 +304,8 @@ private:
 
   // AArch64 ELF
   RelocToApply visitELF_AARCH64_ABS32(RelocationRef R, uint64_t Value) {
-    int64_t Addend = getAddend64LE(R);
+    int64_t Addend;
+    getELFRelocationAddend(R, Addend);
     int64_t Res =  Value + Addend;
 
     // Overflow check allows for both signed and unsigned interpretation.
@@ -315,7 +316,8 @@ private:
   }
 
   RelocToApply visitELF_AARCH64_ABS64(RelocationRef R, uint64_t Value) {
-    int64_t Addend = getAddend64LE(R);
+    int64_t Addend;
+    getELFRelocationAddend(R, Addend);
     return RelocToApply(Value + Addend, 8);
   }
 
@@ -352,8 +354,15 @@ private:
   }
 
   RelocToApply visitELF_ARM_ABS32(RelocationRef R, uint64_t Value) {
-    int64_t Addend = getAddend32LE(R);
-    return RelocToApply(Value + Addend, 4);
+    int64_t Addend;
+    getELFRelocationAddend(R, Addend);
+    int64_t Res = Value + Addend;
+
+    // Overflow check allows for both signed and unsigned interpretation.
+    if (Res < INT32_MIN || Res > UINT32_MAX)
+      HasError = true;
+
+    return RelocToApply(static_cast<uint32_t>(Res), 4);
   }
 
 };