Merge remote-tracking branch 'mfoliveira/ppc64el-v2'
[mono.git] / mono / mini / aot-compiler.c
index 2689b1e9e4fec1b359c6315ac2fc4d9cc04745e6..bc9c01f401fc9f688c25190250d77ad4a934f8cd 100644 (file)
 #define TV_GETTIME(tv) tv = mono_100ns_ticks ()
 #define TV_ELAPSED(start,end) (((end) - (start)) / 10)
 
-#ifdef TARGET_WIN32
-#define SHARED_EXT ".dll"
-#elif defined(__ppc__) && defined(TARGET_MACH)
-#define SHARED_EXT ".dylib"
-#elif defined(TARGET_MACH) && defined(TARGET_X86) && !defined(__native_client_codegen__)
-#define SHARED_EXT ".dylib"
-#elif defined(TARGET_MACH) && defined(TARGET_AMD64) && !defined(__native_client_codegen__)
-#define SHARED_EXT ".dylib"
-#else
-#define SHARED_EXT ".so"
-#endif
-
 #define ALIGN_TO(val,align) ((((guint64)val) + ((align) - 1)) & ~((align) - 1))
 #define ALIGN_PTR_TO(ptr,align) (gpointer)((((gssize)(ptr)) + (align - 1)) & (~(align - 1)))
 #define ROUND_DOWN(VALUE,SIZE) ((VALUE) & ~((SIZE) - 1))
@@ -4872,13 +4860,14 @@ get_debug_sym (MonoMethod *method, const char *prefix, GHashTable *cache)
        char *name1, *name2, *cached;
        int i, j, len, count;
 
+       name1 = mono_method_full_name (method, TRUE);
+
 #ifdef TARGET_MACH
        // This is so that we don't accidentally create a local symbol (which starts with 'L')
-       if (!prefix || !*prefix)
+       if ((!prefix || !*prefix) && name1 [0] == 'L')
                prefix = "_";
 #endif
 
-       name1 = mono_method_full_name (method, TRUE);
        len = strlen (name1);
        name2 = malloc (strlen (prefix) + len + 16);
        memcpy (name2, prefix, strlen (prefix));
@@ -5385,6 +5374,15 @@ emit_exception_debug_info (MonoAotCompile *acfg, MonoCompile *cfg)
                encode_value (table->num_holes, p, &p);
        }
 
+       if (jinfo->has_arch_eh_info) {
+               /*
+                * In AOT mode, the code length is calculated from the address of the previous method,
+                * which could include alignment padding, so calculating the start of the epilog as
+                * code_len - epilog_size is correct any more. Save the real code len as a workaround.
+                */
+               encode_value (jinfo->code_size, p, &p);
+       }
+
        /* Exception table */
        if (cfg->compile_llvm) {
                /*
@@ -7102,7 +7100,7 @@ emit_llvm_file (MonoAotCompile *acfg)
 
 
        tempbc = g_strdup_printf ("%s.bc", acfg->tmpbasename);
-       mono_llvm_emit_aot_module (tempbc, acfg->final_got_size);
+       mono_llvm_emit_aot_module (tempbc, g_path_get_basename (acfg->image->name), acfg->final_got_size);
        g_free (tempbc);
 
        /*
@@ -8640,7 +8638,7 @@ compile_asm (MonoAotCompile *acfg)
        if (acfg->aot_opts.outfile)
                outfile_name = g_strdup_printf ("%s", acfg->aot_opts.outfile);
        else
-               outfile_name = g_strdup_printf ("%s%s", acfg->image->name, SHARED_EXT);
+               outfile_name = g_strdup_printf ("%s%s", acfg->image->name, MONO_SOLIB_EXT);
 
        tmp_outfile_name = g_strdup_printf ("%s.tmp", outfile_name);
 
@@ -8660,7 +8658,7 @@ compile_asm (MonoAotCompile *acfg)
 
        g_free (command);
 
-       /*com = g_strdup_printf ("strip --strip-unneeded %s%s", acfg->image->name, SHARED_EXT);
+       /*com = g_strdup_printf ("strip --strip-unneeded %s%s", acfg->image->name, MONO_SOLIB_EXT);
        printf ("Stripping the binary: %s\n", com);
        system (com);
        g_free (com);*/
@@ -9011,7 +9009,7 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options)
                if (acfg->aot_opts.outfile)
                        outfile_name = g_strdup_printf ("%s", acfg->aot_opts.outfile);
                else
-                       outfile_name = g_strdup_printf ("%s%s", acfg->image->name, SHARED_EXT);
+                       outfile_name = g_strdup_printf ("%s%s", acfg->image->name, MONO_SOLIB_EXT);
 
                /* 
                 * Can't use g_file_open_tmp () as it will be deleted at exit, and