Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6515 serge 1
/* Operating system specific defines to be used when targeting GCC for
2
   hosting on Windows32, using a Unix style C library and tools.
3
   Copyright (C) 1995-2015 Free Software Foundation, Inc.
4
 
5
This file is part of GCC.
6
 
7
GCC is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 3, or (at your option)
10
any later version.
11
 
12
GCC is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
GNU General Public License for more details.
16
 
17
You should have received a copy of the GNU General Public License
18
along with GCC; see the file COPYING3.  If not see
19
.  */
20
 
21
#define DBX_DEBUGGING_INFO 1
22
#define SDB_DEBUGGING_INFO 1
23
#if TARGET_64BIT_DEFAULT || defined (HAVE_GAS_PE_SECREL32_RELOC)
24
#define DWARF2_DEBUGGING_INFO 1
25
#endif
26
 
27
#undef PREFERRED_DEBUGGING_TYPE
28
#if (DWARF2_DEBUGGING_INFO)
29
#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
30
#else
31
#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
32
#endif
33
 
34
#undef TARGET_SEH
35
#define TARGET_SEH  (TARGET_64BIT_MS_ABI && flag_unwind_tables)
36
 
37
/* Win64 with SEH cannot represent DRAP stack frames.  Disable its use.
38
   Force the use of different mechanisms to allocate aligned local data.  */
39
#undef MAX_STACK_ALIGNMENT
40
#define MAX_STACK_ALIGNMENT  (TARGET_SEH ? 128 : MAX_OFILE_ALIGNMENT)
41
 
42
/* Support hooks for SEH.  */
43
#undef  TARGET_ASM_UNWIND_EMIT
44
#define TARGET_ASM_UNWIND_EMIT  i386_pe_seh_unwind_emit
45
#undef  TARGET_ASM_UNWIND_EMIT_BEFORE_INSN
46
#define TARGET_ASM_UNWIND_EMIT_BEFORE_INSN  false
47
#undef  TARGET_ASM_FUNCTION_END_PROLOGUE
48
#define TARGET_ASM_FUNCTION_END_PROLOGUE  i386_pe_seh_end_prologue
49
#undef  TARGET_ASM_EMIT_EXCEPT_PERSONALITY
50
#define TARGET_ASM_EMIT_EXCEPT_PERSONALITY i386_pe_seh_emit_except_personality
51
#undef  TARGET_ASM_INIT_SECTIONS
52
#define TARGET_ASM_INIT_SECTIONS  i386_pe_seh_init_sections
53
#define SUBTARGET_ASM_UNWIND_INIT  i386_pe_seh_init
54
 
55
#undef DEFAULT_ABI
56
#define DEFAULT_ABI (TARGET_64BIT ? MS_ABI : SYSV_ABI)
57
 
58
#undef TARGET_PECOFF
59
#define TARGET_PECOFF 1
60
 
61
#if ! defined (USE_MINGW64_LEADING_UNDERSCORES)
62
#undef USER_LABEL_PREFIX
63
#define USER_LABEL_PREFIX (TARGET_64BIT ? "" : "_")
64
 
65
#undef LOCAL_LABEL_PREFIX
66
#define LOCAL_LABEL_PREFIX (TARGET_64BIT ? "." : "")
67
 
68
#undef ASM_GENERATE_INTERNAL_LABEL
69
#define ASM_GENERATE_INTERNAL_LABEL(BUF,PREFIX,NUMBER)  \
70
  sprintf ((BUF), "*%s%s%ld", LOCAL_LABEL_PREFIX, \
71
	   (PREFIX), (long)(NUMBER))
72
 
73
#undef LPREFIX
74
#define LPREFIX (TARGET_64BIT ? ".L" : "L")
75
 
76
#endif
77
 
78
#undef DBX_REGISTER_NUMBER
79
#define DBX_REGISTER_NUMBER(n)				\
80
  (TARGET_64BIT ? dbx64_register_map[n]			\
81
   : (write_symbols == DWARF2_DEBUG			\
82
      ? svr4_dbx_register_map[n] : dbx_register_map[n]))
