mono_arch_unwindinfo_install_tramp_unwind_info can only be called for JIT:ed code.
authorlateralusX <lateralusx.github@gmail.com>
Wed, 15 Mar 2017 09:18:17 +0000 (10:18 +0100)
committerlateralusX <lateralusx.github@gmail.com>
Wed, 15 Mar 2017 09:18:17 +0000 (10:18 +0100)
Currently mono_arch_unwindinfo_install_tramp_unwind_info can only be called on
JIT:ed code since it assumes place for unwind info has been allocated behind
code block. When called by AOT:ed code the complete this is have not done and
the unwind info should not be registered with OS for AOT:ed code
(should be part of the image).

mono/mini/aot-runtime.c
mono/mini/mini-runtime.c
mono/mini/mini.h

index ce87be85147787fadc4017bb32d96a9be54733ac..622ad2e4f95b94cdbd824482273c823d16519edf 100644 (file)
@@ -2262,7 +2262,7 @@ load_aot_module (MonoAssembly *assembly, gpointer user_data)
        /*
         * Register the plt region as a single trampoline so we can unwind from this code
         */
-       mono_tramp_info_register (
+       mono_aot_tramp_info_register (
                mono_tramp_info_create (
                        NULL,
                        amodule->plt,
@@ -5143,7 +5143,7 @@ mono_aot_get_trampoline (const char *name)
        gpointer code;
 
        code =  mono_aot_get_trampoline_full (name, &out_tinfo);
-       mono_tramp_info_register (out_tinfo, NULL);
+       mono_aot_tramp_info_register (out_tinfo, NULL);
 
        return code;
 }
@@ -5297,7 +5297,7 @@ get_new_trampoline_from_page (int tramp_type)
                /* Register the generic part at the beggining of the trampoline page */
                gen_info = mono_tramp_info_create (NULL, (guint8*)taddr, amodule->info.tramp_page_code_offsets [tramp_type], NULL, NULL);
                read_page_trampoline_uwinfo (gen_info, tramp_type, TRUE);
-               mono_tramp_info_register (gen_info, NULL);
+               mono_aot_tramp_info_register (gen_info, NULL);
                /*
                 * FIXME
                 * Registering each specific trampoline produces a lot of
@@ -5308,7 +5308,7 @@ get_new_trampoline_from_page (int tramp_type)
                        /* Register the rest of the page as a single trampoline */
                        sp_info = mono_tramp_info_create (NULL, code, page->trampolines_end - code, NULL, NULL);
                        read_page_trampoline_uwinfo (sp_info, tramp_type, FALSE);
-                       mono_tramp_info_register (sp_info, NULL);
+                       mono_aot_tramp_info_register (sp_info, NULL);
                }
                return code;
        }
@@ -5577,7 +5577,7 @@ mono_aot_get_unbox_trampoline (MonoMethod *method)
        }
 
        tinfo->code_size = *(guint32*)symbol_addr;
-       mono_tramp_info_register (tinfo, NULL);
+       mono_aot_tramp_info_register (tinfo, NULL);
 
        /* The caller expects an ftnptr */
        return mono_create_ftnptr (mono_domain_get (), code);
index d573c31ce04be54923e55f37bb708299940016df..bacfceedd7c6a6bd8971a536a914f222936059be 100644 (file)
@@ -474,8 +474,8 @@ register_trampoline_jit_info (MonoDomain *domain, MonoTrampInfo *info)
  * INFO can be NULL.
  * Frees INFO.
  */
-void
-mono_tramp_info_register (MonoTrampInfo *info, MonoDomain *domain)
+static void
+mono_tramp_info_register_internal (MonoTrampInfo *info, MonoDomain *domain, gboolean aot)
 {
        MonoTrampInfo *copy;
 
@@ -506,7 +506,8 @@ mono_tramp_info_register (MonoTrampInfo *info, MonoDomain *domain)
        mono_lldb_save_trampoline_info (info);
 
 #ifdef MONO_ARCH_HAVE_UNWIND_TABLE
-       mono_arch_unwindinfo_install_tramp_unwind_info (info->unwind_ops, info->code, info->code_size);
+       if (!aot)
+               mono_arch_unwindinfo_install_tramp_unwind_info (info->unwind_ops, info->code, info->code_size);
 #endif
 
        /* Only register trampolines that have unwind infos */
@@ -519,6 +520,18 @@ mono_tramp_info_register (MonoTrampInfo *info, MonoDomain *domain)
        mono_tramp_info_free (info);
 }
 
+void
+mono_tramp_info_register (MonoTrampInfo *info, MonoDomain *domain)
+{
+       mono_tramp_info_register_internal (info, domain, FALSE);
+}
+
+void
+mono_aot_tramp_info_register (MonoTrampInfo *info, MonoDomain *domain)
+{
+       mono_tramp_info_register_internal (info, domain, TRUE);
+}
+
 static void
 mono_tramp_info_cleanup (void)
 {
index e7fc859c250c3b22c299c1d6b94ace2ec2e3bb92..0191d1fc2cec6412c36136720bc3c5efe3e2c56a 100644 (file)
@@ -2632,6 +2632,7 @@ void              mono_emit_unwind_op (MonoCompile *cfg, int when,
                                                                           int val);
 MonoTrampInfo*    mono_tramp_info_create (const char *name, guint8 *code, guint32 code_size, MonoJumpInfo *ji, GSList *unwind_ops);
 void              mono_tramp_info_free (MonoTrampInfo *info);
+void              mono_aot_tramp_info_register (MonoTrampInfo *info, MonoDomain *domain);
 void              mono_tramp_info_register (MonoTrampInfo *info, MonoDomain *domain);
 int               mini_exception_id_by_name (const char *name);
 gboolean          mini_type_is_hfa (MonoType *t, int *out_nfields, int *out_esize) MONO_LLVM_INTERNAL;