+static void emit_section_macho(be_gas_section_t section)
+{
+ be_gas_section_t base = section & GAS_SECTION_TYPE_MASK;
+ be_gas_section_t flags = section & ~GAS_SECTION_TYPE_MASK;
+ const char *name;
+
+ if (current_section == section)
+ return;
+ current_section = section;
+
+ /* shortforms */
+ if (flags == 0) {
+ switch (base) {
+ case GAS_SECTION_TEXT: name = "text"; break;
+ case GAS_SECTION_DATA: name = "data"; break;
+ case GAS_SECTION_RODATA: name = "const"; break;
+ case GAS_SECTION_BSS: name = "data"; break;
+ case GAS_SECTION_CONSTRUCTORS: name = "mod_init_func"; break;
+ case GAS_SECTION_DESTRUCTORS: name = "mod_term_func"; break;
+ case GAS_SECTION_PIC_TRAMPOLINES: name = "section\t__IMPORT,__jump_table,symbol_stubs,self_modifying_code+pure_instructions,5"; break;
+ case GAS_SECTION_PIC_SYMBOLS: name = "section\t__IMPORT,__pointers,non_lazy_symbol_pointers"; break;
+ case GAS_SECTION_CSTRING: name = "cstring"; break;
+ default: panic("unsupported scetion type 0x%X", section);
+ }
+ be_emit_irprintf("\t.%s\n", name);
+ be_emit_write_line();
+ } else if (flags & GAS_SECTION_FLAG_COMDAT) {
+ switch (base) {
+ case GAS_SECTION_TEXT: name = "section __TEXT,__textcoal_nt,coalesced,pure_instructions"; break;
+ case GAS_SECTION_BSS:
+ case GAS_SECTION_DATA: name = "section __DATA,__datacoal_nt,coalesced"; break;
+ case GAS_SECTION_RODATA: name = "section __TEXT,__const_coal,coalesced"; break;
+ case GAS_SECTION_CSTRING: name = "section __TEXT,__const_coal,coalesced"; break;
+ default: panic("unsupported scetion type 0x%X", section);
+ }
+ } else {
+ panic("unsupported section type 0x%X\n", section);
+ }
+}
+
+static void emit_section_sparc(be_gas_section_t section, const ir_entity *entity)
+{
+ be_gas_section_t base = section & GAS_SECTION_TYPE_MASK;
+ be_gas_section_t flags = section & ~GAS_SECTION_TYPE_MASK;
+ static const char *const basename[] = {
+ "text", "data", "rodata", "bss", "ctors", "dtors"
+ };
+
+ if (current_section == section && !(section & GAS_SECTION_FLAG_COMDAT))
+ return;
+ current_section = section;
+
+ be_emit_cstring("\t.section\t\".");
+
+ /* Part1: section-name */
+ if (flags & GAS_SECTION_FLAG_TLS)
+ be_emit_char('t');
+ assert(base < (be_gas_section_t)ARRAY_SIZE(basename));
+ be_emit_string(basename[base]);
+
+ if (flags & GAS_SECTION_FLAG_COMDAT) {
+ be_emit_char('.');
+ be_gas_emit_entity(entity);
+ }
+ be_emit_char('"');
+
+ /* for the simple sections we're done here */
+ if (flags == 0)
+ goto end;
+
+ be_emit_cstring(",#alloc");
+
+ switch (base) {
+ case GAS_SECTION_TEXT: be_emit_cstring(",#execinstr"); break;
+ case GAS_SECTION_DATA:
+ case GAS_SECTION_BSS: be_emit_cstring(",#write"); break;
+ default:
+ /* nothing */
+ break;
+ }
+ if (flags & GAS_SECTION_FLAG_TLS) {
+ be_emit_cstring(",#tls");
+ }
+
+end:
+ be_emit_char('\n');
+ be_emit_write_line();
+}
+