2 * Copyright 1993 Robert J. Amstadt
3 * Copyright 1995 Martin von Loewis
4 * Copyright 1995, 1996, 1997 Alexandre Julliard
5 * Copyright 1997 Eric Youngdale
6 * Copyright 1999 Ulrich Weigand
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #ifndef __WINE_BUILD_H
24 #define __WINE_BUILD_H
32 TYPE_VARIABLE
, /* variable */
33 TYPE_PASCAL
, /* pascal function (Win16) */
34 TYPE_ABS
, /* absolute value (Win16) */
35 TYPE_STUB
, /* unimplemented stub */
36 TYPE_STDCALL
, /* stdcall function (Win32) */
37 TYPE_CDECL
, /* cdecl function (Win32) */
38 TYPE_VARARGS
, /* varargs function (Win32) */
39 TYPE_EXTERN
, /* external symbol (Win32) */
51 ARG_WORD
, /* 16-bit word */
52 ARG_SWORD
, /* 16-bit signed word */
53 ARG_SEGPTR
, /* segmented pointer */
54 ARG_SEGSTR
, /* segmented pointer to Ansi string */
56 ARG_PTR
, /* pointer */
57 ARG_STR
, /* pointer to Ansi string */
58 ARG_WSTR
, /* pointer to Unicode string */
59 ARG_INT64
, /* 64-bit integer */
60 ARG_INT128
, /* 128-bit integer */
61 ARG_FLOAT
, /* 32-bit float */
62 ARG_DOUBLE
, /* 64-bit float */
63 ARG_MAXARG
= ARG_DOUBLE
66 #define MAX_ARGUMENTS 32
78 enum arg_type args
[MAX_ARGUMENTS
];
93 char *name
; /* public name of this function */
94 char *link_name
; /* name of the C symbol to link to */
95 char *export_name
; /* name exported under for noname exports */
106 unsigned int name_off
;
107 unsigned int name_len
;
109 unsigned int hash_len
;
110 unsigned int val_count
;
113 unsigned int name_off
;
114 unsigned int name_len
;
115 unsigned int val_off
;
116 unsigned int val_len
;
124 struct apiset_entry
*entries
;
125 unsigned int str_pos
;
126 unsigned int str_size
;
130 static const unsigned int apiset_hash_factor
= 31;
134 char *src_name
; /* file name of the source spec file */
135 char *file_name
; /* file name of the dll */
136 char *dll_name
; /* internal name of the dll */
137 char *c_name
; /* internal name of the dll, as a C-compatible identifier */
138 char *init_func
; /* initialization routine */
139 char *main_module
; /* main Win32 module for Win16 specs */
140 SPEC_TYPE type
; /* type of dll (Win16/Win32) */
141 int base
; /* ordinal base */
142 int limit
; /* ordinal limit */
143 int stack_size
; /* exe stack size */
144 int heap_size
; /* exe heap size */
145 int nb_entry_points
; /* number of used entry points */
146 int alloc_entry_points
; /* number of allocated entry points */
147 int nb_names
; /* number of entry points with names */
148 unsigned int nb_resources
; /* number of resources */
149 int characteristics
; /* characteristics for the PE header */
150 int dll_characteristics
;/* DLL characteristics for the PE header */
151 int subsystem
; /* subsystem id */
152 int subsystem_major
; /* subsystem version major number */
153 int subsystem_minor
; /* subsystem version minor number */
154 int syscall_table
; /* syscall table id */
155 int unicode_app
; /* default to unicode entry point */
156 ORDDEF
*entry_points
; /* dll entry points */
157 ORDDEF
**names
; /* array of entry point names (points into entry_points) */
158 ORDDEF
**ordinals
; /* array of dll ordinals (points into entry_points) */
159 struct resource
*resources
; /* array of dll resources (format differs between Win16/Win32) */
160 struct apiset apiset
; /* list of defined api sets */
163 extern char *target_alias
;
164 extern struct target target
;
166 static inline unsigned int get_ptr_size(void)
168 return get_target_ptr_size( target
);
171 static inline int is_pe(void)
173 return target
.platform
== PLATFORM_MINGW
|| target
.platform
== PLATFORM_WINDOWS
;
176 /* entry point flags */
177 #define FLAG_NORELAY 0x0001 /* don't use relay debugging for this function */
178 #define FLAG_NONAME 0x0002 /* don't export function by name */
179 #define FLAG_RET16 0x0004 /* function returns a 16-bit value */
180 #define FLAG_RET64 0x0008 /* function returns a 64-bit value */
181 #define FLAG_REGISTER 0x0010 /* use register calling convention */
182 #define FLAG_PRIVATE 0x0020 /* function is private (cannot be imported) */
183 #define FLAG_ORDINAL 0x0040 /* function should be imported by ordinal */
184 #define FLAG_THISCALL 0x0080 /* function uses thiscall calling convention */
185 #define FLAG_FASTCALL 0x0100 /* function uses fastcall calling convention */
186 #define FLAG_SYSCALL 0x0200 /* function is a system call */
187 #define FLAG_IMPORT 0x0400 /* export is imported from another module */
189 #define FLAG_FORWARD 0x1000 /* function is a forwarded name */
190 #define FLAG_EXT_LINK 0x2000 /* function links to an external symbol */
191 #define FLAG_EXPORT32 0x4000 /* 32-bit export in 16-bit spec file */
193 #define FLAG_CPU(cpu) (0x10000 << (cpu))
194 #define FLAG_CPU_MASK (FLAG_CPU_WIN32 | FLAG_CPU_WIN64)
195 #define FLAG_CPU_WIN64 (FLAG_CPU(CPU_x86_64) | FLAG_CPU(CPU_ARM64))
196 #define FLAG_CPU_WIN32 (FLAG_CPU(CPU_i386) | FLAG_CPU(CPU_ARM))
198 #define MAX_ORDINALS 65535
200 /* some Windows constants */
202 #define IMAGE_FILE_RELOCS_STRIPPED 0x0001 /* No relocation info */
203 #define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
204 #define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
205 #define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
206 #define IMAGE_FILE_AGGRESIVE_WS_TRIM 0x0010
207 #define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020
208 #define IMAGE_FILE_16BIT_MACHINE 0x0040
209 #define IMAGE_FILE_BYTES_REVERSED_LO 0x0080
210 #define IMAGE_FILE_32BIT_MACHINE 0x0100
211 #define IMAGE_FILE_DEBUG_STRIPPED 0x0200
212 #define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400
213 #define IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800
214 #define IMAGE_FILE_SYSTEM 0x1000
215 #define IMAGE_FILE_DLL 0x2000
216 #define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000
217 #define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
219 #define IMAGE_DLLCHARACTERISTICS_PREFER_NATIVE 0x0010 /* Wine extension */
220 #define IMAGE_DLLCHARACTERISTICS_NX_COMPAT 0x0100
222 #define IMAGE_SUBSYSTEM_NATIVE 1
223 #define IMAGE_SUBSYSTEM_WINDOWS_GUI 2
224 #define IMAGE_SUBSYSTEM_WINDOWS_CUI 3
225 #define IMAGE_SUBSYSTEM_WINDOWS_CE_GUI 9
227 /* global functions */
229 #ifndef DECLSPEC_NORETURN
230 # if defined(_MSC_VER) && (_MSC_VER >= 1200) && !defined(MIDL_PASS)
231 # define DECLSPEC_NORETURN __declspec(noreturn)
233 # define DECLSPEC_NORETURN __attribute__((noreturn))
236 extern char *strupper(char *s
);
237 extern DECLSPEC_NORETURN
void fatal_error( const char *msg
, ... )
238 __attribute__ ((__format__ (__printf__
, 1, 2)));
239 extern DECLSPEC_NORETURN
void fatal_perror( const char *msg
, ... )
240 __attribute__ ((__format__ (__printf__
, 1, 2)));
241 extern void error( const char *msg
, ... )
242 __attribute__ ((__format__ (__printf__
, 1, 2)));
243 extern void warning( const char *msg
, ... )
244 __attribute__ ((__format__ (__printf__
, 1, 2)));
245 extern int output( const char *format
, ... )
246 __attribute__ ((__format__ (__printf__
, 1, 2)));
247 extern void output_cfi( const char *format
, ... )
248 __attribute__ ((__format__ (__printf__
, 1, 2)));
249 extern void output_seh( const char *format
, ... )
250 __attribute__ ((__format__ (__printf__
, 1, 2)));
251 extern void output_rva( const char *format
, ... )
252 __attribute__ ((__format__ (__printf__
, 1, 2)));
253 extern void output_thunk_rva( int ordinal
, const char *format
, ... )
254 __attribute__ ((__format__ (__printf__
, 2, 3)));
255 extern void spawn( struct strarray array
);
256 extern struct strarray
find_tool( const char *name
, const char * const *names
);
257 extern struct strarray
find_link_tool(void);
258 extern struct strarray
get_as_command(void);
259 extern struct strarray
get_ld_command(void);
260 extern const char *get_nm_command(void);
261 extern void output_standard_file_header(void);
262 extern FILE *open_input_file( const char *srcdir
, const char *name
);
263 extern void close_input_file( FILE *file
);
264 extern void open_output_file(void);
265 extern void close_output_file(void);
266 extern char *open_temp_output_file( const char *suffix
);
267 extern void dump_bytes( const void *buffer
, unsigned int size
);
268 extern int remove_stdcall_decoration( char *name
);
269 extern void assemble_file( const char *src_file
, const char *obj_file
);
270 extern DLLSPEC
*alloc_dll_spec(void);
271 extern void free_dll_spec( DLLSPEC
*spec
);
272 extern char *make_c_identifier( const char *str
);
273 extern const char *get_stub_name( const ORDDEF
*odp
, const DLLSPEC
*spec
);
274 extern const char *get_abi_name( const ORDDEF
*odp
, const char *name
);
275 extern const char *get_link_name( const ORDDEF
*odp
);
276 extern int sort_func_list( ORDDEF
**list
, int count
, int (*compare
)(const void *, const void *) );
277 extern unsigned int get_alignment(unsigned int align
);
278 extern unsigned int get_page_size(void);
279 extern unsigned int get_args_size( const ORDDEF
*odp
);
280 extern const char *asm_name( const char *func
);
281 extern const char *func_declaration( const char *func
);
282 extern const char *asm_globl( const char *func
);
283 extern const char *get_asm_ptr_keyword(void);
284 extern const char *get_asm_string_keyword(void);
285 extern const char *get_asm_export_section(void);
286 extern const char *get_asm_rodata_section(void);
287 extern const char *get_asm_rsrc_section(void);
288 extern const char *get_asm_string_section(void);
289 extern const char *arm64_page( const char *sym
);
290 extern const char *arm64_pageoff( const char *sym
);
291 extern void output_function_size( const char *name
);
292 extern void output_gnu_stack_note(void);
294 extern void add_import_dll( const char *name
, const char *filename
);
295 extern void add_delayed_import( const char *name
);
296 extern void add_extra_ld_symbol( const char *name
);
297 extern void add_spec_extra_ld_symbol( const char *name
);
298 extern void read_undef_symbols( DLLSPEC
*spec
, struct strarray files
);
299 extern void resolve_imports( DLLSPEC
*spec
);
300 extern int is_undefined( const char *name
);
301 extern int has_imports(void);
302 extern int has_delay_imports(void);
303 extern void output_get_pc_thunk(void);
304 extern void output_module( DLLSPEC
*spec
);
305 extern void output_stubs( DLLSPEC
*spec
);
306 extern void output_syscalls( DLLSPEC
*spec
);
307 extern void output_imports( DLLSPEC
*spec
);
308 extern void output_import_lib( DLLSPEC
*spec
, struct strarray files
);
309 extern void output_static_lib( const char *output_name
, struct strarray files
, int create
);
310 extern void output_exports( DLLSPEC
*spec
);
311 extern int load_res32_file( const char *name
, DLLSPEC
*spec
);
312 extern void output_resources( DLLSPEC
*spec
);
313 extern void output_bin_resources( DLLSPEC
*spec
, unsigned int start_rva
);
314 extern void output_spec32_file( DLLSPEC
*spec
);
315 extern void output_fake_module( DLLSPEC
*spec
);
316 extern void output_data_module( DLLSPEC
*spec
);
317 extern void output_def_file( DLLSPEC
*spec
, int import_only
);
318 extern void output_apiset_lib( DLLSPEC
*spec
, const struct apiset
*apiset
);
319 extern void load_res16_file( const char *name
, DLLSPEC
*spec
);
320 extern void output_res16_data( DLLSPEC
*spec
);
321 extern void output_bin_res16_data( DLLSPEC
*spec
);
322 extern void output_res16_directory( DLLSPEC
*spec
);
323 extern void output_bin_res16_directory( DLLSPEC
*spec
, unsigned int data_offset
);
324 extern void output_spec16_file( DLLSPEC
*spec
);
325 extern void output_fake_module16( DLLSPEC
*spec16
);
326 extern void output_res_o_file( DLLSPEC
*spec
);
327 extern void output_asm_relays16(void);
328 extern void make_builtin_files( struct strarray files
);
329 extern void fixup_constructors( struct strarray files
);
331 extern void add_16bit_exports( DLLSPEC
*spec32
, DLLSPEC
*spec16
);
332 extern int parse_spec_file( FILE *file
, DLLSPEC
*spec
);
333 extern int parse_def_file( FILE *file
, DLLSPEC
*spec
);
335 /* buffer management */
337 extern int byte_swapped
;
338 extern const char *input_buffer_filename
;
339 extern const unsigned char *input_buffer
;
340 extern size_t input_buffer_pos
;
341 extern size_t input_buffer_size
;
343 extern void init_input_buffer( const char *file
);
344 extern unsigned char get_byte(void);
345 extern unsigned short get_word(void);
346 extern unsigned int get_dword(void);
347 extern void put_pword( unsigned int val
);
349 /* global variables */
351 extern int current_line
;
353 extern int nb_errors
;
354 extern int display_warnings
;
357 extern int link_ext_symbols
;
358 extern int force_pointer_size
;
359 extern int unwind_tables
;
360 extern int use_dlltool
;
361 extern int use_msvcrt
;
363 extern int prefer_native
;
364 extern int data_only
;
366 extern char *input_file_name
;
367 extern char *spec_file_name
;
368 extern FILE *output_file
;
369 extern const char *output_file_name
;
371 extern struct strarray lib_path
;
372 extern struct strarray tools_path
;
373 extern struct strarray as_command
;
374 extern struct strarray cc_command
;
375 extern struct strarray ld_command
;
376 extern struct strarray nm_command
;
377 extern char *cpu_option
;
378 extern char *fpu_option
;
379 extern char *arch_option
;
380 extern const char *float_abi_option
;
381 extern int thumb_mode
;
382 extern int needs_get_pc_thunk
;
384 #endif /* __WINE_BUILD_H */