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