".data",
NULL, /* TLS is not supported on Mach-O */
".mod_init_func",
- NULL, /* are there destructors on mach-o? */
+ ".mod_term_func",
".cstring",
".section\t__IMPORT,__jump_table,symbol_stubs,self_modifying_code+pure_instructions,5",
".section\t__IMPORT,__pointers,non_lazy_symbol_pointers"
return;
case 16:
+ /* Beware: Mixed endian output! One little endian number emitted as
+ * three longs. Each long initializer is written in big endian. */
be_emit_irprintf(
- "\t.long\t0x%02x%02x%02x%02x0x%02x%02x%02x%02x0x%02x%02x%02x%02x0x%02x%02x%02x%02x",
- get_tarval_sub_bits(tv, 15), get_tarval_sub_bits(tv, 16),
- get_tarval_sub_bits(tv, 13), get_tarval_sub_bits(tv, 12),
- get_tarval_sub_bits(tv, 11), get_tarval_sub_bits(tv, 10),
- get_tarval_sub_bits(tv, 9), get_tarval_sub_bits(tv, 8),
+ "\t.long\t0x%02x%02x%02x%02x\n"
+ "\t.long\t0x%02x%02x%02x%02x\n"
+ "\t.long\t0x%02x%02x%02x%02x\n"
+ "\t.long\t0x%02x%02x%02x%02x",
+ get_tarval_sub_bits(tv, 3), get_tarval_sub_bits(tv, 2),
+ get_tarval_sub_bits(tv, 1), get_tarval_sub_bits(tv, 0),
get_tarval_sub_bits(tv, 7), get_tarval_sub_bits(tv, 6),
get_tarval_sub_bits(tv, 5), get_tarval_sub_bits(tv, 4),
- get_tarval_sub_bits(tv, 3), get_tarval_sub_bits(tv, 2),
- get_tarval_sub_bits(tv, 1), get_tarval_sub_bits(tv, 0)
+ get_tarval_sub_bits(tv, 11), get_tarval_sub_bits(tv, 10),
+ get_tarval_sub_bits(tv, 9), get_tarval_sub_bits(tv, 8),
+ get_tarval_sub_bits(tv, 15), get_tarval_sub_bits(tv, 14),
+ get_tarval_sub_bits(tv, 13), get_tarval_sub_bits(tv, 12)
);
return;
}
case 10:
case 12:
+ case 16: /* Note: .octa does not work on mac */
/* handled in arith */
break;
- case 16:
- be_emit_cstring("\t.octa\t");
- break;
-
default:
panic("Try to dump a type with %u bytes", (unsigned)size);
}
panic("invalid object file format");
}
+static void dump_indirect_symbol(const ir_entity *entity, be_gas_section_t section)
+{
+ /* we can only do PIC code on macho so far */
+ assert(be_gas_object_file_format == OBJECT_FILE_FORMAT_MACH_O);
+
+ be_emit_ident(get_entity_ld_ident(entity));
+ be_emit_cstring(":\n");
+ be_emit_write_line();
+ be_emit_cstring("\t.indirect_symbol ");
+ be_emit_ident(get_entity_ident(entity));
+ be_emit_char('\n');
+ be_emit_write_line();
+ if (section == GAS_SECTION_PIC_TRAMPOLINES) {
+ be_emit_cstring("\thlt ; hlt ; hlt ; hlt ; hlt\n");
+ be_emit_write_line();
+ } else {
+ assert(section == GAS_SECTION_PIC_SYMBOLS);
+ be_emit_cstring("\t.long 0\n");
+ be_emit_write_line();
+ }
+}
+
/**
* Dump a global entity.
*
be_gas_emit_switch_section(section);
+ if (section == GAS_SECTION_PIC_TRAMPOLINES
+ || section == GAS_SECTION_PIC_SYMBOLS) {
+ dump_indirect_symbol(ent, section);
+ return;
+ }
+
/* alignment */
if (alignment > 1) {
emit_align(alignment);
be_emit_ident(ld_ident);
be_emit_irprintf(", %u\n", get_type_size_bytes(type));
}
- be_emit_ident(ld_ident);
- be_emit_cstring(":\n");
- be_emit_write_line();
+
+ if (get_id_str(ld_ident)[0] != '\0') {
+ be_emit_ident(ld_ident);
+ be_emit_cstring(":\n");
+ be_emit_write_line();
+ }
if (ent->initializer != NULL) {
dump_initializer(env, ent);