1 /* Target definitions for GCC for Intel 80386 running Interix 2 Parts Copyright (C) 1991-2013 Free Software Foundation, Inc. 3 4 Parts: 5 by Douglas B. Rupp (drupp@cs.washington.edu). 6 by Ron Guilmette (rfg@netcom.com). 7 by Donn Terry (donn@softway.com). 8 by Mumit Khan (khan@xraylith.wisc.edu). 9 10 This file is part of GCC. 11 12 GCC is free software; you can redistribute it and/or modify 13 it under the terms of the GNU General Public License as published by 14 the Free Software Foundation; either version 3, or (at your option) 15 any later version. 16 17 GCC is distributed in the hope that it will be useful, 18 but WITHOUT ANY WARRANTY; without even the implied warranty of 19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 GNU General Public License for more details. 21 22 You should have received a copy of the GNU General Public License 23 along with GCC; see the file COPYING3. If not see 24 <http://www.gnu.org/licenses/>. */ 25 26 /* Note: Interix doesn't support user-written DLLs (use conventional 27 shared libs (.so) instead). Thus a lot of the stuff that might apply 28 about dllimport/dllexport and the like does not apply here. */ 29 30 #include <stdio.h> 31 32 /* Names to predefine in the preprocessor for this target machine. */ 33 34 #define DBX_DEBUGGING_INFO 1 35 #define SDB_DEBUGGING_INFO 1 36 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG 37 38 /* Our strategy for finding global constructors is a bit different, although 39 not a lot. */ 40 #define DO_GLOBAL_CTORS_BODY \ 41 do { \ 42 int i; \ 43 unsigned long nptrs; \ 44 func_ptr *p; \ 45 asm( \ 46 " .section .ctor_head, \"rw\"\n" \ 47 "1:\n" \ 48 " .text \n" \ 49 ASM_LOAD_ADDR(1b,%0) \ 50 : "=r" (p) : : "cc"); \ 51 for (nptrs = 0; p[nptrs] != 0; nptrs++); \ 52 for (i = nptrs-1; i >= 0; i--) \ 53 p[i] (); \ 54 } while (0) 55 56 #define DO_GLOBAL_DTORS_BODY \ 57 do { \ 58 func_ptr *p; \ 59 asm( \ 60 " .section .dtor_head, \"rw\"\n" \ 61 "1:\n" \ 62 " .text \n" \ 63 ASM_LOAD_ADDR(1b,%0) \ 64 : "=r" (p) : : "cc"); \ 65 while (*p) \ 66 { \ 67 p++; \ 68 (*(p-1)) (); \ 69 } \ 70 } while (0) 71 72 /* We don't use the "usual" push-an-address solution. */ 73 #undef TARGET_ASM_CONSTRUCTOR 74 75 #undef SUBTARGET_SWITCHES 76 #define SUBTARGET_SWITCHES \ 77 { "ms-bitfields", MASK_MS_BITFIELD_LAYOUT, N_("Use native (MS) bitfield layout") }, \ 78 { "no-ms-bitfields", -MASK_MS_BITFIELD_LAYOUT, N_("Use gcc default bitfield layout") }, 79 80 #undef LIB_SPEC 81 #define LIB_SPEC "\ 82 %{!shared:%{!dynamic:-lc -lpsxdll \ 83 }} \ 84 %{!G:%{!dynamic:-lc -lpsxdll \ 85 }} \ 86 %{dynamic:-lc -lpsxdll \ 87 } \ 88 %{v}" 89 90 #undef LINK_SPEC 91 #define LINK_SPEC "%{!shared:-stack 0x4000000,0x10000} \ 92 %{g} \ 93 %{dynamic:-Bdynamic} \ 94 %{static:-Bstatic} \ 95 %{shared:--shared -Bdynamic} \ 96 %{G:--shared -Bdynamic} \ 97 %{symbolic:--shared -Bsymbolic -Bdynamic} \ 98 %{rpath*:--rpath %*} \ 99 " 100 101 #undef STARTFILE_SPEC 102 #define STARTFILE_SPEC \ 103 "%{!shared:%{pg:gcrt0%O%s}%{!pg:%{p:mcrt0%O%s}%{!p:crt0%O%s}}} %{shared:crti%O%s}" 104 105 #define TARGET_DECLSPEC 1 106 107 /* cpp handles __STDC__ */ 108 #define TARGET_OS_CPP_BUILTINS() \ 109 do \ 110 { \ 111 builtin_define ("__INTERIX"); \ 112 builtin_define ("_M_IX86=300"); \ 113 builtin_define ("_X86_=1"); \ 114 builtin_define ("__stdcall=__attribute__((__stdcall__))"); \ 115 builtin_define ("__cdecl=__attribute__((__cdecl__))"); \ 116 builtin_define ("__declspec(x)=__attribute__((x))"); \ 117 builtin_assert ("system=unix"); \ 118 builtin_assert ("system=interix"); \ 119 if (preprocessing_asm_p ()) \ 120 builtin_define_std ("LANGUAGE_ASSEMBLY"); \ 121 else \ 122 { \ 123 builtin_define_std ("LANGUAGE_C"); \ 124 if (c_dialect_cxx ()) \ 125 builtin_define_std ("LANGUAGE_C_PLUS_PLUS"); \ 126 if (c_dialect_objc ()) \ 127 builtin_define_std ("LANGUAGE_OBJECTIVE_C"); \ 128 } \ 129 } \ 130 while (0) 131 132 #undef CPP_SPEC 133 #define CPP_SPEC "%{posix:-D_POSIX_SOURCE}" 134 135 #define SIZE_TYPE "unsigned int" 136 #define PTRDIFF_TYPE "int" 137 #define WCHAR_TYPE "short unsigned int" 138 #define WCHAR_TYPE_SIZE 16 139 140 /* Turn off long double being 96 bits. */ 141 #undef LONG_DOUBLE_TYPE_SIZE 142 #define LONG_DOUBLE_TYPE_SIZE 64 143 #undef LIBGCC2_LONG_DOUBLE_TYPE_SIZE 144 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64 145 146 /* The following are needed for us to be able to use winnt.c, but are not 147 otherwise meaningful to Interix. (The functions that use these are 148 never called because we don't do DLLs.) */ 149 #define TARGET_NOP_FUN_DLLIMPORT 1 150 #define drectve_section() /* nothing */ 151 152 153 #define EH_FRAME_IN_DATA_SECTION 154 155 #define READONLY_DATA_SECTION_ASM_OP "\t.section\t.rdata,\"r\"" 156 157 /* Define this macro if references to a symbol must be treated 158 differently depending on something about the variale or 159 function named by the symbol (such as what section it is in). */ 160 161 #undef TARGET_ENCODE_SECTION_INFO 162 #define TARGET_ENCODE_SECTION_INFO i386_pe_encode_section_info 163 #undef TARGET_STRIP_NAME_ENCODING 164 #define TARGET_STRIP_NAME_ENCODING i386_pe_strip_name_encoding_full 165 166 /* Emit code to check the stack when allocating more that 4000 167 bytes in one go. */ 168 169 #define CHECK_STACK_LIMIT 4000 170 171 /* By default, target has a 80387, uses IEEE compatible arithmetic, 172 and returns float values in the 387 and needs stack probes 173 We also align doubles to 64-bits forMSVC default compatibility 174 Ditto for bitfields. */ 175 #undef TARGET_SUBTARGET_DEFAULT 176 #define TARGET_SUBTARGET_DEFAULT \ 177 (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_STACK_PROBE | \ 178 MASK_ALIGN_DOUBLE | MASK_MS_BITFIELD_LAYOUT) 179 180 /* The MS compilers take alignment as a number of bytes, so we do as well */ 181 #undef ASM_OUTPUT_ALIGN 182 #define ASM_OUTPUT_ALIGN(FILE,LOG) \ 183 if ((LOG)!=0) fprintf ((FILE), "\t.balign %d\n", 1<<(LOG)) 184 185 186 /* Define this macro if in some cases global symbols from one translation 187 unit may not be bound to undefined symbols in another translation unit 188 without user intervention. For instance, under Microsoft Windows 189 symbols must be explicitly imported from shared libraries (DLLs). */ 190 /* 191 * Old gcc(3.3) did not have 1 here 192 */ 193 #define MULTIPLE_SYMBOL_SPACES 1 194 195 extern void i386_pe_unique_section PARAMS ((tree, int)); 196 #define TARGET_ASM_UNIQUE_SECTION i386_pe_unique_section 197 198 /* Switch into a generic section. */ 199 #define TARGET_ASM_NAMED_SECTION default_pe_asm_named_section 200 201 /* Select attributes for named sections. */ 202 #define TARGET_SECTION_TYPE_FLAGS i386_pe_section_type_flags 203 204 /* Write the extra assembler code needed to declare a function 205 properly. If we are generating SDB debugging information, this 206 will happen automatically, so we only need to handle other cases. */ 207 #undef ASM_DECLARE_FUNCTION_NAME 208 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \ 209 do \ 210 { \ 211 if (write_symbols != SDB_DEBUG) \ 212 i386_pe_declare_function_type (FILE, NAME, TREE_PUBLIC (DECL)); \ 213 ASM_OUTPUT_LABEL (FILE, NAME); \ 214 } \ 215 while (0) 216 217 /* Add an external function to the list of functions to be declared at 218 the end of the file. */ 219 #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \ 220 do \ 221 { \ 222 if (TREE_CODE (DECL) == FUNCTION_DECL) \ 223 i386_pe_record_external_function (DECL, NAME); \ 224 } \ 225 while (0) 226 227 /* Declare the type properly for any external libcall. */ 228 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \ 229 i386_pe_declare_function_type (FILE, XSTR (FUN, 0), 1) 230 231 /* This says out to put a global symbol in the BSS section. */ 232 #undef ASM_OUTPUT_ALIGNED_BSS 233 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \ 234 asm_output_aligned_bss ((FILE), (DECL), (NAME), (SIZE), (ALIGN)) 235 236 /* Don't assume anything about the header files. */ 237 #define NO_IMPLICIT_EXTERN_C 238 239 /* External function declarations. */ 240 extern void i386_pe_record_external_function (tree, const char *); 241 extern void i386_pe_declare_function_type (FILE *, const char *, int); 242 extern void i386_pe_record_exported_symbol (const char *, int); 243 extern void i386_pe_asm_file_end (FILE *); 244 245 /* For Win32 ABI compatibility */ 246 #undef DEFAULT_PCC_STRUCT_RETURN 247 #define DEFAULT_PCC_STRUCT_RETURN 0 248 249 /* A bitfield declared as `int' forces `int' alignment for the struct. */ 250 #undef PCC_BITFIELD_TYPE_MATTERS 251 #define PCC_BITFIELD_TYPE_MATTERS 1 252 253 /* Enable alias attribute support. */ 254 #ifndef SET_ASM_OP 255 #define SET_ASM_OP "\t.set\t" 256 #endif 257 258 /* Note that there appears to be two different ways to support const 259 sections at the moment. You can either #define the symbol 260 READONLY_DATA_SECTION (giving it some code which switches to the 261 readonly data section) or else you can #define the symbols 262 EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and 263 SELECT_RTX_SECTION. We do both here just to be on the safe side. */ 264 265 #define USE_CONST_SECTION 1 266 267 /* The linker will take care of this, and having them causes problems with 268 ld -r (specifically -rU). */ 269 #define CTOR_LISTS_DEFINED_EXTERNALLY 1 270 271 /* Output a definition (implements alias) */ 272 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \ 273 do \ 274 { \ 275 fputs (SET_ASM_OP, (FILE)); \ 276 assemble_name (FILE, LABEL1); \ 277 fputc (',', (FILE)); \ 278 assemble_name (FILE, LABEL2); \ 279 fputc ('\n', (FILE)); \ 280 } \ 281 while (0) 282 283 #define HOST_PTR_AS_INT unsigned long 284 285 /* The following two flags are usually "off" for i386, because some non-gnu 286 tools (for the i386) don't handle them. However, we don't have that 287 problem, so.... */ 288 289 /* Forward references to tags are allowed. */ 290 #define SDB_ALLOW_FORWARD_REFERENCES 291 /* Unknown tags are also allowed. */ 292 #define SDB_ALLOW_UNKNOWN_REFERENCES 293 /* DWARF2 Unwinding doesn't work with exception handling yet. */ 294 #define DWARF2_UNWIND_INFO 0 295 /* MSVC returns structs of up to 8 bytes via registers. */ 296 297 #undef SUBTARGET_RETURN_IN_MEMORY 298 #define SUBTARGET_RETURN_IN_MEMORY(TYPE, FNTYPE) \ 299 (TYPE_MODE (TYPE) == BLKmode || \ 300 (AGGREGATE_TYPE_P (TYPE) && int_size_in_bytes(TYPE) > 8 )) 301 302 #define ASM_LOAD_ADDR(loc, reg) " leal " #loc "," #reg "\n" 303 304 /* The integer half of this list needs to be constant. However, there's 305 a lot of disagreement about what the floating point adjustments should 306 be. We pick one that works with gdb. (The underlying problem is 307 what to do about the segment registers. Since we have access to them 308 from /proc, we'll allow them to be accessed in gdb, even tho the 309 gcc compiler can't generate them. (There's some evidence that 310 MSVC does, but possibly only for certain special "canned" sequences.) */ 311 312 #undef DBX_REGISTER_NUMBER 313 #define DBX_REGISTER_NUMBER(n) \ 314 (TARGET_64BIT ? dbx64_register_map[n] \ 315 : (n) == 0 ? (int) 0 \ 316 : (n) == 1 ? (int) 2 \ 317 : (n) == 2 ? (int) 1 \ 318 : (n) == 3 ? (int) 3 \ 319 : (n) == 4 ? (int) 6 \ 320 : (n) == 5 ? (int) 7 \ 321 : (n) == 6 ? (int) 5 \ 322 : (n) == 7 ? (int) 4 \ 323 : ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) ? (int) (n)+8 \ 324 : (int) (-1)) 325 326 #define EH_FRAME_IN_DATA_SECTION 327 328 /* the following are OSF linker (not gld) specific... we don't want them */ 329 #undef HAS_INIT_SECTION 330 #undef LD_INIT_SWITCH 331 #undef LD_FINI_SWITCH 332 333 /* The following are needed for us to be able to use winnt.c, but are not 334 otherwise meaningful to Interix. (The functions that use these are 335 never called because we don't do DLLs.) */ 336 #define TARGET_NOP_FUN_DLLIMPORT 1 337 #define I386_PE_STRIP_ENCODING(SYM_NAME) \ 338 ((SYM_NAME) + ((SYM_NAME)[0] == '@' \ 339 ? ((SYM_NAME)[3] == '*' ? 4 : 3) : 0) \ 340 + ((SYM_NAME)[0] == '*' ? 1 : 0)) 341 342 #define drectve_section() /* nothing */ 343 344