OSDN Git Service

* config.gcc (sh5-*-netbsd*, sh5l*-*-netbsd*)
[pf3gnuchains/gcc-fork.git] / gcc / config / sh / netbsd-elf.h
1 /* Definitions for SH running NetBSD using ELF
2    Copyright (C) 2002 Free Software Foundation, Inc.
3    Contributed by Wasabi Systems, Inc.
4
5 This file is part of GNU CC.
6
7 GNU CC 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 GNU CC 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 this program; see the file COPYING.  If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.  */
21
22 /* Run-time Target Specification.  */
23 #if TARGET_ENDIAN_DEFAULT == LITTLE_ENDIAN_BIT
24 #define TARGET_VERSION_ENDIAN "le"
25 #else
26 #define TARGET_VERSION_ENDIAN ""
27 #endif
28
29 #if TARGET_CPU_DEFAULT & SH5_BIT
30 #if TARGET_CPU_DEFAULT & SH3E_BIT
31 #define TARGET_VERSION_CPU "sh5"
32 #else
33 #define TARGET_VERSION_CPU "sh64"
34 #endif /* SH3E_BIT */
35 #else
36 #define TARGET_VERSION_CPU "sh"
37 #endif /* SH5_BIT */
38
39 #undef TARGET_VERSION
40 #define TARGET_VERSION  fprintf (stderr, " (NetBSD/%s%s ELF)",          \
41                                  TARGET_VERSION_CPU, TARGET_VERSION_ENDIAN)
42
43
44 #define TARGET_OS_CPP_BUILTINS()                                        \
45   do                                                                    \
46     {                                                                   \
47       NETBSD_OS_CPP_BUILTINS_ELF();                                     \
48       if (TARGET_SHMEDIA64)                                             \
49         NETBSD_OS_CPP_BUILTINS_LP64();                                  \
50       builtin_define ("__NO_LEADING_UNDERSCORES__");                    \
51     }                                                                   \
52   while (0)
53
54 /* Provide a LINK_SPEC appropriate for a NetBSD/sh ELF target.
55    We use the SH_LINK_SPEC from sh/sh.h, and define the appropriate
56    SUBTARGET_LINK_SPEC that pulls in what we need from a generic
57    NetBSD ELF LINK_SPEC.  */
58
59 /* LINK_EMUL_PREFIX from sh/elf.h */
60
61 #undef LINK_DEFAULT_CPU_EMUL
62 #if TARGET_CPU_DEFAULT & SH5_BIT
63 #if TARGET_CPU_DEFAULT & SH3E_BIT
64 #define LINK_DEFAULT_CPU_EMUL "32"
65 #else
66 #define LINK_DEFAULT_CPU_EMUL "64"
67 #endif /* SH3E_BIT */
68 #else
69 #define LINK_DEFAULT_CPU_EMUL ""
70 #endif /* SH5_BIT */
71
72 #undef SUBTARGET_LINK_EMUL_SUFFIX
73 #define SUBTARGET_LINK_EMUL_SUFFIX "_nbsd"
74
75 #undef SUBTARGET_LINK_SPEC
76 #define SUBTARGET_LINK_SPEC \
77   "%{assert*} %{R*} \
78    %{shared:-shared} \
79    %{!shared: \
80      -dc -dp \
81      %{!nostdlib: \
82        %{!r*: \
83          %{!e*:-e __start}}} \
84      %{!static: \
85        %{rdynamic:-export-dynamic} \
86        %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}} \
87      %{static:-static}}"
88
89 #undef LINK_SPEC
90 #define LINK_SPEC SH_LINK_SPEC
91
92
93 /* Provide a CPP_SPEC appropriate for NetBSD.  */
94 #undef SUBTARGET_CPP_SPEC
95 #define SUBTARGET_CPP_SPEC NETBSD_CPP_SPEC
96
97 #undef TARGET_DEFAULT
98 #define TARGET_DEFAULT \
99   (TARGET_CPU_DEFAULT | USERMODE_BIT | TARGET_ENDIAN_DEFAULT)
100
101  
102 #undef FUNCTION_PROFILER
103 #define FUNCTION_PROFILER(STREAM,LABELNO)                               \
104 do                                                                      \
105   {                                                                     \
106     if (TARGET_SHMEDIA32)                                               \
107       {                                                                 \
108         /* FIXME */                                                     \
109         abort ();                                                       \
110       }                                                                 \
111     else if (TARGET_SHMEDIA64)                                          \
112       {                                                                 \
113         /* FIXME */                                                     \
114         abort ();                                                       \
115       }                                                                 \
116     else                                                                \
117       {                                                                 \
118         fprintf((STREAM), "\tmov.l\t%cLP%d,r1\n",                       \
119                 LOCAL_LABEL_PREFIX, (LABELNO));                         \
120         fprintf((STREAM), "\tmova\t%cLP%dr,r0\n",                       \
121                 LOCAL_LABEL_PREFIX, (LABELNO));                         \
122         fprintf((STREAM), "\tjmp\t@r1\n");                              \
123         fprintf((STREAM), "\tnop\n");                                   \
124         fprintf((STREAM), "\t.align\t2\n");                             \
125         fprintf((STREAM), "%cLP%d:\t.long\t__mcount\n",                 \
126                 LOCAL_LABEL_PREFIX, (LABELNO));                         \
127         fprintf((STREAM), "%cLP%dr:\n", LOCAL_LABEL_PREFIX, (LABELNO)); \
128       }                                                                 \
129   }                                                                     \
130 while (0)