2009-01-29 Zoltan Varga <vargaz@gmail.com>
[mono.git] / mono / mini / aot-runtime.c
index 3c13c773cf12f12d132498c02aec29517f0d2599..8c988d0784245924a6c2f97bf400fd63bf83c61e 100644 (file)
@@ -73,7 +73,7 @@ typedef struct MonoAotModule {
        guint32 opts;
        /* Pointer to the Global Offset Table */
        gpointer *got;
-       guint32 got_size;
+       guint32 got_size, plt_size;
        GHashTable *name_cache;
        GHashTable *extra_methods;
        /* Maps methods to their code */
@@ -91,9 +91,7 @@ typedef struct MonoAotModule {
        guint8 *code_end;
        guint8 *plt;
        guint8 *plt_end;
-       guint8 *plt_info;
-       guint8 *plt_jump_table;
-       guint32 plt_jump_table_size;
+       guint32 plt_got_offset_base;
        guint32 *code_offsets;
        guint8 *method_info;
        guint32 *method_info_offsets;
@@ -111,11 +109,22 @@ typedef struct MonoAotModule {
        guint32 *extra_method_info_offsets;
        guint8 *extra_method_info;
        guint8 *trampolines;
-       guint32 num_trampolines, first_trampoline_got_offset, trampoline_index;
+       guint32 num_trampolines, trampoline_got_offset_base, trampoline_index;
        gpointer *globals;
        MonoDl *sofile;
 } MonoAotModule;
 
+/* This structure is stored in the AOT file */
+typedef struct MonoAotFileInfo
+{
+       guint32 plt_got_offset_base;
+       guint32 trampoline_got_offset_base;
+       guint32 num_trampolines;
+       guint32 got_size;
+       guint32 plt_size;
+       gpointer *got;
+} MonoAotFileInfo;
+
 static GHashTable *aot_modules;
 #define mono_aot_lock() EnterCriticalSection (&aot_mutex)
 #define mono_aot_unlock() LeaveCriticalSection (&aot_mutex)
@@ -152,7 +161,6 @@ static gboolean spawn_compiler = TRUE;
 static gint32 mono_last_aot_method = -1;
 
 static gboolean make_unreadable = FALSE;
-static guint32 n_pagefaults = 0;
 static guint32 name_table_accesses = 0;
 
 /* Used to speed-up find_aot_module () */
@@ -170,12 +178,6 @@ load_patch_info (MonoAotModule *aot_module, MonoMemPool *mp, int n_patches,
                                 guint32 got_index, guint32 **got_slots, 
                                 guint8 *buf, guint8 **endbuf);
 
-static inline gboolean 
-is_got_patch (MonoJumpInfoType patch_type)
-{
-       return TRUE;
-}
-
 /*****************************************************/
 /*                 AOT RUNTIME                       */
 /*****************************************************/
@@ -518,15 +520,17 @@ decode_method_ref (MonoAotModule *module, guint32 *token, MonoMethod **method, g
                        *method = mono_marshal_get_static_rgctx_invoke (m);
                        break;
                }
-               case MONO_WRAPPER_MONITOR_FAST_ENTER:
-               case MONO_WRAPPER_MONITOR_FAST_EXIT: {
+               case MONO_WRAPPER_UNKNOWN: {
                        MonoMethodDesc *desc;
                        MonoMethod *orig_method;
+                       int subtype = decode_value (p, &p);
 
-                       if (wrapper_type == MONO_WRAPPER_MONITOR_FAST_ENTER)
+                       if (subtype == MONO_AOT_WRAPPER_MONO_ENTER)
                                desc = mono_method_desc_new ("Monitor:Enter", FALSE);
-                       else
+                       else if (subtype == MONO_AOT_WRAPPER_MONO_EXIT)
                                desc = mono_method_desc_new ("Monitor:Exit", FALSE);
+                       else
+                               g_assert_not_reached ();
                        orig_method = mono_method_desc_search_in_class (desc, mono_defaults.monitor_class);
                        g_assert (orig_method);
                        mono_method_desc_free (desc);
@@ -791,16 +795,11 @@ load_aot_module (MonoAssembly *assembly, gpointer user_data)
        gboolean usable = TRUE;
        char *saved_guid = NULL;
        char *aot_version = NULL;
-       char *runtime_version;
+       char *runtime_version, *build_info;
        char *opt_flags = NULL;
        gpointer *globals;
        gboolean full_aot = FALSE;
-       gpointer *plt_jump_table_addr = NULL;
-       guint32 *plt_jump_table_size = NULL;
-       guint32 *trampolines_info = NULL;
-       gpointer *got_addr = NULL;
-       gpointer *got = NULL;
-       guint32 *got_size_ptr = NULL;
+       MonoAotFileInfo *file_info = NULL;
        int i;
 
        if (mono_compile_aot)
@@ -816,6 +815,9 @@ load_aot_module (MonoAssembly *assembly, gpointer user_data)
        if (assembly->image->dynamic)
                return;
 
+       if (mono_security_get_mode () == MONO_SECURITY_MODE_CAS)
+               return;
+
        mono_aot_lock ();
        if (static_aot_modules)
                globals = g_hash_table_lookup (static_aot_modules, assembly->aname.name);
@@ -880,10 +882,12 @@ load_aot_module (MonoAssembly *assembly, gpointer user_data)
                }
        }
 
-       if (!runtime_version || ((strlen (runtime_version) > 0 && strcmp (runtime_version, FULL_VERSION)))) {
-               mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT module %s is compiled against runtime version %s while this runtime has version %s.\n", aot_name, runtime_version, FULL_VERSION);
+       build_info = mono_get_runtime_build_info ();
+       if (!runtime_version || ((strlen (runtime_version) > 0 && strcmp (runtime_version, build_info)))) {
+               mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT module %s is compiled against runtime version '%s' while this runtime has version '%s'.\n", aot_name, runtime_version, build_info);
                usable = FALSE;
        }
+       g_free (build_info);
 
        {
                char *full_aot_str;
@@ -915,18 +919,18 @@ load_aot_module (MonoAssembly *assembly, gpointer user_data)
                return;
        }
 
-       find_symbol (sofile, globals, "got_addr", (gpointer *)&got_addr);
-       g_assert (got_addr);
-       got = (gpointer*)*got_addr;
-       g_assert (got);
-       find_symbol (sofile, globals, "got_size", (gpointer *)&got_size_ptr);
-       g_assert (got_size_ptr);
+       find_symbol (sofile, globals, "mono_aot_file_info", (gpointer*)&file_info);
+       g_assert (file_info);
 
        amodule = g_new0 (MonoAotModule, 1);
        amodule->aot_name = aot_name;
        amodule->assembly = assembly;
-       amodule->got = got;
-       amodule->got_size = *got_size_ptr;
+       amodule->plt_got_offset_base = file_info->plt_got_offset_base;
+       amodule->num_trampolines = file_info->num_trampolines;
+       amodule->trampoline_got_offset_base = file_info->trampoline_got_offset_base;
+       amodule->got_size = file_info->got_size;
+       amodule->plt_size = file_info->plt_size;
+       amodule->got = file_info->got;
        amodule->got [0] = assembly->image;
        amodule->globals = globals;
        amodule->sofile = sofile;
@@ -1000,22 +1004,6 @@ load_aot_module (MonoAssembly *assembly, gpointer user_data)
 
        find_symbol (sofile, globals, "plt", (gpointer*)&amodule->plt);
        find_symbol (sofile, globals, "plt_end", (gpointer*)&amodule->plt_end);
-       find_symbol (sofile, globals, "plt_info", (gpointer*)&amodule->plt_info);
-
-       find_symbol (sofile, globals, "plt_jump_table_addr", (gpointer *)&plt_jump_table_addr);
-       g_assert (plt_jump_table_addr);
-       amodule->plt_jump_table = (guint8*)*plt_jump_table_addr;
-       g_assert (amodule->plt_jump_table);
-
-       find_symbol (sofile, globals, "plt_jump_table_size", (gpointer *)&plt_jump_table_size);
-       g_assert (plt_jump_table_size);
-       amodule->plt_jump_table_size = *plt_jump_table_size;
-
-       find_symbol (sofile, globals, "trampolines_info", (gpointer *)&trampolines_info);
-       if (trampolines_info) {
-               amodule->num_trampolines = trampolines_info [0];
-               amodule->first_trampoline_got_offset = trampolines_info [1];
-       }       
 
        if (make_unreadable) {
 #ifndef PLATFORM_WIN32
@@ -1331,17 +1319,20 @@ mono_aot_get_class_from_name (MonoImage *image, const char *name_space, const ch
        return TRUE;
 }
 
+/*
+ * LOCKING: Acquires the domain lock.
+ */
 static MonoJitInfo*
 decode_exception_debug_info (MonoAotModule *aot_module, MonoDomain *domain, 
                                                         MonoMethod *method, guint8* ex_info, guint8 *code)
 {
        int i, buf_len;
        MonoJitInfo *jinfo;
-       guint code_len, used_int_regs;
-       gboolean has_generic_jit_info;
-       guint8 *p;
+       guint code_len, used_int_regs, flags;
+       gboolean has_generic_jit_info, has_dwarf_unwind_info;
+       guint8 *p, *unwind_info_block;
        MonoMethodHeader *header;
-       int generic_info_size;
+       int generic_info_size, unwind_info_len;
 
        header = mono_method_get_header (method);
 
@@ -1349,8 +1340,21 @@ decode_exception_debug_info (MonoAotModule *aot_module, MonoDomain *domain,
 
        p = ex_info;
        code_len = decode_value (p, &p);
-       used_int_regs = decode_value (p, &p);
-       has_generic_jit_info = decode_value (p, &p);
+       flags = decode_value (p, &p);
+       has_generic_jit_info = (flags & 1) != 0;
+       has_dwarf_unwind_info = (flags & 2) != 0;
+       unwind_info_block = p;
+       if (has_dwarf_unwind_info) {
+               gssize offset;
+
+               unwind_info_len = decode_value (p, &p);
+               offset = unwind_info_block - (guint8*)aot_module->ex_info;
+               g_assert (offset > 0 && offset < (1 << 30));
+               used_int_regs = offset;
+               p += unwind_info_len;
+       } else {
+               used_int_regs = decode_value (p, &p);
+       }
        if (has_generic_jit_info)
                generic_info_size = sizeof (MonoGenericJitInfo);
        else
@@ -1358,9 +1362,11 @@ decode_exception_debug_info (MonoAotModule *aot_module, MonoDomain *domain,
 
        /* Exception table */
        if (header && header->num_clauses) {
+               mono_domain_lock (domain);
                jinfo = 
                        mono_domain_alloc0 (domain, sizeof (MonoJitInfo) + (sizeof (MonoJitExceptionInfo) * header->num_clauses) + generic_info_size);
                jinfo->num_clauses = header->num_clauses;
+               mono_domain_unlock (domain);
 
                for (i = 0; i < header->num_clauses; ++i) {
                        MonoExceptionClause *ec = &header->clauses [i];                         
@@ -1379,14 +1385,18 @@ decode_exception_debug_info (MonoAotModule *aot_module, MonoDomain *domain,
                        ei->handler_start = code + decode_value (p, &p);
                }
        }
-       else
+       else {
+               mono_domain_lock (domain);
                jinfo = mono_domain_alloc0 (domain, sizeof (MonoJitInfo) + generic_info_size);
+               mono_domain_unlock (domain);
+       }
 
        jinfo->code_size = code_len;
        jinfo->used_regs = used_int_regs;
        jinfo->method = method;
        jinfo->code_start = code;
        jinfo->domain_neutral = 0;
+       jinfo->from_aot = 1;
 
        if (has_generic_jit_info) {
                MonoGenericJitInfo *gi;
@@ -1413,6 +1423,25 @@ decode_exception_debug_info (MonoAotModule *aot_module, MonoDomain *domain,
        return jinfo;
 }
 
+/*
+ * mono_aot_get_unwind_info:
+ *
+ *   Return a pointer to the DWARF unwind info belonging to JI.
+ */
+guint8*
+mono_aot_get_unwind_info (MonoJitInfo *ji, guint32 *unwind_info_len)
+{
+       MonoAotModule *amodule = ji->method->klass->image->aot_module;
+       guint8 *p;
+
+       g_assert (amodule);
+       g_assert (ji->from_aot);
+
+       p = amodule->ex_info + ji->used_regs;
+       *unwind_info_len = decode_value (p, &p);
+       return p;
+}
+
 MonoJitInfo *
 mono_aot_find_jit_info (MonoDomain *domain, MonoImage *image, gpointer addr)
 {
@@ -1742,6 +1771,8 @@ decode_patch (MonoAotModule *aot_module, MonoMemPool *mp, MonoJumpInfo *ji, guin
                break;
        case MONO_PATCH_INFO_INTERRUPTION_REQUEST_FLAG:
        case MONO_PATCH_INFO_GENERIC_CLASS_INIT:
+       case MONO_PATCH_INFO_MONITOR_ENTER:
+       case MONO_PATCH_INFO_MONITOR_EXIT:
                break;
        case MONO_PATCH_INFO_RGCTX_FETCH: {
                gboolean res;
@@ -1887,10 +1918,10 @@ static gpointer
 load_method (MonoDomain *domain, MonoAotModule *aot_module, MonoImage *image, MonoMethod *method, guint32 token, int method_index)
 {
        MonoClass *klass;
-       MonoJumpInfo *patch_info = NULL;
+       gboolean from_plt = method == NULL;
        MonoMemPool *mp;
        int i, pindex, got_index = 0, n_patches, used_strings;
-       gboolean non_got_patches, keep_patches = TRUE;
+       gboolean keep_patches = TRUE;
        guint8 *p, *ex_info;
        MonoJitInfo *jinfo = NULL;
        guint8 *code, *info;
@@ -1994,30 +2025,15 @@ load_method (MonoDomain *domain, MonoAotModule *aot_module, MonoImage *image, Mo
                if (patches == NULL)
                        goto cleanup;
 
-               non_got_patches = FALSE;
                for (pindex = 0; pindex < n_patches; ++pindex) {
                        MonoJumpInfo *ji = &patches [pindex];
 
-                       if (is_got_patch (ji->type)) {
-                               if (!aot_module->got [got_slots [pindex]]) {
-                                       aot_module->got [got_slots [pindex]] = mono_resolve_patch_target (method, domain, code, ji, TRUE);
-                                       if (ji->type == MONO_PATCH_INFO_METHOD_JUMP)
-                                               register_jump_target_got_slot (domain, ji->data.method, &(aot_module->got [got_slots [pindex]]));
-                               }
-                               ji->type = MONO_PATCH_INFO_NONE;
-                       }
-                       else
-                               non_got_patches = TRUE;
-               }
-               if (non_got_patches) {
-                       if (!jinfo) {
-                               ex_info = &aot_module->ex_info [aot_module->ex_info_offsets [mono_metadata_token_index (token) - 1]];
-                               jinfo = decode_exception_debug_info (aot_module, domain, method, ex_info, code);
+                       if (!aot_module->got [got_slots [pindex]]) {
+                               aot_module->got [got_slots [pindex]] = mono_resolve_patch_target (method, domain, code, ji, TRUE);
+                               if (ji->type == MONO_PATCH_INFO_METHOD_JUMP)
+                                       register_jump_target_got_slot (domain, ji->data.method, &(aot_module->got [got_slots [pindex]]));
                        }
-
-                       mono_arch_flush_icache (code, jinfo->code_size);
-                       make_writable (code, jinfo->code_size);
-                       mono_arch_patch_code (method, domain, code, patch_info, TRUE);
+                       ji->type = MONO_PATCH_INFO_NONE;
                }
 
                g_free (got_slots);
@@ -2026,10 +2042,6 @@ load_method (MonoDomain *domain, MonoAotModule *aot_module, MonoImage *image, Mo
                        mono_mempool_destroy (mp);
        }
 
-       mono_aot_lock ();
-
-       mono_jit_stats.methods_aot++;
-
        if (mono_trace_is_traced (G_LOG_LEVEL_DEBUG, MONO_TRACE_AOT)) {
                char *full_name;
 
@@ -2047,6 +2059,10 @@ load_method (MonoDomain *domain, MonoAotModule *aot_module, MonoImage *image, Mo
                g_free (full_name);
        }
 
+       mono_aot_lock ();
+
+       mono_jit_stats.methods_aot++;
+
        aot_module->methods_loaded [method_index / 32] |= 1 << (method_index % 32);
 
        init_plt (aot_module);
@@ -2056,7 +2072,7 @@ load_method (MonoDomain *domain, MonoAotModule *aot_module, MonoImage *image, Mo
 
        mono_aot_unlock ();
 
-       if (!method && klass)
+       if (from_plt && klass && !klass->generic_container)
                mono_runtime_class_init (mono_class_vtable (domain, klass));
 
        return code;
@@ -2093,6 +2109,18 @@ find_extra_method_in_amodule (MonoAotModule *amodule, MonoMethod *method)
                        char *tmpsig = mono_signature_get_desc (mono_method_signature (method), TRUE);
                        full_name = g_strdup_printf ("(wrapper runtime-invoke):%s (%s)", method->name, tmpsig);
                        g_free (tmpsig);
+               } else if (method->wrapper_type == MONO_WRAPPER_DELEGATE_INVOKE) {
+                       char *tmpsig = mono_signature_get_desc (mono_method_signature (method), TRUE);
+                       full_name = g_strdup_printf ("(wrapper delegate-invoke):%s (%s)", method->name, tmpsig);
+                       g_free (tmpsig);
+               } else if (method->wrapper_type == MONO_WRAPPER_DELEGATE_BEGIN_INVOKE) {
+                       char *tmpsig = mono_signature_get_desc (mono_method_signature (method), TRUE);
+                       full_name = g_strdup_printf ("(wrapper delegate-begin-invoke):%s (%s)", method->name, tmpsig);
+                       g_free (tmpsig);
+               } else if (method->wrapper_type == MONO_WRAPPER_DELEGATE_END_INVOKE) {
+                       char *tmpsig = mono_signature_get_desc (mono_method_signature (method), TRUE);
+                       full_name = g_strdup_printf ("(wrapper delegate-end-invoke):%s (%s)", method->name, tmpsig);
+                       g_free (tmpsig);
                } else {
                        full_name = mono_method_full_name (method, TRUE);
                }
@@ -2343,106 +2371,6 @@ find_aot_module (guint8 *code)
        return user_data.module;
 }
 
-/*
- * mono_aot_set_make_unreadable:
- *
- *   Set whenever to make all mmaped memory unreadable. In conjuction with a
- * SIGSEGV handler, this is useful to find out which pages the runtime tries to read.
- */
-void
-mono_aot_set_make_unreadable (gboolean unreadable)
-{
-       make_unreadable = unreadable;
-}
-
-typedef struct {
-       MonoAotModule *module;
-       guint8 *ptr;
-} FindMapUserData;
-
-static void
-find_map (gpointer key, gpointer value, gpointer user_data)
-{
-       MonoAotModule *module = (MonoAotModule*)value;
-       FindMapUserData *data = (FindMapUserData*)user_data;
-
-       if (!data->module)
-               if ((data->ptr >= module->mem_begin) && (data->ptr < module->mem_end))
-                       data->module = module;
-}
-
-static MonoAotModule*
-find_module_for_addr (void *ptr)
-{
-       FindMapUserData data;
-
-       if (!make_unreadable)
-               return NULL;
-
-       data.module = NULL;
-       data.ptr = (guint8*)ptr;
-
-       mono_aot_lock ();
-       g_hash_table_foreach (aot_modules, (GHFunc)find_map, &data);
-       mono_aot_unlock ();
-
-       return data.module;
-}
-
-/*
- * mono_aot_is_pagefault:
- *
- *   Should be called from a SIGSEGV signal handler to find out whenever @ptr is
- * within memory allocated by this module.
- */
-gboolean
-mono_aot_is_pagefault (void *ptr)
-{
-       if (!make_unreadable)
-               return FALSE;
-
-       return find_module_for_addr (ptr) != NULL;
-}
-
-/*
- * mono_aot_handle_pagefault:
- *
- *   Handle a pagefault caused by an unreadable page by making it readable again.
- */
-void
-mono_aot_handle_pagefault (void *ptr)
-{
-#ifndef PLATFORM_WIN32
-       guint8* start = (guint8*)ROUND_DOWN (((gssize)ptr), PAGESIZE);
-       int res;
-
-       mono_aot_lock ();
-       res = mprotect (start, PAGESIZE, PROT_READ|PROT_WRITE|PROT_EXEC);
-       g_assert (res == 0);
-
-       n_pagefaults ++;
-       mono_aot_unlock ();
-
-#if 0
- {
-       void *array [256];
-       char **names;
-       int i, size;
-
-       printf ("\nNative stacktrace:\n\n");
-
-       size = backtrace (array, 256);
-       names = backtrace_symbols (array, size);
-       for (i =0; i < size; ++i) {
-               printf ("\t%s\n", names [i]);
-       }
-       free (names);
- }
-#endif
-
-#endif
-}
-
 /*
  * mono_aot_plt_resolve:
  *
@@ -2461,7 +2389,7 @@ mono_aot_plt_resolve (gpointer aot_module, guint32 plt_info_offset, guint8 *code
 
        //printf ("DYN: %p %d\n", aot_module, plt_info_offset);
 
-       p = &module->plt_info [plt_info_offset];
+       p = &module->got_info [plt_info_offset];
 
        ji.type = decode_value (p, &p);
 
@@ -2499,10 +2427,8 @@ init_plt (MonoAotModule *info)
 #ifdef MONO_ARCH_AOT_SUPPORTED
 #ifdef __i386__
        guint8 *buf = info->plt;
-#elif defined(__x86_64__)
-       int i, n_entries;
-#elif defined(__arm__)
-       int i, n_entries;
+#elif defined(__x86_64__) || defined(__arm__)
+       int i;
 #endif
        gpointer tramp;
 
@@ -2517,15 +2443,14 @@ init_plt (MonoAotModule *info)
        x86_jump_code (buf, tramp);
 #elif defined(__x86_64__) || defined(__arm__)
        /*
-        * Initialize the entries in the plt_jump_table to point to the default targets.
+        * Initialize the PLT entries in the GOT to point to the default targets.
         */
-        n_entries = info->plt_jump_table_size / sizeof (gpointer);
 
         /* The first entry points to the AOT trampoline */
-        ((gpointer*)info->plt_jump_table)[0] = tramp;
-        for (i = 1; i < n_entries; ++i)
+        ((gpointer*)info->got)[info->plt_got_offset_base] = tramp;
+        for (i = 1; i < info->plt_size; ++i)
                 /* All the default entries point to the first entry */
-                ((gpointer*)info->plt_jump_table)[i] = info->plt;
+                ((gpointer*)info->got)[info->plt_got_offset_base + i] = info->plt;
 #else
        g_assert_not_reached ();
 #endif
@@ -2674,8 +2599,17 @@ load_named_code (MonoAotModule *amodule, const char *name)
                                        int tramp_type2 = atoi (ji->data.name + strlen ("trampoline_func_"));
                                        target = (gpointer)mono_get_trampoline_func (tramp_type2);
                                } else if (strstr (ji->data.name, "specific_trampoline_lazy_fetch_") == ji->data.name) {
-                                       guint32 slot = atoi (ji->data.name + strlen ("specific_trampoline_lazy_fetch_"));
+                                       /* atoll is needed because the the offset is unsigned */
+                                       guint32 slot;
+                                       int res;
+
+                                       res = sscanf (ji->data.name, "specific_trampoline_lazy_fetch_%u", &slot);
+                                       g_assert (res == 1);
                                        target = mono_create_specific_trampoline (GUINT_TO_POINTER (slot), MONO_TRAMPOLINE_RGCTX_LAZY_FETCH, mono_get_root_domain (), NULL);
+                               } else if (!strcmp (ji->data.name, "specific_trampoline_monitor_enter")) {
+                                       target = mono_create_specific_trampoline (NULL, MONO_TRAMPOLINE_MONITOR_ENTER, mono_get_root_domain (), NULL);
+                               } else if (!strcmp (ji->data.name, "specific_trampoline_monitor_exit")) {
+                                       target = mono_create_specific_trampoline (NULL, MONO_TRAMPOLINE_MONITOR_EXIT, mono_get_root_domain (), NULL);
                                } else {
                                        fprintf (stderr, "Unknown relocation '%s'\n", ji->data.name);
                                        g_assert_not_reached ();
@@ -2755,8 +2689,8 @@ mono_aot_create_specific_trampoline (MonoImage *image, gpointer arg1, MonoTrampo
        tramp = generic_trampolines [tramp_type];
        g_assert (tramp);
 
-       amodule->got [amodule->first_trampoline_got_offset + (index *2)] = tramp;
-       amodule->got [amodule->first_trampoline_got_offset + (index *2) + 1] = arg1;
+       amodule->got [amodule->trampoline_got_offset_base + (index *2)] = tramp;
+       amodule->got [amodule->trampoline_got_offset_base + (index *2) + 1] = arg1;
 
 #ifdef __x86_64__
        tramp_size = 16;
@@ -2803,17 +2737,6 @@ mono_aot_get_lazy_fetch_trampoline (guint32 slot)
        return code;
 }
 
-/*
- * mono_aot_get_n_pagefaults:
- *
- *   Return the number of times handle_pagefault is called.
- */
-guint32
-mono_aot_get_n_pagefaults (void)
-{
-       return n_pagefaults;
-}
-
 #else
 /* AOT disabled */
 
@@ -2858,28 +2781,6 @@ mono_aot_get_method_from_token (MonoDomain *domain, MonoImage *image, guint32 to
        return NULL;
 }
 
-gboolean
-mono_aot_is_pagefault (void *ptr)
-{
-       return FALSE;
-}
-
-void
-mono_aot_set_make_unreadable (gboolean unreadable)
-{
-}
-
-guint32
-mono_aot_get_n_pagefaults (void)
-{
-       return 0;
-}
-
-void
-mono_aot_handle_pagefault (void *ptr)
-{
-}
-
 guint8*
 mono_aot_get_plt_entry (guint8 *code)
 {
@@ -2898,15 +2799,23 @@ mono_aot_get_method_from_vt_slot (MonoDomain *domain, MonoVTable *vtable, int sl
        return NULL;
 }
 
+guint32
+mono_aot_get_plt_info_offset (gssize *regs, guint8 *code)
+{
+       g_assert_not_reached ();
+
+       return 0;
+}
+
 gpointer
-mono_aot_create_specific_trampolines (gpointer arg1, MonoTrampolineType tramp_type, MonoDomain *domain, guint32 *code_len)
+mono_aot_create_specific_trampoline (MonoImage *image, gpointer arg1, MonoTrampolineType tramp_type, MonoDomain *domain, guint32 *code_len)
 {
        g_assert_not_reached ();
        return NULL;
 }
 
 gpointer
-mono_aot_get_named_code (char *name)
+mono_aot_get_named_code (const char *name)
 {
        g_assert_not_reached ();
        return NULL;
@@ -2919,4 +2828,11 @@ mono_aot_get_unbox_trampoline (MonoMethod *method)
        return NULL;
 }
 
+gpointer
+mono_aot_get_lazy_fetch_trampoline (guint32 slot)
+{
+       g_assert_not_reached ();
+       return NULL;
+}
+
 #endif