GPtrArray *patches;
MonoJumpInfo *patch_info;
MonoDebugSourceLocation **locs = NULL;
- gboolean skip;
+ gboolean skip, prologue_end = FALSE;
#ifdef MONO_ARCH_AOT_SUPPORTED
gboolean direct_call, external_call;
guint32 got_slot;
if (locs && locs [i]) {
MonoDebugSourceLocation *loc = locs [i];
int findex;
+ const char *options;
findex = get_file_index (acfg, loc->source_file);
emit_unset_mode (acfg);
- fprintf (acfg->fp, ".loc %d %d 0\n", findex, loc->row);
+ if (!prologue_end)
+ options = " prologue_end";
+ else
+ options = "";
+ prologue_end = TRUE;
+ fprintf (acfg->fp, ".loc %d %d 0%s\n", findex, loc->row, options);
mono_debug_symfile_free_location (loc);
}
return clean;
}
+ // Duplicate a char range and add it to a ptrarray, but only if it is nonempty
+ static void
+ ptr_array_add_range_if_nonempty(GPtrArray *args, gchar const *start, gchar const *end)
+ {
+ ptrdiff_t len = end-start;
+ if (len > 0)
+ g_ptr_array_add (args, g_strndup (start, len));
+ }
+
static GPtrArray *
mono_aot_split_options (const char *aot_options)
{
next:
aot_options++;
+ restart:
// If the next character is end of string, then process the last option.
if (*(aot_options) == '\0') {
end_of_string = TRUE;
continue;
new_opt:
- g_ptr_array_add (args, g_strndup (opt_start, aot_options - opt_start));
+ ptr_array_add_range_if_nonempty (args, opt_start, aot_options);
opt_start = ++aot_options;
if (end_of_string)
break;
- goto next;
+ goto restart; // Check for null and continue loop
}
return args;
#define AS_OPTIONS "--64"
#elif defined(TARGET_POWERPC64)
#define AS_OPTIONS "-a64 -mppc64"
- #define LD_OPTIONS "-m elf64ppc"
#elif defined(sparc) && SIZEOF_VOID_P == 8
#define AS_OPTIONS "-xarch=v9"
#elif defined(TARGET_X86) && defined(TARGET_MACH) && !defined(__native_client_codegen__)
#define AS_NAME "as"
#endif
- #ifndef LD_OPTIONS
- #define LD_OPTIONS ""
- #endif
-
#if defined(sparc)
- #define LD_NAME "ld -shared -G"
+ #define LD_NAME "ld"
+ #define LD_OPTIONS "-shared -G"
#elif defined(__ppc__) && defined(TARGET_MACH)
- #define LD_NAME "gcc -dynamiclib"
+ #define LD_NAME "gcc"
+ #define LD_OPTIONS "-dynamiclib"
#elif defined(TARGET_AMD64) && defined(TARGET_MACH)
- #define LD_NAME "clang --shared"
+ #define LD_NAME "clang"
+ #define LD_OPTIONS "--shared"
#elif defined(TARGET_WIN32) && !defined(TARGET_ANDROID)
- #define LD_NAME "gcc -shared --dll"
+ #define LD_NAME "gcc"
+ #define LD_OPTIONS "-shared"
#elif defined(TARGET_X86) && defined(TARGET_MACH) && !defined(__native_client_codegen__)
- #define LD_NAME "clang -m32 -dynamiclib"
+ #define LD_NAME "clang"
+ #define LD_OPTIONS "-m32 -dynamiclib"
#elif defined(TARGET_ARM) && !defined(TARGET_ANDROID)
- #define LD_NAME "gcc --shared"
+ #define LD_NAME "gcc"
+ #define LD_OPTIONS "--shared"
+ #elif defined(TARGET_POWERPC64)
+ #define LD_OPTIONS "-m elf64ppc"
+ #endif
+
+ #ifndef LD_OPTIONS
+ #define LD_OPTIONS ""
#endif
if (acfg->aot_opts.asm_only) {
ld_flags = g_strdup_printf ("%s %s", ld_flags, "-lstdc++");
#ifdef LD_NAME
- command = g_strdup_printf ("%s -o %s %s %s %s", LD_NAME,
+ command = g_strdup_printf ("%s%s %s -o %s %s %s %s", tool_prefix, LD_NAME, LD_OPTIONS,
wrap_path (tmp_outfile_name), wrap_path (llvm_ofile),
wrap_path (g_strdup_printf ("%s.o", acfg->tmpfname)), ld_flags);
#else
+ // Default (linux)
command = g_strdup_printf ("\"%sld\" %s -shared -o %s %s %s %s", tool_prefix, LD_OPTIONS,
wrap_path (tmp_outfile_name), wrap_path (llvm_ofile),
wrap_path (g_strdup_printf ("%s.o", acfg->tmpfname)), ld_flags);
}
}
- if (acfg->aot_opts.dwarf_debug && acfg->aot_opts.asm_only && acfg->aot_opts.gnu_asm) {
+ if (acfg->aot_opts.dwarf_debug && acfg->aot_opts.gnu_asm) {
/*
* CLANG supports GAS .file/.loc directives, so emit line number information this way
- * FIXME: CLANG only emits line number info for .loc directives followed by assembly, not
- * .byte directives.
*/
- //acfg->gas_line_numbers = TRUE;
+ acfg->gas_line_numbers = TRUE;
}
if ((!acfg->aot_opts.nodebug || acfg->aot_opts.dwarf_debug) && acfg->has_jitted_code) {
aot_printerrf (acfg, "The dwarf AOT option requires the --debug option.\n");
return 1;
}
- acfg->dwarf = mono_dwarf_writer_create (acfg->w, NULL, 0, FALSE, !acfg->gas_line_numbers);
+ acfg->dwarf = mono_dwarf_writer_create (acfg->w, NULL, 0, !acfg->gas_line_numbers);
}
if (acfg->w)
static void
asm_writer_emit_start (MonoImageWriter *acfg)
{
+#if defined(TARGET_ASM_APPLE)
+ fprintf (acfg->fp, ".subsections_via_symbols\n");
+#endif
}
static int
stype = "object";
asm_writer_emit_unset_mode (acfg);
+
#if defined(TARGET_ASM_APPLE)
+ #elif defined(TARGET_WIN32)
+ if (func)
+ fprintf (acfg->fp, "\t.def %s; .scl 2; .type 32; .endef\n", name);
+ else
+ fprintf (acfg->fp, "\t.data\n");
#elif defined(TARGET_ARM)
fprintf (acfg->fp, "\t.type %s,#%s\n", name, stype);
#else
{
asm_writer_emit_unset_mode (acfg);
- #ifndef TARGET_ASM_APPLE
+ #if !defined(TARGET_ASM_APPLE) && !defined(TARGET_WIN32)
fprintf (acfg->fp, "\t.local %s\n", name);
#endif
{
asm_writer_emit_unset_mode (acfg);
- #ifndef TARGET_ASM_APPLE
+
+ #if !defined(TARGET_ASM_APPLE) && !defined(TARGET_WIN32)
fprintf (acfg->fp, "\t.size %s,%s-%s\n", name, end_label, name);
#endif
}