/* output the import and delayed import tables of a Win32 module */ void output_imports( DLLSPEC *spec ) { output_immediate_imports(); output_delayed_imports( spec ); output_immediate_import_thunks(); output_delayed_import_thunks( spec ); output_external_link_imports( spec ); if (nb_imports || ext_link_imports.count || has_stubs(spec) || has_relays(spec)) output_get_pc_thunk(); }
/******************************************************************* * output_exports * * Output the export table for a Win32 module. */ void output_exports( DLLSPEC *spec ) { int i, fwd_size = 0; int nr_exports = spec->base <= spec->limit ? spec->limit - spec->base + 1 : 0; if (!nr_exports) return; output( "\n/* export table */\n\n" ); output( "\t.data\n" ); output( "\t.align %d\n", get_alignment(4) ); output( ".L__wine_spec_exports:\n" ); /* export directory header */ output( "\t.long 0\n" ); /* Characteristics */ output( "\t.long 0\n" ); /* TimeDateStamp */ output( "\t.long 0\n" ); /* MajorVersion/MinorVersion */ output( "\t.long .L__wine_spec_exp_names-.L__wine_spec_rva_base\n" ); /* Name */ output( "\t.long %u\n", spec->base ); /* Base */ output( "\t.long %u\n", nr_exports ); /* NumberOfFunctions */ output( "\t.long %u\n", spec->nb_names ); /* NumberOfNames */ output( "\t.long .L__wine_spec_exports_funcs-.L__wine_spec_rva_base\n" ); /* AddressOfFunctions */ if (spec->nb_names) { output( "\t.long .L__wine_spec_exp_name_ptrs-.L__wine_spec_rva_base\n" ); /* AddressOfNames */ output( "\t.long .L__wine_spec_exp_ordinals-.L__wine_spec_rva_base\n" ); /* AddressOfNameOrdinals */ } else { output( "\t.long 0\n" ); /* AddressOfNames */ output( "\t.long 0\n" ); /* AddressOfNameOrdinals */ } /* output the function pointers */ output( "\n.L__wine_spec_exports_funcs:\n" ); for (i = spec->base; i <= spec->limit; i++) { ORDDEF *odp = spec->ordinals[i]; if (!odp) output( "\t%s 0\n", get_asm_ptr_keyword() ); else switch(odp->type) { case TYPE_EXTERN: case TYPE_STDCALL: case TYPE_VARARGS: case TYPE_CDECL: case TYPE_THISCALL: if (odp->flags & FLAG_FORWARD) { output( "\t%s .L__wine_spec_forwards+%u\n", get_asm_ptr_keyword(), fwd_size ); fwd_size += strlen(odp->link_name) + 1; } else if (odp->flags & FLAG_EXT_LINK) { output( "\t%s %s_%s\n", get_asm_ptr_keyword(), asm_name("__wine_spec_ext_link"), odp->link_name ); } else { output( "\t%s %s\n", get_asm_ptr_keyword(), asm_name(odp->link_name) ); } break; case TYPE_STUB: output( "\t%s %s\n", get_asm_ptr_keyword(), asm_name( get_stub_name( odp, spec )) ); break; default: assert(0); } } if (spec->nb_names) { /* output the function name pointers */ int namepos = strlen(spec->file_name) + 1; output( "\n.L__wine_spec_exp_name_ptrs:\n" ); for (i = 0; i < spec->nb_names; i++) { output( "\t.long .L__wine_spec_exp_names+%u-.L__wine_spec_rva_base\n", namepos ); namepos += strlen(spec->names[i]->name) + 1; } /* output the function ordinals */ output( "\n.L__wine_spec_exp_ordinals:\n" ); for (i = 0; i < spec->nb_names; i++) { output( "\t%s %d\n", get_asm_short_keyword(), spec->names[i]->ordinal - spec->base ); } if (spec->nb_names % 2) { output( "\t%s 0\n", get_asm_short_keyword() ); } } /* output the export name strings */ output( "\n.L__wine_spec_exp_names:\n" ); output( "\t%s \"%s\"\n", get_asm_string_keyword(), spec->file_name ); for (i = 0; i < spec->nb_names; i++) output( "\t%s \"%s\"\n", get_asm_string_keyword(), spec->names[i]->name ); /* output forward strings */ if (fwd_size) { output( "\n.L__wine_spec_forwards:\n" ); for (i = spec->base; i <= spec->limit; i++) { ORDDEF *odp = spec->ordinals[i]; if (odp && (odp->flags & FLAG_FORWARD)) output( "\t%s \"%s\"\n", get_asm_string_keyword(), odp->link_name ); } } output( "\t.align %d\n", get_alignment(get_ptr_size()) ); output( ".L__wine_spec_exports_end:\n" ); /* output relays */ if (!has_relays( spec )) { output( "\t%s 0\n", get_asm_ptr_keyword() ); return; } output( ".L__wine_spec_relay_descr:\n" ); output( "\t%s 0xdeb90001\n", get_asm_ptr_keyword() ); /* magic */ output( "\t%s 0,0\n", get_asm_ptr_keyword() ); /* relay funcs */ output( "\t%s 0\n", get_asm_ptr_keyword() ); /* private data */ output( "\t%s __wine_spec_relay_entry_points\n", get_asm_ptr_keyword() ); output( "\t%s .L__wine_spec_relay_entry_point_offsets\n", get_asm_ptr_keyword() ); output( "\t%s .L__wine_spec_relay_arg_types\n", get_asm_ptr_keyword() ); output_relay_debug( spec ); }