From: Matthias Braun Date: Fri, 5 Feb 2010 18:53:55 +0000 (+0000) Subject: bring back PIC support X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=abe9eb6dc510dc9e8ff347d9de475ec4d9c9f84f;p=libfirm bring back PIC support [r27057] --- diff --git a/ir/be/begnuas.c b/ir/be/begnuas.c index b4bffedaf..097d6938b 100644 --- a/ir/be/begnuas.c +++ b/ir/be/begnuas.c @@ -1186,6 +1186,25 @@ static void emit_common(const ir_entity *ent) 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_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. * @@ -1228,6 +1247,12 @@ static void dump_global(be_gas_decl_env_t *env, const ir_entity *ent) 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);