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
38 DLLSPEC
*spec
; /* description of the imported dll */
39 int delay
; /* delay or not dll loading ? */
40 ORDDEF
**exports
; /* functions exported from this dll */
41 int nb_exports
; /* number of exported functions */
42 ORDDEF
**imports
; /* functions we want to import from this dll */
43 int nb_imports
; /* number of imported functions */
46 static char **undef_symbols
; /* list of undefined symbols */
47 static int nb_undef_symbols
= -1;
48 static int undef_size
;
50 static char **ignore_symbols
; /* list of symbols to ignore */
51 static int nb_ignore_symbols
;
52 static int ignore_size
;
54 static char *ld_tmp_file
; /* ld temp file name */
56 static struct import
**dll_imports
= NULL
;
57 static int nb_imports
= 0; /* number of imported dlls (delayed or not) */
58 static int nb_delayed
= 0; /* number of delayed dlls */
59 static int total_imports
= 0; /* total number of imported functions */
60 static int total_delayed
= 0; /* total number of imported functions in delayed DLLs */
62 /* list of symbols that are ignored by default */
63 static const char * const default_ignored_symbols
[] =
115 # define ppc_high(mem) "ha16(" mem ")"
116 # define ppc_low(mem) "lo16(" mem ")"
117 static const char * const ppc_reg
[32] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
118 "r8", "r9", "r10","r11","r12","r13","r14","r15",
119 "r16","r17","r18","r19","r20","r21","r22","r23",
120 "r24","r25","r26","r27","r28","r29","r30","r31" };
121 # else /* __APPLE__ */
122 # define ppc_high(mem) "(" mem ")@hi"
123 # define ppc_low(mem) "(" mem ")@l"
124 static const char * const ppc_reg
[32] = { "0", "1", "2", "3", "4", "5", "6", "7",
125 "8", "9", "10","11","12","13","14","15",
126 "16","17","18","19","20","21","22","23",
127 "24","25","26","27","28","29","30","31" };
128 # endif /* __APPLE__ */
129 #endif /* __powerpc__ */
131 /* compare function names; helper for resolve_imports */
132 static int name_cmp( const void *name
, const void *entry
)
134 return strcmp( *(const char* const *)name
, *(const char* const *)entry
);
137 /* compare function names; helper for resolve_imports */
138 static int func_cmp( const void *func1
, const void *func2
)
140 const ORDDEF
*odp1
= *(const ORDDEF
* const *)func1
;
141 const ORDDEF
*odp2
= *(const ORDDEF
* const *)func2
;
142 return strcmp( odp1
->name
? odp1
->name
: odp1
->export_name
,
143 odp2
->name
? odp2
->name
: odp2
->export_name
);
146 /* locate a symbol in a (sorted) list */
147 inline static const char *find_symbol( const char *name
, char **table
, int size
)
152 res
= bsearch( &name
, table
, size
, sizeof(*table
), name_cmp
);
155 return res
? *res
: NULL
;
158 /* locate an export in a (sorted) export list */
159 inline static ORDDEF
*find_export( const char *name
, ORDDEF
**table
, int size
)
161 ORDDEF func
, *odp
, **res
= NULL
;
163 func
.name
= (char *)name
;
166 if (table
) res
= bsearch( &odp
, table
, size
, sizeof(*table
), func_cmp
);
167 return res
? *res
: NULL
;
170 /* sort a symbol table */
171 inline static void sort_symbols( char **table
, int size
)
174 qsort( table
, size
, sizeof(*table
), name_cmp
);
177 inline static void output_function_size( FILE *outfile
, const char *name
)
179 #ifdef HAVE_ASM_DOT_SIZE
180 fprintf( outfile
, " \"\\t.size " __ASM_NAME("%s") ", . - " __ASM_NAME("%s") "\\n\"\n", name
, name
);
184 /* free an import structure */
185 static void free_imports( struct import
*imp
)
187 free( imp
->exports
);
188 free( imp
->imports
);
189 free_dll_spec( imp
->spec
);
193 /* remove the temp file at exit */
194 static void remove_ld_tmp_file(void)
196 if (ld_tmp_file
) unlink( ld_tmp_file
);
199 /* check whether a given dll has already been imported */
200 static int is_already_imported( const char *name
)
204 for (i
= 0; i
< nb_imports
; i
++)
206 if (!strcmp( dll_imports
[i
]->spec
->file_name
, name
)) return 1;
211 /* open the .so library for a given dll in a specified path */
212 static char *try_library_path( const char *path
, const char *name
)
217 buffer
= xmalloc( strlen(path
) + strlen(name
) + 9 );
218 sprintf( buffer
, "%s/lib%s.def", path
, name
);
220 /* check if the file exists */
221 if ((fd
= open( buffer
, O_RDONLY
)) != -1)
230 /* open the .so library for a given dll */
231 static char *open_library( const char *name
)
236 for (i
= 0; i
< nb_lib_paths
; i
++)
238 if ((fullname
= try_library_path( lib_path
[i
], name
))) return fullname
;
240 fatal_error( "could not open .def file for %s\n", name
);
244 /* read in the list of exported symbols of an import library */
245 static int read_import_lib( const char *name
, struct import
*imp
)
250 DLLSPEC
*spec
= imp
->spec
;
255 fullname
= open_library( name
);
256 f
= open_input_file( NULL
, fullname
);
259 ret
= parse_def_file( f
, spec
);
260 close_input_file( f
);
262 if (is_already_imported( spec
->file_name
)) return 0;
264 imp
->exports
= xmalloc( spec
->nb_entry_points
* sizeof(*imp
->exports
) );
266 for (i
= 0; i
< spec
->nb_entry_points
; i
++)
268 ORDDEF
*odp
= &spec
->entry_points
[i
];
270 if (odp
->type
!= TYPE_STDCALL
&& odp
->type
!= TYPE_CDECL
) continue;
271 if (odp
->flags
& FLAG_PRIVATE
) continue;
272 imp
->exports
[imp
->nb_exports
++] = odp
;
274 imp
->exports
= xrealloc( imp
->exports
, imp
->nb_exports
* sizeof(*imp
->exports
) );
276 qsort( imp
->exports
, imp
->nb_exports
, sizeof(*imp
->exports
), func_cmp
);
280 /* add a dll to the list of imports */
281 void add_import_dll( const char *name
, int delay
)
286 fullname
= xmalloc( strlen(name
) + 5 );
287 strcpy( fullname
, name
);
288 if (!strchr( fullname
, '.' )) strcat( fullname
, ".dll" );
290 /* check if we already imported it */
291 if (is_already_imported( fullname
))
297 imp
= xmalloc( sizeof(*imp
) );
298 imp
->spec
= alloc_dll_spec();
299 imp
->spec
->file_name
= fullname
;
303 if (delay
) nb_delayed
++;
305 if (read_import_lib( name
, imp
))
307 dll_imports
= xrealloc( dll_imports
, (nb_imports
+1) * sizeof(*dll_imports
) );
308 dll_imports
[nb_imports
++] = imp
;
313 if (nb_errors
) exit(1);
317 /* remove an imported dll, based on its index in the dll_imports array */
318 static void remove_import_dll( int index
)
320 struct import
*imp
= dll_imports
[index
];
322 memmove( &dll_imports
[index
], &dll_imports
[index
+1], sizeof(imp
) * (nb_imports
- index
- 1) );
324 if (imp
->delay
) nb_delayed
--;
328 /* initialize the list of ignored symbols */
329 static void init_ignored_symbols(void)
333 nb_ignore_symbols
= sizeof(default_ignored_symbols
)/sizeof(default_ignored_symbols
[0]);
334 ignore_size
= nb_ignore_symbols
+ 32;
335 ignore_symbols
= xmalloc( ignore_size
* sizeof(*ignore_symbols
) );
336 for (i
= 0; i
< nb_ignore_symbols
; i
++)
337 ignore_symbols
[i
] = xstrdup( default_ignored_symbols
[i
] );
340 /* add a symbol to the ignored symbol list */
341 /* if the name starts with '-' the symbol is removed instead */
342 void add_ignore_symbol( const char *name
)
346 if (!ignore_symbols
) init_ignored_symbols(); /* first time around, fill list with defaults */
348 if (name
[0] == '-') /* remove it */
350 if (!name
[1]) /* remove everything */
352 for (i
= 0; i
< nb_ignore_symbols
; i
++) free( ignore_symbols
[i
] );
353 nb_ignore_symbols
= 0;
357 for (i
= 0; i
< nb_ignore_symbols
; i
++)
359 if (!strcmp( ignore_symbols
[i
], name
+1 ))
361 free( ignore_symbols
[i
] );
362 memmove( &ignore_symbols
[i
], &ignore_symbols
[i
+1], nb_ignore_symbols
- i
- 1 );
370 if (nb_ignore_symbols
== ignore_size
)
373 ignore_symbols
= xrealloc( ignore_symbols
, ignore_size
* sizeof(*ignore_symbols
) );
375 ignore_symbols
[nb_ignore_symbols
++] = xstrdup( name
);
379 /* add a function to the list of imports from a given dll */
380 static void add_import_func( struct import
*imp
, ORDDEF
*func
)
382 imp
->imports
= xrealloc( imp
->imports
, (imp
->nb_imports
+1) * sizeof(*imp
->imports
) );
383 imp
->imports
[imp
->nb_imports
++] = func
;
385 if (imp
->delay
) total_delayed
++;
388 /* add a symbol to the undef list */
389 inline static void add_undef_symbol( const char *name
)
391 if (nb_undef_symbols
== undef_size
)
394 undef_symbols
= xrealloc( undef_symbols
, undef_size
* sizeof(*undef_symbols
) );
396 undef_symbols
[nb_undef_symbols
++] = xstrdup( name
);
399 /* remove all the holes in the undefined symbol list; return the number of removed symbols */
400 static int remove_symbol_holes(void)
403 for (i
= off
= 0; i
< nb_undef_symbols
; i
++)
405 if (!undef_symbols
[i
]) off
++;
406 else undef_symbols
[i
- off
] = undef_symbols
[i
];
408 nb_undef_symbols
-= off
;
412 /* add a symbol to the extra list, but only if needed */
413 static int add_extra_symbol( const char **extras
, int *count
, const char *name
, const DLLSPEC
*spec
)
417 if (!find_symbol( name
, undef_symbols
, nb_undef_symbols
))
419 /* check if the symbol is being exported by this dll */
420 for (i
= 0; i
< spec
->nb_entry_points
; i
++)
422 ORDDEF
*odp
= &spec
->entry_points
[i
];
423 if (odp
->type
== TYPE_STDCALL
||
424 odp
->type
== TYPE_CDECL
||
425 odp
->type
== TYPE_VARARGS
||
426 odp
->type
== TYPE_EXTERN
)
428 if (odp
->name
&& !strcmp( odp
->name
, name
)) return 0;
431 extras
[*count
] = name
;
437 /* add the extra undefined symbols that will be contained in the generated spec file itself */
438 static void add_extra_undef_symbols( const DLLSPEC
*spec
)
440 const char *extras
[10];
441 int i
, count
= 0, nb_stubs
= 0, nb_regs
= 0;
442 int kernel_imports
= 0, ntdll_imports
= 0;
444 sort_symbols( undef_symbols
, nb_undef_symbols
);
446 for (i
= 0; i
< spec
->nb_entry_points
; i
++)
448 ORDDEF
*odp
= &spec
->entry_points
[i
];
449 if (odp
->type
== TYPE_STUB
) nb_stubs
++;
450 if (odp
->flags
& FLAG_REGISTER
) nb_regs
++;
453 /* add symbols that will be contained in the spec file itself */
454 if (!(spec
->characteristics
& IMAGE_FILE_DLL
))
456 switch (spec
->subsystem
)
458 case IMAGE_SUBSYSTEM_WINDOWS_GUI
:
459 case IMAGE_SUBSYSTEM_WINDOWS_CUI
:
460 kernel_imports
+= add_extra_symbol( extras
, &count
, "GetCommandLineA", spec
);
461 kernel_imports
+= add_extra_symbol( extras
, &count
, "GetStartupInfoA", spec
);
462 kernel_imports
+= add_extra_symbol( extras
, &count
, "GetModuleHandleA", spec
);
463 kernel_imports
+= add_extra_symbol( extras
, &count
, "ExitProcess", spec
);
469 kernel_imports
+= add_extra_symbol( extras
, &count
, "LoadLibraryA", spec
);
470 kernel_imports
+= add_extra_symbol( extras
, &count
, "GetProcAddress", spec
);
473 ntdll_imports
+= add_extra_symbol( extras
, &count
, "__wine_call_from_32_regs", spec
);
474 if (nb_delayed
|| nb_stubs
)
475 ntdll_imports
+= add_extra_symbol( extras
, &count
, "RtlRaiseException", spec
);
477 /* make sure we import the dlls that contain these functions */
478 if (kernel_imports
) add_import_dll( "kernel32", 0 );
479 if (ntdll_imports
) add_import_dll( "ntdll", 0 );
483 for (i
= 0; i
< count
; i
++) add_undef_symbol( extras
[i
] );
484 sort_symbols( undef_symbols
, nb_undef_symbols
);
488 /* check if a given imported dll is not needed, taking forwards into account */
489 static int check_unused( const struct import
* imp
, const DLLSPEC
*spec
)
492 const char *file_name
= imp
->spec
->file_name
;
493 size_t len
= strlen( file_name
);
494 const char *p
= strchr( file_name
, '.' );
495 if (p
&& !strcasecmp( p
, ".dll" )) len
= p
- file_name
;
497 for (i
= spec
->base
; i
<= spec
->limit
; i
++)
499 ORDDEF
*odp
= spec
->ordinals
[i
];
500 if (!odp
|| !(odp
->flags
& FLAG_FORWARD
)) continue;
501 if (!strncasecmp( odp
->link_name
, file_name
, len
) &&
502 odp
->link_name
[len
] == '.')
503 return 0; /* found a forward, it is used */
508 /* combine a list of object files with ld into a single object file */
509 /* returns the name of the combined file */
510 static const char *ldcombine_files( char **argv
)
516 if (output_file_name
&& output_file_name
[0])
518 ld_tmp_file
= xmalloc( strlen(output_file_name
) + 10 );
519 strcpy( ld_tmp_file
, output_file_name
);
520 strcat( ld_tmp_file
, ".XXXXXX.o" );
522 else ld_tmp_file
= xstrdup( "/tmp/winebuild.tmp.XXXXXX.o" );
524 if ((fd
= mkstemps( ld_tmp_file
, 2 ) == -1)) fatal_error( "could not generate a temp file\n" );
526 atexit( remove_ld_tmp_file
);
528 for (i
= 0; argv
[i
]; i
++) len
+= strlen(argv
[i
]) + 1;
529 cmd
= xmalloc( len
+ strlen(ld_tmp_file
) + 8 + strlen(ld_command
) );
530 sprintf( cmd
, "%s -r -o %s", ld_command
, ld_tmp_file
);
531 for (i
= 0; argv
[i
]; i
++) sprintf( cmd
+ strlen(cmd
), " %s", argv
[i
] );
533 if (err
) fatal_error( "%s -r failed with status %d\n", ld_command
, err
);
538 /* read in the list of undefined symbols */
539 void read_undef_symbols( char **argv
)
541 static const char name_prefix
[] = __ASM_NAME("");
542 static const int prefix_len
= sizeof(name_prefix
) - 1;
544 char *cmd
, buffer
[1024];
548 if (!argv
[0]) return;
550 undef_size
= nb_undef_symbols
= 0;
552 /* if we have multiple object files, link them together */
553 if (argv
[1]) name
= ldcombine_files( argv
);
556 cmd
= xmalloc( strlen(nm_command
) + strlen(name
) + 5 );
557 sprintf( cmd
, "%s -u %s", nm_command
, name
);
558 if (!(f
= popen( cmd
, "r" )))
559 fatal_error( "Cannot execute '%s'\n", cmd
);
561 while (fgets( buffer
, sizeof(buffer
), f
))
563 char *p
= buffer
+ strlen(buffer
) - 1;
564 if (p
< buffer
) continue;
565 if (*p
== '\n') *p
-- = 0;
567 while (*p
== ' ') p
++;
568 if (p
[0] == 'U' && p
[1] == ' ' && p
[2]) p
+= 2;
569 if (prefix_len
&& !strncmp( p
, name_prefix
, prefix_len
)) p
+= prefix_len
;
570 add_undef_symbol( p
);
572 if ((err
= pclose( f
))) warning( "%s failed with status %d\n", cmd
, err
);
576 static void remove_ignored_symbols(void)
580 if (!ignore_symbols
) init_ignored_symbols();
581 sort_symbols( ignore_symbols
, nb_ignore_symbols
);
582 for (i
= 0; i
< nb_undef_symbols
; i
++)
584 if (find_symbol( undef_symbols
[i
], ignore_symbols
, nb_ignore_symbols
))
586 free( undef_symbols
[i
] );
587 undef_symbols
[i
] = NULL
;
590 remove_symbol_holes();
593 /* resolve the imports for a Win32 module */
594 int resolve_imports( DLLSPEC
*spec
)
598 if (nb_undef_symbols
== -1) return 0; /* no symbol file specified */
600 add_extra_undef_symbols( spec
);
601 remove_ignored_symbols();
603 for (i
= 0; i
< nb_imports
; i
++)
605 struct import
*imp
= dll_imports
[i
];
607 for (j
= 0; j
< nb_undef_symbols
; j
++)
609 ORDDEF
*odp
= find_export( undef_symbols
[j
], imp
->exports
, imp
->nb_exports
);
612 add_import_func( imp
, odp
);
613 free( undef_symbols
[j
] );
614 undef_symbols
[j
] = NULL
;
617 /* remove all the holes in the undef symbols list */
618 if (!remove_symbol_holes() && check_unused( imp
, spec
))
620 /* the dll is not used, get rid of it */
621 warning( "%s imported but no symbols used\n", imp
->spec
->file_name
);
622 remove_import_dll( i
);
629 /* output the import table of a Win32 module */
630 static int output_immediate_imports( FILE *outfile
)
633 int nb_imm
= nb_imports
- nb_delayed
;
634 static const char import_thunks
[] = "__wine_spec_import_thunks";
636 if (!nb_imm
) goto done
;
638 /* main import header */
640 fprintf( outfile
, "\nstatic struct {\n" );
641 fprintf( outfile
, " struct {\n" );
642 fprintf( outfile
, " void *OriginalFirstThunk;\n" );
643 fprintf( outfile
, " unsigned int TimeDateStamp;\n" );
644 fprintf( outfile
, " unsigned int ForwarderChain;\n" );
645 fprintf( outfile
, " const char *Name;\n" );
646 fprintf( outfile
, " void *FirstThunk;\n" );
647 fprintf( outfile
, " } imp[%d];\n", nb_imm
+1 );
648 fprintf( outfile
, " const char *data[%d];\n",
649 total_imports
- total_delayed
+ nb_imm
);
650 fprintf( outfile
, "} imports = {\n {\n" );
654 for (i
= j
= 0; i
< nb_imports
; i
++)
656 if (dll_imports
[i
]->delay
) continue;
657 fprintf( outfile
, " { 0, 0, 0, \"%s\", &imports.data[%d] },\n",
658 dll_imports
[i
]->spec
->file_name
, j
);
659 j
+= dll_imports
[i
]->nb_imports
+ 1;
662 fprintf( outfile
, " { 0, 0, 0, 0, 0 },\n" );
663 fprintf( outfile
, " },\n {\n" );
665 /* list of imported functions */
667 for (i
= 0; i
< nb_imports
; i
++)
669 if (dll_imports
[i
]->delay
) continue;
670 fprintf( outfile
, " /* %s */\n", dll_imports
[i
]->spec
->file_name
);
671 for (j
= 0; j
< dll_imports
[i
]->nb_imports
; j
++)
673 ORDDEF
*odp
= dll_imports
[i
]->imports
[j
];
674 if (!(odp
->flags
& FLAG_NONAME
))
676 unsigned short ord
= odp
->ordinal
;
677 fprintf( outfile
, " \"\\%03o\\%03o%s\",\n",
678 *(unsigned char *)&ord
, *((unsigned char *)&ord
+ 1), odp
->name
);
681 fprintf( outfile
, " (char *)%d,\n", odp
->ordinal
);
683 fprintf( outfile
, " 0,\n" );
685 fprintf( outfile
, " }\n};\n\n" );
687 /* thunks for imported functions */
689 fprintf( outfile
, "#ifndef __GNUC__\nstatic void __asm__dummy_import(void) {\n#endif\n\n" );
690 pos
= (sizeof(void *) + 2*sizeof(unsigned int) + sizeof(const char *) + sizeof(void *)) *
691 (nb_imm
+ 1); /* offset of imports.data from start of imports */
692 fprintf( outfile
, "asm(\".text\\n\\t.align %d\\n\"\n", get_alignment(8) );
693 fprintf( outfile
, " \"" __ASM_NAME("%s") ":\\n\"\n", import_thunks
);
695 for (i
= 0; i
< nb_imports
; i
++)
697 if (dll_imports
[i
]->delay
) continue;
698 for (j
= 0; j
< dll_imports
[i
]->nb_imports
; j
++, pos
+= sizeof(const char *))
700 ORDDEF
*odp
= dll_imports
[i
]->imports
[j
];
701 const char *name
= odp
->name
? odp
->name
: odp
->export_name
;
702 fprintf( outfile
, " \"\\t" __ASM_FUNC("%s") "\\n\"\n", name
);
703 fprintf( outfile
, " \"\\t.globl " __ASM_NAME("%s") "\\n\"\n", name
);
704 fprintf( outfile
, " \"" __ASM_NAME("%s") ":\\n\\t", name
);
707 #if defined(__i386__)
708 if (strstr( name
, "__wine_call_from_16" ))
709 fprintf( outfile
, ".byte 0x2e\\n\\tjmp *(imports+%d)\\n\\tnop\\n", pos
);
711 fprintf( outfile
, "jmp *(imports+%d)\\n\\tmovl %%esi,%%esi\\n", pos
);
712 #elif defined(__sparc__)
715 fprintf( outfile
, "sethi %%hi(imports+%d), %%g1\\n\\t", pos
);
716 fprintf( outfile
, "ld [%%g1+%%lo(imports+%d)], %%g1\\n\\t", pos
);
717 fprintf( outfile
, "jmp %%g1\\n\\tnop\\n" );
721 /* Hmpf. Stupid sparc assembler always interprets global variable
722 names as GOT offsets, so we have to do it the long way ... */
723 fprintf( outfile
, "save %%sp, -96, %%sp\\n" );
724 fprintf( outfile
, "0:\\tcall 1f\\n\\tnop\\n" );
725 fprintf( outfile
, "1:\\tsethi %%hi(imports+%d-0b), %%g1\\n\\t", pos
);
726 fprintf( outfile
, "or %%g1, %%lo(imports+%d-0b), %%g1\\n\\t", pos
);
727 fprintf( outfile
, "ld [%%g1+%%o7], %%g1\\n\\t" );
728 fprintf( outfile
, "jmp %%g1\\n\\trestore\\n" );
731 #elif defined(__powerpc__)
732 fprintf(outfile
, "\taddi %s, %s, -0x4\\n\"\n", ppc_reg
[1], ppc_reg
[1]);
733 fprintf(outfile
, "\t\"\\tstw %s, 0(%s)\\n\"\n", ppc_reg
[9], ppc_reg
[1]);
734 fprintf(outfile
, "\t\"\\taddi %s, %s, -0x4\\n\"\n", ppc_reg
[1], ppc_reg
[1]);
735 fprintf(outfile
, "\t\"\\tstw %s, 0(%s)\\n\"\n", ppc_reg
[8], ppc_reg
[1]);
736 fprintf(outfile
, "\t\"\\taddi %s, %s, -0x4\\n\"\n", ppc_reg
[1], ppc_reg
[1]);
737 fprintf(outfile
, "\t\"\\tstw %s, 0(%s)\\n\"\n", ppc_reg
[7], ppc_reg
[1]);
739 fprintf(outfile
, "\t\"\\tlis %s, " ppc_high(__ASM_NAME("imports") "+ %d") "\\n\"\n", ppc_reg
[9], pos
);
740 fprintf(outfile
, "\t\"\\tla %s, " ppc_low (__ASM_NAME("imports") "+ %d") "(%s)\\n\"\n", ppc_reg
[8], pos
, ppc_reg
[9]);
741 fprintf(outfile
, "\t\"\\tlwz %s, 0(%s)\\n\"\n", ppc_reg
[7], ppc_reg
[8]);
742 fprintf(outfile
, "\t\"\\tmtctr %s\\n\"\n", ppc_reg
[7]);
744 fprintf(outfile
, "\t\"\\tlwz %s, 0(%s)\\n\"\n", ppc_reg
[7], ppc_reg
[1]);
745 fprintf(outfile
, "\t\"\\taddi %s, %s, 0x4\\n\"\n", ppc_reg
[1], ppc_reg
[1]);
746 fprintf(outfile
, "\t\"\\tlwz %s, 0(%s)\\n\"\n", ppc_reg
[8], ppc_reg
[1]);
747 fprintf(outfile
, "\t\"\\taddi %s, %s, 0x4\\n\"\n", ppc_reg
[1], ppc_reg
[1]);
748 fprintf(outfile
, "\t\"\\tlwz %s, 0(%s)\\n\"\n", ppc_reg
[9], ppc_reg
[1]);
749 fprintf(outfile
, "\t\"\\taddi %s, %s, 0x4\\n\"\n", ppc_reg
[1], ppc_reg
[1]);
750 fprintf(outfile
, "\t\"\\tbctr\\n");
751 #elif defined(__ALPHA__)
752 fprintf( outfile
, "\tlda $0,imports\\n\"\n" );
753 fprintf( outfile
, "\t\"\\tlda $0,%d($0)\\n\"\n", pos
);
754 fprintf( outfile
, "\t\"\\tjmp $31,($0)\\n" );
756 #error You need to define import thunks for your architecture!
758 #endif /*__REACTOS__*/
759 fprintf( outfile
, "\"\n" );
760 output_function_size( outfile
, name
);
764 output_function_size( outfile
, import_thunks
);
765 fprintf( outfile
, " \".text\");\n#ifndef __GNUC__\n}\n#endif\n\n" );
771 /* output the delayed import table of a Win32 module */
772 static int output_delayed_imports( FILE *outfile
, const DLLSPEC
*spec
)
775 static const char delayed_import_loaders
[] = "__wine_spec_delayed_import_loaders";
776 static const char delayed_import_thunks
[] = "__wine_spec_delayed_import_thunks";
778 if (!nb_delayed
) goto done
;
780 for (i
= 0; i
< nb_imports
; i
++)
782 if (!dll_imports
[i
]->delay
) continue;
783 fprintf( outfile
, "static void *__wine_delay_imp_%d_hmod;\n", i
);
784 for (j
= 0; j
< dll_imports
[i
]->nb_imports
; j
++)
786 ORDDEF
*odp
= dll_imports
[i
]->imports
[j
];
787 const char *name
= odp
->name
? odp
->name
: odp
->export_name
;
788 fprintf( outfile
, "void __wine_delay_imp_%d_%s();\n", i
, name
);
791 fprintf( outfile
, "\n" );
792 fprintf( outfile
, "static struct {\n" );
793 fprintf( outfile
, " struct ImgDelayDescr {\n" );
794 fprintf( outfile
, " unsigned int grAttrs;\n" );
795 fprintf( outfile
, " const char *szName;\n" );
796 fprintf( outfile
, " void **phmod;\n" );
797 fprintf( outfile
, " void **pIAT;\n" );
798 fprintf( outfile
, " const char **pINT;\n" );
799 fprintf( outfile
, " void* pBoundIAT;\n" );
800 fprintf( outfile
, " void* pUnloadIAT;\n" );
801 fprintf( outfile
, " unsigned long dwTimeStamp;\n" );
802 fprintf( outfile
, " } imp[%d];\n", nb_delayed
);
803 fprintf( outfile
, " void *IAT[%d];\n", total_delayed
);
804 fprintf( outfile
, " const char *INT[%d];\n", total_delayed
);
805 fprintf( outfile
, "} delay_imports = {\n" );
806 fprintf( outfile
, " {\n" );
807 for (i
= j
= 0; i
< nb_imports
; i
++)
809 if (!dll_imports
[i
]->delay
) continue;
810 fprintf( outfile
, " { 0, \"%s\", &__wine_delay_imp_%d_hmod, &delay_imports.IAT[%d], &delay_imports.INT[%d], 0, 0, 0 },\n",
811 dll_imports
[i
]->spec
->file_name
, i
, j
, j
);
812 j
+= dll_imports
[i
]->nb_imports
;
814 fprintf( outfile
, " },\n {\n" );
815 for (i
= 0; i
< nb_imports
; i
++)
817 if (!dll_imports
[i
]->delay
) continue;
818 fprintf( outfile
, " /* %s */\n", dll_imports
[i
]->spec
->file_name
);
819 for (j
= 0; j
< dll_imports
[i
]->nb_imports
; j
++)
821 ORDDEF
*odp
= dll_imports
[i
]->imports
[j
];
822 const char *name
= odp
->name
? odp
->name
: odp
->export_name
;
823 fprintf( outfile
, " &__wine_delay_imp_%d_%s,\n", i
, name
);
826 fprintf( outfile
, " },\n {\n" );
827 for (i
= 0; i
< nb_imports
; i
++)
829 if (!dll_imports
[i
]->delay
) continue;
830 fprintf( outfile
, " /* %s */\n", dll_imports
[i
]->spec
->file_name
);
831 for (j
= 0; j
< dll_imports
[i
]->nb_imports
; j
++)
833 ORDDEF
*odp
= dll_imports
[i
]->imports
[j
];
835 fprintf( outfile
, " (char *)%d,\n", odp
->ordinal
);
837 fprintf( outfile
, " \"%s\",\n", odp
->name
);
840 fprintf( outfile
, " }\n};\n\n" );
842 /* check if there's some stub defined. if so, exception struct
843 * is already defined, so don't emit it twice
845 for (i
= 0; i
< spec
->nb_entry_points
; i
++) if (spec
->entry_points
[i
].type
== TYPE_STUB
) break;
847 if (i
== spec
->nb_entry_points
) {
848 fprintf( outfile
, "struct exc_record {\n" );
849 fprintf( outfile
, " unsigned int code, flags;\n" );
850 fprintf( outfile
, " void *rec, *addr;\n" );
851 fprintf( outfile
, " unsigned int params;\n" );
852 fprintf( outfile
, " const void *info[15];\n" );
853 fprintf( outfile
, "};\n\n" );
854 fprintf( outfile
, "extern void __stdcall RtlRaiseException( struct exc_record * );\n" );
857 fprintf( outfile
, "extern void * __stdcall LoadLibraryA(const char*);\n");
858 fprintf( outfile
, "extern void * __stdcall GetProcAddress(void *, const char*);\n");
859 fprintf( outfile
, "\n" );
861 fprintf( outfile
, "void *__stdcall __wine_delay_load( int idx_nr )\n" );
862 fprintf( outfile
, "{\n" );
863 fprintf( outfile
, " int idx = idx_nr >> 16, nr = idx_nr & 0xffff;\n" );
864 fprintf( outfile
, " struct ImgDelayDescr *imd = delay_imports.imp + idx;\n" );
865 fprintf( outfile
, " void **pIAT = imd->pIAT + nr;\n" );
866 fprintf( outfile
, " const char** pINT = imd->pINT + nr;\n" );
867 fprintf( outfile
, " void *fn;\n\n" );
869 fprintf( outfile
, " if (!*imd->phmod) *imd->phmod = LoadLibraryA(imd->szName);\n" );
870 fprintf( outfile
, " if (*imd->phmod && (fn = GetProcAddress(*imd->phmod, *pINT)))\n");
871 fprintf( outfile
, " /* patch IAT with final value */\n" );
872 fprintf( outfile
, " return *pIAT = fn;\n" );
873 fprintf( outfile
, " else {\n");
874 fprintf( outfile
, " struct exc_record rec;\n" );
875 fprintf( outfile
, " rec.code = 0x80000100;\n" );
876 fprintf( outfile
, " rec.flags = 1;\n" );
877 fprintf( outfile
, " rec.rec = 0;\n" );
878 fprintf( outfile
, " rec.params = 2;\n" );
879 fprintf( outfile
, " rec.info[0] = imd->szName;\n" );
880 fprintf( outfile
, " rec.info[1] = *pINT;\n" );
881 fprintf( outfile
, "#ifdef __GNUC__\n" );
882 fprintf( outfile
, " rec.addr = __builtin_return_address(1);\n" );
883 fprintf( outfile
, "#else\n" );
884 fprintf( outfile
, " rec.addr = 0;\n" );
885 fprintf( outfile
, "#endif\n" );
886 fprintf( outfile
, " for (;;) RtlRaiseException( &rec );\n" );
887 fprintf( outfile
, " return 0; /* shouldn't go here */\n" );
888 fprintf( outfile
, " }\n}\n\n" );
890 fprintf( outfile
, "#ifndef __GNUC__\n" );
891 fprintf( outfile
, "static void __asm__dummy_delay_import(void) {\n" );
892 fprintf( outfile
, "#endif\n" );
894 fprintf( outfile
, "asm(\".align %d\\n\"\n", get_alignment(8) );
895 fprintf( outfile
, " \"" __ASM_NAME("%s") ":\\n\"\n", delayed_import_loaders
);
896 fprintf( outfile
, " \"\\t" __ASM_FUNC("__wine_delay_load_asm") "\\n\"\n" );
897 fprintf( outfile
, " \"" __ASM_NAME("__wine_delay_load_asm") ":\\n\"\n" );
898 #if defined(__i386__)
899 fprintf( outfile
, " \"\\tpushl %%ecx\\n\\tpushl %%edx\\n\\tpushl %%eax\\n\"\n" );
900 fprintf( outfile
, " \"\\tcall __wine_delay_load\\n\"\n" );
901 fprintf( outfile
, " \"\\tpopl %%edx\\n\\tpopl %%ecx\\n\\tjmp *%%eax\\n\"\n" );
902 #elif defined(__sparc__)
903 fprintf( outfile
, " \"\\tsave %%sp, -96, %%sp\\n\"\n" );
904 fprintf( outfile
, " \"\\tcall __wine_delay_load\\n\"\n" );
905 fprintf( outfile
, " \"\\tmov %%g1, %%o0\\n\"\n" );
906 fprintf( outfile
, " \"\\tjmp %%o0\\n\\trestore\\n\"\n" );
907 #elif defined(__powerpc__)
908 # if defined(__APPLE__)
909 /* On darwin an extra 56 bytes must be allowed for the linkage area+param area */
910 # define extra_stack_storage 56
912 # define extra_stack_storage 0
914 /* Save all callee saved registers into a stackframe. */
915 fprintf( outfile
, " \"\\tstwu %s, -%d(%s)\\n\"\n",ppc_reg
[1], 48+extra_stack_storage
, ppc_reg
[1]);
916 fprintf( outfile
, " \"\\tstw %s, %d(%s)\\n\"\n", ppc_reg
[3], 4+extra_stack_storage
, ppc_reg
[1]);
917 fprintf( outfile
, " \"\\tstw %s, %d(%s)\\n\"\n", ppc_reg
[4], 8+extra_stack_storage
, ppc_reg
[1]);
918 fprintf( outfile
, " \"\\tstw %s, %d(%s)\\n\"\n", ppc_reg
[5], 12+extra_stack_storage
, ppc_reg
[1]);
919 fprintf( outfile
, " \"\\tstw %s, %d(%s)\\n\"\n", ppc_reg
[6], 16+extra_stack_storage
, ppc_reg
[1]);
920 fprintf( outfile
, " \"\\tstw %s, %d(%s)\\n\"\n", ppc_reg
[7], 20+extra_stack_storage
, ppc_reg
[1]);
921 fprintf( outfile
, " \"\\tstw %s, %d(%s)\\n\"\n", ppc_reg
[8], 24+extra_stack_storage
, ppc_reg
[1]);
922 fprintf( outfile
, " \"\\tstw %s, %d(%s)\\n\"\n", ppc_reg
[9], 28+extra_stack_storage
, ppc_reg
[1]);
923 fprintf( outfile
, " \"\\tstw %s, %d(%s)\\n\"\n", ppc_reg
[10],32+extra_stack_storage
, ppc_reg
[1]);
924 fprintf( outfile
, " \"\\tstw %s, %d(%s)\\n\"\n", ppc_reg
[11],36+extra_stack_storage
, ppc_reg
[1]);
925 fprintf( outfile
, " \"\\tstw %s, %d(%s)\\n\"\n", ppc_reg
[12],40+extra_stack_storage
, ppc_reg
[1]);
927 /* r0 -> r3 (arg1) */
928 fprintf( outfile
, " \"\\tmr %s, %s\\n\"\n", ppc_reg
[3], ppc_reg
[0]);
930 /* save return address */
931 fprintf( outfile
, " \"\\tmflr %s\\n\"\n", ppc_reg
[0]);
932 fprintf( outfile
, " \"\\tstw %s, %d(%s)\\n\"\n", ppc_reg
[0], 44+extra_stack_storage
, ppc_reg
[1]);
934 /* Call the __wine_delay_load function, arg1 is arg1. */
935 fprintf( outfile
, " \"\\tbl " __ASM_NAME("__wine_delay_load") "\\n\"\n");
937 /* Load return value from call into ctr register */
938 fprintf( outfile
, " \"\\tmtctr %s\\n\"\n", ppc_reg
[3]);
940 /* restore all saved registers and drop stackframe. */
941 fprintf( outfile
, " \"\\tlwz %s, %d(%s)\\n\"\n", ppc_reg
[3], 4+extra_stack_storage
, ppc_reg
[1]);
942 fprintf( outfile
, " \"\\tlwz %s, %d(%s)\\n\"\n", ppc_reg
[4], 8+extra_stack_storage
, ppc_reg
[1]);
943 fprintf( outfile
, " \"\\tlwz %s, %d(%s)\\n\"\n", ppc_reg
[5], 12+extra_stack_storage
, ppc_reg
[1]);
944 fprintf( outfile
, " \"\\tlwz %s, %d(%s)\\n\"\n", ppc_reg
[6], 16+extra_stack_storage
, ppc_reg
[1]);
945 fprintf( outfile
, " \"\\tlwz %s, %d(%s)\\n\"\n", ppc_reg
[7], 20+extra_stack_storage
, ppc_reg
[1]);
946 fprintf( outfile
, " \"\\tlwz %s, %d(%s)\\n\"\n", ppc_reg
[8], 24+extra_stack_storage
, ppc_reg
[1]);
947 fprintf( outfile
, " \"\\tlwz %s, %d(%s)\\n\"\n", ppc_reg
[9], 28+extra_stack_storage
, ppc_reg
[1]);
948 fprintf( outfile
, " \"\\tlwz %s, %d(%s)\\n\"\n", ppc_reg
[10],32+extra_stack_storage
, ppc_reg
[1]);
949 fprintf( outfile
, " \"\\tlwz %s, %d(%s)\\n\"\n", ppc_reg
[11],36+extra_stack_storage
, ppc_reg
[1]);
950 fprintf( outfile
, " \"\\tlwz %s, %d(%s)\\n\"\n", ppc_reg
[12],40+extra_stack_storage
, ppc_reg
[1]);
952 /* Load return value from call into return register */
953 fprintf( outfile
, " \"\\tlwz %s, %d(%s)\\n\"\n", ppc_reg
[0], 44+extra_stack_storage
, ppc_reg
[1]);
954 fprintf( outfile
, " \"\\tmtlr %s\\n\"\n", ppc_reg
[0]);
955 fprintf( outfile
, " \"\\taddi %s, %s, %d\\n\"\n", ppc_reg
[1], ppc_reg
[1], 48+extra_stack_storage
);
957 /* branch to ctr register. */
958 fprintf( outfile
, " \"bctr\\n\"\n");
959 #elif defined(__ALPHA__)
960 fprintf( outfile
, " \"\\tjsr $26,__wine_delay_load\\n\"\n" );
961 fprintf( outfile
, " \"\\tjmp $31,($0)\\n\"\n" );
963 #error You need to defined delayed import thunks for your architecture!
965 output_function_size( outfile
, "__wine_delay_load_asm" );
967 for (i
= idx
= 0; i
< nb_imports
; i
++)
969 if (!dll_imports
[i
]->delay
) continue;
970 for (j
= 0; j
< dll_imports
[i
]->nb_imports
; j
++)
973 ORDDEF
*odp
= dll_imports
[i
]->imports
[j
];
974 const char *name
= odp
->name
? odp
->name
: odp
->export_name
;
976 sprintf( buffer
, "__wine_delay_imp_%d_%s", i
, name
);
977 fprintf( outfile
, " \"\\t" __ASM_FUNC("%s") "\\n\"\n", buffer
);
978 fprintf( outfile
, " \"" __ASM_NAME("%s") ":\\n\"\n", buffer
);
979 #if defined(__i386__)
980 fprintf( outfile
, " \"\\tmovl $%d, %%eax\\n\"\n", (idx
<< 16) | j
);
981 fprintf( outfile
, " \"\\tjmp __wine_delay_load_asm\\n\"\n" );
982 #elif defined(__sparc__)
983 fprintf( outfile
, " \"\\tset %d, %%g1\\n\"\n", (idx
<< 16) | j
);
984 fprintf( outfile
, " \"\\tb,a __wine_delay_load_asm\\n\"\n" );
985 #elif defined(__powerpc__)
987 /* On Darwin we can use r0 and r2 */
988 /* Upper part in r2 */
989 fprintf( outfile
, " \"\\tlis %s, %d\\n\"\n", ppc_reg
[2], idx
);
990 /* Lower part + r2 -> r0, Note we can't use r0 directly */
991 fprintf( outfile
, " \"\\taddi %s, %s, %d\\n\"\n", ppc_reg
[0], ppc_reg
[2], j
);
992 fprintf( outfile
, " \"\\tb " __ASM_NAME("__wine_delay_load_asm") "\\n\"\n");
993 #else /* __APPLE__ */
994 /* On linux we can't use r2 since r2 is not a scratch register (hold the TOC) */
995 /* Save r13 on the stack */
996 fprintf( outfile
, " \"\\taddi %s, %s, -0x4\\n\"\n", ppc_reg
[1], ppc_reg
[1]);
997 fprintf( outfile
, " \"\\tstw %s, 0(%s)\\n\"\n", ppc_reg
[13], ppc_reg
[1]);
998 /* Upper part in r13 */
999 fprintf( outfile
, " \"\\tlis %s, %d\\n\"\n", ppc_reg
[13], idx
);
1000 /* Lower part + r13 -> r0, Note we can't use r0 directly */
1001 fprintf( outfile
, " \"\\taddi %s, %s, %d\\n\"\n", ppc_reg
[0], ppc_reg
[13], j
);
1003 fprintf( outfile
, " \"\\tstw %s, 0(%s)\\n\"\n", ppc_reg
[13], ppc_reg
[1]);
1004 fprintf( outfile
, " \"\\taddic %s, %s, 0x4\\n\"\n", ppc_reg
[1], ppc_reg
[1]);
1005 fprintf( outfile
, " \"\\tb " __ASM_NAME("__wine_delay_load_asm") "\\n\"\n");
1006 #endif /* __APPLE__ */
1007 #elif defined(__ALPHA__)
1008 fprintf( outfile
, " \"\\tlda $0,%d($31)\\n\"\n", j
);
1009 fprintf( outfile
, " \"\\tldah $0,%d($0)\\n\"\n", idx
);
1010 fprintf( outfile
, " \"\\tjmp $31,__wine_delay_load_asm\\n\"\n" );
1012 #error You need to defined delayed import thunks for your architecture!
1014 output_function_size( outfile
, name
);
1018 output_function_size( outfile
, delayed_import_loaders
);
1020 fprintf( outfile
, "\n \".align %d\\n\"\n", get_alignment(8) );
1021 fprintf( outfile
, " \"" __ASM_NAME("%s") ":\\n\"\n", delayed_import_thunks
);
1022 pos
= nb_delayed
* 32;
1023 for (i
= 0; i
< nb_imports
; i
++)
1025 if (!dll_imports
[i
]->delay
) continue;
1026 for (j
= 0; j
< dll_imports
[i
]->nb_imports
; j
++, pos
+= 4)
1028 ORDDEF
*odp
= dll_imports
[i
]->imports
[j
];
1029 const char *name
= odp
->name
? odp
->name
: odp
->export_name
;
1031 fprintf( outfile
, " \"\\t" __ASM_FUNC("%s") "\\n\"\n", name
);
1032 fprintf( outfile
, " \"\\t.globl " __ASM_NAME("%s") "\\n\"\n", name
);
1033 fprintf( outfile
, " \"" __ASM_NAME("%s") ":\\n\\t\"", name
);
1034 #if defined(__i386__)
1035 if (strstr( name
, "__wine_call_from_16" ))
1036 fprintf( outfile
, "\".byte 0x2e\\n\\tjmp *(delay_imports+%d)\\n\\tnop\\n\"", pos
);
1038 fprintf( outfile
, "\"jmp *(delay_imports+%d)\\n\\tmovl %%esi,%%esi\\n\"", pos
);
1039 #elif defined(__sparc__)
1042 fprintf( outfile
, "\"sethi %%hi(delay_imports+%d), %%g1\\n\\t\"", pos
);
1043 fprintf( outfile
, "\"ld [%%g1+%%lo(delay_imports+%d)], %%g1\\n\\t\"", pos
);
1044 fprintf( outfile
, "\"jmp %%g1\\n\\tnop\\n\"" );
1048 /* Hmpf. Stupid sparc assembler always interprets global variable
1049 names as GOT offsets, so we have to do it the long way ... */
1050 fprintf( outfile
, "\"save %%sp, -96, %%sp\\n\"" );
1051 fprintf( outfile
, "\"0:\\tcall 1f\\n\\tnop\\n\"" );
1052 fprintf( outfile
, "\"1:\\tsethi %%hi(delay_imports+%d-0b), %%g1\\n\\t\"", pos
);
1053 fprintf( outfile
, "\"or %%g1, %%lo(delay_imports+%d-0b), %%g1\\n\\t\"", pos
);
1054 fprintf( outfile
, "\"ld [%%g1+%%o7], %%g1\\n\\t\"" );
1055 fprintf( outfile
, "\"jmp %%g1\\n\\trestore\\n\"" );
1058 #elif defined(__powerpc__)
1059 fprintf( outfile
, "\t\"addi %s, %s, -0x4\\n\"\n", ppc_reg
[1], ppc_reg
[1]);
1060 fprintf( outfile
, "\t\"\\tstw %s, 0(%s)\\n\"\n", ppc_reg
[9], ppc_reg
[1]);
1061 fprintf( outfile
, "\t\"\\taddi %s, %s, -0x4\\n\"\n", ppc_reg
[1], ppc_reg
[1]);
1062 fprintf( outfile
, "\t\"\\tstw %s, 0(%s)\\n\"\n", ppc_reg
[8], ppc_reg
[1]);
1063 fprintf( outfile
, "\t\"\\taddi %s, %s, -0x4\\n\"\n", ppc_reg
[1], ppc_reg
[1]);
1064 fprintf( outfile
, "\t\"\\tstw %s, 0(%s)\\n\"\n", ppc_reg
[7], ppc_reg
[1]);
1066 fprintf( outfile
, "\t\"\\tlis %s, " ppc_high(__ASM_NAME("delay_imports") "+ %d") "\\n\"\n", ppc_reg
[9], pos
);
1067 fprintf( outfile
, "\t\"\\tla %s, " ppc_low (__ASM_NAME("delay_imports") "+ %d") "(%s)\\n\"\n", ppc_reg
[8], pos
, ppc_reg
[9]);
1068 fprintf( outfile
, "\t\"\\tlwz %s, 0(%s)\\n\"\n", ppc_reg
[7], ppc_reg
[8]);
1069 fprintf( outfile
, "\t\"\\tmtctr %s\\n\"\n", ppc_reg
[7]);
1071 fprintf( outfile
, "\t\"\\tlwz %s, 0(%s)\\n\"\n", ppc_reg
[7], ppc_reg
[1]);
1072 fprintf( outfile
, "\t\"\\taddi %s, %s, 0x4\\n\"\n", ppc_reg
[1], ppc_reg
[1]);
1073 fprintf( outfile
, "\t\"\\tlwz %s, 0(%s)\\n\"\n", ppc_reg
[8], ppc_reg
[1]);
1074 fprintf( outfile
, "\t\"\\taddi %s, %s, 0x4\\n\"\n", ppc_reg
[1], ppc_reg
[1]);
1075 fprintf( outfile
, "\t\"\\tlwz %s, 0(%s)\\n\"\n", ppc_reg
[9], ppc_reg
[1]);
1076 fprintf( outfile
, "\t\"\\taddi %s, %s, 0x4\\n\"\n", ppc_reg
[1], ppc_reg
[1]);
1077 fprintf( outfile
, "\t\"\\tbctr\\n\"");
1078 #elif defined(__ALPHA__)
1079 fprintf( outfile
, "\t\"lda $0,delay_imports\\n\"\n" );
1080 fprintf( outfile
, "\t\"\\tlda $0,%d($0)\\n\"\n", pos
);
1081 fprintf( outfile
, "\t\"\\tjmp $31,($0)\\n\"" );
1083 #error You need to define delayed import thunks for your architecture!
1085 fprintf( outfile
, "\n" );
1086 output_function_size( outfile
, name
);
1089 output_function_size( outfile
, delayed_import_thunks
);
1090 fprintf( outfile
, ");\n" );
1091 fprintf( outfile
, "#ifndef __GNUC__\n" );
1092 fprintf( outfile
, "}\n" );
1093 fprintf( outfile
, "#endif\n" );
1094 fprintf( outfile
, "\n" );
1100 /* output the import and delayed import tables of a Win32 module
1101 * returns number of DLLs exported in 'immediate' mode
1103 int output_imports( FILE *outfile
, DLLSPEC
*spec
)
1105 output_delayed_imports( outfile
, spec
);
1106 return output_immediate_imports( outfile
);