83
 
84
/* Map gcc register number to DWARF 2 CFA column number. For 32 bit
85
   target, always use the svr4_dbx_register_map for DWARF .eh_frame
86
   even if we don't use DWARF .debug_frame. */
87
#undef DWARF_FRAME_REGNUM
88
#define DWARF_FRAME_REGNUM(n)				\
89
  (TARGET_64BIT ? dbx64_register_map[(n)]		\
90
		: svr4_dbx_register_map[(n)])
91
 
92
/* The 64-bit MS_ABI changes the set of call-used registers.  */
93
#undef DWARF_FRAME_REGISTERS
94
#define DWARF_FRAME_REGISTERS (TARGET_64BIT ? 33 : 17)
95
 
96
#ifdef HAVE_GAS_PE_SECREL32_RELOC
97
/* Use section relative relocations for debugging offsets.  Unlike
98
   other targets that fake this by putting the section VMA at 0, PE
99
   won't allow it.  */
100
#define ASM_OUTPUT_DWARF_OFFSET(FILE, SIZE, LABEL, SECTION)	\
101
  do {								\
102
    switch (SIZE)						\
103
      {								\
104
      case 4:							\
105
	fputs ("\t.secrel32\t", FILE);				\
106
	assemble_name (FILE, LABEL);				\
107
	break;							\
108
      case 8:							\
109
	/* This is a hack.  There is no 64-bit section relative	\
110
	   relocation.  However, the COFF format also does not	\
111
	   support 64-bit file offsets; 64-bit applications are	\
112
	   limited to 32-bits of code+data in any one module.	\
113
	   Fake the 64-bit offset by zero-extending it.  */	\
114
	fputs ("\t.secrel32\t", FILE);				\
115
	assemble_name (FILE, LABEL);				\
116
	fputs ("\n\t.long\t0", FILE);				\
117
	break;							\
118
      default:							\
119
	gcc_unreachable ();					\
120
      }								\
121
  } while (0)
122
#endif
123
 
124
#define TARGET_EXECUTABLE_SUFFIX ".exe"
125
 
126
#define TARGET_OS_CPP_BUILTINS()					\
127
  do									\
128
    {									\
129
	if (!TARGET_64BIT)						\
130
	  builtin_define ("_X86_=1");					\
131
	if (TARGET_SEH)							\
132
	  builtin_define ("__SEH__");				\
133
	builtin_assert ("system=winnt");				\
134
	builtin_define ("__stdcall=__attribute__((__stdcall__))");	\
135
	builtin_define ("__fastcall=__attribute__((__fastcall__))");	\
136
	builtin_define ("__thiscall=__attribute__((__thiscall__))");	\
137
	builtin_define ("__cdecl=__attribute__((__cdecl__))");		\
138
	if (!flag_iso)							\
139
	  {								\
140
	    builtin_define ("_stdcall=__attribute__((__stdcall__))");	\
141
	    builtin_define ("_fastcall=__attribute__((__fastcall__))");	\
142
	    builtin_define ("_thiscall=__attribute__((__thiscall__))");	\
143
	    builtin_define ("_cdecl=__attribute__((__cdecl__))");	\
144
	  }								\
145
	/* Even though linkonce works with static libs, this is needed 	\
146
	    to compare typeinfo symbols across dll boundaries.  */	\
147
	builtin_define ("__GXX_MERGED_TYPEINFO_NAMES=0");		\
148
	builtin_define ("__GXX_TYPEINFO_EQUALITY_INLINE=0");		\
149
	EXTRA_OS_CPP_BUILTINS ();					\
150
  }									\
151
  while (0)
152
 
153
/* Get tree.c to declare a target-specific specialization of
154
   merge_decl_attributes.  */
155
#define TARGET_DLLIMPORT_DECL_ATTRIBUTES 1
156
 
