Merge pull request #1857 from slluis/fix-assembly-resolver
[mono.git] / mono / mini / aot-compiler.c
index 2297d626186b3105687a319642fc0d3959d530e8..933ecfaf395cab7cbbaeced533c87631f4669cc7 100644 (file)
@@ -8510,11 +8510,6 @@ emit_file_info (MonoAotCompile *acfg)
                emit_pointer (acfg, NULL);
                emit_pointer (acfg, NULL);
        }
-       if (acfg->thumb_mixed) {
-               emit_pointer (acfg, "thumb_end");
-       } else {
-               emit_pointer (acfg, NULL);
-       }
        if (acfg->aot_opts.static_link) {
                emit_pointer (acfg, "globals");
        } else {
@@ -9351,8 +9346,14 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options)
                 * Emit all LLVM code into a separate assembly/object file and link with it
                 * normally.
                 */
-               if (!acfg->aot_opts.asm_only)
+               if (!acfg->aot_opts.asm_only) {
                        acfg->llvm_owriter = TRUE;
+               } else if (acfg->aot_opts.llvm_outfile) {
+                       int len = strlen (acfg->aot_opts.llvm_outfile);
+
+                       if (len >= 2 && acfg->aot_opts.llvm_outfile [len - 2] == '.' && acfg->aot_opts.llvm_outfile [len - 1] == 'o')
+                               acfg->llvm_owriter = TRUE;
+               }
        }
 
        if (mono_aot_mode_is_full (&acfg->aot_opts))
@@ -9382,6 +9383,9 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options)
 
        arch_init (acfg);
 
+       if (acfg->llvm && acfg->thumb_mixed)
+               acfg->flags |= MONO_AOT_FILE_FLAG_LLVM_THUMB;
+
        acfg->assembly_name_sym = g_strdup (acfg->image->assembly->aname.name);
        /* Get rid of characters which cannot occur in symbols */
        for (p = acfg->assembly_name_sym; *p; ++p) {
@@ -9479,6 +9483,10 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options)
                        }
                        g_assert (acfg->aot_opts.llvm_outfile);
                        acfg->llvm_sfile = g_strdup (acfg->aot_opts.llvm_outfile);
+                       if (acfg->llvm_owriter)
+                               acfg->llvm_ofile = g_strdup (acfg->aot_opts.llvm_outfile);
+                       else
+                               acfg->llvm_sfile = g_strdup (acfg->aot_opts.llvm_outfile);
                } else {
                        acfg->tmpbasename = g_strdup_printf ("%s", "temp");
                        acfg->tmpfname = g_strdup_printf ("%s.s", acfg->tmpbasename);
@@ -9571,21 +9579,6 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options)
        if (acfg->dwarf)
                mono_dwarf_writer_emit_base_info (acfg->dwarf, g_path_get_basename (acfg->image->name), mono_unwind_get_cie_program ());
 
-       if (acfg->thumb_mixed) {
-               char symbol [256];
-               /*
-                * This global symbol marks the end of THUMB code, and the beginning of ARM
-                * code generated by our JIT.
-                */
-               sprintf (symbol, "thumb_end");
-               emit_section_change (acfg, ".text", 0);
-               emit_alignment_code (acfg, 8);
-               emit_label (acfg, symbol);
-               emit_zero_bytes (acfg, 16);
-
-               fprintf (acfg->fp, ".arm\n");
-       }
-
        emit_code (acfg);
 
        emit_info (acfg);