Fix mono_patch_info_equal () for MONO_PATCH_INFO_GSHAREDVT_CALL.
[mono.git] / mono / mini / aot-compiler.c
index fd87cdda4eca878774b8c0af1ffc53235dad0118..853327fe79f1c43c0a694e9e8dbc706003ad17be 100644 (file)
@@ -222,9 +222,7 @@ typedef struct MonoAotCompile {
        gboolean thumb_mixed, need_no_dead_strip, need_pt_gnu_stack;
        GHashTable *ginst_hash;
        gboolean global_symbols;
-#ifdef MONOTOUCH
        gboolean direct_method_addresses;
-#endif
 } MonoAotCompile;
 
 typedef struct {
@@ -2804,6 +2802,8 @@ get_plt_entry (MonoAotCompile *acfg, MonoJumpInfo *patch_info)
 
                new_ji = mono_patch_info_dup_mp (acfg->mempool, patch_info);
 
+               // g_assert (mono_patch_info_equal (patch_info, new_ji));
+
                res = mono_mempool_alloc0 (acfg->mempool, sizeof (MonoPltEntry));
                res->plt_offset = acfg->plt_offset;
                res->ji = new_ji;
@@ -4278,6 +4278,12 @@ get_debug_sym (MonoMethod *method, const char *prefix, GHashTable *cache)
        char *name1, *name2, *cached;
        int i, j, len, count;
 
+#ifdef TARGET_MACH
+       // This is so that we don't accidentally create a local symbol (which starts with 'L')
+       if (!prefix || !*prefix)
+               prefix = "_";
+#endif
+
        name1 = mono_method_full_name (method, TRUE);
        len = strlen (name1);
        name2 = malloc (strlen (prefix) + len + 16);
@@ -4527,6 +4533,10 @@ encode_patch (MonoAotCompile *acfg, MonoJumpInfo *patch_info, guint8 *buf, guint
        case MONO_PATCH_INFO_SIGNATURE:
                encode_signature (acfg, (MonoMethodSignature*)patch_info->data.target, p, &p);
                break;
+       case MONO_PATCH_INFO_GSHAREDVT_CALL:
+               encode_signature (acfg, (MonoMethodSignature*)patch_info->data.gsharedvt->sig, p, &p);
+               encode_method_ref (acfg, patch_info->data.gsharedvt->method, p, &p);
+               break;
        default:
                g_warning ("unable to handle jump info %d", patch_info->type);
                g_assert_not_reached ();
@@ -5395,11 +5405,13 @@ emit_trampolines (MonoAotCompile *acfg)
 
 #ifdef MONO_ARCH_GSHAREDVT_SUPPORTED
                mono_arch_get_gsharedvt_trampoline (&info, TRUE);
-               emit_trampoline_full (acfg, acfg->got_offset, info, TRUE);
+               if (info) {
+                       emit_trampoline_full (acfg, acfg->got_offset, info, TRUE);
 
-               /* Create a separate out trampoline for more information in stack traces */
-               info->name = g_strdup ("gsharedvt_out_trampoline");
-               emit_trampoline_full (acfg, acfg->got_offset, info, TRUE);
+                       /* Create a separate out trampoline for more information in stack traces */
+                       info->name = g_strdup ("gsharedvt_out_trampoline");
+                       emit_trampoline_full (acfg, acfg->got_offset, info, TRUE);
+               }
 #endif
 
 #if defined(MONO_ARCH_HAVE_GET_TRAMPOLINES)
@@ -6627,7 +6639,10 @@ emit_code (MonoAotCompile *acfg)
                        sprintf (symbol, "ut_%d", index);
 
                        emit_int32 (acfg, index);
-                       emit_symbol_diff (acfg, symbol, end_symbol, 0);
+                       if (acfg->direct_method_addresses)
+                               emit_pointer (acfg, symbol);
+                       else
+                               emit_symbol_diff (acfg, symbol, end_symbol, 0);
                        /* Make sure the table is sorted by index */
                        g_assert (index > prev_index);
                        prev_index = index;