Allow 64 bit method addresses in the amd64 backend, LLVM on osx seems to generate...
authorZoltan Varga <vargaz@gmail.com>
Fri, 5 Oct 2012 05:08:52 +0000 (07:08 +0200)
committerZoltan Varga <vargaz@gmail.com>
Fri, 5 Oct 2012 05:08:52 +0000 (07:08 +0200)
mono/mini/tramp-amd64.c

index d63b055f530dc0aee726510b465b2af4e03494ec..3c108f307cf0cd91a1141a645ff4eef6f9295454 100644 (file)
@@ -158,7 +158,9 @@ mono_arch_patch_callsite (guint8 *method_start, guint8 *orig_code, guint8 *addr)
                                VALGRIND_DISCARD_TRANSLATIONS (orig_code - 11, sizeof (gpointer));
                        }
                } else {
-                       if ((((guint64)(addr)) >> 32) != 0) {
+                       gboolean disp_32bit = ((((gint64)addr - (gint64)orig_code)) < (1 << 30)) && ((((gint64)addr - (gint64)orig_code)) > -(1 << 30));
+
+                       if ((((guint64)(addr)) >> 32) != 0 && !disp_32bit) {
 #ifdef MONO_ARCH_NOMAP32BIT
                                /* Print some diagnostics */
                                MonoJitInfo *ji = mono_jit_info_table_find (mono_domain_get (), (char*)orig_code);
@@ -183,7 +185,6 @@ mono_arch_patch_callsite (guint8 *method_start, guint8 *orig_code, guint8 *addr)
                                mono_arch_flush_icache (thunk_start, thunk_code - thunk_start);
 #endif
                        }
-                       g_assert ((((guint64)(orig_code)) >> 32) == 0);
                        if (can_write) {
                                InterlockedExchange ((gint32*)(orig_code - 4), ((gint64)addr - (gint64)orig_code));
                                VALGRIND_DISCARD_TRANSLATIONS (orig_code - 5, 4);