]>
Commit | Line | Data |
---|---|---|
3a2c1cd8 | 1 | /* Operating system specific defines to be used when targeting GCC for |
db009825 | 2 | hosting on Windows32, using a Unix style C library and tools. |
000b5f54 | 3 | Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001 |
4592bdcb | 4 | Free Software Foundation, Inc. |
3a2c1cd8 MM |
5 | |
6 | This file is part of GNU CC. | |
7 | ||
8 | GNU CC is free software; you can redistribute it and/or modify | |
9 | it under the terms of the GNU General Public License as published by | |
10 | the Free Software Foundation; either version 2, or (at your option) | |
11 | any later version. | |
12 | ||
13 | GNU CC 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 | |
16 | GNU General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
19 | along with GNU CC; see the file COPYING. If not, write to | |
20 | the Free Software Foundation, 59 Temple Place - Suite 330, | |
21 | Boston, MA 02111-1307, USA. */ | |
22 | ||
3a2c1cd8 MM |
23 | #define YES_UNDERSCORES |
24 | ||
73061e0f JW |
25 | #define DBX_DEBUGGING_INFO |
26 | #define SDB_DEBUGGING_INFO | |
27 | #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG | |
3a2c1cd8 | 28 | |
79f96374 | 29 | #include <stdio.h> |
73061e0f JW |
30 | #include "i386/gas.h" |
31 | #include "dbxcoff.h" | |
3a2c1cd8 | 32 | |
040688bd GN |
33 | /* Augment TARGET_SWITCHES with the cygwin/no-cygwin options. */ |
34 | #define MASK_WIN32 0x40000000 /* Use -lming32 interface */ | |
35 | #define MASK_CYGWIN 0x20000000 /* Use -lcygwin interface */ | |
36 | #define MASK_WINDOWS 0x10000000 /* Use windows interface */ | |
37 | #define MASK_DLL 0x08000000 /* Use dll interface */ | |
38 | #define MASK_NOP_FUN_DLLIMPORT 0x20000 /* Ignore dllimport for functions */ | |
39 | ||
40 | #define TARGET_WIN32 (target_flags & MASK_WIN32) | |
41 | #define TARGET_CYGWIN (target_flags & MASK_CYGWIN) | |
42 | #define TARGET_WINDOWS (target_flags & MASK_WINDOWS) | |
43 | #define TARGET_DLL (target_flags & MASK_DLL) | |
44 | #define TARGET_NOP_FUN_DLLIMPORT (target_flags & MASK_NOP_FUN_DLLIMPORT) | |
45 | ||
46 | #undef SUBTARGET_SWITCHES | |
47 | #define SUBTARGET_SWITCHES \ | |
047142d3 PT |
48 | { "cygwin", MASK_CYGWIN, \ |
49 | N_("Use the Cygwin interface") }, \ | |
50 | { "no-cygwin", MASK_WIN32, \ | |
51 | N_("Use the Mingw32 interface") }, \ | |
52 | { "windows", MASK_WINDOWS, N_("Create GUI application") }, \ | |
03fb4780 | 53 | { "no-win32", -MASK_WIN32, N_("Don't set Windows defines") },\ |
f6fc3552 | 54 | { "win32", 0, N_("Set Windows defines") }, \ |
047142d3 PT |
55 | { "console", -MASK_WINDOWS, \ |
56 | N_("Create console application") }, \ | |
57 | { "dll", MASK_DLL, N_("Generate code for a DLL") }, \ | |
58 | { "nop-fun-dllimport", MASK_NOP_FUN_DLLIMPORT, \ | |
59 | N_("Ignore dllimport for functions") }, \ | |
f22a97d2 | 60 | { "no-nop-fun-dllimport", -MASK_NOP_FUN_DLLIMPORT, "" }, \ |
047142d3 | 61 | { "threads", 0, N_("Use Mingw-specific thread support") }, |
040688bd GN |
62 | |
63 | ||
27da1b4d MK |
64 | /* Support the __declspec keyword by turning them into attributes. |
65 | We currently only support: dllimport and dllexport. | |
66 | Note that the current way we do this may result in a collision with | |
67 | predefined attributes later on. This can be solved by using one attribute, | |
68 | say __declspec__, and passing args to it. The problem with that approach | |
69 | is that args are not accumulated: each new appearance would clobber any | |
70 | existing args. */ | |
71 | ||
3a2c1cd8 | 72 | #undef CPP_PREDEFINES |
03fb4780 | 73 | #define CPP_PREDEFINES "-D_X86_=1 -Asystem=winnt" |
3a2c1cd8 | 74 | |
040688bd GN |
75 | /* Normally, -lgcc is not needed since everything in it is in the DLL, but we |
76 | want to allow things to be added to it when installing new versions of | |
77 | GCC without making a new CYGWIN.DLL, so we leave it. Profiling is handled | |
78 | by calling the init function from the prologue. */ | |
79 | ||
03fb4780 | 80 | #undef LIBGCC_SPEC |
f6fc3552 | 81 | #define LIBGCC_SPEC "%{mno-cygwin: %{mthreads:-lmingwthrd} -lmingw32} -lgcc %{mno-cygwin:-lmoldname -lmsvcrt}" |
03fb4780 | 82 | |
f6fc3552 | 83 | #ifdef CROSS_COMPILE |
45677496 | 84 | #define CYGWIN_INCLUDES "-idirafter " CYGWIN_CROSS_DIR "/include" |
936ee790 | 85 | #define CYGWIN_W32API "-idirafter " CYGWIN_CROSS_DIR "/include/w32api" |
4e190cf3 CF |
86 | #define CYGWIN_LIB CYGWIN_CROSS_DIR "/lib" |
87 | #define MINGW_LIBS "-L" CYGWIN_CROSS_DIR "/lib/mingw" | |
936ee790 CF |
88 | #define MINGW_INCLUDES "-isystem " CYGWIN_CROSS_DIR "/include/mingw/g++-3 "\ |
89 | "-isystem " CYGWIN_CROSS_DIR "/include/mingw/g++ "\ | |
90 | "-idirafter " CYGWIN_CROSS_DIR "/include/mingw" | |
f6fc3552 | 91 | #else |
4e190cf3 | 92 | #define CYGWIN_INCLUDES "-isystem /usr/local/include -idirafter /usr/include" |
936ee790 | 93 | #define CYGWIN_W32API "-idirafter /usr/include/w32api" |
4e190cf3 CF |
94 | #define CYGWIN_LIB "/usr/lib" |
95 | #define MINGW_LIBS "-L/usr/local/lib/mingw -L/usr/lib/mingw" | |
936ee790 CF |
96 | #define MINGW_INCLUDES "-isystem /usr/include/mingw/g++-3 "\ |
97 | "-isystem /usr/include/mingw/g++ "\ | |
98 | "-isystem /usr/local/include/mingw" \ | |
99 | "-idirafter /usr/include/mingw" | |
4e190cf3 CF |
100 | #endif |
101 | ||
102 | #undef STARTFILE_SPEC | |
05d9f8b0 | 103 | #define STARTFILE_SPEC "%{shared|mdll: %{mno-cygwin:dllcrt2%O%s}} \ |
4e190cf3 | 104 | %{!shared: %{!mdll: %{!mno-cygwin:crt0%O%s} %{mno-cygwin:" MINGW_LIBS " mingw/crt2%O%s} \ |
05d9f8b0 | 105 | %{pg:gcrt0%O%s}}}" |
4e190cf3 CF |
106 | |
107 | #undef CPP_SPEC | |
f6fc3552 CF |
108 | #define CPP_SPEC "%(cpp_cpu) %{posix:-D_POSIX_SOURCE} \ |
109 | -D__stdcall=__attribute__((__stdcall__)) \ | |
110 | -D__cdecl=__attribute__((__cdecl__)) \ | |
111 | %{!ansi:-D_stdcall=__attribute__((__stdcall__)) \ | |
112 | -D_cdecl=__attribute__((__cdecl__))} \ | |
113 | -D__declspec(x)=__attribute__((x)) \ | |
114 | -D__i386__ -D__i386 \ | |
936ee790 | 115 | %{mno-win32: %{mno-cygwin: %emno-cygwin and mno-win32 are not compatible}} \ |
936ee790 CF |
116 | %{mno-cygwin:-D__MSVCRT__ -D__MINGW32__ %{mthreads:-D_MT} " MINGW_INCLUDES \ |
117 | " -mwin32} \ | |
f6fc3552 | 118 | %{!mno-cygwin:-D__CYGWIN32__ -D__CYGWIN__ -Dunix -D__unix__ -D__unix \ |
4e190cf3 | 119 | " CYGWIN_INCLUDES "} \ |
936ee790 CF |
120 | %{mwin32:-DWIN32 -D_WIN32 -D__WIN32 -D__WIN32__ -DWINNT " CYGWIN_W32API "} \ |
121 | " | |
ffb6cec0 SC |
122 | |
123 | /* This macro defines names of additional specifications to put in the specs | |
124 | that can be used in various specifications like CC1_SPEC. Its definition | |
125 | is an initializer with a subgrouping for each command option. | |
126 | ||
127 | Each subgrouping contains a string constant, that defines the | |
128 | specification name, and a string constant that used by the GNU CC driver | |
129 | program. | |
130 | ||
131 | Do not define this macro if it does not need to do anything. */ | |
132 | ||
133 | #undef SUBTARGET_EXTRA_SPECS | |
134 | #define SUBTARGET_EXTRA_SPECS \ | |
135 | { "mingw_include_path", DEFAULT_TARGET_MACHINE } | |
956d6950 | 136 | |
f5089633 RK |
137 | /* We have to dynamic link to get to the system DLLs. All of libc, libm and |
138 | the Unix stuff is in cygwin.dll. The import library is called | |
139 | 'libcygwin.a'. For Windows applications, include more libraries, but | |
140 | always include kernel32. We'd like to specific subsystem windows to | |
141 | ld, but that doesn't work just yet. */ | |
3a2c1cd8 MM |
142 | |
143 | #undef LIB_SPEC | |
040688bd | 144 | #define LIB_SPEC "%{pg:-lgmon} \ |
03fb4780 CF |
145 | %{!mno-cygwin:-lcygwin} \ |
146 | %{mno-cygwin:%{mthreads:-lmingwthrd} -lmingw32} \ | |
147 | %{mwindows:-lgdi32 -lcomdlg32} \ | |
148 | -luser32 -lkernel32 -ladvapi32 -lshell32" | |
3a2c1cd8 | 149 | |
040688bd | 150 | #define LINK_SPEC "%{mwindows:--subsystem windows} \ |
03fb4780 CF |
151 | %{mconsole:--subsystem console} \ |
152 | %{shared: %{mdll: %eshared and mdll are not compatible}} \ | |
153 | %{shared: --shared} %{mdll:--dll} \ | |
154 | %{static:-Bstatic} %{!static:-Bdynamic} \ | |
155 | %{shared|mdll: -e \ | |
156 | %{mno-cygwin:_DllMainCRTStartup@12} \ | |
157 | %{!mno-cygwin:__cygwin_dll_entry@12}}" | |
26d1d6ad | 158 | |
03fb4780 CF |
159 | #undef MATH_LIBRARY |
160 | #define MATH_LIBRARY "" | |
3a2c1cd8 MM |
161 | |
162 | #define SIZE_TYPE "unsigned int" | |
163 | #define PTRDIFF_TYPE "int" | |
164 | #define WCHAR_UNSIGNED 1 | |
165 | #define WCHAR_TYPE_SIZE 16 | |
166 | #define WCHAR_TYPE "short unsigned int" | |
040688bd | 167 | |
27da1b4d | 168 | \f |
c678a7f8 NC |
169 | /* Enable parsing of #pragma pack(push,<n>) and #pragma pack(pop). */ |
170 | #define HANDLE_PRAGMA_PACK_PUSH_POP 1 | |
171 | ||
27da1b4d MK |
172 | /* A C expression whose value is nonzero if IDENTIFIER with arguments ARGS |
173 | is a valid machine specific attribute for DECL. | |
174 | The attributes in ATTRIBUTES have previously been assigned to DECL. */ | |
03fb4780 CF |
175 | |
176 | union tree_node; | |
177 | #define TREE union tree_node * | |
27da1b4d MK |
178 | |
179 | #undef VALID_MACHINE_DECL_ATTRIBUTE | |
180 | #define VALID_MACHINE_DECL_ATTRIBUTE(DECL, ATTRIBUTES, IDENTIFIER, ARGS) \ | |
181 | i386_pe_valid_decl_attribute_p (DECL, ATTRIBUTES, IDENTIFIER, ARGS) | |
03fb4780 | 182 | extern int i386_pe_valid_decl_attribute_p PARAMS ((TREE, TREE, TREE, TREE)); |
27da1b4d | 183 | |
ac478ac0 JM |
184 | /* A C expression whose value is nonzero if IDENTIFIER with arguments ARGS |
185 | is a valid machine specific attribute for TYPE. | |
186 | The attributes in ATTRIBUTES have previously been assigned to TYPE. */ | |
187 | ||
188 | #undef VALID_MACHINE_TYPE_ATTRIBUTE | |
189 | #define VALID_MACHINE_TYPE_ATTRIBUTE(TYPE, ATTRIBUTES, IDENTIFIER, ARGS) \ | |
190 | i386_pe_valid_type_attribute_p (TYPE, ATTRIBUTES, IDENTIFIER, ARGS) | |
03fb4780 | 191 | extern int i386_pe_valid_type_attribute_p PARAMS ((TREE, TREE, TREE, TREE)); |
ac478ac0 | 192 | |
03fb4780 | 193 | extern union tree_node *i386_pe_merge_decl_attributes PARAMS ((TREE, TREE)); |
27da1b4d MK |
194 | #define MERGE_MACHINE_DECL_ATTRIBUTES(OLD, NEW) \ |
195 | i386_pe_merge_decl_attributes ((OLD), (NEW)) | |
03fb4780 | 196 | extern TREE i386_pe_merge_decl_attributes PARAMS ((TREE, TREE)); |
27da1b4d MK |
197 | |
198 | /* Used to implement dllexport overriding dllimport semantics. It's also used | |
199 | to handle vtables - the first pass won't do anything because | |
200 | DECL_CONTEXT (DECL) will be 0 so i386_pe_dll{ex,im}port_p will return 0. | |
201 | It's also used to handle dllimport override semantics. */ | |
202 | #if 0 | |
203 | #define REDO_SECTION_INFO_P(DECL) \ | |
204 | ((DECL_MACHINE_ATTRIBUTES (DECL) != NULL_TREE) \ | |
205 | || (TREE_CODE (DECL) == VAR_DECL && DECL_VIRTUAL_P (DECL))) | |
206 | #else | |
207 | #define REDO_SECTION_INFO_P(DECL) 1 | |
208 | #endif | |
209 | ||
210 | \f | |
3a2c1cd8 | 211 | #undef EXTRA_SECTIONS |
27da1b4d | 212 | #define EXTRA_SECTIONS in_ctor, in_dtor, in_drectve |
3a2c1cd8 MM |
213 | |
214 | #undef EXTRA_SECTION_FUNCTIONS | |
215 | #define EXTRA_SECTION_FUNCTIONS \ | |
216 | CTOR_SECTION_FUNCTION \ | |
27da1b4d MK |
217 | DTOR_SECTION_FUNCTION \ |
218 | DRECTVE_SECTION_FUNCTION \ | |
219 | SWITCH_TO_SECTION_FUNCTION | |
3a2c1cd8 MM |
220 | |
221 | #define CTOR_SECTION_FUNCTION \ | |
222 | void \ | |
223 | ctor_section () \ | |
224 | { \ | |
225 | if (in_section != in_ctor) \ | |
226 | { \ | |
227 | fprintf (asm_out_file, "\t.section .ctor\n"); \ | |
228 | in_section = in_ctor; \ | |
229 | } \ | |
230 | } | |
79f96374 | 231 | void ctor_section PARAMS ((void)); |
3a2c1cd8 MM |
232 | |
233 | #define DTOR_SECTION_FUNCTION \ | |
234 | void \ | |
235 | dtor_section () \ | |
236 | { \ | |
237 | if (in_section != in_dtor) \ | |
238 | { \ | |
239 | fprintf (asm_out_file, "\t.section .dtor\n"); \ | |
240 | in_section = in_dtor; \ | |
241 | } \ | |
242 | } | |
79f96374 | 243 | void dtor_section PARAMS ((void)); |
3a2c1cd8 | 244 | |
27da1b4d MK |
245 | #define DRECTVE_SECTION_FUNCTION \ |
246 | void \ | |
247 | drectve_section () \ | |
248 | { \ | |
249 | if (in_section != in_drectve) \ | |
250 | { \ | |
251 | fprintf (asm_out_file, "%s\n", "\t.section .drectve\n"); \ | |
252 | in_section = in_drectve; \ | |
253 | } \ | |
254 | } | |
79f96374 | 255 | void drectve_section PARAMS ((void)); |
27da1b4d MK |
256 | |
257 | /* Switch to SECTION (an `enum in_section'). | |
258 | ||
259 | ??? This facility should be provided by GCC proper. | |
260 | The problem is that we want to temporarily switch sections in | |
261 | ASM_DECLARE_OBJECT_NAME and then switch back to the original section | |
262 | afterwards. */ | |
263 | #define SWITCH_TO_SECTION_FUNCTION \ | |
79f96374 | 264 | void switch_to_section PARAMS ((enum in_section, tree)); \ |
27da1b4d MK |
265 | void \ |
266 | switch_to_section (section, decl) \ | |
267 | enum in_section section; \ | |
268 | tree decl; \ | |
269 | { \ | |
270 | switch (section) \ | |
271 | { \ | |
272 | case in_text: text_section (); break; \ | |
273 | case in_data: data_section (); break; \ | |
274 | case in_named: named_section (decl, NULL, 0); break; \ | |
275 | case in_ctor: ctor_section (); break; \ | |
276 | case in_dtor: dtor_section (); break; \ | |
277 | case in_drectve: drectve_section (); break; \ | |
278 | default: abort (); break; \ | |
279 | } \ | |
280 | } | |
281 | ||
3a2c1cd8 MM |
282 | #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \ |
283 | do { \ | |
284 | ctor_section (); \ | |
285 | fprintf (FILE, "%s\t", ASM_LONG); \ | |
286 | assemble_name (FILE, NAME); \ | |
287 | fprintf (FILE, "\n"); \ | |
288 | } while (0) | |
289 | ||
290 | #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \ | |
291 | do { \ | |
292 | dtor_section (); \ | |
293 | fprintf (FILE, "%s\t", ASM_LONG); \ | |
27da1b4d | 294 | assemble_name (FILE, NAME); \ |
3a2c1cd8 MM |
295 | fprintf (FILE, "\n"); \ |
296 | } while (0) | |
297 | ||
2b9f972f MK |
298 | /* Don't allow flag_pic to propagate since gas may produce invalid code |
299 | otherwise. */ | |
300 | ||
301 | #undef SUBTARGET_OVERRIDE_OPTIONS | |
302 | #define SUBTARGET_OVERRIDE_OPTIONS \ | |
303 | do { \ | |
304 | if (flag_pic) \ | |
305 | { \ | |
306 | warning ("-f%s ignored for target (all code is position independent)",\ | |
307 | (flag_pic > 1) ? "PIC" : "pic"); \ | |
308 | flag_pic = 0; \ | |
309 | } \ | |
310 | } while (0) \ | |
311 | ||
3a2c1cd8 MM |
312 | /* Define this macro if references to a symbol must be treated |
313 | differently depending on something about the variable or | |
314 | function named by the symbol (such as what section it is in). | |
315 | ||
3a2c1cd8 MM |
316 | On i386 running Windows NT, modify the assembler name with a suffix |
317 | consisting of an atsign (@) followed by string of digits that represents | |
318 | the number of bytes of arguments passed to the function, if it has the | |
27da1b4d MK |
319 | attribute STDCALL. |
320 | ||
321 | In addition, we must mark dll symbols specially. Definitions of | |
322 | dllexport'd objects install some info in the .drectve section. | |
323 | References to dllimport'd objects are fetched indirectly via | |
324 | _imp__. If both are declared, dllexport overrides. This is also | |
325 | needed to implement one-only vtables: they go into their own | |
326 | section and we need to set DECL_SECTION_NAME so we do that here. | |
327 | Note that we can be called twice on the same decl. */ | |
328 | ||
03fb4780 | 329 | extern void i386_pe_encode_section_info PARAMS ((TREE)); |
3a2c1cd8 MM |
330 | |
331 | #ifdef ENCODE_SECTION_INFO | |
332 | #undef ENCODE_SECTION_INFO | |
3a2c1cd8 | 333 | #endif |
27da1b4d | 334 | #define ENCODE_SECTION_INFO(DECL) i386_pe_encode_section_info (DECL) |
3a2c1cd8 | 335 | |
27da1b4d MK |
336 | /* Utility used only in this file. */ |
337 | #define I386_PE_STRIP_ENCODING(SYM_NAME) \ | |
338 | ((SYM_NAME) + ((SYM_NAME)[0] == '@' ? 3 : 0)) | |
e5e809f4 | 339 | |
27da1b4d MK |
340 | /* This macro gets just the user-specified name |
341 | out of the string in a SYMBOL_REF. Discard | |
342 | trailing @[NUM] encoded by ENCODE_SECTION_INFO. */ | |
93006f8c MK |
343 | #undef STRIP_NAME_ENCODING |
344 | #define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) \ | |
345 | do { \ | |
ec940faa KG |
346 | const char *_p; \ |
347 | const char *_name = I386_PE_STRIP_ENCODING (SYMBOL_NAME); \ | |
93006f8c MK |
348 | for (_p = _name; *_p && *_p != '@'; ++_p) \ |
349 | ; \ | |
350 | if (*_p == '@') \ | |
351 | { \ | |
352 | int _len = _p - _name; \ | |
ec940faa KG |
353 | char *_new_name = (char *) alloca (_len + 1); \ |
354 | strncpy (_new_name, _name, _len); \ | |
355 | _new_name[_len] = '\0'; \ | |
356 | (VAR) = _new_name; \ | |
93006f8c MK |
357 | } \ |
358 | else \ | |
359 | (VAR) = _name; \ | |
360 | } while (0) | |
361 | ||
27da1b4d MK |
362 | \f |
363 | /* Output a reference to a label. */ | |
364 | #undef ASM_OUTPUT_LABELREF | |
365 | #define ASM_OUTPUT_LABELREF(STREAM, NAME) \ | |
366 | fprintf (STREAM, "%s%s", USER_LABEL_PREFIX, \ | |
936ee790 | 367 | I386_PE_STRIP_ENCODING (NAME)) \ |
27da1b4d | 368 | |
27da1b4d MK |
369 | /* Output a common block. */ |
370 | #undef ASM_OUTPUT_COMMON | |
371 | #define ASM_OUTPUT_COMMON(STREAM, NAME, SIZE, ROUNDED) \ | |
372 | do { \ | |
373 | if (i386_pe_dllexport_name_p (NAME)) \ | |
8e260ba4 | 374 | i386_pe_record_exported_symbol (NAME, 1); \ |
27da1b4d MK |
375 | if (! i386_pe_dllimport_name_p (NAME)) \ |
376 | { \ | |
377 | fprintf ((STREAM), "\t.comm\t"); \ | |
378 | assemble_name ((STREAM), (NAME)); \ | |
379 | fprintf ((STREAM), ", %d\t%s %d\n", \ | |
380 | (ROUNDED), ASM_COMMENT_START, (SIZE)); \ | |
381 | } \ | |
382 | } while (0) | |
383 | ||
384 | /* Output the label for an initialized variable. */ | |
385 | #undef ASM_DECLARE_OBJECT_NAME | |
386 | #define ASM_DECLARE_OBJECT_NAME(STREAM, NAME, DECL) \ | |
387 | do { \ | |
388 | if (i386_pe_dllexport_name_p (NAME)) \ | |
8e260ba4 | 389 | i386_pe_record_exported_symbol (NAME, 1); \ |
27da1b4d MK |
390 | ASM_OUTPUT_LABEL ((STREAM), (NAME)); \ |
391 | } while (0) | |
392 | ||
393 | \f | |
1e9b6647 | 394 | /* Emit code to check the stack when allocating more that 4000 |
3a2c1cd8 MM |
395 | bytes in one go. */ |
396 | ||
1e9b6647 | 397 | #define CHECK_STACK_LIMIT 4000 |
3a2c1cd8 MM |
398 | |
399 | /* By default, target has a 80387, uses IEEE compatible arithmetic, | |
400 | and returns float values in the 387 and needs stack probes */ | |
25f94bb5 | 401 | #undef TARGET_SUBTARGET_DEFAULT |
3a2c1cd8 | 402 | |
25f94bb5 | 403 | #define TARGET_SUBTARGET_DEFAULT \ |
3a2c1cd8 MM |
404 | (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_STACK_PROBE) |
405 | ||
d5967781 MM |
406 | /* This is how to output an assembler line |
407 | that says to advance the location counter | |
408 | to a multiple of 2**LOG bytes. */ | |
409 | ||
410 | #undef ASM_OUTPUT_ALIGN | |
411 | #define ASM_OUTPUT_ALIGN(FILE,LOG) \ | |
412 | if ((LOG)!=0) fprintf ((FILE), "\t.align %d\n", 1<<(LOG)) | |
b64deb96 | 413 | |
5b5686f5 JM |
414 | /* Define this macro if in some cases global symbols from one translation |
415 | unit may not be bound to undefined symbols in another translation unit | |
416 | without user intervention. For instance, under Microsoft Windows | |
417 | symbols must be explicitly imported from shared libraries (DLLs). */ | |
418 | #define MULTIPLE_SYMBOL_SPACES | |
419 | ||
ad4ff310 | 420 | #define UNIQUE_SECTION_P(DECL) DECL_ONE_ONLY (DECL) |
03fb4780 | 421 | extern void i386_pe_unique_section PARAMS ((TREE, int)); |
ad4ff310 | 422 | #define UNIQUE_SECTION(DECL,RELOC) i386_pe_unique_section (DECL, RELOC) |
b64deb96 | 423 | |
ad4ff310 | 424 | #define SUPPORTS_ONE_ONLY 1 |
b64deb96 JM |
425 | |
426 | /* A C statement to output something to the assembler file to switch to section | |
427 | NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or | |
428 | NULL_TREE. Some target formats do not support arbitrary sections. Do not | |
429 | define this macro in such cases. */ | |
430 | #undef ASM_OUTPUT_SECTION_NAME | |
a1612a6c MK |
431 | #define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC) \ |
432 | do { \ | |
433 | static struct section_info \ | |
434 | { \ | |
435 | struct section_info *next; \ | |
436 | char *name; \ | |
437 | enum sect_enum {SECT_RW, SECT_RO, SECT_EXEC} type; \ | |
438 | } *sections; \ | |
439 | struct section_info *s; \ | |
3cce094d | 440 | const char *mode; \ |
a1612a6c MK |
441 | enum sect_enum type; \ |
442 | \ | |
443 | for (s = sections; s; s = s->next) \ | |
444 | if (!strcmp (NAME, s->name)) \ | |
445 | break; \ | |
446 | \ | |
447 | if (DECL && TREE_CODE (DECL) == FUNCTION_DECL) \ | |
448 | type = SECT_EXEC, mode = "x"; \ | |
449 | else if (DECL && DECL_READONLY_SECTION (DECL, RELOC)) \ | |
450 | type = SECT_RO, mode = ""; \ | |
451 | else \ | |
593d3a34 MK |
452 | { \ |
453 | type = SECT_RW; \ | |
454 | if (TREE_CODE (DECL) == VAR_DECL \ | |
936ee790 CF |
455 | && lookup_attribute ("shared", DECL_MACHINE_ATTRIBUTES (DECL))) \ |
456 | mode = "ws"; \ | |
593d3a34 | 457 | else \ |
936ee790 | 458 | mode = "w"; \ |
593d3a34 | 459 | } \ |
a1612a6c MK |
460 | \ |
461 | if (s == 0) \ | |
462 | { \ | |
463 | s = (struct section_info *) xmalloc (sizeof (struct section_info)); \ | |
464 | s->name = xmalloc ((strlen (NAME) + 1) * sizeof (*NAME)); \ | |
465 | strcpy (s->name, NAME); \ | |
466 | s->type = type; \ | |
467 | s->next = sections; \ | |
468 | sections = s; \ | |
469 | fprintf (STREAM, ".section\t%s,\"%s\"\n", NAME, mode); \ | |
470 | /* Functions may have been compiled at various levels of \ | |
936ee790 CF |
471 | optimization so we can't use `same_size' here. Instead, \ |
472 | have the linker pick one. */ \ | |
a1612a6c | 473 | if ((DECL) && DECL_ONE_ONLY (DECL)) \ |
936ee790 CF |
474 | fprintf (STREAM, "\t.linkonce %s\n", \ |
475 | TREE_CODE (DECL) == FUNCTION_DECL \ | |
476 | ? "discard" : "same_size"); \ | |
a1612a6c MK |
477 | } \ |
478 | else \ | |
479 | { \ | |
a1612a6c MK |
480 | fprintf (STREAM, ".section\t%s,\"%s\"\n", NAME, mode); \ |
481 | } \ | |
b64deb96 | 482 | } while (0) |
8f3189a4 | 483 | |
672a233f ILT |
484 | /* Write the extra assembler code needed to declare a function |
485 | properly. If we are generating SDB debugging information, this | |
486 | will happen automatically, so we only need to handle other cases. */ | |
c8d9f965 | 487 | #undef ASM_DECLARE_FUNCTION_NAME |
672a233f ILT |
488 | #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \ |
489 | do \ | |
490 | { \ | |
c8d9f965 | 491 | if (i386_pe_dllexport_name_p (NAME)) \ |
8e260ba4 | 492 | i386_pe_record_exported_symbol (NAME, 0); \ |
672a233f ILT |
493 | if (write_symbols != SDB_DEBUG) \ |
494 | i386_pe_declare_function_type (FILE, NAME, TREE_PUBLIC (DECL)); \ | |
495 | ASM_OUTPUT_LABEL (FILE, NAME); \ | |
496 | } \ | |
497 | while (0) | |
498 | ||
499 | /* Add an external function to the list of functions to be declared at | |
500 | the end of the file. */ | |
501 | #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \ | |
502 | do \ | |
503 | { \ | |
504 | if (TREE_CODE (DECL) == FUNCTION_DECL) \ | |
505 | i386_pe_record_external_function (NAME); \ | |
506 | } \ | |
507 | while (0) | |
508 | ||
509 | /* Declare the type properly for any external libcall. */ | |
510 | #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \ | |
511 | i386_pe_declare_function_type (FILE, XSTR (FUN, 0), 1) | |
512 | ||
0181177d JL |
513 | /* This says out to put a global symbol in the BSS section. */ |
514 | #undef ASM_OUTPUT_ALIGNED_BSS | |
515 | #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \ | |
516 | asm_output_aligned_bss ((FILE), (DECL), (NAME), (SIZE), (ALIGN)) | |
517 | ||
672a233f | 518 | /* Output function declarations at the end of the file. */ |
4cf12e7e | 519 | #undef ASM_FILE_END |
672a233f ILT |
520 | #define ASM_FILE_END(FILE) \ |
521 | i386_pe_asm_file_end (FILE) | |
522 | ||
8f3189a4 JW |
523 | #undef ASM_COMMENT_START |
524 | #define ASM_COMMENT_START " #" | |
da932f04 JL |
525 | |
526 | /* DWARF2 Unwinding doesn't work with exception handling yet. */ | |
527 | #define DWARF2_UNWIND_INFO 0 | |
528 | ||
05853640 MK |
529 | /* Don't assume anything about the header files. */ |
530 | #define NO_IMPLICIT_EXTERN_C | |
672a233f | 531 | |
84530511 SC |
532 | #define SUBTARGET_PROLOGUE \ |
533 | if (profile_flag \ | |
5b47282c | 534 | && MAIN_NAME_P (DECL_NAME (current_function_decl))) \ |
84530511 | 535 | { \ |
e075ae69 | 536 | emit_call_insn (gen_rtx (CALL, VOIDmode, \ |
936ee790 | 537 | gen_rtx_MEM (FUNCTION_MODE, \ |
e075ae69 RH |
538 | gen_rtx_SYMBOL_REF (Pmode, "_monstartup")), \ |
539 | const0_rtx)); \ | |
84530511 SC |
540 | } |
541 | ||
672a233f ILT |
542 | /* External function declarations. */ |
543 | ||
79f96374 DB |
544 | extern void i386_pe_record_external_function PARAMS ((const char *)); |
545 | extern void i386_pe_declare_function_type PARAMS ((FILE *, const char *, int)); | |
546 | extern void i386_pe_record_exported_symbol PARAMS ((const char *, int)); | |
547 | extern void i386_pe_asm_file_end PARAMS ((FILE *)); | |
548 | extern int i386_pe_dllexport_name_p PARAMS ((const char *)); | |
549 | extern int i386_pe_dllimport_name_p PARAMS ((const char *)); | |
a2cd38a9 MK |
550 | |
551 | /* For Win32 ABI compatibility */ | |
552 | #undef DEFAULT_PCC_STRUCT_RETURN | |
553 | #define DEFAULT_PCC_STRUCT_RETURN 0 | |
554 | ||
3fafc2f6 MK |
555 | /* No data type wants to be aligned rounder than this. */ |
556 | #undef BIGGEST_ALIGNMENT | |
557 | #define BIGGEST_ALIGNMENT 128 | |
558 | ||
559 | /* A bitfield declared as `int' forces `int' alignment for the struct. */ | |
560 | #undef PCC_BITFIELDS_TYPE_MATTERS | |
03fb4780 CF |
561 | #define PCC_BITFIELDS_TYPE_MATTERS 1 |
562 | #define GROUP_BITFIELDS_BY_ALIGN TYPE_NATIVE(rec) | |
563 | ||
3fafc2f6 | 564 | |
8c84eeed MK |
565 | /* Enable alias attribute support. */ |
566 | #ifndef SET_ASM_OP | |
71d48a01 | 567 | #define SET_ASM_OP "\t.set\t" |
8c84eeed MK |
568 | #endif |
569 | ||
eb70f628 | 570 | #ifndef INT_ASM_OP |
71d48a01 | 571 | #define INT_ASM_OP "\t.long\t" |
eb70f628 MK |
572 | #endif |
573 | ||
abffe289 CF |
574 | #undef MD_STARTFILE_PREFIX |
575 | #define MD_STARTFILE_PREFIX "/usr/lib/" | |
576 | ||
03fb4780 | 577 | #undef STANDARD_STARTFILE_PREFIX |
abffe289 | 578 | #define STANDARD_STARTFILE_PREFIX "/usr/lib/mingw/" |
03fb4780 | 579 | |
f6fc3552 CF |
580 | #ifndef CROSS_COMPILE |
581 | #undef LOCAL_INCLUDE_DIR | |
582 | #undef TOOL_INCLUDE_DIR | |
583 | #undef SYSTEM_INCLUDE_DIR | |
584 | #undef STANDARD_INCLUDE_DIR | |
585 | #define STANDARD_INCLUDE_DIR 0 | |
586 | #endif | |
587 | ||
03fb4780 CF |
588 | #undef TREE |
589 | ||
590 | #ifndef BUFSIZ | |
591 | # undef FILE | |
592 | #endif |