157
/* This macro defines names of additional specifications to put in the specs
158
   that can be used in various specifications like CC1_SPEC.  Its definition
159
   is an initializer with a subgrouping for each command option.
160
 
161
   Each subgrouping contains a string constant, that defines the
162
   specification name, and a string constant that used by the GCC driver
163
   program.
164
 
165
   Do not define this macro if it does not need to do anything.  */
166
 
167
#undef  SUBTARGET_EXTRA_SPECS
168
#define SUBTARGET_EXTRA_SPECS						\
169
  { "mingw_include_path", DEFAULT_TARGET_MACHINE }
170
 
171
#undef MATH_LIBRARY
172
#define MATH_LIBRARY ""
173
 
174
#undef TARGET_LIBC_HAS_FUNCTION
175
#define TARGET_LIBC_HAS_FUNCTION no_c99_libc_has_function
176
 
177
#define SIZE_TYPE (TARGET_64BIT ? "long long unsigned int" : "unsigned int")
178
#define PTRDIFF_TYPE (TARGET_64BIT ? "long long int" : "int")
179
 
180
#define WCHAR_TYPE_SIZE 16
181
#define WCHAR_TYPE "short unsigned int"
182
 
183
/* Windows64 continues to use a 32-bit long type.  */
184
#undef LONG_TYPE_SIZE
185
#define LONG_TYPE_SIZE 32
186
 
187
#define drectve_section() \
188
  (fprintf (asm_out_file, "\t.section .drectve\n"), \
189
   in_section = NULL)
190
 
191
/* Older versions of gas don't handle 'r' as data.
192
   Explicitly set data flag with 'd'.  */
193
#define READONLY_DATA_SECTION_ASM_OP "\t.section .rdata,\"dr\""
194
 
195
/* Don't allow flag_pic to propagate since gas may produce invalid code
196
   otherwise.  */
197
 
198
#undef  SUBTARGET_OVERRIDE_OPTIONS
199
#define SUBTARGET_OVERRIDE_OPTIONS					\
200
do {									\
201
  if (TARGET_64BIT && flag_pic != 1)					\
202
    {									\
203
      if (flag_pic > 1)							\
204
        warning (0,							\
205
	         "-fPIC ignored for target (all code is position independent)"\
206
                 );                         				\
207
      flag_pic = 1;							\
208
    }									\
209
  else if (!TARGET_64BIT && flag_pic)					\
210
    {									\
211
      warning (0, "-f%s ignored for target (all code is position independent)",\
212
	       (flag_pic > 1) ? "PIC" : "pic");				\
213
      flag_pic = 0;							\
214
    }									\
215
} while (0)
216
 
217
/* Define this macro if references to a symbol must be treated
218
   differently depending on something about the variable or
219
   function named by the symbol (such as what section it is in).
220
 
221
   On i386 running Windows NT, modify the assembler name with a suffix
222
   consisting of an atsign (@) followed by string of digits that represents
223
   the number of bytes of arguments passed to the function, if it has the
224
   attribute STDCALL.
225
 
226
   In addition, we must mark dll symbols specially. Definitions of
227
   dllexport'd objects install some info in the .drectve section.
228
   References to dllimport'd objects are fetched indirectly via
229
   _imp__.  If both are declared, dllexport overrides.  This is also
230
   needed to implement one-only vtables: they go into their own
231
   section and we need to set DECL_SECTION_NAME so we do that here.
232
   Note that we can be called twice on the same decl.  */
233
 
234
#define SUBTARGET_ENCODE_SECTION_INFO  i386_pe_encode_section_info
235
 
236
/* Local and global relocs can be placed always into readonly memory
237
   for PE-COFF targets.  */
238
#undef TARGET_ASM_RELOC_RW_MASK
239
#define TARGET_ASM_RELOC_RW_MASK i386_pe_reloc_rw_mask
240
 
241
/* Output a common block.  */
242
#undef ASM_OUTPUT_ALIGNED_DECL_COMMON
243
#define ASM_OUTPUT_ALIGNED_DECL_COMMON \
244
  i386_pe_asm_output_aligned_decl_common
245
 
