freebsd.h revision 107647
1139823Simp/* Definitions for Sun Sparc64 running FreeBSD using the ELF format
2122702Sandre   Copyright (C) 2001, 2002 Free Software Foundation, Inc.
3122702Sandre   Contributed by David E. O'Brien <obrien@FreeBSD.org> and BSDi.
4122702Sandre
5122702SandreThis file is part of GNU CC.
6122702Sandre
7122702SandreGNU CC is free software; you can redistribute it and/or modify
8122702Sandreit under the terms of the GNU General Public License as published by
9122702Sandrethe Free Software Foundation; either version 2, or (at your option)
10122702Sandreany later version.
11122702Sandre
12122702SandreGNU CC is distributed in the hope that it will be useful,
13122702Sandrebut WITHOUT ANY WARRANTY; without even the implied warranty of
14122702SandreMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15122702SandreGNU General Public License for more details.
16122702Sandre
17122702SandreYou should have received a copy of the GNU General Public License
18122702Sandrealong with GNU CC; see the file COPYING.  If not, write to
19122702Sandrethe Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
20122702Sandre
21122702Sandre/* $FreeBSD: head/contrib/gcc/config/sparc/freebsd.h 107647 2002-12-05 18:40:24Z obrien $ */
22122702Sandre
23122702Sandre/* FreeBSD needs the platform name (sparc64) defined.
24122702Sandre   Emacs needs to know if the arch is 64 or 32-bits.  */
25122702Sandre
26122702Sandre#undef  CPP_CPU64_DEFAULT_SPEC
27122702Sandre#define CPP_CPU64_DEFAULT_SPEC \
28122702Sandre  "-D__sparc64__ -D__sparc_v9__ -D__sparcv9 -D__sparc__ -D__arch64__"
29122702Sandre
30122702Sandre/* Because we include sparc/sysv4.h.  */
31122702Sandre#undef  CPP_PREDEFINES
32122702Sandre#define CPP_PREDEFINES FBSD_CPP_PREDEFINES
33122702Sandre
34122702Sandre#define LINK_SPEC "%(link_arch)						\
35122702Sandre  %{!mno-relax:%{!r:-relax}}						\
36122702Sandre  %{p:%e`-p' not supported; use `-pg' and gprof(1)}			\
37148324Skeramida  %{Wl,*:%*}								\
38122702Sandre  %{assert*} %{R*} %{rpath*} %{defsym*}					\
39122759Sandre  %{shared:-Bshareable %{h*} %{soname*}}				\
40122759Sandre  %{symbolic:-Bsymbolic}						\
41122759Sandre  %{!shared:								\
42122759Sandre    %{!static:								\
43122702Sandre      %{rdynamic:-export-dynamic}					\
44148324Skeramida      %{!dynamic-linker:-dynamic-linker /usr/libexec/ld-elf.so.1}}	\
45122702Sandre    %{static:-Bstatic}}"
46148324Skeramida
47122702Sandre
48122702Sandre/************************[  Target stuff  ]***********************************/
49122702Sandre
50122702Sandre/* Define the actual types of some ANSI-mandated types.
51122702Sandre   Needs to agree with <machine/ansi.h>.  GCC defaults come from c-decl.c,
52122702Sandre   c-common.c, and config/<arch>/<arch>.h.  */
53122702Sandre
54122702Sandre/* Earlier headers may get this wrong for FreeBSD.
55122702Sandre   We use the GCC defaults instead.  */
56122702Sandre#undef WCHAR_TYPE
57122702Sandre
58122702Sandre#undef  WCHAR_UNSIGNED
59122702Sandre#define WCHAR_UNSIGNED 0
60122702Sandre
61148324Skeramida#undef  WCHAR_TYPE_SIZE
62122702Sandre#define WCHAR_TYPE_SIZE 32
63122702Sandre
64122702Sandre/* Define for support of TFmode long double and REAL_ARITHMETIC.
65122702Sandre   Sparc ABI says that long double is 4 words.  */
66148324Skeramida#undef  LONG_DOUBLE_TYPE_SIZE
67148324Skeramida#define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
68148324Skeramida
69148324Skeramida/* Constant which presents upper bound of the above value.  */
70148324Skeramida#undef  MAX_LONG_DOUBLE_TYPE_SIZE
71122702Sandre#define MAX_LONG_DOUBLE_TYPE_SIZE 128
72122702Sandre
73122702Sandre/* Define this to set long double type size to use in libgcc2.c, which can
74122702Sandre   not depend on target_flags.  */
75122702Sandre#if defined(__arch64__) || defined(__LONG_DOUBLE_128__)
76122702Sandre#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
77122702Sandre#else
78122702Sandre#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
79122702Sandre#endif
80122702Sandre
81122702Sandre/* Definitions for 64-bit SPARC running systems with ELF. */
82122702Sandre
83122702Sandre#undef  SUBTARGET_SWITCHES
84122702Sandre#define SUBTARGET_SWITCHES						    \
85122702Sandre  {"long-double-64", -MASK_LONG_DOUBLE_128, N_("Use 64 bit long doubles") },  \
86122702Sandre  {"long-double-128", MASK_LONG_DOUBLE_128, N_("Use 128 bit long doubles") },
87122702Sandre
88122702Sandre#undef  TARGET_VERSION
89122702Sandre#define TARGET_VERSION fprintf (stderr, " (FreeBSD/sparc64 ELF)");
90122702Sandre
91122702Sandre#define TARGET_ELF		1
92122702Sandre
93122702Sandre/* XXX */
94122702Sandre/* A 64 bit v9 compiler with stack-bias,
95122702Sandre   in a Medium/mid code model environment.  */
96122702Sandre
97122702Sandre#undef  TARGET_DEFAULT
98122702Sandre#define TARGET_DEFAULT \
99122702Sandre  (MASK_V9 + MASK_64BIT + MASK_PTR64 /* + MASK_FASTER_STRUCTS */ \
100122702Sandre   + MASK_STACK_BIAS + MASK_APP_REGS + MASK_FPU \
101122702Sandre   + MASK_LONG_DOUBLE_128 /* + MASK_HARD_QUAD */)
102122702Sandre
103122702Sandre/* The default code model.  */
104122702Sandre#undef  SPARC_DEFAULT_CMODEL
105122702Sandre#define SPARC_DEFAULT_CMODEL	CM_MEDLOW
106122702Sandre
107122702Sandre#define TRANSFER_FROM_TRAMPOLINE					\
108122702Sandre  static int need_enable_exec_stack;					\
109122702Sandre  static void check_enabling(void) __attribute__ ((constructor));	\
110128872Sandre  static void check_enabling(void)					\
111133497Sandre  {									\
112128872Sandre    extern int sysctlbyname(const char *, void *, size_t *, void *, size_t);\
113128872Sandre    int prot = 0;							\
114128872Sandre    size_t len = sizeof(prot);						\
115128872Sandre									\
116128872Sandre    sysctlbyname ("kern.stackprot", &prot, &len, NULL, 0);		\
117128872Sandre    if (prot != 7)							\
118128872Sandre      need_enable_exec_stack = 1;					\
119128872Sandre  }									\
120128872Sandre  extern void __enable_execute_stack (void *);				\
121128872Sandre  void __enable_execute_stack (void *addr)				\
122128872Sandre  {									\
123133497Sandre    if (!need_enable_exec_stack)					\
124128872Sandre      return;								\
125128872Sandre    else {								\
126128872Sandre      /* 7 is PROT_READ | PROT_WRITE | PROT_EXEC */ 			\
127128872Sandre      if (mprotect (addr, TRAMPOLINE_SIZE, 7) < 0)			\
128128872Sandre        perror ("mprotect of trampoline code");				\
129128872Sandre    }									\
130128872Sandre  }
131128872Sandre
132148887Srwatson
133128872Sandre/************************[  Assembler stuff  ]********************************/
134128872Sandre
135128872Sandre#undef	LOCAL_LABEL_PREFIX
136128872Sandre#define LOCAL_LABEL_PREFIX  "."
137128872Sandre
138128872Sandre/* XXX2 */
139128872Sandre/* This is how to output a definition of an internal numbered label where
140145863Sandre   PREFIX is the class of label and NUM is the number within the class.  */
141128872Sandre
142128872Sandre#undef  ASM_OUTPUT_INTERNAL_LABEL
143128872Sandre#define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM)			\
144128872Sandre  fprintf (FILE, ".L%s%d:\n", PREFIX, NUM)
145128872Sandre
146122702Sandre/* XXX2 */
147122702Sandre/* This is how to output a reference to an internal numbered label where
148122702Sandre   PREFIX is the class of label and NUM is the number within the class.  */
149122702Sandre
150122702Sandre#undef  ASM_OUTPUT_INTERNAL_LABELREF
151122702Sandre#define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM)			\
152122702Sandre  fprintf (FILE, ".L%s%d", PREFIX, NUM)
153122702Sandre
154122702Sandre/* XXX2 */
155122702Sandre/* This is how to store into the string LABEL
156122702Sandre   the symbol_ref name of an internal numbered label where
157122702Sandre   PREFIX is the class of label and NUM is the number within the class.
158122702Sandre   This is suitable for output with `assemble_name'.  */
159122702Sandre
160128872Sandre#undef  ASM_GENERATE_INTERNAL_LABEL
161133497Sandre#define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)			\
162128872Sandre  sprintf (LABEL, "*.L%s%d", PREFIX, NUM)
163122702Sandre
164133920Sandre
165133920Sandre/************************[  Debugger stuff  ]*********************************/
166133920Sandre
167133920Sandre/* This is the char to use for continuation (in case we need to turn
168122702Sandre   continuation back on).  */
169122702Sandre
170122702Sandre#undef  DBX_CONTIN_CHAR
171122702Sandre#define DBX_CONTIN_CHAR	'?'
172122702Sandre
173122702Sandre/* DWARF bits.  */
174122702Sandre
175122702Sandre/* Follow Irix 6 and not the Dwarf2 draft in using 64-bit offsets.
176122702Sandre   Obviously the Dwarf2 folks havn't tried to actually build systems
177122702Sandre   with their spec.  On a 64-bit system, only 64-bit relocs become
178128872Sandre   RELATIVE relocations.  */
179128872Sandre
180122702Sandre/* #define DWARF_OFFSET_SIZE PTR_SIZE */
181122702Sandre
182122702Sandre#undef ENDFILE_SPEC
183122702Sandre#define ENDFILE_SPEC \
184122702Sandre  	"%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s}" \
185122702Sandre	FBSD_ENDFILE_SPEC
186122702Sandre
187122702Sandre/* We use GNU ld so undefine this so that attribute((init_priority)) works.  */
188122702Sandre#undef CTORS_SECTION_ASM_OP
189122702Sandre#undef DTORS_SECTION_ASM_OP
190122702Sandre