X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmini%2Fimage-writer.c;h=2e4619301d1b6ca24b81da6be81759e9fbef874b;hb=fee5ece80556eb45d16da5f6c0fde991e5af1d40;hp=ab3bf8094a56e711648810e6ea8e7bfe3ea4c8dd;hpb=aef549e364e3d7b1c8959900a99852fec39bc3a2;p=mono.git diff --git a/mono/mini/image-writer.c b/mono/mini/image-writer.c index ab3bf8094a5..2e4619301d1 100644 --- a/mono/mini/image-writer.c +++ b/mono/mini/image-writer.c @@ -5,6 +5,7 @@ * Dietmar Maurer (dietmar@ximian.com) * Zoltan Varga (vargaz@gmail.com) * Paolo Molaro (lupus@ximian.com) + * Johan Lorensson (lateralusx.github@gmail.com) * * (C) 2002 Ximian, Inc. */ @@ -88,6 +89,8 @@ #if defined(TARGET_ASM_APPLE) #define AS_INT16_DIRECTIVE ".short" +#elif defined(TARGET_ASM_GAS) && defined(TARGET_WIN32) +#define AS_INT16_DIRECTIVE ".word" #elif defined(TARGET_ASM_GAS) #define AS_INT16_DIRECTIVE ".hword" #else @@ -1735,8 +1738,45 @@ const char *get_label (const char *s) return s; } +#ifdef TARGET_WIN32 +#define GLOBAL_SYMBOL_DEF_SCL 2 +#define LOCAL_SYMBOL_DEF_SCL 3 + +static gboolean +asm_writer_in_data_section (MonoImageWriter *acfg) +{ + gboolean in_data_section = FALSE; + const char *data_sections [] = {".data", ".bss", ".rdata"}; + + for (guchar i = 0; i < G_N_ELEMENTS (data_sections); ++i) { + if (strcmp (acfg->current_section, data_sections [i]) == 0) { + in_data_section = TRUE; + break; + } + } + + return in_data_section; +} + +static void +asm_writer_emit_symbol_type (MonoImageWriter *acfg, const char *name, gboolean func, gboolean global) +{ + asm_writer_emit_unset_mode (acfg); + + if (func) { + fprintf (acfg->fp, "\t.def %s; .scl %d; .type 32; .endef\n", name, (global == TRUE ? GLOBAL_SYMBOL_DEF_SCL : LOCAL_SYMBOL_DEF_SCL)); + } else { + if (!asm_writer_in_data_section (acfg)) + fprintf (acfg->fp, "\t.data\n"); + } + + return; +} + +#else + static void -asm_writer_emit_symbol_type (MonoImageWriter *acfg, const char *name, gboolean func) +asm_writer_emit_symbol_type (MonoImageWriter *acfg, const char *name, gboolean func, gboolean global) { const char *stype; @@ -1749,17 +1789,13 @@ asm_writer_emit_symbol_type (MonoImageWriter *acfg, const char *name, gboolean f #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 fprintf (acfg->fp, "\t.type %s,@%s\n", name, stype); #endif } +#endif /* TARGET_WIN32 */ static void asm_writer_emit_global (MonoImageWriter *acfg, const char *name, gboolean func) @@ -1768,7 +1804,7 @@ asm_writer_emit_global (MonoImageWriter *acfg, const char *name, gboolean func) fprintf (acfg->fp, "\t.globl %s\n", name); - asm_writer_emit_symbol_type (acfg, name, func); + asm_writer_emit_symbol_type (acfg, name, func, TRUE); } static void @@ -1780,7 +1816,7 @@ asm_writer_emit_local_symbol (MonoImageWriter *acfg, const char *name, const cha fprintf (acfg->fp, "\t.local %s\n", name); #endif - asm_writer_emit_symbol_type (acfg, name, func); + asm_writer_emit_symbol_type (acfg, name, func, FALSE); } static void