Add support for ARM and AArch64 BE object files
[oota-llvm.git] / include / llvm / Object / RelocVisitor.h
index 36852f21b513d41109e29736bac4dc3bc194bf06..0e99f368b48d2202610c7ef8436a83dc57af57f7 100644 (file)
@@ -306,7 +306,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.
@@ -317,7 +318,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);
   }
 
@@ -354,8 +356,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);
   }
 
 };