OSDN Git Service

cd51815085dd2ed757d17977881bbeebbfb43e63
[pf3gnuchains/gcc-fork.git] / gcc / config / i386 / beos-elf.h
1 /* Definitions for Intel x86 running BeOS
2    Copyright (C) 1998-99, 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 <i386/i386.h>  /* Base i386 target machine definitions */
22 #include <i386/att.h>   /* Use the i386 AT&T assembler syntax */
23 #include <svr4.h>       /* some common stuff */
24
25 #undef TARGET_VERSION
26 #define TARGET_VERSION fprintf (stderr, " (i386 BeOS/ELF)");
27
28 /* Change debugging to Dwarf2.  */
29 #undef PREFERRED_DEBUGGING_TYPE
30 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
31
32 /* The SVR4 ABI for the i386 says that records and unions are returned
33    in memory.  */
34 #undef DEFAULT_PCC_STRUCT_RETURN
35 #define DEFAULT_PCC_STRUCT_RETURN 1
36
37 #undef ASM_COMMENT_START
38 #define ASM_COMMENT_START " #"
39
40 /* This is how to output an element of a case-vector that is relative.
41    This is only used for PIC code.  See comments by the `casesi' insn in
42    i386.md for an explanation of the expression this outputs. */
43 #undef ASM_OUTPUT_ADDR_DIFF_ELT
44 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
45   fprintf (FILE, "\t.long _GLOBAL_OFFSET_TABLE_+[.-%s%d]\n", LPREFIX, VALUE)
46
47 /* Indicate that jump tables go in the text section.  This is
48    necessary when compiling PIC code.  */
49 #define JUMP_TABLES_IN_TEXT_SECTION (flag_pic)
50
51 #undef DBX_REGISTER_NUMBER
52 #define DBX_REGISTER_NUMBER(n)  svr4_dbx_register_map[n]
53
54 /* Output assembler code to FILE to increment profiler label # LABELNO
55    for profiling a function entry.  */
56
57 #undef FUNCTION_PROFILER
58 #define FUNCTION_PROFILER(FILE, LABELNO)  \
59 {                                                                       \
60   if (flag_pic)                                                         \
61     {                                                                   \
62       fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%edx\n",              \
63                LPREFIX, (LABELNO));                                     \
64       fprintf (FILE, "\tcall *mcount@GOT(%%ebx)\n");                    \
65     }                                                                   \
66   else                                                                  \
67     {                                                                   \
68       fprintf (FILE, "\tmovl $%sP%d,%%edx\n", LPREFIX, (LABELNO));      \
69       fprintf (FILE, "\tcall mcount\n");                                \
70     }                                                                   \
71 }
72
73 #undef SIZE_TYPE
74 #define SIZE_TYPE "long unsigned int"
75  
76 #undef PTRDIFF_TYPE
77 #define PTRDIFF_TYPE "long int"
78   
79 #undef WCHAR_TYPE
80 #define WCHAR_TYPE "short unsigned int"
81    
82 #undef WCHAR_UNSIGNED
83 #define WCHAR_UNSIGNED 1
84
85 #undef WCHAR_TYPE_SIZE
86 #define WCHAR_TYPE_SIZE 16
87     
88 #undef CPP_PREDEFINES
89 #define CPP_PREDEFINES "-D__ELF__ -D__BEOS__ -D__INTEL__ -D_X86_=1 \
90 -D__stdcall=__attribute__((__stdcall__)) \
91 -D__cdecl=__attribute__((__cdecl__)) \
92 -D__declspec(x)=__attribute__((x)) \
93 -Asystem(beos)"
94
95 #undef CPP_SPEC
96 #define CPP_SPEC "%(cpp_cpu) %{!no-fPIC:%{!no-fpic:-D__PIC__ -D__pic__}}"
97
98 /* BeOS uses lots of multichars, so don't warn about them unless the
99    user explicitly asks for the warnings with -Wmultichar.  Note that
100    CC1_SPEC is used for both cc1 and cc1plus. */
101
102 #undef CC1_SPEC
103 #define CC1_SPEC "%{!no-fpic:%{!fPIC:-fpic}} %{!Wmultichar: -Wno-multichar} %(cc1_cpu) %{profile:-p}"
104
105 #undef CC1PLUS_SPEC
106 #define CC1PLUS_SPEC "%{!Wctor-dtor-privacy:-Wno-ctor-dtor-privacy}"
107
108 /* Provide a LINK_SPEC appropriate for BeOS.  Here we provide support
109    for the special GCC options -static and -shared, which allow us to
110    link things in one of these three modes by applying the appropriate
111    combinations of options at link-time. */
112
113 /* If ELF is the default format, we should not use /lib/elf. */
114
115 #undef  LINK_SPEC
116 #define LINK_SPEC "%{!o*:-o %b} -m elf_i386_be -shared -Bsymbolic %{nostart:-e 0}"
117
118 /* Provide start and end file specs appropriate to glibc.  */
119
120 /* LIB_SPEC for BeOS */
121 #undef LIB_SPEC
122 #define LIB_SPEC "-lnet -lroot"
123
124 /* gcc runtime lib is built into libroot.so on BeOS */
125 /* ??? This is gonna be lovely when the next release of gcc has 
126    some new symbol in, so that links start failing.  */
127 #undef LIBGCC_SPEC
128 #define LIBGCC_SPEC ""
129
130 #undef  STARTFILE_SPEC
131 #define STARTFILE_SPEC "crti.o%s crtbegin.o%s %{!nostart:start_dyn.o%s}"
132
133 #undef  ENDFILE_SPEC
134 #define ENDFILE_SPEC "crtend.o%s crtn.o%s"
135
136 /* Get perform_* macros to build libgcc.a.  */
137 #include "i386/perform.h"
138
139 /* A C statement (sans semicolon) to output to the stdio stream
140    FILE the assembler definition of uninitialized global DECL named
141    NAME whose size is SIZE bytes and alignment is ALIGN bytes.
142    Try to use asm_output_aligned_bss to implement this macro.  */
143
144 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
145   asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
146
147 /* A C statement to output to the stdio stream FILE an assembler
148    command to advance the location counter to a multiple of 1<<LOG
149    bytes if it is within MAX_SKIP bytes.
150
151    This is used to align code labels according to Intel recommendations.  */
152
153 #ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
154 #define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP) \
155   if ((LOG)!=0) \
156     if ((MAX_SKIP)==0) fprintf ((FILE), "\t.p2align %d\n", (LOG)); \
157     else fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP))
158 #endif
159
160 /*
161  * Support for __declspec(dllimport) & __declspec(dllexport).
162  */
163
164 /* We don't care about dllimport.  */
165
166 #define TARGET_NOP_FUN_DLLIMPORT 1
167
168 /* A C expression whose value is nonzero if IDENTIFIER with arguments ARGS
169    is a valid machine specific attribute for DECL.
170    The attributes in ATTRIBUTES have previously been assigned to DECL.  */
171
172 #undef VALID_MACHINE_DECL_ATTRIBUTE
173 #define VALID_MACHINE_DECL_ATTRIBUTE(DECL, ATTRIBUTES, IDENTIFIER, ARGS) \
174   i386_pe_valid_decl_attribute_p (DECL, ATTRIBUTES, IDENTIFIER, ARGS)
175 extern int i386_pe_valid_decl_attribute_p ();
176
177 /* A C expression whose value is nonzero if IDENTIFIER with arguments ARGS
178    is a valid machine specific attribute for TYPE.
179    The attributes in ATTRIBUTES have previously been assigned to TYPE.  */
180
181 #undef VALID_MACHINE_TYPE_ATTRIBUTE
182 #define VALID_MACHINE_TYPE_ATTRIBUTE(TYPE, ATTRIBUTES, IDENTIFIER, ARGS) \
183   i386_pe_valid_type_attribute_p (TYPE, ATTRIBUTES, IDENTIFIER, ARGS)
184 extern int i386_pe_valid_type_attribute_p ();
185
186 #define MERGE_MACHINE_DECL_ATTRIBUTES(OLD, NEW) \
187   i386_pe_merge_decl_attributes ((OLD), (NEW))
188 extern union tree_node *i386_pe_merge_decl_attributes ();
189
190 /* Used to implement dllexport overriding dllimport semantics.  It's also used
191    to handle vtables - the first pass won't do anything because
192    DECL_CONTEXT (DECL) will be 0 so i386_pe_dll{ex,im}port_p will return 0.
193    It's also used to handle dllimport override semantics.  */
194 #if 0
195 #define REDO_SECTION_INFO_P(DECL) \
196   ((DECL_MACHINE_ATTRIBUTES (DECL) != NULL_TREE) \
197    || (TREE_CODE (DECL) == VAR_DECL && DECL_VIRTUAL_P (DECL)))
198 #else
199 #define REDO_SECTION_INFO_P(DECL) 1
200 #endif
201
202 /* Used only here locally.  If the decl has been exported, emit the 
203    necessary assembly.  */
204
205 #define ASM_EXPORT_DECL(FILE, NAME, DECL)                               \
206   do {                                                                  \
207     if ((DECL) && i386_pe_dllexport_p (DECL))                           \
208       {                                                                 \
209         fprintf ((FILE), ".section .exports\n");                        \
210         fprintf ((FILE), "\t%s\t\"", STRING_ASM_OP);                    \
211         assemble_name (FILE, NAME);                                     \
212         fprintf ((FILE), "\"\n.previous\n");                            \
213       }                                                                 \
214   } while (0)
215
216 /* Write the extra assembler code needed to declare a function properly.
217    Some svr4 assemblers need to also have something extra said about the
218    function's return value.  We allow for that here.  */
219
220 #undef ASM_DECLARE_FUNCTION_NAME
221 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)                     \
222   do {                                                                  \
223     ASM_EXPORT_DECL(FILE, NAME, DECL);                                  \
224     fprintf (FILE, "\t%s\t ", TYPE_ASM_OP);                             \
225     assemble_name (FILE, NAME);                                         \
226     putc (',', FILE);                                                   \
227     fprintf (FILE, TYPE_OPERAND_FMT, "function");                       \
228     putc ('\n', FILE);                                                  \
229     ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL));                      \
230     ASM_OUTPUT_LABEL(FILE, NAME);                                       \
231   } while (0)
232
233 /* Write the extra assembler code needed to declare an object properly.  */
234
235 #undef ASM_DECLARE_OBJECT_NAME
236 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)                       \
237   do {                                                                  \
238     ASM_EXPORT_DECL(FILE, NAME, DECL);                                  \
239     fprintf (FILE, "\t%s\t ", TYPE_ASM_OP);                             \
240     assemble_name (FILE, NAME);                                         \
241     putc (',', FILE);                                                   \
242     fprintf (FILE, TYPE_OPERAND_FMT, "object");                         \
243     putc ('\n', FILE);                                                  \
244     size_directive_output = 0;                                          \
245     if (!flag_inhibit_size_directive && DECL_SIZE (DECL))               \
246       {                                                                 \
247         size_directive_output = 1;                                      \
248         fprintf (FILE, "\t%s\t ", SIZE_ASM_OP);                         \
249         assemble_name (FILE, NAME);                                     \
250         putc (',', FILE);                                               \
251         fprintf (FILE, HOST_WIDE_INT_PRINT_DEC,                         \
252                  int_size_in_bytes (TREE_TYPE (DECL)));                 \
253         fputc ('\n', FILE);                                             \
254       }                                                                 \
255     ASM_OUTPUT_LABEL(FILE, NAME);                                       \
256   } while (0)
257
258 /* Similarly for COMMON symbols.  */
259
260 #undef ASM_OUTPUT_ALIGNED_COMMON
261 #undef ASM_OUTPUT_ALIGNED_DECL_COMMON
262 #define ASM_OUTPUT_ALIGNED_DECL_COMMON(FILE, DECL, NAME, SIZE, ALIGN)   \
263   do {                                                                  \
264     ASM_EXPORT_DECL(FILE, NAME, DECL);                                  \
265     fprintf ((FILE), "\t%s\t", COMMON_ASM_OP);                          \
266     assemble_name ((FILE), (NAME));                                     \
267     fprintf ((FILE), ",%u,%u\n", (SIZE), (ALIGN) / BITS_PER_UNIT);      \
268   } while (0)
269
270 #undef ASM_OUTPUT_ALIGNED_LOCAL
271 #undef ASM_OUTPUT_ALIGNED_DECL_LOCAL
272 #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(FILE, DECL, NAME, SIZE, ALIGN)         \
273   do {                                                                       \
274     fprintf ((FILE), "\t%s\t", LOCAL_ASM_OP);                                \
275     assemble_name ((FILE), (NAME));                                          \
276     fprintf ((FILE), "\n");                                                  \
277     ASM_OUTPUT_ALIGNED_DECL_COMMON((FILE), (DECL), (NAME), (SIZE), (ALIGN)); \
278   } while (0)
279
280 /* This macro gets just the user-specified name out of the string in a
281    SYMBOL_REF.  Discard trailing @[NUM] encoded by ENCODE_SECTION_INFO.  */
282 /* Unused except to let winnt.c compile.  */
283
284 #undef  STRIP_NAME_ENCODING
285 #define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) ((VAR) = (SYMBOL_NAME))
286
287 /* For native compiler, use standard BeOS include file search paths
288    rooted in /boot/develop/headers.  For a cross compiler, don't
289    expect the host to use the BeOS directory scheme, and instead look
290    for the BeOS include files relative to TOOL_INCLUDE_DIR.  Yes, we
291    use ANSI string concatenation here (FIXME) */
292
293 #ifndef CROSS_COMPILE
294 #undef INCLUDE_DEFAULTS
295 #define INCLUDE_DEFAULTS \
296     { \
297     { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1 },\
298     { GCC_INCLUDE_DIR, "GCC", 0, 0 },\
299     { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1}, \
300     { "/boot/develop/headers/be/add-ons/graphics", 0, 0, 0 },\
301     { "/boot/develop/headers/be/devel", 0, 0, 0 },\
302     { "/boot/develop/headers/be/translation", 0, 0, 0 },\
303     { "/boot/develop/headers/be/mail", 0, 0, 0 },\
304     { "/boot/develop/headers/gnu", 0, 0, 0 },\
305     { "/boot/develop/headers/be/drivers", 0, 0, 0 },\
306     { "/boot/develop/headers/be/opengl", 0, 0, 0 },\
307     { "/boot/develop/headers/be/game", 0, 0, 0 },\
308     { "/boot/develop/headers/be/support", 0, 0, 0 },\
309     { "/boot/develop/headers/be/storage", 0, 0, 0 },\
310     { "/boot/develop/headers/be/kernel", 0, 0, 0 },\
311     { "/boot/develop/headers/be/net", 0, 0, 0 },\
312     { "/boot/develop/headers/be/midi", 0, 0, 0 },\
313     { "/boot/develop/headers/be/media", 0, 0, 0 },\
314     { "/boot/develop/headers/be/interface", 0, 0, 0 },\
315     { "/boot/develop/headers/be/device", 0, 0, 0 },\
316     { "/boot/develop/headers/be/app", 0, 0, 0 },\
317     { "/boot/develop/headers/cpp", 0, 0, 0 },\
318     { "/boot/develop/headers/posix", 0, 0, 0 },\
319     { "/boot/develop/headers/be/precompiled", 0, 0, 0 },\
320     { "/boot/develop/headers/be", 0, 0, 0 },\
321     { "/boot/develop/headers", 0, 0, 0 }, \
322     { 0, 0, 0, 0 } \
323     };
324 #else /* CROSS_COMPILE */
325 #undef  INCLUDE_DEFAULTS
326 #define INCLUDE_DEFAULTS                                \
327     { \
328     { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1 },\
329     { GCC_INCLUDE_DIR, "GCC", 0, 0 },\
330     { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1}, \
331     { CROSS_INCLUDE_DIR "/be/add-ons/graphics", 0, 0, 0 },\
332     { CROSS_INCLUDE_DIR "/be/devel", 0, 0, 0 },\
333     { CROSS_INCLUDE_DIR "/be/translation", 0, 0, 0 },\
334     { CROSS_INCLUDE_DIR "/be/mail", 0, 0, 0 },\
335     { CROSS_INCLUDE_DIR "/gnu", 0, 0, 0 },\
336     { CROSS_INCLUDE_DIR "/be/drivers", 0, 0, 0 },\
337     { CROSS_INCLUDE_DIR "/be/opengl", 0, 0, 0 },\
338     { CROSS_INCLUDE_DIR "/be/game", 0, 0, 0 },\
339     { CROSS_INCLUDE_DIR "/be/support", 0, 0, 0 },\
340     { CROSS_INCLUDE_DIR "/be/storage", 0, 0, 0 },\
341     { CROSS_INCLUDE_DIR "/be/kernel", 0, 0, 0 },\
342     { CROSS_INCLUDE_DIR "/be/net", 0, 0, 0 },\
343     { CROSS_INCLUDE_DIR "/be/midi", 0, 0, 0 },\
344     { CROSS_INCLUDE_DIR "/be/media", 0, 0, 0 },\
345     { CROSS_INCLUDE_DIR "/be/interface", 0, 0, 0 },\
346     { CROSS_INCLUDE_DIR "/be/device", 0, 0, 0 },\
347     { CROSS_INCLUDE_DIR "/be/app", 0, 0, 0 },\
348     { CROSS_INCLUDE_DIR "/cpp", 0, 0, 0 },\
349     { CROSS_INCLUDE_DIR "/posix", 0, 0, 0 },\
350     { CROSS_INCLUDE_DIR "/be/precompiled", 0, 0, 0 },\
351     { CROSS_INCLUDE_DIR "/be", 0, 0, 0 },\
352     { CROSS_INCLUDE_DIR , 0, 0, 0 }, \
353     { 0, 0, 0, 0 } \
354     };
355 #endif
356
357 /* Whee.  LIBRARY_PATH is Be's LD_LIBRARY_PATH, which of course will
358    cause nasty problems if we override it.  */
359 #define LIBRARY_PATH_ENV        "BELIBRARIES"
360
361 /* BeOS doesn't have a separate math library.  */
362 #define MATH_LIBRARY ""
363
364 /* BeOS headers are C++-aware (and often use C++).  */
365 #define NO_IMPLICIT_EXTERN_C
366
367 /* Define this macro if in some cases global symbols from one translation
368    unit may not be bound to undefined symbols in another translation unit
369    without user intervention.  For instance, under Microsoft Windows
370    symbols must be explicitly imported from shared libraries (DLLs).  */
371 #define MULTIPLE_SYMBOL_SPACES
372
373 /* A C statement to output assembler commands which will identify the object
374    file as having been compiled with GNU CC.  This isn't needed for BeOS
375    because we use DWARF and DWARF has an DW_AT_producer tag that does the
376    same thing.  BeOS debuggers, like bdb, that don't know about this hack
377    can get confused when they find two symbols with the same address, and
378    print the wrong one (gcc2_compiled) in things like backtraces.  The most
379    likely ill effect of disabling this is that a BeOS port of gdb would not
380    be able to tell that an executable was compiled with gcc if there was no
381    DWARF info. */
382 #undef ASM_IDENTIFY_GCC
383 #define ASM_IDENTIFY_GCC(FILE)