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
30 #ifdef HAVE_SYS_STAT_H
31 # include <sys/stat.h>
40 #ifndef EXCEPTION_NONCONTINUABLE
41 #define EXCEPTION_NONCONTINUABLE 1
44 #define EXCEPTION_WINE_STUB 0x80000100 /* stub entry point called */
48 DLLSPEC
*spec
; /* description of the imported dll */
49 char *full_name
; /* full name of the input file */
50 dev_t dev
; /* device/inode of the input file */
52 int delay
; /* delay or not dll loading ? */
53 ORDDEF
**exports
; /* functions exported from this dll */
54 int nb_exports
; /* number of exported functions */
55 ORDDEF
**imports
; /* functions we want to import from this dll */
56 int nb_imports
; /* number of imported functions */
62 unsigned int count
, size
;
65 static struct name_table undef_symbols
; /* list of undefined symbols */
66 static struct name_table ignore_symbols
; /* list of symbols to ignore */
67 static struct name_table extra_ld_symbols
; /* list of extra symbols that ld should resolve */
68 static struct name_table delayed_imports
; /* list of delayed import dlls */
69 static struct name_table ext_link_imports
; /* list of external symbols to link to */
71 static struct import
**dll_imports
= NULL
;
72 static int nb_imports
= 0; /* number of imported dlls (delayed or not) */
73 static int nb_delayed
= 0; /* number of delayed dlls */
74 static int total_imports
= 0; /* total number of imported functions */
75 static int total_delayed
= 0; /* total number of imported functions in delayed DLLs */
77 /* list of symbols that are ignored by default */
78 static const char * const default_ignored_symbols
[] =
129 static inline const char *ppc_reg( int reg
)
131 static const char * const ppc_regs
[32] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
132 "r8", "r9", "r10","r11","r12","r13","r14","r15",
133 "r16","r17","r18","r19","r20","r21","r22","r23",
134 "r24","r25","r26","r27","r28","r29","r30","r31" };
135 if (target_platform
== PLATFORM_APPLE
) return ppc_regs
[reg
];
136 return ppc_regs
[reg
] + 1; /* skip the 'r' */
139 /* compare function names; helper for resolve_imports */
140 static int name_cmp( const void *name
, const void *entry
)
142 return strcmp( *(const char* const *)name
, *(const char* const *)entry
);
145 /* compare function names; helper for resolve_imports */
146 static int func_cmp( const void *func1
, const void *func2
)
148 const ORDDEF
*odp1
= *(const ORDDEF
* const *)func1
;
149 const ORDDEF
*odp2
= *(const ORDDEF
* const *)func2
;
150 return strcmp( odp1
->name
? odp1
->name
: odp1
->export_name
,
151 odp2
->name
? odp2
->name
: odp2
->export_name
);
154 /* add a name to a name table */
155 inline static void add_name( struct name_table
*table
, const char *name
)
157 if (table
->count
== table
->size
)
159 table
->size
+= (table
->size
/ 2);
160 if (table
->size
< 32) table
->size
= 32;
161 table
->names
= xrealloc( table
->names
, table
->size
* sizeof(*table
->names
) );
163 table
->names
[table
->count
++] = xstrdup( name
);
166 /* remove a name from a name table */
167 inline static void remove_name( struct name_table
*table
, unsigned int idx
)
169 assert( idx
< table
->count
);
170 free( table
->names
[idx
] );
171 memmove( table
->names
+ idx
, table
->names
+ idx
+ 1,
172 (table
->count
- idx
- 1) * sizeof(*table
->names
) );
176 /* make a name table empty */
177 inline static void empty_name_table( struct name_table
*table
)
181 for (i
= 0; i
< table
->count
; i
++) free( table
->names
[i
] );
185 /* locate a name in a (sorted) list */
186 inline static const char *find_name( const char *name
, const struct name_table
*table
)
190 if (table
->count
) res
= bsearch( &name
, table
->names
, table
->count
, sizeof(*table
->names
), name_cmp
);
191 return res
? *res
: NULL
;
194 /* sort a name table */
195 inline static void sort_names( struct name_table
*table
)
197 if (table
->count
) qsort( table
->names
, table
->count
, sizeof(*table
->names
), name_cmp
);
200 /* locate an export in a (sorted) export list */
201 inline static ORDDEF
*find_export( const char *name
, ORDDEF
**table
, int size
)
203 ORDDEF func
, *odp
, **res
= NULL
;
205 func
.name
= (char *)name
;
208 if (table
) res
= bsearch( &odp
, table
, size
, sizeof(*table
), func_cmp
);
209 return res
? *res
: NULL
;
212 /* free an import structure */
213 static void free_imports( struct import
*imp
)
215 free( imp
->exports
);
216 free( imp
->imports
);
217 free_dll_spec( imp
->spec
);
218 free( imp
->full_name
);
222 /* check whether a given dll is imported in delayed mode */
223 static int is_delayed_import( const char *name
)
227 for (i
= 0; i
< delayed_imports
.count
; i
++)
229 if (!strcmp( delayed_imports
.names
[i
], name
)) return 1;
234 /* check whether a given dll has already been imported */
235 static struct import
*is_already_imported( const char *name
)
239 for (i
= 0; i
< nb_imports
; i
++)
241 if (!strcmp( dll_imports
[i
]->spec
->file_name
, name
)) return dll_imports
[i
];
246 /* open the .so library for a given dll in a specified path */
247 static char *try_library_path( const char *path
, const char *name
)
252 buffer
= xmalloc( strlen(path
) + strlen(name
) + 9 );
253 sprintf( buffer
, "%s/lib%s.def", path
, name
);
255 /* check if the file exists */
256 if ((fd
= open( buffer
, O_RDONLY
)) != -1)
265 /* find the .def import library for a given dll */
266 static char *find_library( const char *name
)
271 for (i
= 0; i
< nb_lib_paths
; i
++)
273 if ((fullname
= try_library_path( lib_path
[i
], name
))) return fullname
;
275 fatal_error( "could not open .def file for %s\n", name
);
279 /* read in the list of exported symbols of an import library */
280 static int read_import_lib( struct import
*imp
)
285 struct import
*prev_imp
;
286 DLLSPEC
*spec
= imp
->spec
;
288 f
= open_input_file( NULL
, imp
->full_name
);
289 fstat( fileno(f
), &stat
);
290 imp
->dev
= stat
.st_dev
;
291 imp
->ino
= stat
.st_ino
;
292 ret
= parse_def_file( f
, spec
);
293 close_input_file( f
);
296 /* check if we already imported that library from a different file */
297 if ((prev_imp
= is_already_imported( spec
->file_name
)))
299 if (prev_imp
->dev
!= imp
->dev
|| prev_imp
->ino
!= imp
->ino
)
300 fatal_error( "%s and %s have the same export name '%s'\n",
301 prev_imp
->full_name
, imp
->full_name
, spec
->file_name
);
302 return 0; /* the same file was already loaded, ignore this one */
305 if (is_delayed_import( spec
->file_name
))
311 imp
->exports
= xmalloc( spec
->nb_entry_points
* sizeof(*imp
->exports
) );
313 for (i
= 0; i
< spec
->nb_entry_points
; i
++)
315 ORDDEF
*odp
= &spec
->entry_points
[i
];
317 if (odp
->type
!= TYPE_STDCALL
&& odp
->type
!= TYPE_CDECL
) continue;
318 if (odp
->flags
& FLAG_PRIVATE
) continue;
319 imp
->exports
[imp
->nb_exports
++] = odp
;
321 imp
->exports
= xrealloc( imp
->exports
, imp
->nb_exports
* sizeof(*imp
->exports
) );
323 qsort( imp
->exports
, imp
->nb_exports
, sizeof(*imp
->exports
), func_cmp
);
327 /* build the dll exported name from the import lib name or path */
328 static char *get_dll_name( const char *name
, const char *filename
)
334 const char *basename
= strrchr( filename
, '/' );
335 if (!basename
) basename
= filename
;
337 if (!strncmp( basename
, "lib", 3 )) basename
+= 3;
338 ret
= xmalloc( strlen(basename
) + 5 );
339 strcpy( ret
, basename
);
340 if (strendswith( ret
, ".def" )) ret
[strlen(ret
)-4] = 0;
344 ret
= xmalloc( strlen(name
) + 5 );
347 if (!strchr( ret
, '.' )) strcat( ret
, ".dll" );
351 /* add a dll to the list of imports */
352 void add_import_dll( const char *name
, const char *filename
)
354 struct import
*imp
= xmalloc( sizeof(*imp
) );
356 imp
->spec
= alloc_dll_spec();
357 imp
->spec
->file_name
= get_dll_name( name
, filename
);
364 if (filename
) imp
->full_name
= xstrdup( filename
);
365 else imp
->full_name
= find_library( name
);
367 if (read_import_lib( imp
))
369 dll_imports
= xrealloc( dll_imports
, (nb_imports
+1) * sizeof(*dll_imports
) );
370 dll_imports
[nb_imports
++] = imp
;
375 if (nb_errors
) exit(1);
379 /* add a library to the list of delayed imports */
380 void add_delayed_import( const char *name
)
383 char *fullname
= get_dll_name( name
, NULL
);
385 add_name( &delayed_imports
, fullname
);
386 if ((imp
= is_already_imported( fullname
)) && !imp
->delay
)
394 /* remove an imported dll, based on its index in the dll_imports array */
395 static void remove_import_dll( int index
)
397 struct import
*imp
= dll_imports
[index
];
399 memmove( &dll_imports
[index
], &dll_imports
[index
+1], sizeof(imp
) * (nb_imports
- index
- 1) );
401 if (imp
->delay
) nb_delayed
--;
405 /* initialize the list of ignored symbols */
406 static void init_ignored_symbols(void)
410 for (i
= 0; i
< sizeof(default_ignored_symbols
)/sizeof(default_ignored_symbols
[0]); i
++)
411 add_name( &ignore_symbols
, default_ignored_symbols
[i
] );
414 /* add a symbol to the ignored symbol list */
415 /* if the name starts with '-' the symbol is removed instead */
416 void add_ignore_symbol( const char *name
)
420 if (!ignore_symbols
.size
) init_ignored_symbols(); /* first time around, fill list with defaults */
422 if (name
[0] == '-') /* remove it */
424 if (!name
[1]) empty_name_table( &ignore_symbols
); /* remove everything */
425 else for (i
= 0; i
< ignore_symbols
.count
; i
++)
427 if (!strcmp( ignore_symbols
.names
[i
], name
+1 )) remove_name( &ignore_symbols
, i
-- );
430 else add_name( &ignore_symbols
, name
);
433 /* add a symbol to the list of extra symbols that ld must resolve */
434 void add_extra_ld_symbol( const char *name
)
436 add_name( &extra_ld_symbols
, name
);
439 /* add a function to the list of imports from a given dll */
440 static void add_import_func( struct import
*imp
, ORDDEF
*func
)
442 imp
->imports
= xrealloc( imp
->imports
, (imp
->nb_imports
+1) * sizeof(*imp
->imports
) );
443 imp
->imports
[imp
->nb_imports
++] = func
;
445 if (imp
->delay
) total_delayed
++;
448 /* get the default entry point for a given spec file */
449 static const char *get_default_entry_point( const DLLSPEC
*spec
)
451 if (spec
->characteristics
& IMAGE_FILE_DLL
) return "__wine_spec_dll_entry";
452 if (spec
->subsystem
== IMAGE_SUBSYSTEM_NATIVE
) return "__wine_spec_drv_entry";
453 return "__wine_spec_exe_entry";
456 /* check if the spec file exports any stubs */
457 static int has_stubs( const DLLSPEC
*spec
)
460 for (i
= 0; i
< spec
->nb_entry_points
; i
++)
462 ORDDEF
*odp
= &spec
->entry_points
[i
];
463 if (odp
->type
== TYPE_STUB
) return 1;
468 /* add the extra undefined symbols that will be contained in the generated spec file itself */
469 static void add_extra_undef_symbols( DLLSPEC
*spec
)
471 if (!spec
->init_func
) spec
->init_func
= xstrdup( get_default_entry_point(spec
) );
472 add_extra_ld_symbol( spec
->init_func
);
473 if (has_stubs( spec
)) add_extra_ld_symbol( "__wine_spec_unimplemented_stub" );
474 if (nb_delayed
) add_extra_ld_symbol( "__wine_spec_delay_load" );
477 /* check if a given imported dll is not needed, taking forwards into account */
478 static int check_unused( const struct import
* imp
, const DLLSPEC
*spec
)
481 const char *file_name
= imp
->spec
->file_name
;
482 size_t len
= strlen( file_name
);
483 const char *p
= strchr( file_name
, '.' );
484 if (p
&& !strcasecmp( p
, ".dll" )) len
= p
- file_name
;
486 for (i
= spec
->base
; i
<= spec
->limit
; i
++)
488 ORDDEF
*odp
= spec
->ordinals
[i
];
489 if (!odp
|| !(odp
->flags
& FLAG_FORWARD
)) continue;
490 if (!strncasecmp( odp
->link_name
, file_name
, len
) &&
491 odp
->link_name
[len
] == '.')
492 return 0; /* found a forward, it is used */
497 /* flag the dll exports that link to an undefined symbol */
498 static void check_undefined_exports( DLLSPEC
*spec
)
502 for (i
= 0; i
< spec
->nb_entry_points
; i
++)
504 ORDDEF
*odp
= &spec
->entry_points
[i
];
505 if (odp
->type
== TYPE_STUB
) continue;
506 if (odp
->flags
& FLAG_FORWARD
) continue;
507 if (find_name( odp
->link_name
, &undef_symbols
))
509 odp
->flags
|= FLAG_EXT_LINK
;
510 add_name( &ext_link_imports
, odp
->link_name
);
515 /* create a .o file that references all the undefined symbols we want to resolve */
516 static char *create_undef_symbols_file( DLLSPEC
*spec
)
518 char *as_file
, *obj_file
;
522 as_file
= get_temp_file_name( output_file_name
, ".s" );
523 if (!(f
= fopen( as_file
, "w" ))) fatal_error( "Cannot create %s\n", as_file
);
524 fprintf( f
, "\t.data\n" );
526 for (i
= 0; i
< spec
->nb_entry_points
; i
++)
528 ORDDEF
*odp
= &spec
->entry_points
[i
];
529 if (odp
->type
== TYPE_STUB
) continue;
530 if (odp
->flags
& FLAG_FORWARD
) continue;
531 fprintf( f
, "\t%s %s\n", get_asm_ptr_keyword(), asm_name(odp
->link_name
) );
533 for (i
= 0; i
< extra_ld_symbols
.count
; i
++)
534 fprintf( f
, "\t%s %s\n", get_asm_ptr_keyword(), asm_name(extra_ld_symbols
.names
[i
]) );
537 obj_file
= get_temp_file_name( output_file_name
, ".o" );
538 assemble_file( as_file
, obj_file
);
542 /* combine a list of object files with ld into a single object file */
543 /* returns the name of the combined file */
544 static const char *ldcombine_files( DLLSPEC
*spec
, char **argv
)
546 unsigned int i
, len
= 0;
547 char *cmd
, *p
, *ld_tmp_file
, *undef_file
;
550 undef_file
= create_undef_symbols_file( spec
);
551 len
+= strlen(undef_file
) + 1;
552 ld_tmp_file
= get_temp_file_name( output_file_name
, ".o" );
553 if (!ld_command
) ld_command
= xstrdup("ld");
554 for (i
= 0; argv
[i
]; i
++) len
+= strlen(argv
[i
]) + 1;
555 cmd
= p
= xmalloc( len
+ strlen(ld_tmp_file
) + 8 + strlen(ld_command
) );
556 p
+= sprintf( cmd
, "%s -r -o %s %s", ld_command
, ld_tmp_file
, undef_file
);
557 for (i
= 0; argv
[i
]; i
++)
558 p
+= sprintf( p
, " %s", argv
[i
] );
559 if (verbose
) fprintf( stderr
, "%s\n", cmd
);
561 if (err
) fatal_error( "%s -r failed with status %d\n", ld_command
, err
);
566 /* read in the list of undefined symbols */
567 void read_undef_symbols( DLLSPEC
*spec
, char **argv
)
571 char *cmd
, buffer
[1024], name_prefix
[16];
575 if (!argv
[0]) return;
577 add_extra_undef_symbols( spec
);
579 strcpy( name_prefix
, asm_name("") );
580 prefix_len
= strlen( name_prefix
);
582 name
= ldcombine_files( spec
, argv
);
584 if (!nm_command
) nm_command
= xstrdup("nm");
585 cmd
= xmalloc( strlen(nm_command
) + strlen(name
) + 5 );
586 sprintf( cmd
, "%s -u %s", nm_command
, name
);
587 if (!(f
= popen( cmd
, "r" )))
588 fatal_error( "Cannot execute '%s'\n", cmd
);
590 while (fgets( buffer
, sizeof(buffer
), f
))
592 char *p
= buffer
+ strlen(buffer
) - 1;
593 if (p
< buffer
) continue;
594 if (*p
== '\n') *p
-- = 0;
596 while (*p
== ' ') p
++;
597 if (p
[0] == 'U' && p
[1] == ' ' && p
[2]) p
+= 2;
598 if (prefix_len
&& !strncmp( p
, name_prefix
, prefix_len
)) p
+= prefix_len
;
599 add_name( &undef_symbols
, p
);
601 if ((err
= pclose( f
))) warning( "%s failed with status %d\n", cmd
, err
);
605 /* resolve the imports for a Win32 module */
606 int resolve_imports( DLLSPEC
*spec
)
608 unsigned int i
, j
, removed
;
611 if (!ignore_symbols
.size
) init_ignored_symbols();
612 sort_names( &ignore_symbols
);
614 for (i
= 0; i
< nb_imports
; i
++)
616 struct import
*imp
= dll_imports
[i
];
618 for (j
= removed
= 0; j
< undef_symbols
.count
; j
++)
620 if (find_name( undef_symbols
.names
[j
], &ignore_symbols
)) continue;
621 odp
= find_export( undef_symbols
.names
[j
], imp
->exports
, imp
->nb_exports
);
624 add_import_func( imp
, odp
);
625 remove_name( &undef_symbols
, j
-- );
629 if (!removed
&& check_unused( imp
, spec
))
631 /* the dll is not used, get rid of it */
632 warning( "%s imported but no symbols used\n", imp
->spec
->file_name
);
633 remove_import_dll( i
);
638 sort_names( &undef_symbols
);
639 check_undefined_exports( spec
);
644 /* output the get_pc thunk if needed */
645 void output_get_pc_thunk( FILE *outfile
)
647 if (target_cpu
!= CPU_x86
) return;
649 fprintf( outfile
, "\n\t.text\n" );
650 fprintf( outfile
, "\t.align %d\n", get_alignment(4) );
651 fprintf( outfile
, "\t%s\n", func_declaration("__wine_spec_get_pc_thunk_eax") );
652 fprintf( outfile
, "%s:\n", asm_name("__wine_spec_get_pc_thunk_eax") );
653 fprintf( outfile
, "\tpopl %%eax\n" );
654 fprintf( outfile
, "\tpushl %%eax\n" );
655 fprintf( outfile
, "\tret\n" );
656 output_function_size( outfile
, "__wine_spec_get_pc_thunk_eax" );
659 /* output a single import thunk */
660 static void output_import_thunk( FILE *outfile
, const char *name
, const char *table
, int pos
)
662 fprintf( outfile
, "\n\t.align %d\n", get_alignment(4) );
663 fprintf( outfile
, "\t%s\n", func_declaration(name
) );
664 fprintf( outfile
, "%s\n", asm_globl(name
) );
671 fprintf( outfile
, "\tjmp *(%s+%d)\n", table
, pos
);
675 fprintf( outfile
, "\tcall %s\n", asm_name("__wine_spec_get_pc_thunk_eax") );
676 fprintf( outfile
, "1:\tjmp *%s+%d-1b(%%eax)\n", table
, pos
);
680 fprintf( outfile
, "\tjmpq *%s+%d(%%rip)\n", table
, pos
);
685 fprintf( outfile
, "\tsethi %%hi(%s+%d), %%g1\n", table
, pos
);
686 fprintf( outfile
, "\tld [%%g1+%%lo(%s+%d)], %%g1\n", table
, pos
);
687 fprintf( outfile
, "\tjmp %%g1\n" );
688 fprintf( outfile
, "\tnop\n" );
692 /* Hmpf. Stupid sparc assembler always interprets global variable
693 names as GOT offsets, so we have to do it the long way ... */
694 fprintf( outfile
, "\tsave %%sp, -96, %%sp\n" );
695 fprintf( outfile
, "0:\tcall 1f\n" );
696 fprintf( outfile
, "\tnop\n" );
697 fprintf( outfile
, "1:\tsethi %%hi(%s+%d-0b), %%g1\n", table
, pos
);
698 fprintf( outfile
, "\tor %%g1, %%lo(%s+%d-0b), %%g1\n", table
, pos
);
699 fprintf( outfile
, "\tld [%%g1+%%o7], %%g1\n" );
700 fprintf( outfile
, "\tjmp %%g1\n" );
701 fprintf( outfile
, "\trestore\n" );
705 fprintf( outfile
, "\tlda $0,%s\n", table
);
706 fprintf( outfile
, "\tlda $0,%d($0)\n", pos
);
707 fprintf( outfile
, "\tjmp $31,($0)\n" );
710 fprintf( outfile
, "\taddi %s, %s, -0x4\n", ppc_reg(1), ppc_reg(1) );
711 fprintf( outfile
, "\tstw %s, 0(%s)\n", ppc_reg(9), ppc_reg(1) );
712 fprintf( outfile
, "\taddi %s, %s, -0x4\n", ppc_reg(1), ppc_reg(1) );
713 fprintf( outfile
, "\tstw %s, 0(%s)\n", ppc_reg(8), ppc_reg(1) );
714 fprintf( outfile
, "\taddi %s, %s, -0x4\n", ppc_reg(1), ppc_reg(1) );
715 fprintf( outfile
, "\tstw %s, 0(%s)\n", ppc_reg(7), ppc_reg(1) );
716 if (target_platform
== PLATFORM_APPLE
)
718 fprintf( outfile
, "\tlis %s, ha16(%s+%d)\n", ppc_reg(9), table
, pos
);
719 fprintf( outfile
, "\tla %s, lo16(%s+%d)(%s)\n", ppc_reg(8), table
, pos
, ppc_reg(9) );
723 fprintf( outfile
, "\tlis %s, (%s+%d)@h\n", ppc_reg(9), table
, pos
);
724 fprintf( outfile
, "\tla %s, (%s+%d)@l(%s)\n", ppc_reg(8), table
, pos
, ppc_reg(9) );
726 fprintf( outfile
, "\tlwz %s, 0(%s)\n", ppc_reg(7), ppc_reg(8) );
727 fprintf( outfile
, "\tmtctr %s\n", ppc_reg(7) );
728 fprintf( outfile
, "\tlwz %s, 0(%s)\n", ppc_reg(7), ppc_reg(1) );
729 fprintf( outfile
, "\taddi %s, %s, 0x4\n", ppc_reg(1), ppc_reg(1) );
730 fprintf( outfile
, "\tlwz %s, 0(%s)\n", ppc_reg(8), ppc_reg(1) );
731 fprintf( outfile
, "\taddi %s, %s, 0x4\n", ppc_reg(1), ppc_reg(1) );
732 fprintf( outfile
, "\tlwz %s, 0(%s)\n", ppc_reg(9), ppc_reg(1) );
733 fprintf( outfile
, "\taddi %s, %s, 0x4\n", ppc_reg(1), ppc_reg(1) );
734 fprintf( outfile
, "\tbctr\n" );
737 output_function_size( outfile
, name
);
740 /* check if we need an import directory */
741 int has_imports(void)
743 return (nb_imports
- nb_delayed
) > 0;
746 /* output the import table of a Win32 module */
747 static void output_immediate_imports( FILE *outfile
)
750 const char *dll_name
;
752 if (nb_imports
== nb_delayed
) return; /* no immediate imports */
754 /* main import header */
756 fprintf( outfile
, "\n/* import table */\n" );
757 fprintf( outfile
, "\n\t.data\n" );
758 fprintf( outfile
, "\t.align %d\n", get_alignment(4) );
759 fprintf( outfile
, ".L__wine_spec_imports:\n" );
763 for (i
= j
= 0; i
< nb_imports
; i
++)
765 if (dll_imports
[i
]->delay
) continue;
766 dll_name
= make_c_identifier( dll_imports
[i
]->spec
->file_name
);
767 fprintf( outfile
, "\t.long 0\n" ); /* OriginalFirstThunk */
768 fprintf( outfile
, "\t.long 0\n" ); /* TimeDateStamp */
769 fprintf( outfile
, "\t.long 0\n" ); /* ForwarderChain */
770 fprintf( outfile
, "\t.long .L__wine_spec_import_name_%s-.L__wine_spec_rva_base\n", /* Name */
772 fprintf( outfile
, "\t.long .L__wine_spec_import_data_ptrs+%d-.L__wine_spec_rva_base\n", /* FirstThunk */
773 j
* get_ptr_size() );
774 j
+= dll_imports
[i
]->nb_imports
+ 1;
776 fprintf( outfile
, "\t.long 0\n" ); /* OriginalFirstThunk */
777 fprintf( outfile
, "\t.long 0\n" ); /* TimeDateStamp */
778 fprintf( outfile
, "\t.long 0\n" ); /* ForwarderChain */
779 fprintf( outfile
, "\t.long 0\n" ); /* Name */
780 fprintf( outfile
, "\t.long 0\n" ); /* FirstThunk */
782 fprintf( outfile
, "\n\t.align %d\n", get_alignment(get_ptr_size()) );
783 fprintf( outfile
, ".L__wine_spec_import_data_ptrs:\n" );
784 for (i
= 0; i
< nb_imports
; i
++)
786 if (dll_imports
[i
]->delay
) continue;
787 dll_name
= make_c_identifier( dll_imports
[i
]->spec
->file_name
);
788 for (j
= 0; j
< dll_imports
[i
]->nb_imports
; j
++)
790 ORDDEF
*odp
= dll_imports
[i
]->imports
[j
];
791 if (!(odp
->flags
& FLAG_NONAME
))
792 fprintf( outfile
, "\t%s .L__wine_spec_import_data_%s_%s-.L__wine_spec_rva_base\n",
793 get_asm_ptr_keyword(), dll_name
, odp
->name
);
796 if (get_ptr_size() == 8)
797 fprintf( outfile
, "\t.quad 0x800000000000%04x\n", odp
->ordinal
);
799 fprintf( outfile
, "\t.long 0x8000%04x\n", odp
->ordinal
);
802 fprintf( outfile
, "\t%s 0\n", get_asm_ptr_keyword() );
804 fprintf( outfile
, ".L__wine_spec_imports_end:\n" );
806 for (i
= 0; i
< nb_imports
; i
++)
808 if (dll_imports
[i
]->delay
) continue;
809 dll_name
= make_c_identifier( dll_imports
[i
]->spec
->file_name
);
810 for (j
= 0; j
< dll_imports
[i
]->nb_imports
; j
++)
812 ORDDEF
*odp
= dll_imports
[i
]->imports
[j
];
813 if (!(odp
->flags
& FLAG_NONAME
))
815 fprintf( outfile
, "\t.align %d\n", get_alignment(2) );
816 fprintf( outfile
, ".L__wine_spec_import_data_%s_%s:\n", dll_name
, odp
->name
);
817 fprintf( outfile
, "\t%s %d\n", get_asm_short_keyword(), odp
->ordinal
);
818 fprintf( outfile
, "\t%s \"%s\"\n", get_asm_string_keyword(), odp
->name
);
823 for (i
= 0; i
< nb_imports
; i
++)
825 if (dll_imports
[i
]->delay
) continue;
826 dll_name
= make_c_identifier( dll_imports
[i
]->spec
->file_name
);
827 fprintf( outfile
, ".L__wine_spec_import_name_%s:\n\t%s \"%s\"\n",
828 dll_name
, get_asm_string_keyword(), dll_imports
[i
]->spec
->file_name
);
832 /* output the import thunks of a Win32 module */
833 static void output_immediate_import_thunks( FILE *outfile
)
836 int nb_imm
= nb_imports
- nb_delayed
;
837 static const char import_thunks
[] = "__wine_spec_import_thunks";
841 fprintf( outfile
, "\n/* immediate import thunks */\n\n" );
842 fprintf( outfile
, "\t.text\n" );
843 fprintf( outfile
, "\t.align %d\n", get_alignment(8) );
844 fprintf( outfile
, "%s:\n", asm_name(import_thunks
));
846 for (i
= pos
= 0; i
< nb_imports
; i
++)
848 if (dll_imports
[i
]->delay
) continue;
849 for (j
= 0; j
< dll_imports
[i
]->nb_imports
; j
++, pos
+= get_ptr_size())
851 ORDDEF
*odp
= dll_imports
[i
]->imports
[j
];
852 output_import_thunk( outfile
, odp
->name
? odp
->name
: odp
->export_name
,
853 ".L__wine_spec_import_data_ptrs", pos
);
855 pos
+= get_ptr_size();
857 output_function_size( outfile
, import_thunks
);
860 /* output the delayed import table of a Win32 module */
861 static void output_delayed_imports( FILE *outfile
, const DLLSPEC
*spec
)
865 if (!nb_delayed
) return;
867 fprintf( outfile
, "\n/* delayed imports */\n\n" );
868 fprintf( outfile
, "\t.data\n" );
869 fprintf( outfile
, "\t.align %d\n", get_alignment(get_ptr_size()) );
870 fprintf( outfile
, "%s\n", asm_globl("__wine_spec_delay_imports") );
874 for (i
= j
= 0; i
< nb_imports
; i
++)
876 if (!dll_imports
[i
]->delay
) continue;
877 fprintf( outfile
, "\t%s 0\n", get_asm_ptr_keyword() ); /* grAttrs */
878 fprintf( outfile
, "\t%s .L__wine_delay_name_%d\n", /* szName */
879 get_asm_ptr_keyword(), i
);
880 fprintf( outfile
, "\t%s .L__wine_delay_modules+%d\n", /* phmod */
881 get_asm_ptr_keyword(), i
* get_ptr_size() );
882 fprintf( outfile
, "\t%s .L__wine_delay_IAT+%d\n", /* pIAT */
883 get_asm_ptr_keyword(), j
* get_ptr_size() );
884 fprintf( outfile
, "\t%s .L__wine_delay_INT+%d\n", /* pINT */
885 get_asm_ptr_keyword(), j
* get_ptr_size() );
886 fprintf( outfile
, "\t%s 0\n", get_asm_ptr_keyword() ); /* pBoundIAT */
887 fprintf( outfile
, "\t%s 0\n", get_asm_ptr_keyword() ); /* pUnloadIAT */
888 fprintf( outfile
, "\t%s 0\n", get_asm_ptr_keyword() ); /* dwTimeStamp */
889 j
+= dll_imports
[i
]->nb_imports
;
891 fprintf( outfile
, "\t%s 0\n", get_asm_ptr_keyword() ); /* grAttrs */
892 fprintf( outfile
, "\t%s 0\n", get_asm_ptr_keyword() ); /* szName */
893 fprintf( outfile
, "\t%s 0\n", get_asm_ptr_keyword() ); /* phmod */
894 fprintf( outfile
, "\t%s 0\n", get_asm_ptr_keyword() ); /* pIAT */
895 fprintf( outfile
, "\t%s 0\n", get_asm_ptr_keyword() ); /* pINT */
896 fprintf( outfile
, "\t%s 0\n", get_asm_ptr_keyword() ); /* pBoundIAT */
897 fprintf( outfile
, "\t%s 0\n", get_asm_ptr_keyword() ); /* pUnloadIAT */
898 fprintf( outfile
, "\t%s 0\n", get_asm_ptr_keyword() ); /* dwTimeStamp */
900 fprintf( outfile
, "\n.L__wine_delay_IAT:\n" );
901 for (i
= 0; i
< nb_imports
; i
++)
903 if (!dll_imports
[i
]->delay
) continue;
904 for (j
= 0; j
< dll_imports
[i
]->nb_imports
; j
++)
906 ORDDEF
*odp
= dll_imports
[i
]->imports
[j
];
907 const char *name
= odp
->name
? odp
->name
: odp
->export_name
;
908 fprintf( outfile
, "\t%s .L__wine_delay_imp_%d_%s\n",
909 get_asm_ptr_keyword(), i
, name
);
913 fprintf( outfile
, "\n.L__wine_delay_INT:\n" );
914 for (i
= 0; i
< nb_imports
; i
++)
916 if (!dll_imports
[i
]->delay
) continue;
917 for (j
= 0; j
< dll_imports
[i
]->nb_imports
; j
++)
919 ORDDEF
*odp
= dll_imports
[i
]->imports
[j
];
921 fprintf( outfile
, "\t%s %d\n", get_asm_ptr_keyword(), odp
->ordinal
);
923 fprintf( outfile
, "\t%s .L__wine_delay_data_%d_%s\n",
924 get_asm_ptr_keyword(), i
, odp
->name
);
928 fprintf( outfile
, "\n.L__wine_delay_modules:\n" );
929 for (i
= 0; i
< nb_imports
; i
++)
931 if (dll_imports
[i
]->delay
) fprintf( outfile
, "\t%s 0\n", get_asm_ptr_keyword() );
934 for (i
= 0; i
< nb_imports
; i
++)
936 if (!dll_imports
[i
]->delay
) continue;
937 fprintf( outfile
, ".L__wine_delay_name_%d:\n", i
);
938 fprintf( outfile
, "\t%s \"%s\"\n",
939 get_asm_string_keyword(), dll_imports
[i
]->spec
->file_name
);
942 for (i
= 0; i
< nb_imports
; i
++)
944 if (!dll_imports
[i
]->delay
) continue;
945 for (j
= 0; j
< dll_imports
[i
]->nb_imports
; j
++)
947 ORDDEF
*odp
= dll_imports
[i
]->imports
[j
];
948 if (!odp
->name
) continue;
949 fprintf( outfile
, ".L__wine_delay_data_%d_%s:\n", i
, odp
->name
);
950 fprintf( outfile
, "\t%s \"%s\"\n", get_asm_string_keyword(), odp
->name
);
953 output_function_size( outfile
, "__wine_spec_delay_imports" );
956 /* output the delayed import thunks of a Win32 module */
957 static void output_delayed_import_thunks( FILE *outfile
, const DLLSPEC
*spec
)
959 int i
, idx
, j
, pos
, extra_stack_storage
= 0;
960 static const char delayed_import_loaders
[] = "__wine_spec_delayed_import_loaders";
961 static const char delayed_import_thunks
[] = "__wine_spec_delayed_import_thunks";
963 if (!nb_delayed
) return;
965 fprintf( outfile
, "\n/* delayed import thunks */\n\n" );
966 fprintf( outfile
, "\t.text\n" );
967 fprintf( outfile
, "\t.align %d\n", get_alignment(8) );
968 fprintf( outfile
, "%s:\n", asm_name(delayed_import_loaders
));
969 fprintf( outfile
, "\t%s\n", func_declaration("__wine_delay_load_asm") );
970 fprintf( outfile
, "%s:\n", asm_name("__wine_delay_load_asm") );
974 fprintf( outfile
, "\tpushl %%ecx\n" );
975 fprintf( outfile
, "\tpushl %%edx\n" );
976 fprintf( outfile
, "\tpushl %%eax\n" );
977 fprintf( outfile
, "\tcall %s\n", asm_name("__wine_spec_delay_load") );
978 fprintf( outfile
, "\tpopl %%edx\n" );
979 fprintf( outfile
, "\tpopl %%ecx\n" );
980 fprintf( outfile
, "\tjmp *%%eax\n" );
983 fprintf( outfile
, "\tpushq %%rdi\n" );
984 fprintf( outfile
, "\tsubq $8,%%rsp\n" );
985 fprintf( outfile
, "\tmovq %%r11,%%rdi\n" );
986 fprintf( outfile
, "\tcall %s\n", asm_name("__wine_spec_delay_load") );
987 fprintf( outfile
, "\taddq $8,%%rsp\n" );
988 fprintf( outfile
, "\tpopq %%rdi\n" );
989 fprintf( outfile
, "\tjmp *%%rax\n" );
992 fprintf( outfile
, "\tsave %%sp, -96, %%sp\n" );
993 fprintf( outfile
, "\tcall %s\n", asm_name("__wine_spec_delay_load") );
994 fprintf( outfile
, "\tmov %%g1, %%o0\n" );
995 fprintf( outfile
, "\tjmp %%o0\n" );
996 fprintf( outfile
, "\trestore\n" );
999 fprintf( outfile
, "\tjsr $26,%s\n", asm_name("__wine_spec_delay_load") );
1000 fprintf( outfile
, "\tjmp $31,($0)\n" );
1003 if (target_platform
== PLATFORM_APPLE
) extra_stack_storage
= 56;
1005 /* Save all callee saved registers into a stackframe. */
1006 fprintf( outfile
, "\tstwu %s, -%d(%s)\n",ppc_reg(1), 48+extra_stack_storage
, ppc_reg(1));
1007 fprintf( outfile
, "\tstw %s, %d(%s)\n", ppc_reg(3), 4+extra_stack_storage
, ppc_reg(1));
1008 fprintf( outfile
, "\tstw %s, %d(%s)\n", ppc_reg(4), 8+extra_stack_storage
, ppc_reg(1));
1009 fprintf( outfile
, "\tstw %s, %d(%s)\n", ppc_reg(5), 12+extra_stack_storage
, ppc_reg(1));
1010 fprintf( outfile
, "\tstw %s, %d(%s)\n", ppc_reg(6), 16+extra_stack_storage
, ppc_reg(1));
1011 fprintf( outfile
, "\tstw %s, %d(%s)\n", ppc_reg(7), 20+extra_stack_storage
, ppc_reg(1));
1012 fprintf( outfile
, "\tstw %s, %d(%s)\n", ppc_reg(8), 24+extra_stack_storage
, ppc_reg(1));
1013 fprintf( outfile
, "\tstw %s, %d(%s)\n", ppc_reg(9), 28+extra_stack_storage
, ppc_reg(1));
1014 fprintf( outfile
, "\tstw %s, %d(%s)\n", ppc_reg(10),32+extra_stack_storage
, ppc_reg(1));
1015 fprintf( outfile
, "\tstw %s, %d(%s)\n", ppc_reg(11),36+extra_stack_storage
, ppc_reg(1));
1016 fprintf( outfile
, "\tstw %s, %d(%s)\n", ppc_reg(12),40+extra_stack_storage
, ppc_reg(1));
1018 /* r0 -> r3 (arg1) */
1019 fprintf( outfile
, "\tmr %s, %s\n", ppc_reg(3), ppc_reg(0));
1021 /* save return address */
1022 fprintf( outfile
, "\tmflr %s\n", ppc_reg(0));
1023 fprintf( outfile
, "\tstw %s, %d(%s)\n", ppc_reg(0), 44+extra_stack_storage
, ppc_reg(1));
1025 /* Call the __wine_delay_load function, arg1 is arg1. */
1026 fprintf( outfile
, "\tbl %s\n", asm_name("__wine_spec_delay_load") );
1028 /* Load return value from call into ctr register */
1029 fprintf( outfile
, "\tmtctr %s\n", ppc_reg(3));
1031 /* restore all saved registers and drop stackframe. */
1032 fprintf( outfile
, "\tlwz %s, %d(%s)\n", ppc_reg(3), 4+extra_stack_storage
, ppc_reg(1));
1033 fprintf( outfile
, "\tlwz %s, %d(%s)\n", ppc_reg(4), 8+extra_stack_storage
, ppc_reg(1));
1034 fprintf( outfile
, "\tlwz %s, %d(%s)\n", ppc_reg(5), 12+extra_stack_storage
, ppc_reg(1));
1035 fprintf( outfile
, "\tlwz %s, %d(%s)\n", ppc_reg(6), 16+extra_stack_storage
, ppc_reg(1));
1036 fprintf( outfile
, "\tlwz %s, %d(%s)\n", ppc_reg(7), 20+extra_stack_storage
, ppc_reg(1));
1037 fprintf( outfile
, "\tlwz %s, %d(%s)\n", ppc_reg(8), 24+extra_stack_storage
, ppc_reg(1));
1038 fprintf( outfile
, "\tlwz %s, %d(%s)\n", ppc_reg(9), 28+extra_stack_storage
, ppc_reg(1));
1039 fprintf( outfile
, "\tlwz %s, %d(%s)\n", ppc_reg(10),32+extra_stack_storage
, ppc_reg(1));
1040 fprintf( outfile
, "\tlwz %s, %d(%s)\n", ppc_reg(11),36+extra_stack_storage
, ppc_reg(1));
1041 fprintf( outfile
, "\tlwz %s, %d(%s)\n", ppc_reg(12),40+extra_stack_storage
, ppc_reg(1));
1043 /* Load return value from call into return register */
1044 fprintf( outfile
, "\tlwz %s, %d(%s)\n", ppc_reg(0), 44+extra_stack_storage
, ppc_reg(1));
1045 fprintf( outfile
, "\tmtlr %s\n", ppc_reg(0));
1046 fprintf( outfile
, "\taddi %s, %s, %d\n", ppc_reg(1), ppc_reg(1), 48+extra_stack_storage
);
1048 /* branch to ctr register. */
1049 fprintf( outfile
, "\tbctr\n");
1052 output_function_size( outfile
, "__wine_delay_load_asm" );
1053 fprintf( outfile
, "\n" );
1055 for (i
= idx
= 0; i
< nb_imports
; i
++)
1057 if (!dll_imports
[i
]->delay
) continue;
1058 for (j
= 0; j
< dll_imports
[i
]->nb_imports
; j
++)
1060 ORDDEF
*odp
= dll_imports
[i
]->imports
[j
];
1061 const char *name
= odp
->name
? odp
->name
: odp
->export_name
;
1063 fprintf( outfile
, ".L__wine_delay_imp_%d_%s:\n", i
, name
);
1067 fprintf( outfile
, "\tmovl $%d, %%eax\n", (idx
<< 16) | j
);
1068 fprintf( outfile
, "\tjmp %s\n", asm_name("__wine_delay_load_asm") );
1071 fprintf( outfile
, "\tmovq $%d,%%r11\n", (idx
<< 16) | j
);
1072 fprintf( outfile
, "\tjmp %s\n", asm_name("__wine_delay_load_asm") );
1075 fprintf( outfile
, "\tset %d, %%g1\n", (idx
<< 16) | j
);
1076 fprintf( outfile
, "\tb,a %s\n", asm_name("__wine_delay_load_asm") );
1079 fprintf( outfile
, "\tlda $0,%d($31)\n", j
);
1080 fprintf( outfile
, "\tldah $0,%d($0)\n", idx
);
1081 fprintf( outfile
, "\tjmp $31,%s\n", asm_name("__wine_delay_load_asm") );
1084 switch(target_platform
)
1086 case PLATFORM_APPLE
:
1087 /* On Darwin we can use r0 and r2 */
1088 /* Upper part in r2 */
1089 fprintf( outfile
, "\tlis %s, %d\n", ppc_reg(2), idx
);
1090 /* Lower part + r2 -> r0, Note we can't use r0 directly */
1091 fprintf( outfile
, "\taddi %s, %s, %d\n", ppc_reg(0), ppc_reg(2), j
);
1092 fprintf( outfile
, "\tb %s\n", asm_name("__wine_delay_load_asm") );
1095 /* On linux we can't use r2 since r2 is not a scratch register (hold the TOC) */
1096 /* Save r13 on the stack */
1097 fprintf( outfile
, "\taddi %s, %s, -0x4\n", ppc_reg(1), ppc_reg(1));
1098 fprintf( outfile
, "\tstw %s, 0(%s)\n", ppc_reg(13), ppc_reg(1));
1099 /* Upper part in r13 */
1100 fprintf( outfile
, "\tlis %s, %d\n", ppc_reg(13), idx
);
1101 /* Lower part + r13 -> r0, Note we can't use r0 directly */
1102 fprintf( outfile
, "\taddi %s, %s, %d\n", ppc_reg(0), ppc_reg(13), j
);
1104 fprintf( outfile
, "\tstw %s, 0(%s)\n", ppc_reg(13), ppc_reg(1));
1105 fprintf( outfile
, "\taddic %s, %s, 0x4\n", ppc_reg(1), ppc_reg(1));
1106 fprintf( outfile
, "\tb %s\n", asm_name("__wine_delay_load_asm") );
1114 output_function_size( outfile
, delayed_import_loaders
);
1116 fprintf( outfile
, "\n\t.align %d\n", get_alignment(get_ptr_size()) );
1117 fprintf( outfile
, "%s:\n", asm_name(delayed_import_thunks
));
1118 for (i
= pos
= 0; i
< nb_imports
; i
++)
1120 if (!dll_imports
[i
]->delay
) continue;
1121 for (j
= 0; j
< dll_imports
[i
]->nb_imports
; j
++, pos
+= get_ptr_size())
1123 ORDDEF
*odp
= dll_imports
[i
]->imports
[j
];
1124 output_import_thunk( outfile
, odp
->name
? odp
->name
: odp
->export_name
,
1125 ".L__wine_delay_IAT", pos
);
1128 output_function_size( outfile
, delayed_import_thunks
);
1131 /* output import stubs for exported entry points that link to external symbols */
1132 static void output_external_link_imports( FILE *outfile
, DLLSPEC
*spec
)
1134 unsigned int i
, pos
;
1136 if (!ext_link_imports
.count
) return; /* nothing to do */
1138 sort_names( &ext_link_imports
);
1140 /* get rid of duplicate names */
1141 for (i
= 1; i
< ext_link_imports
.count
; i
++)
1143 if (!strcmp( ext_link_imports
.names
[i
-1], ext_link_imports
.names
[i
] ))
1144 remove_name( &ext_link_imports
, i
-- );
1147 fprintf( outfile
, "\n/* external link thunks */\n\n" );
1148 fprintf( outfile
, "\t.data\n" );
1149 fprintf( outfile
, "\t.align %d\n", get_alignment(get_ptr_size()) );
1150 fprintf( outfile
, ".L__wine_spec_external_links:\n" );
1151 for (i
= 0; i
< ext_link_imports
.count
; i
++)
1152 fprintf( outfile
, "\t%s %s\n", get_asm_ptr_keyword(), asm_name(ext_link_imports
.names
[i
]) );
1154 fprintf( outfile
, "\n\t.text\n" );
1155 fprintf( outfile
, "\t.align %d\n", get_alignment(get_ptr_size()) );
1156 fprintf( outfile
, "%s:\n", asm_name("__wine_spec_external_link_thunks") );
1158 for (i
= pos
= 0; i
< ext_link_imports
.count
; i
++)
1161 sprintf( buffer
, "__wine_spec_ext_link_%s", ext_link_imports
.names
[i
] );
1162 output_import_thunk( outfile
, buffer
, ".L__wine_spec_external_links", pos
);
1163 pos
+= get_ptr_size();
1165 output_function_size( outfile
, "__wine_spec_external_link_thunks" );
1168 /*******************************************************************
1171 * Output the functions for stub entry points
1173 void output_stubs( FILE *outfile
, DLLSPEC
*spec
)
1175 const char *name
, *exp_name
;
1178 if (!has_stubs( spec
)) return;
1180 fprintf( outfile
, "\n/* stub functions */\n\n" );
1181 fprintf( outfile
, "\t.text\n" );
1183 for (i
= pos
= 0; i
< spec
->nb_entry_points
; i
++)
1185 ORDDEF
*odp
= &spec
->entry_points
[i
];
1186 if (odp
->type
!= TYPE_STUB
) continue;
1188 name
= get_stub_name( odp
, spec
);
1189 exp_name
= odp
->name
? odp
->name
: odp
->export_name
;
1190 fprintf( outfile
, "\t.align %d\n", get_alignment(4) );
1191 fprintf( outfile
, "\t%s\n", func_declaration(name
) );
1192 fprintf( outfile
, "%s:\n", asm_name(name
) );
1193 fprintf( outfile
, "\tsubl $4,%%esp\n" );
1197 fprintf( outfile
, "\tcall %s\n", asm_name("__wine_spec_get_pc_thunk_eax") );
1198 fprintf( outfile
, "1:" );
1201 fprintf( outfile
, "\tleal .L__wine_stub_strings+%d-1b(%%eax),%%ecx\n", pos
);
1202 fprintf( outfile
, "\tpushl %%ecx\n" );
1203 pos
+= strlen(exp_name
) + 1;
1206 fprintf( outfile
, "\tpushl $%d\n", odp
->ordinal
);
1207 fprintf( outfile
, "\tleal .L__wine_spec_file_name-1b(%%eax),%%ecx\n" );
1208 fprintf( outfile
, "\tpushl %%ecx\n" );
1214 fprintf( outfile
, "\tpushl $.L__wine_stub_strings+%d\n", pos
);
1215 pos
+= strlen(exp_name
) + 1;
1218 fprintf( outfile
, "\tpushl $%d\n", odp
->ordinal
);
1219 fprintf( outfile
, "\tpushl $.L__wine_spec_file_name\n" );
1221 fprintf( outfile
, "\tcall %s\n", asm_name("__wine_spec_unimplemented_stub") );
1222 output_function_size( outfile
, name
);
1227 fprintf( outfile
, "\t%s\n", get_asm_string_section() );
1228 fprintf( outfile
, ".L__wine_stub_strings:\n" );
1229 for (i
= 0; i
< spec
->nb_entry_points
; i
++)
1231 ORDDEF
*odp
= &spec
->entry_points
[i
];
1232 if (odp
->type
!= TYPE_STUB
) continue;
1233 exp_name
= odp
->name
? odp
->name
: odp
->export_name
;
1235 fprintf( outfile
, "\t%s \"%s\"\n", get_asm_string_keyword(), exp_name
);
1240 /* output the import and delayed import tables of a Win32 module */
1241 void output_imports( FILE *outfile
, DLLSPEC
*spec
)
1243 output_immediate_imports( outfile
);
1244 output_delayed_imports( outfile
, spec
);
1245 output_immediate_import_thunks( outfile
);
1246 output_delayed_import_thunks( outfile
, spec
);
1247 output_external_link_imports( outfile
, spec
);
1248 if (nb_imports
|| ext_link_imports
.count
|| has_stubs(spec
) || has_relays(spec
))
1249 output_get_pc_thunk( outfile
);