fix bug where compound_graph_pathe were consider null
[libfirm] / ir / be / begnuas.c
index a259ff5..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;
@@ -662,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);
@@ -1382,26 +1381,23 @@ static void emit_indirect_symbol(const ir_entity *entity, be_gas_section_t secti
        }
 }
 
-static void emit_private_prefix(void)
+char const *be_gas_get_private_prefix(void)
 {
-       if (be_gas_object_file_format == OBJECT_FILE_FORMAT_MACH_O) {
-               be_emit_char('L');
-       } else {
-               be_emit_cstring(".L");
-       }
+       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);
-               emit_private_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) {
-               emit_private_prefix();
+               be_emit_string(be_gas_get_private_prefix());
        }
        be_emit_ident(get_entity_ld_ident(entity));
 }
@@ -1412,8 +1408,7 @@ void be_gas_emit_block_name(const ir_node *block)
                ir_entity *entity = get_Block_entity(block);
                be_gas_emit_entity(entity);
        } else {
-               emit_private_prefix();
-               be_emit_irprintf("%ld", get_irn_node_nr(block));
+               be_emit_irprintf("%s%ld", be_gas_get_private_prefix(), get_irn_node_nr(block));
        }
 }
 
@@ -1511,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);