246
/* Output the label for an initialized variable.  */
247
#undef ASM_DECLARE_OBJECT_NAME
248
#define ASM_DECLARE_OBJECT_NAME(STREAM, NAME, DECL)	\
249
do {							\
250
  i386_pe_maybe_record_exported_symbol (DECL, NAME, 1);	\
251
  ASM_OUTPUT_LABEL ((STREAM), (NAME));			\
252
} while (0)
253
 
254
/* Output a reference to a label. Fastcall function symbols
255
   keep their '@' prefix, while other symbols are prefixed
256
   with user_label_prefix.  */
257
#undef ASM_OUTPUT_LABELREF
258
#define  ASM_OUTPUT_LABELREF(STREAM, NAME)	\
259
do {						\
260
  if ((NAME)[0] != FASTCALL_PREFIX)		\
261
    fputs (user_label_prefix, (STREAM));	\
262
  fputs ((NAME), (STREAM));			\
263
} while (0)
264
 
265
/* This does much the same in memory rather than to a stream.  */
266
#undef TARGET_MANGLE_ASSEMBLER_NAME
267
#define TARGET_MANGLE_ASSEMBLER_NAME i386_pe_mangle_assembler_name
268
 
269
 
270
/* Emit code to check the stack when allocating more than 4000
271
   bytes in one go.  */
272
#define CHECK_STACK_LIMIT 4000
273
 
274
#undef STACK_BOUNDARY
275
#define STACK_BOUNDARY	(TARGET_64BIT && ix86_abi == MS_ABI ? 128 : BITS_PER_WORD)
276
 
277
/* By default, target has a 80387, uses IEEE compatible arithmetic,
278
   returns float values in the 387 and needs stack probes.
279
   We also align doubles to 64-bits for MSVC default compatibility.  */
280
 
281
#undef TARGET_SUBTARGET_DEFAULT
282
#define TARGET_SUBTARGET_DEFAULT \
283
	(MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS \
284
	 | MASK_STACK_PROBE | MASK_ALIGN_DOUBLE)
285
 
286
#undef TARGET_SUBTARGET64_DEFAULT
287
#define TARGET_SUBTARGET64_DEFAULT \
288
	MASK_128BIT_LONG_DOUBLE
289
 
290
/* This is how to output an assembler line
291
   that says to advance the location counter
292
   to a multiple of 2**LOG bytes.  */
293
 
294
#undef ASM_OUTPUT_ALIGN
295
#define ASM_OUTPUT_ALIGN(FILE,LOG)	\
296
    if ((LOG)!=0) fprintf ((FILE), "\t.align %d\n", 1<<(LOG))
297
 
298
/* Windows uses explicit import from shared libraries.  */
299
#define MULTIPLE_SYMBOL_SPACES 1
300
 
301
#define TARGET_ASM_UNIQUE_SECTION i386_pe_unique_section
302
#define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
303
 
304
#define SUPPORTS_ONE_ONLY 1
305
 
306
/* Switch into a generic section.  */
307
#define TARGET_ASM_NAMED_SECTION  i386_pe_asm_named_section
308
 
309
/* Select attributes for named sections.  */
310
#define TARGET_SECTION_TYPE_FLAGS  i386_pe_section_type_flags
311
 
312
/* Write the extra assembler code needed to declare a function
313
   properly.  If we are generating SDB debugging information, this
314
   will happen automatically, so we only need to handle other cases.  */
315
#undef ASM_DECLARE_FUNCTION_NAME
316
#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
317
  i386_pe_start_function (FILE, NAME, DECL)
318
 
319
#undef ASM_DECLARE_FUNCTION_SIZE
320
#define ASM_DECLARE_FUNCTION_SIZE(FILE,NAME,DECL) \
321
  i386_pe_end_function (FILE, NAME, DECL)
322
 
323
/* Add an external function to the list of functions to be declared at
324
   the end of the file.  */
325
#define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME)				\
326
  do									\
