summaryrefslogtreecommitdiffhomepage
path: root/ir/be/begnuas.c
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2015-05-25 23:50:27 +0200
committerMatthias Braun <matze@braunis.de>2015-05-26 00:46:34 +0200
commitd382a20a5eeadef2236ef168916cf0ae989232df (patch)
tree624d1b363161ff0a68b2140a8f8151144120421a /ir/be/begnuas.c
parentd09c3a536baefaf4d0538d32fb5d7af09ee5ec7f (diff)
begnuas: Introduce emit_symbol_directive
Diffstat (limited to 'ir/be/begnuas.c')
-rw-r--r--ir/be/begnuas.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/ir/be/begnuas.c b/ir/be/begnuas.c
index b6dfb9d..b9392bc 100644
--- a/ir/be/begnuas.c
+++ b/ir/be/begnuas.c
@@ -447,16 +447,26 @@ static be_gas_section_t determine_section(be_main_env_t const *const main_env, i
panic("couldn't determine section for %+F", entity);
}
+static void emit_symbol_directive(const char *directive,
+ const ir_entity *entity)
+{
+ be_emit_char('\t');
+ be_emit_string(directive);
+ be_emit_char(' ');
+ be_gas_emit_entity(entity);
+ be_emit_char('\n');
+ be_emit_write_line();
+}
+
static void emit_weak(const ir_entity *entity)
{
+ const char *directive;
if (be_gas_object_file_format == OBJECT_FILE_FORMAT_MACH_O) {
- be_emit_cstring("\t.weak_reference ");
+ directive = ".weak_reference";
} else {
- be_emit_cstring("\t.weak ");
+ directive = ".weak";
}
- be_gas_emit_entity(entity);
- be_emit_char('\n');
- be_emit_write_line();
+ emit_symbol_directive(directive, entity);
}
static void emit_visibility(const ir_entity *entity)
@@ -468,19 +478,13 @@ static void emit_visibility(const ir_entity *entity)
/* Note: .weak seems to imply .globl so no need to output .globl */
} else if (get_entity_visibility(entity) == ir_visibility_external
&& entity_has_definition(entity)) {
- be_emit_cstring("\t.globl ");
- be_gas_emit_entity(entity);
- be_emit_char('\n');
- be_emit_write_line();
+ emit_symbol_directive(".globl", entity);
}
if (be_gas_object_file_format == OBJECT_FILE_FORMAT_MACH_O
&& (linkage & IR_LINKAGE_HIDDEN_USER)
&& get_entity_ld_name(entity)[0] != '\0') {
- be_emit_cstring("\t.no_dead_strip ");
- be_gas_emit_entity(entity);
- be_emit_char('\n');
- be_emit_write_line();
+ emit_symbol_directive(".no_dead_strip", entity);
}
}
@@ -1158,10 +1162,7 @@ static void emit_local_common(const ir_entity *entity)
be_emit_write_line();
return;
case OBJECT_FILE_FORMAT_ELF:
- be_emit_cstring("\t.local ");
- be_gas_emit_entity(entity);
- be_emit_cstring("\n");
- be_emit_write_line();
+ emit_symbol_directive(".local", entity);
be_emit_cstring("\t.comm ");
be_gas_emit_entity(entity);
be_emit_irprintf(",%u,%u\n", size, alignment);