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