guint8 *data;
while (new_size <= new_offset)
new_size *= 2;
- data = g_malloc0 (new_size);
+ data = (guint8 *)g_malloc0 (new_size);
#ifdef __native_client_codegen__
/* for Native Client, fill empty space with HLT instruction */
/* instead of 00. */
}
}
-#ifdef __native_client_codegen__
-static void
-bin_writer_emit_nacl_call_alignment (MonoImageWriter *acfg) {
- int offset = acfg->cur_section->cur_offset;
- int padding = kNaClAlignment - (offset & kNaClAlignmentMask) - kNaClLengthOfCallImm;
- guint8 padc = '\x90';
-
- if (padding < 0) padding += kNaClAlignment;
-
- while (padding > 0) {
- bin_writer_emit_bytes(acfg, &padc, 1);
- padding -= 1;
- }
-}
-#endif /* __native_client_codegen__ */
-
static void
bin_writer_emit_pointer_unaligned (MonoImageWriter *acfg, const char *target)
{
create_reloc (MonoImageWriter *acfg, const char *end, const char* start, int offset)
{
BinReloc *reloc;
- reloc = mono_mempool_alloc0 (acfg->mempool, sizeof (BinReloc));
+ reloc = (BinReloc *)mono_mempool_alloc0 (acfg->mempool, sizeof (BinReloc));
reloc->val1 = mono_mempool_strdup (acfg->mempool, end);
if (strcmp (start, ".") == 0) {
reloc->val2_section = acfg->cur_section;
BinSection *section;
gsize value;
- lab = g_hash_table_lookup (acfg->labels, name);
+ lab = (BinLabel *)g_hash_table_lookup (acfg->labels, name);
if (!lab)
g_error ("Undefined label: '%s'.\n", name);
section = lab->section;
/*g_print ("sym name %s tabled to %d\n", symbol->name, symbols [i].st_name);*/
section = symbol->section;
symbols [i].st_shndx = section->parent? section->parent->shidx: section->shidx;
- lab = g_hash_table_lookup (acfg->labels, symbol->name);
+ lab = (BinLabel *)g_hash_table_lookup (acfg->labels, symbol->name);
offset = lab->offset;
if (section->parent) {
symbols [i].st_value = section->parent->virt_offset + section->cur_offset + offset;
}
if (symbol->end_label) {
- BinLabel *elab = g_hash_table_lookup (acfg->labels, symbol->end_label);
+ BinLabel *elab = (BinLabel *)g_hash_table_lookup (acfg->labels, symbol->end_label);
g_assert (elab);
symbols [i].st_size = elab->offset - lab->offset;
}
if (dynamic && !symbol->is_global)
continue;
section = symbol->section;
- lab = g_hash_table_lookup (acfg->labels, symbol->name);
+ lab = (BinLabel *)g_hash_table_lookup (acfg->labels, symbol->name);
offset = lab->offset;
if (section->parent) {
symbols [i].st_value = sheaders [section->parent->shidx].sh_addr + section->cur_offset + offset;
if (!acfg->fp) {
acfg->out_buf_size = file_offset + sizeof (secth);
- acfg->out_buf = g_malloc (acfg->out_buf_size);
+ acfg->out_buf = (guint8 *)g_malloc (acfg->out_buf_size);
}
bin_writer_fwrite (acfg, &header, sizeof (header), 1);
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
}
}
#endif
-#ifdef __native_client_codegen__
-static void
-asm_writer_emit_nacl_call_alignment (MonoImageWriter *acfg) {
- int padding = kNaClAlignment - kNaClLengthOfCallImm;
- guint8 padc = '\x90';
-
- fprintf (acfg->fp, "\n\t.align %d", kNaClAlignment);
- while (padding > 0) {
- fprintf (acfg->fp, "\n\t.byte %d", padc);
- padding -= 1;
- }
-}
-#endif /* __native_client_codegen__ */
-
static void
asm_writer_emit_pointer_unaligned (MonoImageWriter *acfg, const char *target)
{
#endif
}
-#ifdef __native_client_codegen__
-void
-mono_img_writer_emit_nacl_call_alignment (MonoImageWriter *acfg) {
-#ifdef USE_BIN_WRITER
- if (acfg->use_bin_writer)
- bin_writer_emit_nacl_call_alignment (acfg);
- else
- asm_writer_emit_nacl_call_alignment (acfg);
-#else
- g_assert_not_reached();
-#endif
-}
-#endif /* __native_client_codegen__ */
-
void
mono_img_writer_emit_pointer_unaligned (MonoImageWriter *acfg, const char *target)
{