[arm64] Assert that the displacement is not out of range int he b/bl macros, instead...
authorZoltan Varga <vargaz@gmail.com>
Wed, 3 Aug 2016 23:50:11 +0000 (19:50 -0400)
committerZoltan Varga <vargaz@gmail.com>
Wed, 3 Aug 2016 23:50:11 +0000 (19:50 -0400)
mono/arch/arm64/arm64-codegen.h

index 6ca4da6d88127686f16fe2ac70c759a8839a6f4e..2d8c4c5a91554532a5da89ffa62b92993b4727bf 100644 (file)
@@ -179,9 +179,9 @@ arm_get_disp (void *p, void *target)
 }
 
 // 0b00101 == 0x5
-#define arm_b(p, target) arm_emit (p, (0x0 << 31) | (0x5 << 26) | ((arm_get_disp ((p), (target)) << 0)))
+#define arm_b(p, target) do { if ((target)) g_assert (arm_is_bl_disp ((p), (target))); arm_emit (p, (0x0 << 31) | (0x5 << 26) | ((arm_get_disp ((p), (target)) << 0))); } while (0)
 
-#define arm_bl(p, target) arm_emit (p, (0x1 << 31) | (0x5 << 26) | ((arm_get_disp ((p), (target)) << 0)))
+#define arm_bl(p, target) do { if ((target)) g_assert (arm_is_bl_disp ((p), (target))); arm_emit (p, (0x1 << 31) | (0x5 << 26) | ((arm_get_disp ((p), (target)) << 0))); } while (0)
 
 /* Conditional branch */