~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/tools/winebuild/spec32.c

Version: ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~ [ wine-1.0-rc5 ] ~ [ wine-1.0-rc4 ] ~ [ wine-1.0-rc3 ] ~ [ wine-1.0-rc2 ] ~ [ wine-1.0-rc1 ] ~ [ wine-0.9.61 ] ~ [ wine-0.9.60 ] ~ [ wine-0.9.59 ] ~ [ wine-0.9.58 ] ~ [ wine-0.9.57 ] ~ [ wine-0.9.56 ] ~ [ wine-0.9.55 ] ~ [ wine-0.9.54 ] ~ [ wine-0.9.53 ] ~ [ wine-0.9.52 ] ~ [ wine-0.9.51 ] ~ [ wine-0.9.50 ] ~ [ wine-0.9.49 ] ~ [ wine-0.9.48 ] ~ [ wine-0.9.47 ] ~ [ wine-0.9.46 ] ~ [ wine-0.9.45 ] ~ [ wine-0.9.44 ] ~ [ wine-0.9.43 ] ~ [ wine-0.9.42 ] ~ [ wine-0.9.41 ] ~ [ wine-0.9.40 ] ~ [ wine-0.9.39 ] ~ [ wine-0.9.38 ] ~ [ wine-0.9.37 ] ~ [ wine-0.9.36 ] ~ [ wine-0.9.35 ] ~ [ wine-0.9.34 ] ~ [ wine-0.9.33 ] ~ [ wine-0.9.32 ] ~ [ wine-0.9.31 ] ~ [ wine-0.9.30 ] ~ [ wine-0.9.29 ] ~ [ wine-0.9.28 ] ~ [ wine-0.9.27 ] ~ [ wine-0.9.26 ] ~ [ wine-0.9.25 ] ~ [ wine-0.9.24 ] ~ [ wine-0.9.23 ] ~ [ wine-0.9.22 ] ~ [ wine-0.9.21 ] ~ [ wine-0.9.20 ] ~ [ wine-0.9.19 ] ~ [ wine-0.9.18 ] ~ [ wine-0.9.17 ] ~ [ wine-0.9.16 ] ~ [ wine-0.9.15 ] ~ [ wine-0.9.14 ] ~ [ wine-0.9.13 ] ~ [ wine-0.9.12 ] ~ [ wine-0.9.11 ] ~ [ wine-0.9.10 ] ~ [ wine-0.9.9 ] ~ [ wine-0.9.8 ] ~ [ wine-0.9.7 ] ~ [ wine-0.9.6 ] ~ [ wine-0.9.5 ] ~ [ wine-0.9.4 ] ~ [ wine-0.9.3 ] ~ [ wine-0.9.2 ] ~ [ wine-0.9.1 ] ~ [ wine-0.9 ] ~ [ wine20050930 ] ~ [ wine20050830 ] ~ [ wine20050725 ] ~ [ wine20050628 ] ~ [ wine20050524 ] ~ [ wine20050419 ] ~ [ wine20050310 ] ~ [ wine20050211 ] ~ [ wine20050111 ] ~ [ wine20041201 ] ~ [ wine20041019 ] ~ [ wine20040914 ] ~ [ wine20040813 ] ~ [ wine20040716 ] ~ [ wine20040615 ] ~ [ wine20040505 ] ~ [ wine20040408 ] ~ [ wine20040309 ] ~ [ wine20040213 ] ~ [ wine20040121 ] ~ [ wine20031212 ] ~ [ wine20031118 ] ~ [ wine20031016 ] ~ [ wine20030911 ] ~ [ wine20030813 ] ~ [ wine20030709 ] ~ [ wine20030618 ] ~ [ wine20030508 ] ~ [ wine20030408 ] ~ [ wine20030318 ] ~ [ wine20030219 ] ~ [ wine20030115 ] ~ [ wine20021219 ] ~ [ wine20021125 ] ~ [ wine20021031 ] ~ [ wine20021007 ] ~ [ wine20020904 ] ~ [ wine20020804 ] ~ [ wine20020710 ] ~ [ wine20020605 ] ~ [ wine20020509 ] ~ [ wine20020411 ] ~ [ wine20020310 ] ~ [ wine20020228 ] ~ [ wine20011226 ] ~ [ wine20011108 ] ~ [ wine20011004 ] ~ [ wine20010824 ] ~ [ wine20010731 ] ~ [ wine20010629 ] ~ [ wine20010510 ] ~ [ wine20010418 ] ~ [ wine20010326 ] ~ [ wine20010305 ] ~ [ wine20010216 ] ~ [ wine20010112 ] ~ [ wine20001222 ] ~ [ wine20001202 ] ~ [ wine20001026 ] ~ [ wine20001002 ] ~ [ wine20000909 ] ~ [ wine20000821 ] ~ [ wine20000801 ] ~ [ wine20000716 ] ~ [ wine20000326 ] ~ [ wine20000227 ] ~ [ wine20000130 ] ~ [ wine20000109 ] ~

  1 /*
  2  * 32-bit spec files
  3  *
  4  * Copyright 1993 Robert J. Amstadt
  5  * Copyright 1995 Martin von Loewis
  6  * Copyright 1995, 1996, 1997 Alexandre Julliard
  7  * Copyright 1997 Eric Youngdale
  8  * Copyright 1999 Ulrich Weigand
  9  *
 10  * This library is free software; you can redistribute it and/or
 11  * modify it under the terms of the GNU Lesser General Public
 12  * License as published by the Free Software Foundation; either
 13  * version 2.1 of the License, or (at your option) any later version.
 14  *
 15  * This library is distributed in the hope that it will be useful,
 16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 18  * Lesser General Public License for more details.
 19  *
 20  * You should have received a copy of the GNU Lesser General Public
 21  * License along with this library; if not, write to the Free Software
 22  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 23  */
 24 
 25 #include "config.h"
 26 #include "wine/port.h"
 27 
 28 #include <assert.h>
 29 #include <ctype.h>
 30 #include <stdarg.h>
 31 #include <string.h>
 32 
 33 #include "windef.h"
 34 #include "winbase.h"
 35 #include "wine/exception.h"
 36 #include "build.h"
 37 
 38 
 39 /* check if entry point needs a relay thunk */
 40 static inline int needs_relay( const ORDDEF *odp )
 41 {
 42     /* skip nonexistent entry points */
 43     if (!odp) return 0;
 44     /* skip non-functions */
 45     if ((odp->type != TYPE_STDCALL) && (odp->type != TYPE_CDECL)) return 0;
 46     /* skip norelay and forward entry points */
 47     if (odp->flags & (FLAG_NORELAY|FLAG_FORWARD)) return 0;
 48     return 1;
 49 }
 50 
 51 /* check if dll will output relay thunks */
 52 int has_relays( DLLSPEC *spec )
 53 {
 54     int i;
 55 
 56     if (target_cpu != CPU_x86) return 0;
 57 
 58     for (i = spec->base; i <= spec->limit; i++)
 59     {
 60         ORDDEF *odp = spec->ordinals[i];
 61         if (needs_relay( odp )) return 1;
 62     }
 63     return 0;
 64 }
 65 
 66 /*******************************************************************
 67  *         output_relay_debug
 68  *
 69  * Output entry points for relay debugging
 70  */
 71 static void output_relay_debug( DLLSPEC *spec )
 72 {
 73     int i;
 74     unsigned int j, args, flags;
 75 
 76     /* first the table of entry point offsets */
 77 
 78     output( "\t%s\n", get_asm_rodata_section() );
 79     output( "\t.align %d\n", get_alignment(4) );
 80     output( ".L__wine_spec_relay_entry_point_offsets:\n" );
 81 
 82     for (i = spec->base; i <= spec->limit; i++)
 83     {
 84         ORDDEF *odp = spec->ordinals[i];
 85 
 86         if (needs_relay( odp ))
 87             output( "\t.long .L__wine_spec_relay_entry_point_%d-__wine_spec_relay_entry_points\n", i );
 88         else
 89             output( "\t.long 0\n" );
 90     }
 91 
 92     /* then the table of argument types */
 93 
 94     output( "\t.align %d\n", get_alignment(4) );
 95     output( ".L__wine_spec_relay_arg_types:\n" );
 96 
 97     for (i = spec->base; i <= spec->limit; i++)
 98     {
 99         ORDDEF *odp = spec->ordinals[i];
100         unsigned int mask = 0;
101 
102         if (needs_relay( odp ))
103         {
104             for (j = 0; j < 16 && odp->u.func.arg_types[j]; j++)
105             {
106                 if (odp->u.func.arg_types[j] == 't') mask |= 1<< (j*2);
107                 if (odp->u.func.arg_types[j] == 'W') mask |= 2<< (j*2);
108             }
109         }
110         output( "\t.long 0x%08x\n", mask );
111     }
112 
113     /* then the relay thunks */
114 
115     output( "\t.text\n" );
116     output( "__wine_spec_relay_entry_points:\n" );
117     output( "\tnop\n" );  /* to avoid 0 offset */
118 
119     for (i = spec->base; i <= spec->limit; i++)
120     {
121         ORDDEF *odp = spec->ordinals[i];
122 
123         if (!needs_relay( odp )) continue;
124 
125         output( "\t.align %d\n", get_alignment(4) );
126         output( ".L__wine_spec_relay_entry_point_%d:\n", i );
127 
128         if (odp->flags & FLAG_REGISTER)
129             output( "\tpushl %%eax\n" );
130         else
131             output( "\tpushl %%esp\n" );
132 
133         args = strlen(odp->u.func.arg_types);
134         flags = 0;
135         if (odp->flags & FLAG_RET64) flags |= 1;
136         if (odp->type == TYPE_STDCALL) flags |= 2;
137         output( "\tpushl $%u\n", (flags << 24) | (args << 16) | (i - spec->base) );
138 
139         if (UsePIC)
140         {
141             output( "\tcall %s\n", asm_name("__wine_spec_get_pc_thunk_eax") );
142             output( "1:\tleal .L__wine_spec_relay_descr-1b(%%eax),%%eax\n" );
143         }
144         else output( "\tmovl $.L__wine_spec_relay_descr,%%eax\n" );
145         output( "\tpushl %%eax\n" );
146 
147         if (odp->flags & FLAG_REGISTER)
148         {
149             output( "\tcall *8(%%eax)\n" );
150         }
151         else
152         {
153             output( "\tcall *4(%%eax)\n" );
154             if (odp->type == TYPE_STDCALL)
155                 output( "\tret $%u\n", args * get_ptr_size() );
156             else
157                 output( "\tret\n" );
158         }
159     }
160 }
161 
162 /*******************************************************************
163  *         output_exports
164  *
165  * Output the export table for a Win32 module.
166  */
167 static void output_exports( DLLSPEC *spec )
168 {
169     int i, fwd_size = 0;
170     int nr_exports = spec->base <= spec->limit ? spec->limit - spec->base + 1 : 0;
171 
172     if (!nr_exports) return;
173 
174     output( "\n/* export table */\n\n" );
175     output( "\t.data\n" );
176     output( "\t.align %d\n", get_alignment(4) );
177     output( ".L__wine_spec_exports:\n" );
178 
179     /* export directory header */
180 
181     output( "\t.long 0\n" );                       /* Characteristics */
182     output( "\t.long 0\n" );                       /* TimeDateStamp */
183     output( "\t.long 0\n" );                       /* MajorVersion/MinorVersion */
184     output( "\t.long .L__wine_spec_exp_names-.L__wine_spec_rva_base\n" ); /* Name */
185     output( "\t.long %u\n", spec->base );          /* Base */
186     output( "\t.long %u\n", nr_exports );          /* NumberOfFunctions */
187     output( "\t.long %u\n", spec->nb_names );      /* NumberOfNames */
188     output( "\t.long .L__wine_spec_exports_funcs-.L__wine_spec_rva_base\n" ); /* AddressOfFunctions */
189     if (spec->nb_names)
190     {
191         output( "\t.long .L__wine_spec_exp_name_ptrs-.L__wine_spec_rva_base\n" ); /* AddressOfNames */
192         output( "\t.long .L__wine_spec_exp_ordinals-.L__wine_spec_rva_base\n" );  /* AddressOfNameOrdinals */
193     }
194     else
195     {
196         output( "\t.long 0\n" );  /* AddressOfNames */
197         output( "\t.long 0\n" );  /* AddressOfNameOrdinals */
198     }
199 
200     /* output the function pointers */
201 
202     output( "\n.L__wine_spec_exports_funcs:\n" );
203     for (i = spec->base; i <= spec->limit; i++)
204     {
205         ORDDEF *odp = spec->ordinals[i];
206         if (!odp) output( "\t%s 0\n", get_asm_ptr_keyword() );
207         else switch(odp->type)
208         {
209         case TYPE_EXTERN:
210         case TYPE_STDCALL:
211         case TYPE_VARARGS:
212         case TYPE_CDECL:
213             if (odp->flags & FLAG_FORWARD)
214             {
215                 output( "\t%s .L__wine_spec_forwards+%u\n", get_asm_ptr_keyword(), fwd_size );
216                 fwd_size += strlen(odp->link_name) + 1;
217             }
218             else if (odp->flags & FLAG_EXT_LINK)
219             {
220                 output( "\t%s %s_%s\n",
221                          get_asm_ptr_keyword(), asm_name("__wine_spec_ext_link"), odp->link_name );
222             }
223             else
224             {
225                 output( "\t%s %s\n", get_asm_ptr_keyword(), asm_name(odp->link_name) );
226             }
227             break;
228         case TYPE_STUB:
229             output( "\t%s %s\n", get_asm_ptr_keyword(),
230                      asm_name( get_stub_name( odp, spec )) );
231             break;
232         default:
233             assert(0);
234         }
235     }
236 
237     if (spec->nb_names)
238     {
239         /* output the function name pointers */
240 
241         int namepos = strlen(spec->file_name) + 1;
242 
243         output( "\n.L__wine_spec_exp_name_ptrs:\n" );
244         for (i = 0; i < spec->nb_names; i++)
245         {
246             output( "\t.long .L__wine_spec_exp_names+%u-.L__wine_spec_rva_base\n", namepos );
247             namepos += strlen(spec->names[i]->name) + 1;
248         }
249 
250         /* output the function ordinals */
251 
252         output( "\n.L__wine_spec_exp_ordinals:\n" );
253         for (i = 0; i < spec->nb_names; i++)
254         {
255             output( "\t%s %d\n",
256                      get_asm_short_keyword(), spec->names[i]->ordinal - spec->base );
257         }
258         if (spec->nb_names % 2)
259         {
260             output( "\t%s 0\n", get_asm_short_keyword() );
261         }
262     }
263 
264     /* output the export name strings */
265 
266     output( "\n.L__wine_spec_exp_names:\n" );
267     output( "\t%s \"%s\"\n", get_asm_string_keyword(), spec->file_name );
268     for (i = 0; i < spec->nb_names; i++)
269         output( "\t%s \"%s\"\n",
270                  get_asm_string_keyword(), spec->names[i]->name );
271 
272     /* output forward strings */
273 
274     if (fwd_size)
275     {
276         output( "\n.L__wine_spec_forwards:\n" );
277         for (i = spec->base; i <= spec->limit; i++)
278         {
279             ORDDEF *odp = spec->ordinals[i];
280             if (odp && (odp->flags & FLAG_FORWARD))
281                 output( "\t%s \"%s\"\n", get_asm_string_keyword(), odp->link_name );
282         }
283     }
284     output( "\t.align %d\n", get_alignment(get_ptr_size()) );
285     output( ".L__wine_spec_exports_end:\n" );
286 
287     /* output relays */
288 
289     /* we only support relay debugging on i386 */
290     if (target_cpu != CPU_x86)
291     {
292         output( "\t%s 0\n", get_asm_ptr_keyword() );
293         return;
294     }
295 
296     output( ".L__wine_spec_relay_descr:\n" );
297     output( "\t%s 0xdeb90001\n", get_asm_ptr_keyword() );  /* magic */
298     output( "\t%s 0,0\n", get_asm_ptr_keyword() );         /* relay funcs */
299     output( "\t%s 0\n", get_asm_ptr_keyword() );           /* private data */
300     output( "\t%s __wine_spec_relay_entry_points\n", get_asm_ptr_keyword() );
301     output( "\t%s .L__wine_spec_relay_entry_point_offsets\n", get_asm_ptr_keyword() );
302     output( "\t%s .L__wine_spec_relay_arg_types\n", get_asm_ptr_keyword() );
303 
304     output_relay_debug( spec );
305 }
306 
307 
308 /*******************************************************************
309  *         output_asm_constructor
310  *
311  * Output code for calling a dll constructor.
312  */
313 static void output_asm_constructor( const char *constructor )
314 {
315     if (target_platform == PLATFORM_APPLE)
316     {
317         /* Mach-O doesn't have an init section */
318         output( "\n\t.mod_init_func\n" );
319         output( "\t.align %d\n", get_alignment(4) );
320         output( "\t.long %s\n", asm_name(constructor) );
321     }
322     else
323     {
324         output( "\n\t.section \".init\",\"ax\"\n" );
325         switch(target_cpu)
326         {
327         case CPU_x86:
328         case CPU_x86_64:
329             output( "\tcall %s\n", asm_name(constructor) );
330             break;
331         case CPU_SPARC:
332             output( "\tcall %s\n", asm_name(constructor) );
333             output( "\tnop\n" );
334             break;
335         case CPU_ALPHA:
336             output( "\tjsr $26,%s\n", asm_name(constructor) );
337             break;
338         case CPU_POWERPC:
339             output( "\tbl %s\n", asm_name(constructor) );
340             break;
341         }
342     }
343 }
344 
345 
346 /*******************************************************************
347  *         BuildSpec32File
348  *
349  * Build a Win32 C file from a spec file.
350  */
351 void BuildSpec32File( DLLSPEC *spec )
352 {
353     int machine = 0;
354     unsigned int page_size = get_page_size();
355 
356     resolve_imports( spec );
357     output_standard_file_header();
358 
359     /* Reserve some space for the PE header */
360 
361     switch (target_platform)
362     {
363     case PLATFORM_APPLE:
364         output( "\t.text\n" );
365         output( "\t.align %d\n", get_alignment(page_size) );
366         output( "__wine_spec_pe_header:\n" );
367         output( "\t.space 65536\n" );
368         break;
369     case PLATFORM_SOLARIS:
370         output( "\n\t.section \".text\",\"ax\"\n" );
371         output( "__wine_spec_pe_header:\n" );
372         output( "\t.skip %u\n", 65536 + page_size );
373         break;
374     default:
375         output( "\n\t.section \".init\",\"ax\"\n" );
376         switch(target_cpu)
377         {
378         case CPU_x86:
379         case CPU_x86_64:
380         case CPU_ALPHA:
381         case CPU_SPARC:
382             output( "\tjmp 1f\n" );
383             break;
384         case CPU_POWERPC:
385             output( "\tb 1f\n" );
386             break;
387         }
388         output( "__wine_spec_pe_header:\n" );
389         output( "\t.skip %u\n", 65536 + page_size );
390         output( "1:\n" );
391         break;
392     }
393 
394     /* Output the NT header */
395 
396     output( "\n\t.data\n" );
397     output( "\t.align %d\n", get_alignment(get_ptr_size()) );
398     output( "%s\n", asm_globl("__wine_spec_nt_header") );
399     output( ".L__wine_spec_rva_base:\n" );
400 
401     output( "\t.long 0x%04x\n", IMAGE_NT_SIGNATURE );    /* Signature */
402     switch(target_cpu)
403     {
404     case CPU_x86:     machine = IMAGE_FILE_MACHINE_I386; break;
405     case CPU_x86_64:  machine = IMAGE_FILE_MACHINE_AMD64; break;
406     case CPU_POWERPC: machine = IMAGE_FILE_MACHINE_POWERPC; break;
407     case CPU_ALPHA:   machine = IMAGE_FILE_MACHINE_ALPHA; break;
408     case CPU_SPARC:   machine = IMAGE_FILE_MACHINE_UNKNOWN; break;
409     }
410     output( "\t%s 0x%04x\n",              /* Machine */
411              get_asm_short_keyword(), machine );
412     output( "\t%s 0\n",                   /* NumberOfSections */
413              get_asm_short_keyword() );
414     output( "\t.long 0\n" );              /* TimeDateStamp */
415     output( "\t.long 0\n" );              /* PointerToSymbolTable */
416     output( "\t.long 0\n" );              /* NumberOfSymbols */
417     output( "\t%s %d\n",                  /* SizeOfOptionalHeader */
418              get_asm_short_keyword(),
419              get_ptr_size() == 8 ? IMAGE_SIZEOF_NT_OPTIONAL64_HEADER : IMAGE_SIZEOF_NT_OPTIONAL32_HEADER );
420     output( "\t%s 0x%04x\n",              /* Characteristics */
421              get_asm_short_keyword(), spec->characteristics );
422     output( "\t%s 0x%04x\n",              /* Magic */
423              get_asm_short_keyword(),
424              get_ptr_size() == 8 ? IMAGE_NT_OPTIONAL_HDR64_MAGIC : IMAGE_NT_OPTIONAL_HDR32_MAGIC );
425     output( "\t.byte 0\n" );              /* MajorLinkerVersion */
426     output( "\t.byte 0\n" );              /* MinorLinkerVersion */
427     output( "\t.long 0\n" );              /* SizeOfCode */
428     output( "\t.long 0\n" );              /* SizeOfInitializedData */
429     output( "\t.long 0\n" );              /* SizeOfUninitializedData */
430     /* note: we expand the AddressOfEntryPoint field on 64-bit by overwriting the BaseOfCode field */
431     output( "\t%s %s\n",                  /* AddressOfEntryPoint */
432              get_asm_ptr_keyword(), asm_name(spec->init_func) );
433     if (get_ptr_size() == 4)
434     {
435         output( "\t.long 0\n" );          /* BaseOfCode */
436         output( "\t.long 0\n" );          /* BaseOfData */
437     }
438     output( "\t%s __wine_spec_pe_header\n",         /* ImageBase */
439              get_asm_ptr_keyword() );
440     output( "\t.long %u\n", page_size );  /* SectionAlignment */
441     output( "\t.long %u\n", page_size );  /* FileAlignment */
442     output( "\t%s 1,0\n",                 /* Major/MinorOperatingSystemVersion */
443              get_asm_short_keyword() );
444     output( "\t%s 0,0\n",                 /* Major/MinorImageVersion */
445              get_asm_short_keyword() );
446     output( "\t%s %u,%u\n",               /* Major/MinorSubsystemVersion */
447              get_asm_short_keyword(), spec->subsystem_major, spec->subsystem_minor );
448     output( "\t.long 0\n" );                          /* Win32VersionValue */
449     output( "\t.long %s-.L__wine_spec_rva_base\n",    /* SizeOfImage */
450              asm_name("_end") );
451     output( "\t.long %u\n", page_size );  /* SizeOfHeaders */
452     output( "\t.long 0\n" );              /* CheckSum */
453     output( "\t%s 0x%04x\n",              /* Subsystem */
454              get_asm_short_keyword(), spec->subsystem );
455     output( "\t%s 0x%04x\n",              /* DllCharacteristics */
456             get_asm_short_keyword(), spec->dll_characteristics );
457     output( "\t%s %u,%u\n",               /* SizeOfStackReserve/Commit */
458              get_asm_ptr_keyword(), (spec->stack_size ? spec->stack_size : 1024) * 1024, page_size );
459     output( "\t%s %u,%u\n",               /* SizeOfHeapReserve/Commit */
460              get_asm_ptr_keyword(), (spec->heap_size ? spec->heap_size : 1024) * 1024, page_size );
461     output( "\t.long 0\n" );              /* LoaderFlags */
462     output( "\t.long 16\n" );             /* NumberOfRvaAndSizes */
463 
464     if (spec->base <= spec->limit)   /* DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT] */
465         output( "\t.long .L__wine_spec_exports-.L__wine_spec_rva_base,"
466                  ".L__wine_spec_exports_end-.L__wine_spec_exports\n" );
467     else
468         output( "\t.long 0,0\n" );
469 
470     if (has_imports())   /* DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT] */
471         output( "\t.long .L__wine_spec_imports-.L__wine_spec_rva_base,"
472                  ".L__wine_spec_imports_end-.L__wine_spec_imports\n" );
473     else
474         output( "\t.long 0,0\n" );
475 
476     if (spec->nb_resources)   /* DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE] */
477         output( "\t.long .L__wine_spec_resources-.L__wine_spec_rva_base,"
478                  ".L__wine_spec_resources_end-.L__wine_spec_resources\n" );
479     else
480         output( "\t.long 0,0\n" );
481 
482     output( "\t.long 0,0\n" );  /* DataDirectory[3] */
483     output( "\t.long 0,0\n" );  /* DataDirectory[4] */
484     output( "\t.long 0,0\n" );  /* DataDirectory[5] */
485     output( "\t.long 0,0\n" );  /* DataDirectory[6] */
486     output( "\t.long 0,0\n" );  /* DataDirectory[7] */
487     output( "\t.long 0,0\n" );  /* DataDirectory[8] */
488     output( "\t.long 0,0\n" );  /* DataDirectory[9] */
489     output( "\t.long 0,0\n" );  /* DataDirectory[10] */
490     output( "\t.long 0,0\n" );  /* DataDirectory[11] */
491     output( "\t.long 0,0\n" );  /* DataDirectory[12] */
492     output( "\t.long 0,0\n" );  /* DataDirectory[13] */
493     output( "\t.long 0,0\n" );  /* DataDirectory[14] */
494     output( "\t.long 0,0\n" );  /* DataDirectory[15] */
495 
496     output( "\n\t%s\n", get_asm_string_section() );
497     output( "%s\n", asm_globl("__wine_spec_file_name") );
498     output( ".L__wine_spec_file_name:\n" );
499     output( "\t%s \"%s\"\n", get_asm_string_keyword(), spec->file_name );
500     if (target_platform == PLATFORM_APPLE)
501         output( "\t.lcomm %s,4\n", asm_name("_end") );
502 
503     output_stubs( spec );
504     output_exports( spec );
505     output_imports( spec );
506     output_resources( spec );
507     output_asm_constructor( "__wine_spec_init_ctor" );
508     output_gnu_stack_note();
509 }
510 
511 
512 /*******************************************************************
513  *         BuildDef32File
514  *
515  * Build a Win32 def file from a spec file.
516  */
517 void BuildDef32File( DLLSPEC *spec )
518 {
519     const char *name;
520     int i, total;
521 
522     if (spec_file_name)
523         output( "; File generated automatically from %s; do not edit!\n\n",
524                  spec_file_name );
525     else
526         output( "; File generated automatically; do not edit!\n\n" );
527 
528     output( "LIBRARY %s\n\n", spec->file_name);
529     output( "EXPORTS\n");
530 
531     /* Output the exports and relay entry points */
532 
533     for (i = total = 0; i < spec->nb_entry_points; i++)
534     {
535         const ORDDEF *odp = &spec->entry_points[i];
536         int is_data = 0;
537 
538         if (!odp) continue;
539 
540         if (odp->name) name = odp->name;
541         else if (odp->export_name) name = odp->export_name;
542         else continue;
543 
544         if (!(odp->flags & FLAG_PRIVATE)) total++;
545 
546         if (odp->type == TYPE_STUB) continue;
547 
548         output( "  %s", name );
549 
550         switch(odp->type)
551         {
552         case TYPE_EXTERN:
553             is_data = 1;
554             /* fall through */
555         case TYPE_VARARGS:
556         case TYPE_CDECL:
557             /* try to reduce output */
558             if(strcmp(name, odp->link_name) || (odp->flags & FLAG_FORWARD))
559                 output( "=%s", odp->link_name );
560             break;
561         case TYPE_STDCALL:
562         {
563             int at_param = strlen(odp->u.func.arg_types) * get_ptr_size();
564             if (!kill_at) output( "@%d", at_param );
565             if  (odp->flags & FLAG_FORWARD)
566             {
567                 output( "=%s", odp->link_name );
568             }
569             else if (strcmp(name, odp->link_name)) /* try to reduce output */
570             {
571                 output( "=%s", odp->link_name );
572                 if (!kill_at) output( "@%d", at_param );
573             }
574             break;
575         }
576         default:
577             assert(0);
578         }
579         output( " @%d", odp->ordinal );
580         if (!odp->name || (odp->flags & FLAG_ORDINAL)) output( " NONAME" );
581         if (is_data) output( " DATA" );
582         if (odp->flags & FLAG_PRIVATE) output( " PRIVATE" );
583         output( "\n" );
584     }
585     if (!total) warning( "%s: Import library doesn't export anything\n", spec->file_name );
586 }
587 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.