327
    {									\
328
      if (TREE_CODE (DECL) == FUNCTION_DECL)				\
329
	i386_pe_record_external_function ((DECL), (NAME));		\
330
    }									\
331
  while (0)
332
 
333
/* Declare the type properly for any external libcall.  */
334
#define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
335
  i386_pe_declare_function_type (FILE, XSTR (FUN, 0), 1)
336
 
337
/* This says out to put a global symbol in the BSS section.  */
338
#undef ASM_OUTPUT_ALIGNED_BSS
339
#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
340
  asm_output_aligned_bss ((FILE), (DECL), (NAME), (SIZE), (ALIGN))
341
 
342
/* Output function declarations at the end of the file.  */
343
#undef TARGET_ASM_FILE_END
344
#define TARGET_ASM_FILE_END i386_pe_file_end
345
 
346
#undef ASM_COMMENT_START
347
#define ASM_COMMENT_START " #"
348
 
349
#ifndef DWARF2_UNWIND_INFO
350
/* If configured with --disable-sjlj-exceptions, use DWARF2, else
351
   default to SJLJ.  */
352
#if  (defined (CONFIG_SJLJ_EXCEPTIONS) && !CONFIG_SJLJ_EXCEPTIONS)
353
/* The logic of this #if must be kept synchronised with the logic
354
   for selecting the tmake_eh_file fragment in config.gcc.  */
355
#define DWARF2_UNWIND_INFO 1
356
/* If multilib is selected break build as sjlj is required.  */
357
#if defined (TARGET_BI_ARCH)
358
#error For 64-bit windows and 32-bit based multilib version of gcc just SJLJ exceptions are supported.
359
#endif
360
#else
361
#define DWARF2_UNWIND_INFO 0
362
#endif
363
#endif
364
 
365
/* Don't assume anything about the header files.  */
366
#define NO_IMPLICIT_EXTERN_C
367
 
368
#undef PROFILE_HOOK
369
#define PROFILE_HOOK(LABEL)						\
370
  if (MAIN_NAME_P (DECL_NAME (current_function_decl)))			\
371
    {									\
372
      emit_call_insn (gen_rtx_CALL (VOIDmode,				\
373
	gen_rtx_MEM (FUNCTION_MODE,					\
374
		     gen_rtx_SYMBOL_REF (Pmode, "_monstartup")),	\
375
	const0_rtx));							\
376
    }
377
 
378
/* Java Native Interface (JNI) methods on Win32 are invoked using the
379
   stdcall calling convention.  */
380
#undef MODIFY_JNI_METHOD_CALL
381
#define MODIFY_JNI_METHOD_CALL(MDECL)					      \
382
  build_type_attribute_variant ((MDECL),				      \
383
			       build_tree_list (get_identifier ("stdcall"),   \
384
						NULL))
385
 
386
/* For Win32 ABI compatibility */
387
#undef DEFAULT_PCC_STRUCT_RETURN
388
#define DEFAULT_PCC_STRUCT_RETURN 0
389
 
390
/* MSVC returns aggregate types of up to 8 bytes via registers.
391
   See i386.c:ix86_return_in_memory.  */
392
#undef MS_AGGREGATE_RETURN
393
#define MS_AGGREGATE_RETURN 1
394
 
395
/* Biggest alignment supported by the object file format of this
396
   machine.  Use this macro to limit the alignment which can be
397
   specified using the `__attribute__ ((aligned (N)))' construct.  If
398
   not defined, the default value is `BIGGEST_ALIGNMENT'.  */
399
/* IMAGE_SCN_ALIGN_8192BYTES is the largest section alignment flag
400
   specified in the PECOFF60 spec.  Native MS compiler also limits
401
   user-specified alignment to 8192 bytes.  */
402
#undef MAX_OFILE_ALIGNMENT
403
#define MAX_OFILE_ALIGNMENT (8192 * 8)
404
 
405
/* BIGGEST_FIELD_ALIGNMENT macro is used directly by libobjc, There, we
406
   align internal doubles in structures on dword boundaries. Otherwise,
407
   support vector modes using ADJUST_FIELD_ALIGN, defined in i386.h.  */
