AOT: Add option to emit global symbols for methods. Fixes #2471.
authorRolf Bjarne Kvinge <rolf@xamarin.com>
Thu, 15 Dec 2011 22:59:56 +0000 (23:59 +0100)
committerRodrigo Kumpera <kumpera@gmail.com>
Thu, 15 Nov 2012 20:16:52 +0000 (15:16 -0500)
The logic here is that we emit the debug name for a method as the global
symbol, not the generated name we otherwise use, and we don't emit a debug
symbol. The issue is that if we have both a global debug symbol and a global
(generated) method name, which one will show up in stack traces is undefined.

This is a temporary patch until it has been reviewed by the runtime
people (it's only on mobile-master for now).

mono/mini/aot-compiler.c

index 93805edadc79d42b3d76e830630023aeaaed1371..51325ebc6f799097fdba2a01fd581950747d8b43 100644 (file)
@@ -217,6 +217,7 @@ typedef struct MonoAotCompile {
        GHashTable *plt_entry_debug_sym_cache;
        gboolean thumb_mixed, need_no_dead_strip, need_pt_gnu_stack;
        GHashTable *ginst_hash;
+       gboolean global_symbols;
 #ifdef MONOTOUCH
        gboolean direct_method_addresses;
 #endif
@@ -615,6 +616,7 @@ arch_init (MonoAotCompile *acfg)
 
 #ifdef MONOTOUCH
        acfg->direct_method_addresses = TRUE;
+       acfg->global_symbols = TRUE;
 #endif
 }
 
@@ -3993,9 +3995,13 @@ emit_method_code (MonoAotCompile *acfg, MonoCompile *cfg)
        /* Make the labels local */
        emit_section_change (acfg, ".text", 0);
        emit_alignment (acfg, func_alignment);
+       
+       if (acfg->global_symbols && acfg->need_no_dead_strip)
+               fprintf (acfg->fp, "    .no_dead_strip %s\n", cfg->asm_symbol);
+       
        emit_label (acfg, cfg->asm_symbol);
 
-       if (acfg->aot_opts.write_symbols) {
+       if (acfg->aot_opts.write_symbols && !acfg->global_symbols) {
                /* 
                 * Write a C style symbol for every method, this has two uses:
                 * - it works on platforms where the dwarf debugging info is not
@@ -7750,6 +7756,8 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options)
 
                        if (COMPILE_LLVM (cfg))
                                cfg->asm_symbol = g_strdup_printf ("%s%s", acfg->llvm_label_prefix, cfg->llvm_method_name);
+                       else if (acfg->global_symbols)
+                               cfg->asm_symbol = get_debug_sym (cfg->method, "", acfg->method_label_hash);
                        else
                                cfg->asm_symbol = g_strdup_printf ("%s%sm_%x", acfg->temp_prefix, acfg->llvm_label_prefix, method_index);
                }