Index: /trunk/src/recompiler/new/VBoxREMWrapper.cpp
===================================================================
--- /trunk/src/recompiler/new/VBoxREMWrapper.cpp	(revision 339)
+++ /trunk/src/recompiler/new/VBoxREMWrapper.cpp	(revision 340)
@@ -158,6 +158,14 @@
  * use calling convention wrappers.
  */
-#if defined(__WIN64__) || defined(__DOXYGEN__)
+#if (defined(__AMD64__) && defined(__WIN__)) || defined(__DOXYGEN__)
 # define USE_REM_CALLING_CONVENTION_GLUE
+#endif
+
+/** @def USE_REM_IMPORT_JUMP_GLUE
+ * Define USE_REM_IMPORT_JUMP_GLUE for platforms where we need to 
+ * emit some jump glue to deal with big addresses.
+ */
+#if (defined(__AMD64__) && !defined(USE_REM_CALLING_CONVENTION_GLUE) && !defined(__DARWIN__)) || defined(__DOXYGEN__)
+# define USE_REM_IMPORT_JUMP_GLUE
 #endif
 
@@ -1002,5 +1010,5 @@
 
 
-# ifdef USE_REM_CALLING_CONVENTION_GLUE
+# if defined(USE_REM_CALLING_CONVENTION_GLUE) || defined(USE_REM_IMPORT_JUMP_GLUE) 
 /** LIFO of read-write-executable memory chunks used for wrappers. */
 static PREMEXECMEM g_pExecMemHead;
@@ -1040,5 +1048,5 @@
 
 
-# ifdef USE_REM_CALLING_CONVENTION_GLUE
+# if defined(USE_REM_CALLING_CONVENTION_GLUE) || defined(USE_REM_IMPORT_JUMP_GLUE) 
 /**
  * Allocates a block of memory for glue code.
@@ -1074,6 +1082,8 @@
     return memset((uint8_t *)pCur + RT_ALIGN_Z(sizeof(*pCur), 32), 0xcc, cbAligned);
 }
-
-
+# endif /* USE_REM_CALLING_CONVENTION_GLUE || USE_REM_IMPORT_JUMP_GLUE */
+
+
+# ifdef USE_REM_CALLING_CONVENTION_GLUE
 /**
  * Checks if a function is all straight forward integers.
@@ -1321,7 +1331,8 @@
 static int remGenerateImportGlue(PRTUINTPTR pValue, PREMFNDESC pDesc)
 {
-# ifdef USE_REM_CALLING_CONVENTION_GLUE
+# if defined(USE_REM_CALLING_CONVENTION_GLUE) || defined(USE_REM_IMPORT_JUMP_GLUE) 
     if (!pDesc->pvWrapper)
     {
+#  ifdef USE_REM_CALLING_CONVENTION_GLUE
         if (remIsFunctionAllInts(pDesc))
         {
@@ -1382,7 +1393,29 @@
 #endif
         }
+#  else  /* !USE_REM_CALLING_CONVENTION_GLUE */
+
+        /*
+         * Generate a jump patch.
+         */
+        uint8_t *pb;
+#   ifdef __AMD64__
+        pDesc->pvWrapper = pb = (uint8_t *)remAllocGlue(32);
+        AssertReturn(pDesc->pvWrapper, VERR_NO_MEMORY);
+        *pb++ = 0xcc;
+        *pb++ = 0xff;
+        *pb++ = 0x24;
+        *pb++ = 0x25;
+        *(uint32_t *)pb = (uintptr_t)pb + 5;
+        pb += 5;
+        *(uint64_t *)pb = (uint64_t)pDesc->pv;
+#   else
+        pDesc->pvWrapper = pb = (uint8_t *)remAllocGlue(8);
+        AssertReturn(pDesc->pvWrapper, VERR_NO_MEMORY);
+        *pb++ = 0xea;
+        *(uint32_t *)pb = (uint32_t)pDesc->pv;
+#   endif
+#  endif /* !USE_REM_CALLING_CONVENTION_GLUE */
     }
     *pValue = (uintptr_t)pDesc->pvWrapper;
-
 # else  /* !USE_REM_CALLING_CONVENTION_GLUE */
     *pValue = (uintptr_t)pDesc->pv;
@@ -1495,5 +1528,5 @@
     for (i = 0; i < ELEMENTS(g_aExports); i++)
         *(void **)g_aExports[i].pv = NULL;
-# ifdef USE_REM_CALLING_CONVENTION_GLUE
+# if defined(USE_REM_CALLING_CONVENTION_GLUE) || defined(USE_REM_IMPORT_JUMP_GLUE) 
     for (i = 0; i < ELEMENTS(g_aVMMImports); i++)
         g_aVMMImports[i].pvWrapper = NULL;
