OSDN Git Service

2006-02-02 Andreas Tobler <a.tobler@schweiz.ch>
[pf3gnuchains/gcc-fork.git] / gcc / config / sparc / freebsd.h
index 33b0716..9e432a3 100644 (file)
@@ -1,42 +1,45 @@
-/* Definitions for Sun Sparc64 running FreeBSD using the ELF format
-   Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+/* Definitions for Sun SPARC64 running FreeBSD using the ELF format
+   Copyright (C) 2001, 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
    Contributed by David E. O'Brien <obrien@FreeBSD.org> and BSDi.
 
-This file is part of GNU CC.
+This file is part of GCC.
 
-GNU CC is free software; you can redistribute it and/or modify
+GCC is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2, or (at your option)
 any later version.
 
-GNU CC is distributed in the hope that it will be useful,
+GCC is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING.  If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+along with GCC; see the file COPYING.  If not, write to
+the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.  */
 
-/* FreeBSD needs's the platform name (sparc64) defined.  */
+#undef  SUBTARGET_EXTRA_SPECS
+#define SUBTARGET_EXTRA_SPECS \
+  { "fbsd_dynamic_linker", FBSD_DYNAMIC_LINKER }
 
-#undef  CPP_CPU64_DEFAULT_SPEC
-#define CPP_CPU64_DEFAULT_SPEC "-D__sparc64__ -D__sparc_v9__"
+/* FreeBSD needs the platform name (sparc64) defined.
+   Emacs needs to know if the arch is 64 or 32-bits.  */
 
-#undef  CPP_PREDEFINES
-#define CPP_PREDEFINES FBSD_CPP_PREDEFINES
+#undef  CPP_CPU64_DEFAULT_SPEC
+#define CPP_CPU64_DEFAULT_SPEC \
+  "-D__sparc64__ -D__sparc_v9__ -D__sparcv9 -D__arch64__"
 
 #define LINK_SPEC "%(link_arch)                                                \
   %{!mno-relax:%{!r:-relax}}                                           \
-  %{p:%e`-p' not supported; use `-pg' and gprof(1)}                    \
-  %{Wl,*:%*}                                                           \
+  %{p:%nconsider using `-pg' instead of `-p' with gprof(1)}            \
   %{assert*} %{R*} %{rpath*} %{defsym*}                                        \
   %{shared:-Bshareable %{h*} %{soname*}}                               \
   %{symbolic:-Bsymbolic}                                               \
   %{!shared:                                                           \
     %{!static:                                                         \
       %{rdynamic:-export-dynamic}                                      \
-      %{!dynamic-linker:-dynamic-linker /usr/libexec/ld-elf.so.1}}     \
+      %{!dynamic-linker:-dynamic-linker %(fbsd_dynamic_linker) }}      \
     %{static:-Bstatic}}"
 
 
@@ -50,21 +53,14 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
    We use the GCC defaults instead.  */
 #undef WCHAR_TYPE
 
-#undef  WCHAR_UNSIGNED
-#define WCHAR_UNSIGNED 0
-
 #undef  WCHAR_TYPE_SIZE
 #define WCHAR_TYPE_SIZE 32
 
 /* Define for support of TFmode long double.
-   Sparc ABI says that long double is 4 words.  */
+   SPARC ABI says that long double is 4 words.  */
 #undef  LONG_DOUBLE_TYPE_SIZE
 #define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
 
-/* Constant which presents upper bound of the above value.  */
-#undef  MAX_LONG_DOUBLE_TYPE_SIZE
-#define MAX_LONG_DOUBLE_TYPE_SIZE 128
-
 /* Define this to set long double type size to use in libgcc2.c, which can
    not depend on target_flags.  */
 #if defined(__arch64__) || defined(__LONG_DOUBLE_128__)
@@ -75,11 +71,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 /* Definitions for 64-bit SPARC running systems with ELF. */
 
-#undef  SUBTARGET_SWITCHES
-#define SUBTARGET_SWITCHES                                                 \
-  {"long-double-64", -MASK_LONG_DOUBLE_128, N_("Use 64 bit long doubles") },  \
-  {"long-double-128", MASK_LONG_DOUBLE_128, N_("Use 128 bit long doubles") },
-
 #undef  TARGET_VERSION
 #define TARGET_VERSION fprintf (stderr, " (FreeBSD/sparc64 ELF)");
 
@@ -97,7 +88,32 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 /* The default code model.  */
 #undef  SPARC_DEFAULT_CMODEL
-#define SPARC_DEFAULT_CMODEL   CM_MEDMID
+#define SPARC_DEFAULT_CMODEL   CM_MEDLOW
+
+#define ENABLE_EXECUTE_STACK                                           \
+  static int need_enable_exec_stack;                                   \
+  static void check_enabling(void) __attribute__ ((constructor));      \
+  static void check_enabling(void)                                     \
+  {                                                                    \
+    extern int sysctlbyname(const char *, void *, size_t *, void *, size_t);\
+    int prot = 0;                                                      \
+    size_t len = sizeof(prot);                                         \
+                                                                       \
+    sysctlbyname ("kern.stackprot", &prot, &len, NULL, 0);             \
+    if (prot != 7)                                                     \
+      need_enable_exec_stack = 1;                                      \
+  }                                                                    \
+  extern void __enable_execute_stack (void *);                         \
+  void __enable_execute_stack (void *addr)                             \
+  {                                                                    \
+    if (!need_enable_exec_stack)                                       \
+      return;                                                          \
+    else {                                                             \
+      /* 7 is PROT_READ | PROT_WRITE | PROT_EXEC */                    \
+      if (mprotect (addr, TRAMPOLINE_SIZE, 7) < 0)                     \
+        perror ("mprotect of trampoline code");                                \
+    }                                                                  \
+  }
 
 
 /************************[  Assembler stuff  ]********************************/
@@ -106,22 +122,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #define LOCAL_LABEL_PREFIX  "."
 
 /* XXX2 */
-/* This is how to output a definition of an internal numbered label where
-   PREFIX is the class of label and NUM is the number within the class.  */
-
-#undef  ASM_OUTPUT_INTERNAL_LABEL
-#define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM)                     \
-  fprintf (FILE, ".L%s%d:\n", PREFIX, NUM)
-
-/* XXX2 */
-/* This is how to output a reference to an internal numbered label where
-   PREFIX is the class of label and NUM is the number within the class.  */
-
-#undef  ASM_OUTPUT_INTERNAL_LABELREF
-#define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM)                  \
-  fprintf (FILE, ".L%s%d", PREFIX, NUM)
-
-/* XXX2 */
 /* This is how to store into the string LABEL
    the symbol_ref name of an internal numbered label where
    PREFIX is the class of label and NUM is the number within the class.
@@ -129,7 +129,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 #undef  ASM_GENERATE_INTERNAL_LABEL
 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)                  \
-  sprintf (LABEL, "*.L%s%d", PREFIX, NUM)
+  sprintf (LABEL, "*.L%s%lu", PREFIX, (unsigned long)(NUM))
 
 
 /************************[  Debugger stuff  ]*********************************/
@@ -150,6 +150,10 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 /* #define DWARF_OFFSET_SIZE PTR_SIZE */
 
 #undef ENDFILE_SPEC
-#define ENDFILE_SPEC \
-       "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s}" \
-       FBSD_ENDFILE_SPEC
+#define ENDFILE_SPEC                                           \
+  "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} "  \
+  FBSD_ENDFILE_SPEC
+
+/* We use GNU ld so undefine this so that attribute((init_priority)) works.  */
+#undef CTORS_SECTION_ASM_OP
+#undef DTORS_SECTION_ASM_OP