408
#ifdef IN_TARGET_LIBS
409
#undef	BIGGEST_FIELD_ALIGNMENT
410
#define BIGGEST_FIELD_ALIGNMENT 64
411
#endif
412
 
413
/* A bit-field declared as `int' forces `int' alignment for the struct.  */
414
#undef PCC_BITFIELD_TYPE_MATTERS
415
#define PCC_BITFIELD_TYPE_MATTERS 1
416
#define GROUP_BITFIELDS_BY_ALIGN TYPE_NATIVE(rec)
417
 
418
/* Enable alias attribute support.  */
419
#ifndef SET_ASM_OP
420
#define SET_ASM_OP "\t.set\t"
421
#endif
422
 
423
/* This implements the `alias' attribute, keeping any stdcall or
424
   fastcall decoration.  */
425
#undef	ASM_OUTPUT_DEF_FROM_DECLS
426
#define	ASM_OUTPUT_DEF_FROM_DECLS(STREAM, DECL, TARGET)			\
427
  do									\
428
    {									\
429
      const char *alias							\
430
	= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL));		\
431
      i386_pe_maybe_record_exported_symbol (DECL, alias, 0);		\
432
      if (TREE_CODE (DECL) == FUNCTION_DECL)				\
433
	i386_pe_declare_function_type (STREAM, alias,			\
434
				       TREE_PUBLIC (DECL));		\
435
      ASM_OUTPUT_DEF (STREAM, alias, IDENTIFIER_POINTER (TARGET));	\
436
    } while (0)
437
 
438
/* GNU as supports weak symbols on PECOFF. */
439
#ifdef HAVE_GAS_WEAK
440
#define ASM_WEAKEN_LABEL(FILE, NAME)  \
441
  do                                  \
442
    {                                 \
443
      fputs ("\t.weak\t", (FILE));    \
444
      assemble_name ((FILE), (NAME)); \
445
      fputc ('\n', (FILE));           \
446
    }                                 \
447
  while (0)
448
#endif /* HAVE_GAS_WEAK */
449
 
450
/* FIXME: SUPPORTS_WEAK && TARGET_HAVE_NAMED_SECTIONS is true,
451
   but for .jcr section to work we also need crtbegin and crtend
452
   objects.  */
453
#define TARGET_USE_JCR_SECTION 1
454
 
455
/* Decide whether it is safe to use a local alias for a virtual function
456
   when constructing thunks.  */
457
#undef TARGET_USE_LOCAL_THUNK_ALIAS_P
458
#define TARGET_USE_LOCAL_THUNK_ALIAS_P(DECL) (!DECL_ONE_ONLY (DECL))
459
 
460
#define SUBTARGET_ATTRIBUTE_TABLE \
461
  { "selectany", 0, 0, true, false, false, ix86_handle_selectany_attribute, \
462
    false }
463
  /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,
464
       affects_type_identity } */
465
 
466
/*  mcount() does not need a counter variable.  */
467
#undef NO_PROFILE_COUNTERS
468
#define NO_PROFILE_COUNTERS 1
469
 
470
#define TARGET_VALID_DLLIMPORT_ATTRIBUTE_P i386_pe_valid_dllimport_attribute_p
471
#define TARGET_CXX_ADJUST_CLASS_AT_DEFINITION i386_pe_adjust_class_at_definition
472
#define SUBTARGET_MANGLE_DECL_ASSEMBLER_NAME i386_pe_mangle_decl_assembler_name
473
 
474
#undef TARGET_ASM_ASSEMBLE_VISIBILITY
475
#define TARGET_ASM_ASSEMBLE_VISIBILITY i386_pe_assemble_visibility
476
 
477
#undef SUB_TARGET_RECORD_STUB
478
#define SUB_TARGET_RECORD_STUB i386_pe_record_stub
479
 
480
/* Static stack checking is supported by means of probes.  */
481
#define STACK_CHECK_STATIC_BUILTIN 1