OSDN Git Service

* config/sparc/aout.h, config/sparc/biarch64.h, config/sparc/elf.h,
[pf3gnuchains/gcc-fork.git] / gcc / config / sparc / freebsd.h
1 /* Definitions for Sun SPARC64 running FreeBSD using the ELF format
2    Copyright (C) 2001, 2002 Free Software Foundation, Inc.
3    Contributed by David E. O'Brien <obrien@FreeBSD.org> and BSDi.
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 2, 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 COPYING.  If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
20
21 /* FreeBSD needs the platform name (sparc64) defined.
22    Emacs needs to know if the arch is 64 or 32-bits.  */
23
24 #undef  CPP_CPU64_DEFAULT_SPEC
25 #define CPP_CPU64_DEFAULT_SPEC \
26   "-D__sparc64__ -D__sparc_v9__ -D__sparcv9 -D__arch64__"
27
28 #define LINK_SPEC "%(link_arch)                                         \
29   %{!mno-relax:%{!r:-relax}}                                            \
30   %{p:%nconsider using `-pg' instead of `-p' with gprof(1)}                             \
31   %{Wl,*:%*}                                                            \
32   %{assert*} %{R*} %{rpath*} %{defsym*}                                 \
33   %{shared:-Bshareable %{h*} %{soname*}}                                \
34   %{symbolic:-Bsymbolic}                                                \
35   %{!shared:                                                            \
36     %{!static:                                                          \
37       %{rdynamic:-export-dynamic}                                       \
38       %{!dynamic-linker:-dynamic-linker /usr/libexec/ld-elf.so.1}}      \
39     %{static:-Bstatic}}"
40
41
42 /************************[  Target stuff  ]***********************************/
43
44 /* Define the actual types of some ANSI-mandated types.  
45    Needs to agree with <machine/ansi.h>.  GCC defaults come from c-decl.c,
46    c-common.c, and config/<arch>/<arch>.h.  */
47
48 /* Earlier headers may get this wrong for FreeBSD.
49    We use the GCC defaults instead.  */
50 #undef WCHAR_TYPE
51
52 #undef  WCHAR_TYPE_SIZE
53 #define WCHAR_TYPE_SIZE 32
54
55 /* Define for support of TFmode long double.
56    SPARC ABI says that long double is 4 words.  */
57 #undef  LONG_DOUBLE_TYPE_SIZE
58 #define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
59
60 /* Constant which presents upper bound of the above value.  */
61 #undef  MAX_LONG_DOUBLE_TYPE_SIZE
62 #define MAX_LONG_DOUBLE_TYPE_SIZE 128
63
64 /* Define this to set long double type size to use in libgcc2.c, which can
65    not depend on target_flags.  */
66 #if defined(__arch64__) || defined(__LONG_DOUBLE_128__)
67 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
68 #else
69 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
70 #endif
71
72 /* Definitions for 64-bit SPARC running systems with ELF. */
73
74 #undef  SUBTARGET_SWITCHES
75 #define SUBTARGET_SWITCHES                                                  \
76   {"long-double-64", -MASK_LONG_DOUBLE_128, N_("Use 64 bit long doubles") },  \
77   {"long-double-128", MASK_LONG_DOUBLE_128, N_("Use 128 bit long doubles") },
78
79 #undef  TARGET_VERSION
80 #define TARGET_VERSION fprintf (stderr, " (FreeBSD/sparc64 ELF)");
81
82 #define TARGET_ELF              1
83
84 /* XXX */
85 /* A 64 bit v9 compiler with stack-bias,
86    in a Medium/mid code model environment.  */
87
88 #undef  TARGET_DEFAULT
89 #define TARGET_DEFAULT \
90   (MASK_V9 + MASK_64BIT + MASK_PTR64 /* + MASK_FASTER_STRUCTS */ \
91    + MASK_STACK_BIAS + MASK_APP_REGS + MASK_FPU \
92    + MASK_LONG_DOUBLE_128 /* + MASK_HARD_QUAD */)
93
94 /* The default code model.  */
95 #undef  SPARC_DEFAULT_CMODEL
96 #define SPARC_DEFAULT_CMODEL    CM_MEDLOW
97
98 #define TRANSFER_FROM_TRAMPOLINE                                        \
99   static int need_enable_exec_stack;                                    \
100   static void check_enabling(void) __attribute__ ((constructor));       \
101   static void check_enabling(void)                                      \
102   {                                                                     \
103     extern int sysctlbyname(const char *, void *, size_t *, void *, size_t);\
104     int prot = 0;                                                       \
105     size_t len = sizeof(prot);                                          \
106                                                                         \
107     sysctlbyname ("kern.stackprot", &prot, &len, NULL, 0);              \
108     if (prot != 7)                                                      \
109       need_enable_exec_stack = 1;                                       \
110   }                                                                     \
111   extern void __enable_execute_stack (void *);                          \
112   void __enable_execute_stack (void *addr)                              \
113   {                                                                     \
114     if (!need_enable_exec_stack)                                        \
115       return;                                                           \
116     else {                                                              \
117       /* 7 is PROT_READ | PROT_WRITE | PROT_EXEC */                     \
118       if (mprotect (addr, TRAMPOLINE_SIZE, 7) < 0)                      \
119         perror ("mprotect of trampoline code");                         \
120     }                                                                   \
121   }
122
123
124 /************************[  Assembler stuff  ]********************************/
125
126 #undef  LOCAL_LABEL_PREFIX
127 #define LOCAL_LABEL_PREFIX  "."
128
129 /* XXX2 */
130 /* This is how to output a reference to an internal numbered label where
131    PREFIX is the class of label and NUM is the number within the class.  */
132
133 #undef  ASM_OUTPUT_INTERNAL_LABELREF
134 #define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM)                   \
135   fprintf (FILE, ".L%s%d", PREFIX, NUM)
136
137 /* XXX2 */
138 /* This is how to store into the string LABEL
139    the symbol_ref name of an internal numbered label where
140    PREFIX is the class of label and NUM is the number within the class.
141    This is suitable for output with `assemble_name'.  */
142
143 #undef  ASM_GENERATE_INTERNAL_LABEL
144 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)                   \
145   sprintf (LABEL, "*.L%s%lu", PREFIX, (unsigned long)(NUM))
146
147
148 /************************[  Debugger stuff  ]*********************************/
149
150 /* This is the char to use for continuation (in case we need to turn
151    continuation back on).  */
152
153 #undef  DBX_CONTIN_CHAR
154 #define DBX_CONTIN_CHAR '?'
155
156 /* DWARF bits.  */
157
158 /* Follow Irix 6 and not the Dwarf2 draft in using 64-bit offsets. 
159    Obviously the Dwarf2 folks havn't tried to actually build systems
160    with their spec.  On a 64-bit system, only 64-bit relocs become
161    RELATIVE relocations.  */
162
163 /* #define DWARF_OFFSET_SIZE PTR_SIZE */
164
165 #undef ENDFILE_SPEC
166 #define ENDFILE_SPEC \
167         "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s}" \
168         FBSD_ENDFILE_SPEC
169
170 /* We use GNU ld so undefine this so that attribute((init_priority)) works.  */
171 #undef CTORS_SECTION_ASM_OP
172 #undef DTORS_SECTION_ASM_OP