libwine: Added magic handling of dll path when running in build dir.
[wine/wine-kai.git] / tools / winebuild / import.c
blob43956e8af39659d9667eb7fcaed53f5df7b57782
1 /*
2 * DLL imports support
4 * Copyright 2000, 2004 Alexandre Julliard
5 * Copyright 2000 Eric Pouech
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "config.h"
23 #include "wine/port.h"
25 #include <assert.h>
26 #include <ctype.h>
27 #include <fcntl.h>
28 #include <stdio.h>
29 #include <string.h>
30 #include <stdarg.h>
31 #ifdef HAVE_SYS_STAT_H
32 # include <sys/stat.h>
33 #endif
34 #ifdef HAVE_UNISTD_H
35 # include <unistd.h>
36 #endif
38 #include "windef.h"
39 #include "winbase.h"
40 #include "build.h"
42 struct import
44 DLLSPEC *spec; /* description of the imported dll */
45 char *full_name; /* full name of the input file */
46 dev_t dev; /* device/inode of the input file */
47 ino_t ino;
48 int delay; /* delay or not dll loading ? */
49 ORDDEF **exports; /* functions exported from this dll */
50 int nb_exports; /* number of exported functions */
51 ORDDEF **imports; /* functions we want to import from this dll */
52 int nb_imports; /* number of imported functions */
55 struct name_table
57 char **names;
58 unsigned int count, size;
61 static struct name_table undef_symbols; /* list of undefined symbols */
62 static struct name_table ignore_symbols; /* list of symbols to ignore */
63 static struct name_table extra_ld_symbols; /* list of extra symbols that ld should resolve */
64 static struct name_table delayed_imports; /* list of delayed import dlls */
65 static struct name_table ext_link_imports; /* list of external symbols to link to */
67 static struct import **dll_imports = NULL;
68 static int nb_imports = 0; /* number of imported dlls (delayed or not) */
69 static int nb_delayed = 0; /* number of delayed dlls */
70 static int total_imports = 0; /* total number of imported functions */
71 static int total_delayed = 0; /* total number of imported functions in delayed DLLs */
74 static inline const char *ppc_reg( int reg )
76 static const char * const ppc_regs[32] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
77 "r8", "r9", "r10","r11","r12","r13","r14","r15",
78 "r16","r17","r18","r19","r20","r21","r22","r23",
79 "r24","r25","r26","r27","r28","r29","r30","r31" };
80 if (target_platform == PLATFORM_APPLE) return ppc_regs[reg];
81 return ppc_regs[reg] + 1; /* skip the 'r' */
84 /* compare function names; helper for resolve_imports */
85 static int name_cmp( const void *name, const void *entry )
87 return strcmp( *(const char* const *)name, *(const char* const *)entry );
90 /* compare function names; helper for resolve_imports */
91 static int func_cmp( const void *func1, const void *func2 )
93 const ORDDEF *odp1 = *(const ORDDEF * const *)func1;
94 const ORDDEF *odp2 = *(const ORDDEF * const *)func2;
95 return strcmp( odp1->name ? odp1->name : odp1->export_name,
96 odp2->name ? odp2->name : odp2->export_name );
99 /* add a name to a name table */
100 inline static void add_name( struct name_table *table, const char *name )
102 if (table->count == table->size)
104 table->size += (table->size / 2);
105 if (table->size < 32) table->size = 32;
106 table->names = xrealloc( table->names, table->size * sizeof(*table->names) );
108 table->names[table->count++] = xstrdup( name );
111 /* remove a name from a name table */
112 inline static void remove_name( struct name_table *table, unsigned int idx )
114 assert( idx < table->count );
115 free( table->names[idx] );
116 memmove( table->names + idx, table->names + idx + 1,
117 (table->count - idx - 1) * sizeof(*table->names) );
118 table->count--;
121 /* make a name table empty */
122 inline static void empty_name_table( struct name_table *table )
124 unsigned int i;
126 for (i = 0; i < table->count; i++) free( table->names[i] );
127 table->count = 0;
130 /* locate a name in a (sorted) list */
131 inline static const char *find_name( const char *name, const struct name_table *table )
133 char **res = NULL;
135 if (table->count) res = bsearch( &name, table->names, table->count, sizeof(*table->names), name_cmp );
136 return res ? *res : NULL;
139 /* sort a name table */
140 inline static void sort_names( struct name_table *table )
142 if (table->count) qsort( table->names, table->count, sizeof(*table->names), name_cmp );
145 /* locate an export in a (sorted) export list */
146 inline static ORDDEF *find_export( const char *name, ORDDEF **table, int size )
148 ORDDEF func, *odp, **res = NULL;
150 func.name = (char *)name;
151 func.ordinal = -1;
152 odp = &func;
153 if (table) res = bsearch( &odp, table, size, sizeof(*table), func_cmp );
154 return res ? *res : NULL;
157 /* free an import structure */
158 static void free_imports( struct import *imp )
160 free( imp->exports );
161 free( imp->imports );
162 free_dll_spec( imp->spec );
163 free( imp->full_name );
164 free( imp );
167 /* check whether a given dll is imported in delayed mode */
168 static int is_delayed_import( const char *name )
170 int i;
172 for (i = 0; i < delayed_imports.count; i++)
174 if (!strcmp( delayed_imports.names[i], name )) return 1;
176 return 0;
179 /* check whether a given dll has already been imported */
180 static struct import *is_already_imported( const char *name )
182 int i;
184 for (i = 0; i < nb_imports; i++)
186 if (!strcmp( dll_imports[i]->spec->file_name, name )) return dll_imports[i];
188 return NULL;
191 /* open the .so library for a given dll in a specified path */
192 static char *try_library_path( const char *path, const char *name )
194 char *buffer;
195 int fd;
197 buffer = xmalloc( strlen(path) + strlen(name) + 9 );
198 sprintf( buffer, "%s/lib%s.def", path, name );
200 /* check if the file exists */
201 if ((fd = open( buffer, O_RDONLY )) != -1)
203 close( fd );
204 return buffer;
206 free( buffer );
207 return NULL;
210 /* find the .def import library for a given dll */
211 static char *find_library( const char *name )
213 char *fullname;
214 int i;
216 for (i = 0; i < nb_lib_paths; i++)
218 if ((fullname = try_library_path( lib_path[i], name ))) return fullname;
220 fatal_error( "could not open .def file for %s\n", name );
221 return NULL;
224 /* read in the list of exported symbols of an import library */
225 static int read_import_lib( struct import *imp )
227 FILE *f;
228 int i, ret;
229 struct stat stat;
230 struct import *prev_imp;
231 DLLSPEC *spec = imp->spec;
233 f = open_input_file( NULL, imp->full_name );
234 fstat( fileno(f), &stat );
235 imp->dev = stat.st_dev;
236 imp->ino = stat.st_ino;
237 ret = parse_def_file( f, spec );
238 close_input_file( f );
239 if (!ret) return 0;
241 /* check if we already imported that library from a different file */
242 if ((prev_imp = is_already_imported( spec->file_name )))
244 if (prev_imp->dev != imp->dev || prev_imp->ino != imp->ino)
245 fatal_error( "%s and %s have the same export name '%s'\n",
246 prev_imp->full_name, imp->full_name, spec->file_name );
247 return 0; /* the same file was already loaded, ignore this one */
250 if (is_delayed_import( spec->file_name ))
252 imp->delay = 1;
253 nb_delayed++;
256 imp->exports = xmalloc( spec->nb_entry_points * sizeof(*imp->exports) );
258 for (i = 0; i < spec->nb_entry_points; i++)
260 ORDDEF *odp = &spec->entry_points[i];
262 if (odp->type != TYPE_STDCALL && odp->type != TYPE_CDECL) continue;
263 if (odp->flags & FLAG_PRIVATE) continue;
264 imp->exports[imp->nb_exports++] = odp;
266 imp->exports = xrealloc( imp->exports, imp->nb_exports * sizeof(*imp->exports) );
267 if (imp->nb_exports)
268 qsort( imp->exports, imp->nb_exports, sizeof(*imp->exports), func_cmp );
269 return 1;
272 /* build the dll exported name from the import lib name or path */
273 static char *get_dll_name( const char *name, const char *filename )
275 char *ret;
277 if (filename)
279 const char *basename = strrchr( filename, '/' );
280 if (!basename) basename = filename;
281 else basename++;
282 if (!strncmp( basename, "lib", 3 )) basename += 3;
283 ret = xmalloc( strlen(basename) + 5 );
284 strcpy( ret, basename );
285 if (strendswith( ret, ".def" )) ret[strlen(ret)-4] = 0;
287 else
289 ret = xmalloc( strlen(name) + 5 );
290 strcpy( ret, name );
292 if (!strchr( ret, '.' )) strcat( ret, ".dll" );
293 return ret;
296 /* add a dll to the list of imports */
297 void add_import_dll( const char *name, const char *filename )
299 struct import *imp = xmalloc( sizeof(*imp) );
301 imp->spec = alloc_dll_spec();
302 imp->spec->file_name = get_dll_name( name, filename );
303 imp->delay = 0;
304 imp->imports = NULL;
305 imp->nb_imports = 0;
306 imp->exports = NULL;
307 imp->nb_exports = 0;
309 if (filename) imp->full_name = xstrdup( filename );
310 else imp->full_name = find_library( name );
312 if (read_import_lib( imp ))
314 dll_imports = xrealloc( dll_imports, (nb_imports+1) * sizeof(*dll_imports) );
315 dll_imports[nb_imports++] = imp;
317 else
319 free_imports( imp );
320 if (nb_errors) exit(1);
324 /* add a library to the list of delayed imports */
325 void add_delayed_import( const char *name )
327 struct import *imp;
328 char *fullname = get_dll_name( name, NULL );
330 add_name( &delayed_imports, fullname );
331 if ((imp = is_already_imported( fullname )) && !imp->delay)
333 imp->delay = 1;
334 nb_delayed++;
336 free( fullname );
339 /* remove an imported dll, based on its index in the dll_imports array */
340 static void remove_import_dll( int index )
342 struct import *imp = dll_imports[index];
344 memmove( &dll_imports[index], &dll_imports[index+1], sizeof(imp) * (nb_imports - index - 1) );
345 nb_imports--;
346 if (imp->delay) nb_delayed--;
347 free_imports( imp );
350 /* add a symbol to the ignored symbol list */
351 /* if the name starts with '-' the symbol is removed instead */
352 void add_ignore_symbol( const char *name )
354 unsigned int i;
356 if (name[0] == '-') /* remove it */
358 if (!name[1]) empty_name_table( &ignore_symbols ); /* remove everything */
359 else for (i = 0; i < ignore_symbols.count; i++)
361 if (!strcmp( ignore_symbols.names[i], name+1 )) remove_name( &ignore_symbols, i-- );
364 else add_name( &ignore_symbols, name );
367 /* add a symbol to the list of extra symbols that ld must resolve */
368 void add_extra_ld_symbol( const char *name )
370 add_name( &extra_ld_symbols, name );
373 /* add a function to the list of imports from a given dll */
374 static void add_import_func( struct import *imp, ORDDEF *func )
376 imp->imports = xrealloc( imp->imports, (imp->nb_imports+1) * sizeof(*imp->imports) );
377 imp->imports[imp->nb_imports++] = func;
378 total_imports++;
379 if (imp->delay) total_delayed++;
382 /* get the default entry point for a given spec file */
383 static const char *get_default_entry_point( const DLLSPEC *spec )
385 if (spec->characteristics & IMAGE_FILE_DLL) return "__wine_spec_dll_entry";
386 if (spec->subsystem == IMAGE_SUBSYSTEM_NATIVE) return "__wine_spec_drv_entry";
387 return "__wine_spec_exe_entry";
390 /* check if the spec file exports any stubs */
391 static int has_stubs( const DLLSPEC *spec )
393 int i;
394 for (i = 0; i < spec->nb_entry_points; i++)
396 ORDDEF *odp = &spec->entry_points[i];
397 if (odp->type == TYPE_STUB) return 1;
399 return 0;
402 /* add the extra undefined symbols that will be contained in the generated spec file itself */
403 static void add_extra_undef_symbols( DLLSPEC *spec )
405 if (!spec->init_func) spec->init_func = xstrdup( get_default_entry_point(spec) );
406 add_extra_ld_symbol( spec->init_func );
407 if (has_stubs( spec )) add_extra_ld_symbol( "__wine_spec_unimplemented_stub" );
408 if (nb_delayed) add_extra_ld_symbol( "__wine_spec_delay_load" );
411 /* check if a given imported dll is not needed, taking forwards into account */
412 static int check_unused( const struct import* imp, const DLLSPEC *spec )
414 int i;
415 const char *file_name = imp->spec->file_name;
416 size_t len = strlen( file_name );
417 const char *p = strchr( file_name, '.' );
418 if (p && !strcasecmp( p, ".dll" )) len = p - file_name;
420 for (i = spec->base; i <= spec->limit; i++)
422 ORDDEF *odp = spec->ordinals[i];
423 if (!odp || !(odp->flags & FLAG_FORWARD)) continue;
424 if (!strncasecmp( odp->link_name, file_name, len ) &&
425 odp->link_name[len] == '.')
426 return 0; /* found a forward, it is used */
428 return 1;
431 /* flag the dll exports that link to an undefined symbol */
432 static void check_undefined_exports( DLLSPEC *spec )
434 int i;
436 for (i = 0; i < spec->nb_entry_points; i++)
438 ORDDEF *odp = &spec->entry_points[i];
439 if (odp->type == TYPE_STUB) continue;
440 if (odp->flags & FLAG_FORWARD) continue;
441 if (find_name( odp->link_name, &undef_symbols ))
443 odp->flags |= FLAG_EXT_LINK;
444 add_name( &ext_link_imports, odp->link_name );
449 /* create a .o file that references all the undefined symbols we want to resolve */
450 static char *create_undef_symbols_file( DLLSPEC *spec )
452 char *as_file, *obj_file;
453 unsigned int i;
454 FILE *f;
456 as_file = get_temp_file_name( output_file_name, ".s" );
457 if (!(f = fopen( as_file, "w" ))) fatal_error( "Cannot create %s\n", as_file );
458 fprintf( f, "\t.data\n" );
460 for (i = 0; i < spec->nb_entry_points; i++)
462 ORDDEF *odp = &spec->entry_points[i];
463 if (odp->type == TYPE_STUB) continue;
464 if (odp->flags & FLAG_FORWARD) continue;
465 fprintf( f, "\t%s %s\n", get_asm_ptr_keyword(), asm_name(odp->link_name) );
467 for (i = 0; i < extra_ld_symbols.count; i++)
468 fprintf( f, "\t%s %s\n", get_asm_ptr_keyword(), asm_name(extra_ld_symbols.names[i]) );
469 fclose( f );
471 obj_file = get_temp_file_name( output_file_name, ".o" );
472 assemble_file( as_file, obj_file );
473 return obj_file;
476 /* combine a list of object files with ld into a single object file */
477 /* returns the name of the combined file */
478 static const char *ldcombine_files( DLLSPEC *spec, char **argv )
480 unsigned int i, len = 0;
481 char *cmd, *p, *ld_tmp_file, *undef_file;
482 int err;
484 undef_file = create_undef_symbols_file( spec );
485 len += strlen(undef_file) + 1;
486 ld_tmp_file = get_temp_file_name( output_file_name, ".o" );
487 if (!ld_command) ld_command = xstrdup("ld");
488 for (i = 0; argv[i]; i++) len += strlen(argv[i]) + 1;
489 cmd = p = xmalloc( len + strlen(ld_tmp_file) + 8 + strlen(ld_command) );
490 p += sprintf( cmd, "%s -r -o %s %s", ld_command, ld_tmp_file, undef_file );
491 for (i = 0; argv[i]; i++)
492 p += sprintf( p, " %s", argv[i] );
493 if (verbose) fprintf( stderr, "%s\n", cmd );
494 err = system( cmd );
495 if (err) fatal_error( "%s -r failed with status %d\n", ld_command, err );
496 free( cmd );
497 return ld_tmp_file;
500 /* read in the list of undefined symbols */
501 void read_undef_symbols( DLLSPEC *spec, char **argv )
503 size_t prefix_len;
504 FILE *f;
505 char *cmd, buffer[1024], name_prefix[16];
506 int err;
507 const char *name;
509 if (!argv[0]) return;
511 add_extra_undef_symbols( spec );
513 strcpy( name_prefix, asm_name("") );
514 prefix_len = strlen( name_prefix );
516 name = ldcombine_files( spec, argv );
518 if (!nm_command) nm_command = xstrdup("nm");
519 cmd = xmalloc( strlen(nm_command) + strlen(name) + 5 );
520 sprintf( cmd, "%s -u %s", nm_command, name );
521 if (!(f = popen( cmd, "r" )))
522 fatal_error( "Cannot execute '%s'\n", cmd );
524 while (fgets( buffer, sizeof(buffer), f ))
526 char *p = buffer + strlen(buffer) - 1;
527 if (p < buffer) continue;
528 if (*p == '\n') *p-- = 0;
529 p = buffer;
530 while (*p == ' ') p++;
531 if (p[0] == 'U' && p[1] == ' ' && p[2]) p += 2;
532 if (prefix_len && !strncmp( p, name_prefix, prefix_len )) p += prefix_len;
533 add_name( &undef_symbols, p );
535 if ((err = pclose( f ))) warning( "%s failed with status %d\n", cmd, err );
536 free( cmd );
539 /* resolve the imports for a Win32 module */
540 int resolve_imports( DLLSPEC *spec )
542 unsigned int i, j, removed;
543 ORDDEF *odp;
545 sort_names( &ignore_symbols );
547 for (i = 0; i < nb_imports; i++)
549 struct import *imp = dll_imports[i];
551 for (j = removed = 0; j < undef_symbols.count; j++)
553 if (find_name( undef_symbols.names[j], &ignore_symbols )) continue;
554 odp = find_export( undef_symbols.names[j], imp->exports, imp->nb_exports );
555 if (odp)
557 add_import_func( imp, odp );
558 remove_name( &undef_symbols, j-- );
559 removed++;
562 if (!removed && check_unused( imp, spec ))
564 /* the dll is not used, get rid of it */
565 warning( "%s imported but no symbols used\n", imp->spec->file_name );
566 remove_import_dll( i );
567 i--;
571 sort_names( &undef_symbols );
572 check_undefined_exports( spec );
574 return 1;
577 /* output the get_pc thunk if needed */
578 void output_get_pc_thunk( FILE *outfile )
580 if (target_cpu != CPU_x86) return;
581 if (!UsePIC) return;
582 fprintf( outfile, "\n\t.text\n" );
583 fprintf( outfile, "\t.align %d\n", get_alignment(4) );
584 fprintf( outfile, "\t%s\n", func_declaration("__wine_spec_get_pc_thunk_eax") );
585 fprintf( outfile, "%s:\n", asm_name("__wine_spec_get_pc_thunk_eax") );
586 fprintf( outfile, "\tpopl %%eax\n" );
587 fprintf( outfile, "\tpushl %%eax\n" );
588 fprintf( outfile, "\tret\n" );
589 output_function_size( outfile, "__wine_spec_get_pc_thunk_eax" );
592 /* output a single import thunk */
593 static void output_import_thunk( FILE *outfile, const char *name, const char *table, int pos )
595 fprintf( outfile, "\n\t.align %d\n", get_alignment(4) );
596 fprintf( outfile, "\t%s\n", func_declaration(name) );
597 fprintf( outfile, "%s\n", asm_globl(name) );
599 switch(target_cpu)
601 case CPU_x86:
602 if (!UsePIC)
604 fprintf( outfile, "\tjmp *(%s+%d)\n", table, pos );
606 else
608 fprintf( outfile, "\tcall %s\n", asm_name("__wine_spec_get_pc_thunk_eax") );
609 fprintf( outfile, "1:\tjmp *%s+%d-1b(%%eax)\n", table, pos );
611 break;
612 case CPU_x86_64:
613 fprintf( outfile, "\tjmpq *%s+%d(%%rip)\n", table, pos );
614 break;
615 case CPU_SPARC:
616 if ( !UsePIC )
618 fprintf( outfile, "\tsethi %%hi(%s+%d), %%g1\n", table, pos );
619 fprintf( outfile, "\tld [%%g1+%%lo(%s+%d)], %%g1\n", table, pos );
620 fprintf( outfile, "\tjmp %%g1\n" );
621 fprintf( outfile, "\tnop\n" );
623 else
625 /* Hmpf. Stupid sparc assembler always interprets global variable
626 names as GOT offsets, so we have to do it the long way ... */
627 fprintf( outfile, "\tsave %%sp, -96, %%sp\n" );
628 fprintf( outfile, "0:\tcall 1f\n" );
629 fprintf( outfile, "\tnop\n" );
630 fprintf( outfile, "1:\tsethi %%hi(%s+%d-0b), %%g1\n", table, pos );
631 fprintf( outfile, "\tor %%g1, %%lo(%s+%d-0b), %%g1\n", table, pos );
632 fprintf( outfile, "\tld [%%g1+%%o7], %%g1\n" );
633 fprintf( outfile, "\tjmp %%g1\n" );
634 fprintf( outfile, "\trestore\n" );
636 break;
637 case CPU_ALPHA:
638 fprintf( outfile, "\tlda $0,%s\n", table );
639 fprintf( outfile, "\tlda $0,%d($0)\n", pos );
640 fprintf( outfile, "\tjmp $31,($0)\n" );
641 break;
642 case CPU_POWERPC:
643 fprintf( outfile, "\taddi %s, %s, -0x4\n", ppc_reg(1), ppc_reg(1) );
644 fprintf( outfile, "\tstw %s, 0(%s)\n", ppc_reg(9), ppc_reg(1) );
645 fprintf( outfile, "\taddi %s, %s, -0x4\n", ppc_reg(1), ppc_reg(1) );
646 fprintf( outfile, "\tstw %s, 0(%s)\n", ppc_reg(8), ppc_reg(1) );
647 fprintf( outfile, "\taddi %s, %s, -0x4\n", ppc_reg(1), ppc_reg(1) );
648 fprintf( outfile, "\tstw %s, 0(%s)\n", ppc_reg(7), ppc_reg(1) );
649 if (target_platform == PLATFORM_APPLE)
651 fprintf( outfile, "\tlis %s, ha16(%s+%d)\n", ppc_reg(9), table, pos );
652 fprintf( outfile, "\tla %s, lo16(%s+%d)(%s)\n", ppc_reg(8), table, pos, ppc_reg(9) );
654 else
656 fprintf( outfile, "\tlis %s, (%s+%d)@h\n", ppc_reg(9), table, pos );
657 fprintf( outfile, "\tla %s, (%s+%d)@l(%s)\n", ppc_reg(8), table, pos, ppc_reg(9) );
659 fprintf( outfile, "\tlwz %s, 0(%s)\n", ppc_reg(7), ppc_reg(8) );
660 fprintf( outfile, "\tmtctr %s\n", ppc_reg(7) );
661 fprintf( outfile, "\tlwz %s, 0(%s)\n", ppc_reg(7), ppc_reg(1) );
662 fprintf( outfile, "\taddi %s, %s, 0x4\n", ppc_reg(1), ppc_reg(1) );
663 fprintf( outfile, "\tlwz %s, 0(%s)\n", ppc_reg(8), ppc_reg(1) );
664 fprintf( outfile, "\taddi %s, %s, 0x4\n", ppc_reg(1), ppc_reg(1) );
665 fprintf( outfile, "\tlwz %s, 0(%s)\n", ppc_reg(9), ppc_reg(1) );
666 fprintf( outfile, "\taddi %s, %s, 0x4\n", ppc_reg(1), ppc_reg(1) );
667 fprintf( outfile, "\tbctr\n" );
668 break;
670 output_function_size( outfile, name );
673 /* check if we need an import directory */
674 int has_imports(void)
676 return (nb_imports - nb_delayed) > 0;
679 /* output the import table of a Win32 module */
680 static void output_immediate_imports( FILE *outfile )
682 int i, j;
683 const char *dll_name;
685 if (nb_imports == nb_delayed) return; /* no immediate imports */
687 /* main import header */
689 fprintf( outfile, "\n/* import table */\n" );
690 fprintf( outfile, "\n\t.data\n" );
691 fprintf( outfile, "\t.align %d\n", get_alignment(4) );
692 fprintf( outfile, ".L__wine_spec_imports:\n" );
694 /* list of dlls */
696 for (i = j = 0; i < nb_imports; i++)
698 if (dll_imports[i]->delay) continue;
699 dll_name = make_c_identifier( dll_imports[i]->spec->file_name );
700 fprintf( outfile, "\t.long 0\n" ); /* OriginalFirstThunk */
701 fprintf( outfile, "\t.long 0\n" ); /* TimeDateStamp */
702 fprintf( outfile, "\t.long 0\n" ); /* ForwarderChain */
703 fprintf( outfile, "\t.long .L__wine_spec_import_name_%s-.L__wine_spec_rva_base\n", /* Name */
704 dll_name );
705 fprintf( outfile, "\t.long .L__wine_spec_import_data_ptrs+%d-.L__wine_spec_rva_base\n", /* FirstThunk */
706 j * get_ptr_size() );
707 j += dll_imports[i]->nb_imports + 1;
709 fprintf( outfile, "\t.long 0\n" ); /* OriginalFirstThunk */
710 fprintf( outfile, "\t.long 0\n" ); /* TimeDateStamp */
711 fprintf( outfile, "\t.long 0\n" ); /* ForwarderChain */
712 fprintf( outfile, "\t.long 0\n" ); /* Name */
713 fprintf( outfile, "\t.long 0\n" ); /* FirstThunk */
715 fprintf( outfile, "\n\t.align %d\n", get_alignment(get_ptr_size()) );
716 fprintf( outfile, ".L__wine_spec_import_data_ptrs:\n" );
717 for (i = 0; i < nb_imports; i++)
719 if (dll_imports[i]->delay) continue;
720 dll_name = make_c_identifier( dll_imports[i]->spec->file_name );
721 for (j = 0; j < dll_imports[i]->nb_imports; j++)
723 ORDDEF *odp = dll_imports[i]->imports[j];
724 if (!(odp->flags & FLAG_NONAME))
725 fprintf( outfile, "\t%s .L__wine_spec_import_data_%s_%s-.L__wine_spec_rva_base\n",
726 get_asm_ptr_keyword(), dll_name, odp->name );
727 else
729 if (get_ptr_size() == 8)
730 fprintf( outfile, "\t.quad 0x800000000000%04x\n", odp->ordinal );
731 else
732 fprintf( outfile, "\t.long 0x8000%04x\n", odp->ordinal );
735 fprintf( outfile, "\t%s 0\n", get_asm_ptr_keyword() );
737 fprintf( outfile, ".L__wine_spec_imports_end:\n" );
739 for (i = 0; i < nb_imports; i++)
741 if (dll_imports[i]->delay) continue;
742 dll_name = make_c_identifier( dll_imports[i]->spec->file_name );
743 for (j = 0; j < dll_imports[i]->nb_imports; j++)
745 ORDDEF *odp = dll_imports[i]->imports[j];
746 if (!(odp->flags & FLAG_NONAME))
748 fprintf( outfile, "\t.align %d\n", get_alignment(2) );
749 fprintf( outfile, ".L__wine_spec_import_data_%s_%s:\n", dll_name, odp->name );
750 fprintf( outfile, "\t%s %d\n", get_asm_short_keyword(), odp->ordinal );
751 fprintf( outfile, "\t%s \"%s\"\n", get_asm_string_keyword(), odp->name );
756 for (i = 0; i < nb_imports; i++)
758 if (dll_imports[i]->delay) continue;
759 dll_name = make_c_identifier( dll_imports[i]->spec->file_name );
760 fprintf( outfile, ".L__wine_spec_import_name_%s:\n\t%s \"%s\"\n",
761 dll_name, get_asm_string_keyword(), dll_imports[i]->spec->file_name );
765 /* output the import thunks of a Win32 module */
766 static void output_immediate_import_thunks( FILE *outfile )
768 int i, j, pos;
769 int nb_imm = nb_imports - nb_delayed;
770 static const char import_thunks[] = "__wine_spec_import_thunks";
772 if (!nb_imm) return;
774 fprintf( outfile, "\n/* immediate import thunks */\n\n" );
775 fprintf( outfile, "\t.text\n" );
776 fprintf( outfile, "\t.align %d\n", get_alignment(8) );
777 fprintf( outfile, "%s:\n", asm_name(import_thunks));
779 for (i = pos = 0; i < nb_imports; i++)
781 if (dll_imports[i]->delay) continue;
782 for (j = 0; j < dll_imports[i]->nb_imports; j++, pos += get_ptr_size())
784 ORDDEF *odp = dll_imports[i]->imports[j];
785 output_import_thunk( outfile, odp->name ? odp->name : odp->export_name,
786 ".L__wine_spec_import_data_ptrs", pos );
788 pos += get_ptr_size();
790 output_function_size( outfile, import_thunks );
793 /* output the delayed import table of a Win32 module */
794 static void output_delayed_imports( FILE *outfile, const DLLSPEC *spec )
796 int i, j;
798 if (!nb_delayed) return;
800 fprintf( outfile, "\n/* delayed imports */\n\n" );
801 fprintf( outfile, "\t.data\n" );
802 fprintf( outfile, "\t.align %d\n", get_alignment(get_ptr_size()) );
803 fprintf( outfile, "%s\n", asm_globl("__wine_spec_delay_imports") );
805 /* list of dlls */
807 for (i = j = 0; i < nb_imports; i++)
809 if (!dll_imports[i]->delay) continue;
810 fprintf( outfile, "\t%s 0\n", get_asm_ptr_keyword() ); /* grAttrs */
811 fprintf( outfile, "\t%s .L__wine_delay_name_%d\n", /* szName */
812 get_asm_ptr_keyword(), i );
813 fprintf( outfile, "\t%s .L__wine_delay_modules+%d\n", /* phmod */
814 get_asm_ptr_keyword(), i * get_ptr_size() );
815 fprintf( outfile, "\t%s .L__wine_delay_IAT+%d\n", /* pIAT */
816 get_asm_ptr_keyword(), j * get_ptr_size() );
817 fprintf( outfile, "\t%s .L__wine_delay_INT+%d\n", /* pINT */
818 get_asm_ptr_keyword(), j * get_ptr_size() );
819 fprintf( outfile, "\t%s 0\n", get_asm_ptr_keyword() ); /* pBoundIAT */
820 fprintf( outfile, "\t%s 0\n", get_asm_ptr_keyword() ); /* pUnloadIAT */
821 fprintf( outfile, "\t%s 0\n", get_asm_ptr_keyword() ); /* dwTimeStamp */
822 j += dll_imports[i]->nb_imports;
824 fprintf( outfile, "\t%s 0\n", get_asm_ptr_keyword() ); /* grAttrs */
825 fprintf( outfile, "\t%s 0\n", get_asm_ptr_keyword() ); /* szName */
826 fprintf( outfile, "\t%s 0\n", get_asm_ptr_keyword() ); /* phmod */
827 fprintf( outfile, "\t%s 0\n", get_asm_ptr_keyword() ); /* pIAT */
828 fprintf( outfile, "\t%s 0\n", get_asm_ptr_keyword() ); /* pINT */
829 fprintf( outfile, "\t%s 0\n", get_asm_ptr_keyword() ); /* pBoundIAT */
830 fprintf( outfile, "\t%s 0\n", get_asm_ptr_keyword() ); /* pUnloadIAT */
831 fprintf( outfile, "\t%s 0\n", get_asm_ptr_keyword() ); /* dwTimeStamp */
833 fprintf( outfile, "\n.L__wine_delay_IAT:\n" );
834 for (i = 0; i < nb_imports; i++)
836 if (!dll_imports[i]->delay) continue;
837 for (j = 0; j < dll_imports[i]->nb_imports; j++)
839 ORDDEF *odp = dll_imports[i]->imports[j];
840 const char *name = odp->name ? odp->name : odp->export_name;
841 fprintf( outfile, "\t%s .L__wine_delay_imp_%d_%s\n",
842 get_asm_ptr_keyword(), i, name );
846 fprintf( outfile, "\n.L__wine_delay_INT:\n" );
847 for (i = 0; i < nb_imports; i++)
849 if (!dll_imports[i]->delay) continue;
850 for (j = 0; j < dll_imports[i]->nb_imports; j++)
852 ORDDEF *odp = dll_imports[i]->imports[j];
853 if (!odp->name)
854 fprintf( outfile, "\t%s %d\n", get_asm_ptr_keyword(), odp->ordinal );
855 else
856 fprintf( outfile, "\t%s .L__wine_delay_data_%d_%s\n",
857 get_asm_ptr_keyword(), i, odp->name );
861 fprintf( outfile, "\n.L__wine_delay_modules:\n" );
862 for (i = 0; i < nb_imports; i++)
864 if (dll_imports[i]->delay) fprintf( outfile, "\t%s 0\n", get_asm_ptr_keyword() );
867 for (i = 0; i < nb_imports; i++)
869 if (!dll_imports[i]->delay) continue;
870 fprintf( outfile, ".L__wine_delay_name_%d:\n", i );
871 fprintf( outfile, "\t%s \"%s\"\n",
872 get_asm_string_keyword(), dll_imports[i]->spec->file_name );
875 for (i = 0; i < nb_imports; i++)
877 if (!dll_imports[i]->delay) continue;
878 for (j = 0; j < dll_imports[i]->nb_imports; j++)
880 ORDDEF *odp = dll_imports[i]->imports[j];
881 if (!odp->name) continue;
882 fprintf( outfile, ".L__wine_delay_data_%d_%s:\n", i, odp->name );
883 fprintf( outfile, "\t%s \"%s\"\n", get_asm_string_keyword(), odp->name );
886 output_function_size( outfile, "__wine_spec_delay_imports" );
889 /* output the delayed import thunks of a Win32 module */
890 static void output_delayed_import_thunks( FILE *outfile, const DLLSPEC *spec )
892 int i, idx, j, pos, extra_stack_storage = 0;
893 static const char delayed_import_loaders[] = "__wine_spec_delayed_import_loaders";
894 static const char delayed_import_thunks[] = "__wine_spec_delayed_import_thunks";
896 if (!nb_delayed) return;
898 fprintf( outfile, "\n/* delayed import thunks */\n\n" );
899 fprintf( outfile, "\t.text\n" );
900 fprintf( outfile, "\t.align %d\n", get_alignment(8) );
901 fprintf( outfile, "%s:\n", asm_name(delayed_import_loaders));
902 fprintf( outfile, "\t%s\n", func_declaration("__wine_delay_load_asm") );
903 fprintf( outfile, "%s:\n", asm_name("__wine_delay_load_asm") );
904 switch(target_cpu)
906 case CPU_x86:
907 fprintf( outfile, "\tpushl %%ecx\n" );
908 fprintf( outfile, "\tpushl %%edx\n" );
909 fprintf( outfile, "\tpushl %%eax\n" );
910 fprintf( outfile, "\tcall %s\n", asm_name("__wine_spec_delay_load") );
911 fprintf( outfile, "\tpopl %%edx\n" );
912 fprintf( outfile, "\tpopl %%ecx\n" );
913 fprintf( outfile, "\tjmp *%%eax\n" );
914 break;
915 case CPU_x86_64:
916 fprintf( outfile, "\tpushq %%rdi\n" );
917 fprintf( outfile, "\tsubq $8,%%rsp\n" );
918 fprintf( outfile, "\tmovq %%r11,%%rdi\n" );
919 fprintf( outfile, "\tcall %s\n", asm_name("__wine_spec_delay_load") );
920 fprintf( outfile, "\taddq $8,%%rsp\n" );
921 fprintf( outfile, "\tpopq %%rdi\n" );
922 fprintf( outfile, "\tjmp *%%rax\n" );
923 break;
924 case CPU_SPARC:
925 fprintf( outfile, "\tsave %%sp, -96, %%sp\n" );
926 fprintf( outfile, "\tcall %s\n", asm_name("__wine_spec_delay_load") );
927 fprintf( outfile, "\tmov %%g1, %%o0\n" );
928 fprintf( outfile, "\tjmp %%o0\n" );
929 fprintf( outfile, "\trestore\n" );
930 break;
931 case CPU_ALPHA:
932 fprintf( outfile, "\tjsr $26,%s\n", asm_name("__wine_spec_delay_load") );
933 fprintf( outfile, "\tjmp $31,($0)\n" );
934 break;
935 case CPU_POWERPC:
936 if (target_platform == PLATFORM_APPLE) extra_stack_storage = 56;
938 /* Save all callee saved registers into a stackframe. */
939 fprintf( outfile, "\tstwu %s, -%d(%s)\n",ppc_reg(1), 48+extra_stack_storage, ppc_reg(1));
940 fprintf( outfile, "\tstw %s, %d(%s)\n", ppc_reg(3), 4+extra_stack_storage, ppc_reg(1));
941 fprintf( outfile, "\tstw %s, %d(%s)\n", ppc_reg(4), 8+extra_stack_storage, ppc_reg(1));
942 fprintf( outfile, "\tstw %s, %d(%s)\n", ppc_reg(5), 12+extra_stack_storage, ppc_reg(1));
943 fprintf( outfile, "\tstw %s, %d(%s)\n", ppc_reg(6), 16+extra_stack_storage, ppc_reg(1));
944 fprintf( outfile, "\tstw %s, %d(%s)\n", ppc_reg(7), 20+extra_stack_storage, ppc_reg(1));
945 fprintf( outfile, "\tstw %s, %d(%s)\n", ppc_reg(8), 24+extra_stack_storage, ppc_reg(1));
946 fprintf( outfile, "\tstw %s, %d(%s)\n", ppc_reg(9), 28+extra_stack_storage, ppc_reg(1));
947 fprintf( outfile, "\tstw %s, %d(%s)\n", ppc_reg(10),32+extra_stack_storage, ppc_reg(1));
948 fprintf( outfile, "\tstw %s, %d(%s)\n", ppc_reg(11),36+extra_stack_storage, ppc_reg(1));
949 fprintf( outfile, "\tstw %s, %d(%s)\n", ppc_reg(12),40+extra_stack_storage, ppc_reg(1));
951 /* r0 -> r3 (arg1) */
952 fprintf( outfile, "\tmr %s, %s\n", ppc_reg(3), ppc_reg(0));
954 /* save return address */
955 fprintf( outfile, "\tmflr %s\n", ppc_reg(0));
956 fprintf( outfile, "\tstw %s, %d(%s)\n", ppc_reg(0), 44+extra_stack_storage, ppc_reg(1));
958 /* Call the __wine_delay_load function, arg1 is arg1. */
959 fprintf( outfile, "\tbl %s\n", asm_name("__wine_spec_delay_load") );
961 /* Load return value from call into ctr register */
962 fprintf( outfile, "\tmtctr %s\n", ppc_reg(3));
964 /* restore all saved registers and drop stackframe. */
965 fprintf( outfile, "\tlwz %s, %d(%s)\n", ppc_reg(3), 4+extra_stack_storage, ppc_reg(1));
966 fprintf( outfile, "\tlwz %s, %d(%s)\n", ppc_reg(4), 8+extra_stack_storage, ppc_reg(1));
967 fprintf( outfile, "\tlwz %s, %d(%s)\n", ppc_reg(5), 12+extra_stack_storage, ppc_reg(1));
968 fprintf( outfile, "\tlwz %s, %d(%s)\n", ppc_reg(6), 16+extra_stack_storage, ppc_reg(1));
969 fprintf( outfile, "\tlwz %s, %d(%s)\n", ppc_reg(7), 20+extra_stack_storage, ppc_reg(1));
970 fprintf( outfile, "\tlwz %s, %d(%s)\n", ppc_reg(8), 24+extra_stack_storage, ppc_reg(1));
971 fprintf( outfile, "\tlwz %s, %d(%s)\n", ppc_reg(9), 28+extra_stack_storage, ppc_reg(1));
972 fprintf( outfile, "\tlwz %s, %d(%s)\n", ppc_reg(10),32+extra_stack_storage, ppc_reg(1));
973 fprintf( outfile, "\tlwz %s, %d(%s)\n", ppc_reg(11),36+extra_stack_storage, ppc_reg(1));
974 fprintf( outfile, "\tlwz %s, %d(%s)\n", ppc_reg(12),40+extra_stack_storage, ppc_reg(1));
976 /* Load return value from call into return register */
977 fprintf( outfile, "\tlwz %s, %d(%s)\n", ppc_reg(0), 44+extra_stack_storage, ppc_reg(1));
978 fprintf( outfile, "\tmtlr %s\n", ppc_reg(0));
979 fprintf( outfile, "\taddi %s, %s, %d\n", ppc_reg(1), ppc_reg(1), 48+extra_stack_storage);
981 /* branch to ctr register. */
982 fprintf( outfile, "\tbctr\n");
983 break;
985 output_function_size( outfile, "__wine_delay_load_asm" );
986 fprintf( outfile, "\n" );
988 for (i = idx = 0; i < nb_imports; i++)
990 if (!dll_imports[i]->delay) continue;
991 for (j = 0; j < dll_imports[i]->nb_imports; j++)
993 ORDDEF *odp = dll_imports[i]->imports[j];
994 const char *name = odp->name ? odp->name : odp->export_name;
996 fprintf( outfile, ".L__wine_delay_imp_%d_%s:\n", i, name );
997 switch(target_cpu)
999 case CPU_x86:
1000 fprintf( outfile, "\tmovl $%d, %%eax\n", (idx << 16) | j );
1001 fprintf( outfile, "\tjmp %s\n", asm_name("__wine_delay_load_asm") );
1002 break;
1003 case CPU_x86_64:
1004 fprintf( outfile, "\tmovq $%d,%%r11\n", (idx << 16) | j );
1005 fprintf( outfile, "\tjmp %s\n", asm_name("__wine_delay_load_asm") );
1006 break;
1007 case CPU_SPARC:
1008 fprintf( outfile, "\tset %d, %%g1\n", (idx << 16) | j );
1009 fprintf( outfile, "\tb,a %s\n", asm_name("__wine_delay_load_asm") );
1010 break;
1011 case CPU_ALPHA:
1012 fprintf( outfile, "\tlda $0,%d($31)\n", j);
1013 fprintf( outfile, "\tldah $0,%d($0)\n", idx);
1014 fprintf( outfile, "\tjmp $31,%s\n", asm_name("__wine_delay_load_asm") );
1015 break;
1016 case CPU_POWERPC:
1017 switch(target_platform)
1019 case PLATFORM_APPLE:
1020 /* On Darwin we can use r0 and r2 */
1021 /* Upper part in r2 */
1022 fprintf( outfile, "\tlis %s, %d\n", ppc_reg(2), idx);
1023 /* Lower part + r2 -> r0, Note we can't use r0 directly */
1024 fprintf( outfile, "\taddi %s, %s, %d\n", ppc_reg(0), ppc_reg(2), j);
1025 fprintf( outfile, "\tb %s\n", asm_name("__wine_delay_load_asm") );
1026 break;
1027 default:
1028 /* On linux we can't use r2 since r2 is not a scratch register (hold the TOC) */
1029 /* Save r13 on the stack */
1030 fprintf( outfile, "\taddi %s, %s, -0x4\n", ppc_reg(1), ppc_reg(1));
1031 fprintf( outfile, "\tstw %s, 0(%s)\n", ppc_reg(13), ppc_reg(1));
1032 /* Upper part in r13 */
1033 fprintf( outfile, "\tlis %s, %d\n", ppc_reg(13), idx);
1034 /* Lower part + r13 -> r0, Note we can't use r0 directly */
1035 fprintf( outfile, "\taddi %s, %s, %d\n", ppc_reg(0), ppc_reg(13), j);
1036 /* Restore r13 */
1037 fprintf( outfile, "\tstw %s, 0(%s)\n", ppc_reg(13), ppc_reg(1));
1038 fprintf( outfile, "\taddic %s, %s, 0x4\n", ppc_reg(1), ppc_reg(1));
1039 fprintf( outfile, "\tb %s\n", asm_name("__wine_delay_load_asm") );
1040 break;
1042 break;
1045 idx++;
1047 output_function_size( outfile, delayed_import_loaders );
1049 fprintf( outfile, "\n\t.align %d\n", get_alignment(get_ptr_size()) );
1050 fprintf( outfile, "%s:\n", asm_name(delayed_import_thunks));
1051 for (i = pos = 0; i < nb_imports; i++)
1053 if (!dll_imports[i]->delay) continue;
1054 for (j = 0; j < dll_imports[i]->nb_imports; j++, pos += get_ptr_size())
1056 ORDDEF *odp = dll_imports[i]->imports[j];
1057 output_import_thunk( outfile, odp->name ? odp->name : odp->export_name,
1058 ".L__wine_delay_IAT", pos );
1061 output_function_size( outfile, delayed_import_thunks );
1064 /* output import stubs for exported entry points that link to external symbols */
1065 static void output_external_link_imports( FILE *outfile, DLLSPEC *spec )
1067 unsigned int i, pos;
1069 if (!ext_link_imports.count) return; /* nothing to do */
1071 sort_names( &ext_link_imports );
1073 /* get rid of duplicate names */
1074 for (i = 1; i < ext_link_imports.count; i++)
1076 if (!strcmp( ext_link_imports.names[i-1], ext_link_imports.names[i] ))
1077 remove_name( &ext_link_imports, i-- );
1080 fprintf( outfile, "\n/* external link thunks */\n\n" );
1081 fprintf( outfile, "\t.data\n" );
1082 fprintf( outfile, "\t.align %d\n", get_alignment(get_ptr_size()) );
1083 fprintf( outfile, ".L__wine_spec_external_links:\n" );
1084 for (i = 0; i < ext_link_imports.count; i++)
1085 fprintf( outfile, "\t%s %s\n", get_asm_ptr_keyword(), asm_name(ext_link_imports.names[i]) );
1087 fprintf( outfile, "\n\t.text\n" );
1088 fprintf( outfile, "\t.align %d\n", get_alignment(get_ptr_size()) );
1089 fprintf( outfile, "%s:\n", asm_name("__wine_spec_external_link_thunks") );
1091 for (i = pos = 0; i < ext_link_imports.count; i++)
1093 char buffer[256];
1094 sprintf( buffer, "__wine_spec_ext_link_%s", ext_link_imports.names[i] );
1095 output_import_thunk( outfile, buffer, ".L__wine_spec_external_links", pos );
1096 pos += get_ptr_size();
1098 output_function_size( outfile, "__wine_spec_external_link_thunks" );
1101 /*******************************************************************
1102 * output_stubs
1104 * Output the functions for stub entry points
1106 void output_stubs( FILE *outfile, DLLSPEC *spec )
1108 const char *name, *exp_name;
1109 int i, pos;
1111 if (!has_stubs( spec )) return;
1113 fprintf( outfile, "\n/* stub functions */\n\n" );
1114 fprintf( outfile, "\t.text\n" );
1116 for (i = pos = 0; i < spec->nb_entry_points; i++)
1118 ORDDEF *odp = &spec->entry_points[i];
1119 if (odp->type != TYPE_STUB) continue;
1121 name = get_stub_name( odp, spec );
1122 exp_name = odp->name ? odp->name : odp->export_name;
1123 fprintf( outfile, "\t.align %d\n", get_alignment(4) );
1124 fprintf( outfile, "\t%s\n", func_declaration(name) );
1125 fprintf( outfile, "%s:\n", asm_name(name) );
1126 fprintf( outfile, "\tsubl $4,%%esp\n" );
1128 if (UsePIC)
1130 fprintf( outfile, "\tcall %s\n", asm_name("__wine_spec_get_pc_thunk_eax") );
1131 fprintf( outfile, "1:" );
1132 if (exp_name)
1134 fprintf( outfile, "\tleal .L__wine_stub_strings+%d-1b(%%eax),%%ecx\n", pos );
1135 fprintf( outfile, "\tpushl %%ecx\n" );
1136 pos += strlen(exp_name) + 1;
1138 else
1139 fprintf( outfile, "\tpushl $%d\n", odp->ordinal );
1140 fprintf( outfile, "\tleal .L__wine_spec_file_name-1b(%%eax),%%ecx\n" );
1141 fprintf( outfile, "\tpushl %%ecx\n" );
1143 else
1145 if (exp_name)
1147 fprintf( outfile, "\tpushl $.L__wine_stub_strings+%d\n", pos );
1148 pos += strlen(exp_name) + 1;
1150 else
1151 fprintf( outfile, "\tpushl $%d\n", odp->ordinal );
1152 fprintf( outfile, "\tpushl $.L__wine_spec_file_name\n" );
1154 fprintf( outfile, "\tcall %s\n", asm_name("__wine_spec_unimplemented_stub") );
1155 output_function_size( outfile, name );
1158 if (pos)
1160 fprintf( outfile, "\t%s\n", get_asm_string_section() );
1161 fprintf( outfile, ".L__wine_stub_strings:\n" );
1162 for (i = 0; i < spec->nb_entry_points; i++)
1164 ORDDEF *odp = &spec->entry_points[i];
1165 if (odp->type != TYPE_STUB) continue;
1166 exp_name = odp->name ? odp->name : odp->export_name;
1167 if (exp_name)
1168 fprintf( outfile, "\t%s \"%s\"\n", get_asm_string_keyword(), exp_name );
1173 /* output the import and delayed import tables of a Win32 module */
1174 void output_imports( FILE *outfile, DLLSPEC *spec )
1176 output_immediate_imports( outfile );
1177 output_delayed_imports( outfile, spec );
1178 output_immediate_import_thunks( outfile );
1179 output_delayed_import_thunks( outfile, spec );
1180 output_external_link_imports( outfile, spec );
1181 if (nb_imports || ext_link_imports.count || has_stubs(spec) || has_relays(spec))
1182 output_get_pc_thunk( outfile );