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