freebsd.h revision 117404
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
5This file is part of GNU CC.
6
7GNU CC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2, or (at your option)
10any later version.
11
12GNU CC is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GNU CC; see the file COPYING.  If not, write to
19the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
20
21/* $FreeBSD: head/contrib/gcc/config/sparc/freebsd.h 117404 2003-07-11 04:00:23Z kan $ */
22
23/* FreeBSD needs the platform name (sparc64) defined.
24   Emacs needs to know if the arch is 64 or 32-bits.  */
25
26#undef  CPP_CPU64_DEFAULT_SPEC
27#define CPP_CPU64_DEFAULT_SPEC \
28  "-D__sparc64__ -D__sparc_v9__ -D__sparcv9 -D__sparc__ -D__arch64__"
29
30/* Because we include sparc/sysv4.h.  */
31#undef  CPP_PREDEFINES
32/* Do not define it here, we now use TARGET_OS_CPP_BUILTINS.  */
33
34#define LINK_SPEC "%(link_arch)						\
35  %{!mno-relax:%{!r:-relax}}						\
36  %{p:%e`-p' not supported; use `-pg' and gprof(1)}			\
37  %{Wl,*:%*}								\
38  %{assert*} %{R*} %{rpath*} %{defsym*}					\
39  %{shared:-Bshareable %{h*} %{soname*}}				\
40  %{symbolic:-Bsymbolic}						\
41  %{!shared:								\
42    %{!static:								\
43      %{rdynamic:-export-dynamic}					\
44      %{!dynamic-linker:-dynamic-linker /usr/libexec/ld-elf.so.1}}	\
45    %{static:-Bstatic}}"
46
47
48/************************[  Target stuff  ]***********************************/
49
50/* Define the actual types of some ANSI-mandated types.
51   Needs to agree with <machine/ansi.h>.  GCC defaults come from c-decl.c,
52   c-common.c, and config/<arch>/<arch>.h.  */
53
54/* Earlier headers may get this wrong for FreeBSD.
55   We use the GCC defaults instead.  */
56#undef WCHAR_TYPE
57
58#undef  WCHAR_TYPE_SIZE
59#define WCHAR_TYPE_SIZE 32
60
61/* Define for support of TFmode long double.
62   SPARC ABI says that long double is 4 words.  */
63#undef  LONG_DOUBLE_TYPE_SIZE
64#define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
65
66/* Constant which presents upper bound of the above value.  */
67#undef  MAX_LONG_DOUBLE_TYPE_SIZE
68#define MAX_LONG_DOUBLE_TYPE_SIZE 128
69
70/* Define this to set long double type size to use in libgcc2.c, which can
71   not depend on target_flags.  */
72#if defined(__arch64__) || defined(__LONG_DOUBLE_128__)
73#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
74#else
75#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
76#endif
77
78/* Definitions for 64-bit SPARC running systems with ELF. */
79
80#undef  SUBTARGET_SWITCHES
81#define SUBTARGET_SWITCHES						    \
82  {"long-double-64", -MASK_LONG_DOUBLE_128, N_("Use 64 bit long doubles") },  \
83  {"long-double-128", MASK_LONG_DOUBLE_128, N_("Use 128 bit long doubles") },
84
85#undef  TARGET_VERSION
86#define TARGET_VERSION fprintf (stderr, " (FreeBSD/sparc64 ELF)");
87
88#define TARGET_ELF		1
89
90/* XXX */
91/* A 64 bit v9 compiler with stack-bias,
92   in a Medium/mid code model environment.  */
93
94#undef  TARGET_DEFAULT
95#define TARGET_DEFAULT \
96  (MASK_V9 + MASK_64BIT + MASK_PTR64 /* + MASK_FASTER_STRUCTS */ \
97   + MASK_STACK_BIAS + MASK_APP_REGS + MASK_FPU \
98   + MASK_LONG_DOUBLE_128 /* + MASK_HARD_QUAD */)
99
100/* The default code model.  */
101#undef  SPARC_DEFAULT_CMODEL
102#define SPARC_DEFAULT_CMODEL	CM_MEDLOW
103
104#define TRANSFER_FROM_TRAMPOLINE					\
105  static int need_enable_exec_stack;					\
106  static void check_enabling(void) __attribute__ ((constructor));	\
107  static void check_enabling(void)					\
108  {									\
109    extern int sysctlbyname(const char *, void *, size_t *, void *, size_t);\
110    int prot = 0;							\
111    size_t len = sizeof(prot);						\
112									\
113    sysctlbyname ("kern.stackprot", &prot, &len, NULL, 0);		\
114    if (prot != 7)							\
115      need_enable_exec_stack = 1;					\
116  }									\
117  extern void __enable_execute_stack (void *);				\
118  void __enable_execute_stack (void *addr)				\
119  {									\
120    if (!need_enable_exec_stack)					\
121      return;								\
122    else {								\
123      /* 7 is PROT_READ | PROT_WRITE | PROT_EXEC */ 			\
124      if (mprotect (addr, TRAMPOLINE_SIZE, 7) < 0)			\
125        perror ("mprotect of trampoline code");				\
126    }									\
127  }
128
129
130/************************[  Assembler stuff  ]********************************/
131
132#undef	LOCAL_LABEL_PREFIX
133#define LOCAL_LABEL_PREFIX  "."
134
135/* XXX2 */
136/* This is how to output a definition of an internal numbered label where
137   PREFIX is the class of label and NUM is the number within the class.  */
138
139#undef  ASM_OUTPUT_INTERNAL_LABEL
140#define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM)			\
141  fprintf (FILE, ".L%s%d:\n", PREFIX, NUM)
142
143/* XXX2 */
144/* This is how to output a reference to an internal numbered label where
145   PREFIX is the class of label and NUM is the number within the class.  */
146
147#undef  ASM_OUTPUT_INTERNAL_LABELREF
148#define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM)			\
149  fprintf (FILE, ".L%s%d", PREFIX, NUM)
150
151/* XXX2 */
152/* This is how to store into the string LABEL
153   the symbol_ref name of an internal numbered label where
154   PREFIX is the class of label and NUM is the number within the class.
155   This is suitable for output with `assemble_name'.  */
156
157#undef  ASM_GENERATE_INTERNAL_LABEL
158#define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)			\
159  sprintf (LABEL, "*.L%s%d", PREFIX, NUM)
160
161
162/************************[  Debugger stuff  ]*********************************/
163
164/* This is the char to use for continuation (in case we need to turn
165   continuation back on).  */
166
167#undef  DBX_CONTIN_CHAR
168#define DBX_CONTIN_CHAR	'?'
169
170/* DWARF bits.  */
171
172/* Follow Irix 6 and not the Dwarf2 draft in using 64-bit offsets.
173   Obviously the Dwarf2 folks havn't tried to actually build systems
174   with their spec.  On a 64-bit system, only 64-bit relocs become
175   RELATIVE relocations.  */
176
177/* #define DWARF_OFFSET_SIZE PTR_SIZE */
178
179#undef ENDFILE_SPEC
180#define ENDFILE_SPEC \
181  	"%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s}" \
182	FBSD_ENDFILE_SPEC
183
184/* We use GNU ld so undefine this so that attribute((init_priority)) works.  */
185#undef CTORS_SECTION_ASM_OP
186#undef DTORS_SECTION_ASM_OP
187