OSDN Git Service

* config/i386/djgpp.h (UNIQUE_SECTION): Constify the variables
[pf3gnuchains/gcc-fork.git] / gcc / config / i386 / djgpp.h
1 /* Configuration for an i386 running MS-DOS with DJGPP.
2    Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
3
4 This file is part of GNU CC.
5
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING.  If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.  */
20
21 #include "dbxcoff.h"
22
23 /* Don't assume anything about the header files. */
24 #define NO_IMPLICIT_EXTERN_C
25
26 #define HANDLE_SYSV_PRAGMA
27
28 /* Enable parsing of #pragma pack(push,<n>) and #pragma pack(pop).  */
29 #define HANDLE_PRAGMA_PACK_PUSH_POP 1
30
31 #define YES_UNDERSCORES
32
33 #include "i386/gas.h"
34
35 /* If defined, a C expression whose value is a string containing the
36    assembler operation to identify the following data as
37    uninitialized global data.  If not defined, and neither
38    `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined,
39    uninitialized global data will be output in the data section if
40    `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be
41    used.  */
42 #undef BSS_SECTION_ASM_OP
43 #define BSS_SECTION_ASM_OP "\t.section\t.bss"
44
45 /* Define the name of the .ctor section.  */
46 #undef CTORS_SECTION_ASM_OP
47 #define CTORS_SECTION_ASM_OP "\t.section .ctor"
48
49 /* Define the name of the .data section.  */
50 #undef DATA_SECTION_ASM_OP
51 #define DATA_SECTION_ASM_OP "\t.section .data"
52
53 /* Define the name of the .dtor section.  */
54 #undef DTORS_SECTION_ASM_OP
55 #define DTORS_SECTION_ASM_OP "\t.section .dtor"
56
57 /* Define the name of the .eh_frame section.  */
58 #undef EH_FRAME_SECTION_ASM_OP
59 #define EH_FRAME_SECTION_ASM_OP "\t.section .eh_frame"
60
61 /* Define the name of the .ident op.  */
62 #undef IDENT_ASM_OP
63 #define IDENT_ASM_OP "\t.ident\t"
64
65 /* Define the name of the .int op.  */
66 #undef INT_ASM_OP
67 #define INT_ASM_OP "\t.long\t"
68
69 /* Enable alias attribute support.  */
70 #ifndef SET_ASM_OP
71 #define SET_ASM_OP "\t.set\t"
72 #endif
73
74 /* Define the name of the .text section.  */
75 #undef TEXT_SECTION_ASM_OP
76 #define TEXT_SECTION_ASM_OP "\t.section .text"
77
78 /* Tell GCC where our standard include directory is.  */
79 #undef STANDARD_INCLUDE_DIR
80 #define STANDARD_INCLUDE_DIR "/dev/env/DJDIR/include/"
81
82 /* Search for as.exe and ld.exe in DJGPP's binary directory. */ 
83 #define MD_EXEC_PREFIX "/dev/env/DJDIR/bin/"
84
85 /* Correctly handle absolute filename detection in cp/xref.c */
86 #define FILE_NAME_ABSOLUTE_P(NAME) \
87         (((NAME)[0] == '/') || ((NAME)[0] == '\\') || \
88         (((NAME)[0] >= 'A') && ((NAME)[0] <= 'z') && ((NAME)[1] == ':')))
89
90 #undef CPP_PREDEFINES
91 #define CPP_PREDEFINES "-DGO32 -DDJGPP=2 -D__MSDOS__ -Asystem(msdos)"
92
93 /* Include <sys/version.h> so __DJGPP__ and __DJGPP_MINOR__ are defined.  */
94 #undef CPP_SPEC
95 #define CPP_SPEC "-remap %(cpp_cpu) %{posix:-D_POSIX_SOURCE} \
96   -imacros %s../include/sys/version.h"
97
98 /* We need to override link_command_spec in gcc.c so support -Tdjgpp.djl.
99    This cannot be done in LINK_SPECS as that LINK_SPECS is processed
100    before library search directories are known by the linker.
101    This avoids problems when specs file is not available. An alternate way,
102    suggested by Robert Hoehne, is to use SUBTARGET_EXTRA_SPECS instead.
103 */ 
104
105 #undef LINK_COMMAND_SPEC
106 #define LINK_COMMAND_SPEC \
107 "%{!fsyntax-only: \
108 %{!c:%{!M:%{!MM:%{!E:%{!S:%(linker) %l %X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} \
109 \t%{r} %{s} %{t} %{u*} %{x} %{z} %{Z}\
110 \t%{!A:%{!nostdlib:%{!nostartfiles:%S}}}\
111 \t%{static:} %{L*} %D %o\
112 \t%{!nostdlib:%{!nodefaultlibs:%G %L %G}}\
113 \t%{!A:%{!nostdlib:%{!nostartfiles:%E}}}\
114 \t-Tdjgpp.djl %{T*}}}}}}}\n\
115 %{!c:%{!M:%{!MM:%{!E:%{!S:stubify %{v} %{o*:%*} %{!o*:a.out} }}}}}"
116
117 /* Always just link in 'libc.a'.  */
118 #undef LIB_SPEC
119 #define LIB_SPEC "-lc"
120
121 /* Pick the right startup code depending on the -pg flag.  */
122 #undef STARTFILE_SPEC
123 #define STARTFILE_SPEC "%{pg:gcrt0.o%s}%{!pg:crt0.o%s}"
124
125 /* Make sure that gcc will not look for .h files in /usr/local/include 
126    unless user explicitly requests it.  */
127 #undef LOCAL_INCLUDE_DIR
128
129 #undef EXTRA_SECTIONS
130 #define EXTRA_SECTIONS in_ctor, in_dtor
131
132 #undef EXTRA_SECTION_FUNCTIONS
133 #define EXTRA_SECTION_FUNCTIONS                                 \
134   CTOR_SECTION_FUNCTION                                         \
135   DTOR_SECTION_FUNCTION
136
137 #define CTOR_SECTION_FUNCTION                                   \
138 void                                                            \
139 ctor_section ()                                                 \
140 {                                                               \
141   if (in_section != in_ctor)                                    \
142     {                                                           \
143       fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP);     \
144       in_section = in_ctor;                                     \
145     }                                                           \
146 }
147
148 #define DTOR_SECTION_FUNCTION                                   \
149 void                                                            \
150 dtor_section ()                                                 \
151 {                                                               \
152   if (in_section != in_dtor)                                    \
153     {                                                           \
154       fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP);     \
155       in_section = in_dtor;                                     \
156     }                                                           \
157 }
158
159 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME)       \
160   do {                                          \
161     ctor_section ();                            \
162     fprintf (FILE, "%s\t", ASM_LONG);           \
163     assemble_name (FILE, NAME);                 \
164     fprintf (FILE, "\n");                       \
165   } while (0)
166
167 /* Tell GCC how to output a section name. Add "x" for code sections.  */
168 #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC)\
169   do {                                                                  \
170     if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL)                    \
171       fprintf ((FILE), "\t.section %s,\"x\"\n", (NAME));                \
172     else                                                                \
173       fprintf ((FILE), "\t.section %s\n", (NAME));                      \
174   } while (0)
175
176 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME)        \
177   do {                                          \
178     dtor_section ();                            \
179     fprintf (FILE, "%s\t", ASM_LONG);           \
180     assemble_name (FILE, NAME);                 \
181     fprintf (FILE, "\n");                       \
182   } while (0)
183
184 /* Output at beginning of assembler file.  */
185 /* The .file command should always begin the output.  */
186
187 #undef ASM_FILE_START
188 #define ASM_FILE_START(FILE)                                            \
189   do {                                                                  \
190         output_file_directive (FILE, main_input_filename);              \
191   } while (0)
192
193 /* This is how to output an assembler line
194    that says to advance the location counter
195    to a multiple of 2**LOG bytes.  */
196
197 #undef ASM_OUTPUT_ALIGN
198 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
199   if ((LOG) != 0) fprintf ((FILE), "\t.p2align %d\n", LOG)
200
201 /* This is how to output a global symbol in the BSS section.  */
202 #undef ASM_OUTPUT_ALIGNED_BSS
203 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
204   asm_output_aligned_bss ((FILE), (DECL), (NAME), (SIZE), (ALIGN))
205
206 /* This is how to tell assembler that a symbol is weak  */ 
207 #undef ASM_WEAKEN_LABEL
208 #define ASM_WEAKEN_LABEL(FILE,NAME) \
209   do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
210        fputc ('\n', FILE); } while (0)
211
212 /* djgpp automatically calls its own version of __main, so don't define one
213    in libgcc, nor call one in main().  */
214 #define HAS_INIT_SECTION
215
216 /* Definitions for types and sizes. Wide characters are 16-bits long so
217    Win32 compiler add-ons will be wide character compatible.  */
218 #undef WCHAR_UNSIGNED
219 #define WCHAR_UNSIGNED 1
220
221 #undef WCHAR_TYPE_SIZE
222 #define WCHAR_TYPE_SIZE 16
223
224 #undef WCHAR_TYPE
225 #define WCHAR_TYPE "short unsigned int"
226
227 #undef WINT_TYPE
228 #define WINT_TYPE "int"
229
230 #undef SIZE_TYPE
231 #define SIZE_TYPE "long unsigned int"
232
233 #undef PTRDIFF_TYPE
234 #define PTRDIFF_TYPE "int"
235
236 /* Used to be defined in xm-djgpp.h, but moved here for cross-compilers.  */
237 #define LIBSTDCXX "-lstdcxx"
238
239 /* Add command line option -mbnu210 to indicate we can use binutil 2.10's features.  */
240 #undef MASK_BNU210
241 #define MASK_BNU210 (0x40000000)
242
243 #undef SUBTARGET_SWITCHES
244 #define SUBTARGET_SWITCHES              \
245   { "bnu210", -MASK_BNU210, "Enable weak symbol and enhanced C++ template support. Binutils 2.10 or higher required." }, \
246   { "no-bnu210", MASK_BNU210, "Disable weak symbol and enhanced C++ template support." },
247
248 /* Weak symbols and .gnu.linkonce are only in Binutils-2.10 and later. 
249    Default to using Binutils 2.10 features.  */
250 #undef SUPPORTS_WEAK
251 #define SUPPORTS_WEAK ((target_flags & MASK_BNU210) == 0)
252
253 #undef SUPPORTS_ONE_ONLY
254 #define SUPPORTS_ONE_ONLY ((target_flags & MASK_BNU210) == 0)
255
256 /* Support for C++ templates.  */
257 #undef MAKE_DECL_ONE_ONLY
258 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
259
260 /* Additional support for C++ templates and support for
261    garbage collection.  */
262 #undef UNIQUE_SECTION_P
263 #define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL))
264
265 #undef UNIQUE_SECTION
266 #define UNIQUE_SECTION(DECL,RELOC)                              \
267 do {                                                            \
268   int len;                                                      \
269   const char *name, *prefix;                                    \
270   char *string;                                                 \
271                                                                 \
272   name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL));       \
273                                                                 \
274   if (! DECL_ONE_ONLY (DECL))                                   \
275     {                                                           \
276       if (TREE_CODE (DECL) == FUNCTION_DECL)                    \
277         prefix = ".text.";                                      \
278       else if (DECL_READONLY_SECTION (DECL, RELOC))             \
279         prefix = ".rodata.";                                    \
280       else                                                      \
281         prefix = ".data.";                                      \
282     }                                                           \
283   else if (TREE_CODE (DECL) == FUNCTION_DECL)                   \
284     prefix = ".gnu.linkonce.t.";                                \
285   else if (DECL_READONLY_SECTION (DECL, RELOC))                 \
286     prefix = ".gnu.linkonce.r.";                                \
287   else                                                          \
288     prefix = ".gnu.linkonce.d.";                                \
289                                                                 \
290   len = strlen (name) + strlen (prefix);                        \
291   string = alloca (len + 1);                                    \
292   sprintf (string, "%s%s", prefix, name);                       \
293                                                                 \
294   DECL_SECTION_NAME (DECL) = build_string (len, string);        \
295 } while (0)