Update libfirm submodule reference
[cparser] / driver / firm_machine.c
index ca6a5fe..7c016fb 100644 (file)
@@ -14,6 +14,17 @@ static void set_be_option(const char *arg)
        assert(res);
 }
 
+static ir_entity *underscore_compilerlib_entity_creator(ident *id, ir_type *mt)
+{
+       ir_entity *entity = new_entity(get_glob_type(), id, mt);
+       ident     *ldname = id_mangle3("_", id, "");
+
+       set_entity_visibility(entity, ir_visibility_external);
+       set_entity_ld_ident(entity, ldname);
+
+       return entity;
+}
+
 /**
  * Initialize firm codegeneration for a specific operating system.
  * The argument is the operating system part of a target-triple
@@ -27,8 +38,10 @@ static bool setup_os_support(const char *os)
                set_be_option("ia32-gasmode=macho");
                set_be_option("ia32-stackalign=4");
                set_be_option("pic=true");
+               set_compilerlib_entity_creator(underscore_compilerlib_entity_creator);
        } else if (strstr(os, "mingw") != NULL || streq(os, "win32")) {
                set_be_option("ia32-gasmode=mingw");
+               set_compilerlib_entity_creator(underscore_compilerlib_entity_creator);
        } else {
                return false;
        }
@@ -119,7 +132,7 @@ machine_triple_t *firm_parse_machine_triple(const char *triple_string)
 
        machine_triple_t *triple = XMALLOCZ(machine_triple_t);
 
-       size_t cpu_type_len = manufacturer-cpu+1;
+       size_t cpu_type_len = manufacturer-cpu;
        triple->cpu_type = XMALLOCN(char, cpu_type_len);
        memcpy(triple->cpu_type, cpu, cpu_type_len-1);
        triple->cpu_type[cpu_type_len-1] = '\0';
@@ -130,7 +143,7 @@ machine_triple_t *firm_parse_machine_triple(const char *triple_string)
                triple->manufacturer = xstrdup("unknown");
                os = manufacturer;
        } else {
-               size_t manufacturer_len = os-manufacturer+1;
+               size_t manufacturer_len = os-manufacturer;
                triple->manufacturer = XMALLOCN(char, manufacturer_len);
                memcpy(triple->manufacturer, manufacturer, manufacturer_len-1);
                triple->manufacturer[manufacturer_len-1] = '\0';