fix bug where compound_graph_pathe were consider null
[libfirm] / ir / be / begnuas.c
index d3cf561..28dd243 100644 (file)
@@ -161,7 +161,9 @@ static void emit_section(be_gas_section_t section, const ir_entity *entity)
        be_emit_cstring(",\"");
        if (be_gas_object_file_format != OBJECT_FILE_FORMAT_COFF)
                be_emit_char('a');
-       if (base != GAS_SECTION_RODATA)
+       if (base == GAS_SECTION_TEXT)
+               be_emit_char('x');
+       if (base != GAS_SECTION_RODATA && base != GAS_SECTION_TEXT)
                be_emit_char('w');
        if (flags & GAS_SECTION_FLAG_TLS)
                be_emit_char('T');
@@ -333,6 +335,7 @@ static bool entity_is_null(const ir_entity *entity)
        } else if (entity_has_compound_ent_values(entity)) {
                /* I'm too lazy to implement this case as compound graph paths will be
                 * remove anyway in the future */
+               return false;
        }
        /* uninitialized, NULL is fine */
        return true;
@@ -572,14 +575,6 @@ static void emit_arith_tarval(tarval *tv, int bytes)
        panic("Can't dump a tarval with %d bytes", bytes);
 }
 
-/**
- * Return the label prefix for labeled blocks.
- */
-const char *be_gas_block_label_prefix(void)
-{
-       return ".LG";
-}
-
 /**
  * Return the label prefix for labeled instructions.
  */
@@ -670,10 +665,6 @@ static void do_emit_atomic_init(be_gas_decl_env_t *env, ir_node *init)
 
        case iro_SymConst:
                switch (get_SymConst_kind(init)) {
-               case symconst_addr_name:
-                       be_emit_ident(get_SymConst_name(init));
-                       break;
-
                case symconst_addr_ent:
                        ent = get_SymConst_entity(init);
                        be_gas_emit_entity(ent);
@@ -1373,7 +1364,7 @@ static void emit_indirect_symbol(const ir_entity *entity, be_gas_section_t secti
        /* 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_gas_emit_entity(entity);
        be_emit_cstring(":\n");
        be_emit_write_line();
        be_emit_cstring("\t.indirect_symbol ");
@@ -1390,21 +1381,37 @@ static void emit_indirect_symbol(const ir_entity *entity, be_gas_section_t secti
        }
 }
 
+char const *be_gas_get_private_prefix(void)
+{
+       return
+               be_gas_object_file_format == OBJECT_FILE_FORMAT_MACH_O ? "L" :
+               ".L";
+}
+
 void be_gas_emit_entity(const ir_entity *entity)
 {
        if (entity->type == firm_code_type) {
                ir_label_t label = get_entity_label(entity);
-               be_emit_string(be_gas_block_label_prefix());
-               be_emit_irprintf("%lu", label);
+               be_emit_irprintf("%s_%lu", be_gas_get_private_prefix(), label);
                return;
        }
 
        if (get_entity_visibility(entity) == ir_visibility_private) {
-               be_emit_cstring(".L");
+               be_emit_string(be_gas_get_private_prefix());
        }
        be_emit_ident(get_entity_ld_ident(entity));
 }
 
+void be_gas_emit_block_name(const ir_node *block)
+{
+       if (has_Block_entity(block)) {
+               ir_entity *entity = get_Block_entity(block);
+               be_gas_emit_entity(entity);
+       } else {
+               be_emit_irprintf("%s%ld", be_gas_get_private_prefix(), get_irn_node_nr(block));
+       }
+}
+
 /**
  * Dump a global entity.
  *
@@ -1499,7 +1506,7 @@ static void emit_global(be_gas_decl_env_t *env, const ir_entity *entity)
        if (entity_is_null(entity)) {
                be_emit_irprintf("\t.space %u\n", get_type_size_bytes(type));
                be_emit_write_line();
-       } else if(entity_has_compound_ent_values(entity)) {
+       } else if (entity_has_compound_ent_values(entity)) {
                emit_compound_graph_init(env, entity);
        } else {
                assert(entity->initializer != NULL);