+/**
+ * Mangles an entity linker (ld) name for win32 usage.
+ *
+ * @param ent the entity to be mangled
+ * @param decl_modifiers the set of modifiers for this entity
+ */
+static ir_ident_ptr decorate_win32(ir_entity_ptr ent, decl_modifiers_t decl_modifiers) {
+ ir_ident_ptr id;
+
+ if (is_Method_type(get_entity_type(ent)))
+ id = decorate_win32_c_fkt(ent, get_entity_ident(ent));
+ else {
+ /* always add an underscore in win32 */
+ id = mangle(new_id_from_chars("_", 1), get_entity_ident(ent));
+ }
+
+ if (decl_modifiers & DM_DLLIMPORT) {
+ /* add prefix for imported symbols */
+ id = mangle(new_id_from_chars("__imp_", 6), id);
+ }
+ return id;
+}
+
+/**
+ * Mangles an entity linker (ld) name from a declaration.
+ *
+ * @param ent the entity to be mangled
+ * @param declaration the declaration
+ */
+static void mangle_ent_from_decl(ir_entity *ent, declaration_t *declaration)
+{
+ ident *id;
+
+ if (firm_opt.os_support == OS_SUPPORT_MINGW)
+ id = decorate_win32(ent, declaration->decl_modifiers);
+ else
+ id = get_entity_ident(ent);
+
+ set_entity_ld_ident(ent, id);
+}
+