OSDN Git Service

f10f83b743755bf56b62179aaa5a3d3174d8c2ab
[pf3gnuchains/gcc-fork.git] / gcc / config / i386 / osf1elf.h
1 /* OSF/1 1.3 now is compitable with SVR4, so include sysv4.h, and
2    put difference here.  */
3
4 #include <stdio.h>
5 #include "i386/sysv4.h" /* Base i386 target machine definitions */
6
7 #undef TARGET_VERSION
8 #define TARGET_VERSION fprintf (stderr, " (i386 OSF/1)");
9
10 /* WORD_SWITCH_TAKES_ARG defined in svr4 is not correct. We also
11  need an extra -soname */
12 #undef WORD_SWITCH_TAKES_ARG
13 #define WORD_SWITCH_TAKES_ARG(STR)                    \
14  (DEFAULT_WORD_SWITCH_TAKES_ARG (STR)                 \
15   || !strcmp (STR, "Tdata") || !strcmp (STR, "Ttext") \
16   || !strcmp (STR, "Tbss") || !strcmp (STR, "soname"))
17
18 /* Note, -fpic and -fPIC are equivalent */
19 #undef  CPP_SPEC
20 #define CPP_SPEC "\
21 %(cpp_cpu)
22 %{fpic: -D__SHARED__} %{fPIC: %{!fpic: -D__SHARED__}} \
23 %{.S:   %{!ansi:%{!traditional:%{!traditional-cpp:%{!ftraditional: -traditional}}}}} \
24 %{.S:   -D__LANGUAGE_ASSEMBLY %{!ansi:-DLANGUAGE_ASSEMBLY}} \
25 %{.cc:  -D__LANGUAGE_C_PLUS_PLUS} \
26 %{.cxx: -D__LANGUAGE_C_PLUS_PLUS} \
27 %{.C:   -D__LANGUAGE_C_PLUS_PLUS} \
28 %{.m:   -D__LANGUAGE_OBJECTIVE_C} \
29 %{!.S:  -D__LANGUAGE_C %{!ansi:-DLANGUAGE_C}}"
30
31 /* -mmcount or -mno-mcount should be used with -pg or -p */
32 #undef  CC1_SPEC
33 #define CC1_SPEC "%(cc1_cpu) %{p: %{!mmcount: %{!mno-mcount: -mno-mcount }}} \
34 %{!p: %{pg: %{!mmcount: %{!mno-mcount: -mno-mcount }}}}"
35
36 /* Note, -D__NO_UNDERSCORES__ -D__ELF__ are provided in the older version of
37    OSF/1 gcc. We keep them here, so that old /usr/include/i386/asm.h works.
38    */
39 #undef CPP_PREDEFINES
40 #define CPP_PREDEFINES \
41   "-D__NO_UNDERSCORES__ -D__ELF__ -DOSF -DOSF1 -Dunix \
42    -Asystem(unix) -Asystem(xpg4) -Asystem(osf1)"
43
44 /* current OSF/1 doesn't provide separate crti.o and gcrti.o (and also, crtn.o
45    and gcrtn.o) for profile.  */
46
47 #undef  STARTFILE_SPEC
48 #define STARTFILE_SPEC "%{!shared: \
49                          %{!symbolic: \
50                           %{pg:gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crt0.o%s}}}}\
51                         crti.o%s \
52                         crtbegin.o%s"
53
54 #undef  ENDFILE_SPEC
55 #define ENDFILE_SPEC "crtend.o%s crtn.o%s"
56
57 #undef  ASM_SPEC
58 #define ASM_SPEC       "%{v*: -v}"
59
60 #undef  LINK_SPEC
61 #define LINK_SPEC      "%{v*: -v} \
62                 %{h*} %{z*} \
63                 %{dy:-call_shared} %{dn:-static} \
64                 %{static:-static} \
65                 %{shared:-shared} \
66                 %{call_shared:-call_shared} \
67                 %{symbolic:-Bsymbolic -shared -call_shared} \
68                 %{!dy: %{!dn: %{!static: %{!shared: %{!symbolic: \
69                         %{noshrlib: -static } \
70                         %{!noshrlib: -call_shared}}}}}}"
71
72 #undef MD_EXEC_PREFIX
73 #define MD_EXEC_PREFIX  "/usr/ccs/gcc/"
74
75 #undef  MD_STARTFILE_PREFIX
76 #define MD_STARTFILE_PREFIX     "/usr/ccs/lib/"
77
78 /* Define this macro meaning that gcc should find the library 'libgcc.a'
79    by hand, rather than passing the argument '-lgcc' to tell the linker
80    to do the search */
81 #define LINK_LIBGCC_SPECIAL
82
83 /* This goes with LINK_LIBGCC_SPECIAL, we need tell libgcc.a differently */
84 #undef  LIBGCC_SPEC
85 #define LIBGCC_SPEC "%{!shared:%{!symbolic:libgcc.a%s}}"
86
87 /* A C statement to output assembler commands which will identify the object
88   file as having been compile with GNU CC. We don't need or want this for
89   OSF1. */
90 #undef ASM_IDENTIFY_GCC
91 #define ASM_IDENTIFY_GCC(FILE)
92
93 /* Identify the front-end which produced this file.  To keep symbol
94    space down, and not confuse kdb, only do this if the language is
95    not C.  */
96 #define ASM_IDENTIFY_LANGUAGE(STREAM)                                   \
97 {                                                                       \
98   if (strcmp (lang_identify (), "c") != 0)                              \
99     output_lang_identify (STREAM);                                      \
100 }
101
102 /* Specify size_t, ptrdiff_t, and wchar_t types.  */
103 #undef  SIZE_TYPE
104 #undef  PTRDIFF_TYPE
105 #undef  WCHAR_TYPE
106 #undef  WCHAR_TYPE_SIZE
107
108 #define SIZE_TYPE       "long unsigned int"
109 #define PTRDIFF_TYPE    "int"
110 #define WCHAR_TYPE      "unsigned int"
111 #define WCHAR_TYPE_SIZE BITS_PER_WORD
112
113 /* Turn off long double being 96 bits.  */
114 #undef LONG_DOUBLE_TYPE_SIZE
115 #define LONG_DOUBLE_TYPE_SIZE 64
116
117 /* Work with OSF/1 profile */
118 #define MASK_NO_MCOUNT          000200000000    /* profiling uses mcount_ptr */
119
120 #define TARGET_MCOUNT           ((target_flags & MASK_NO_MCOUNT) == 0)
121
122 #undef  SUBTARGET_SWITCHES
123 #define SUBTARGET_SWITCHES                                              \
124      { "mcount",                -MASK_NO_MCOUNT, "Profiling uses mcount" },                     \
125      { "no-mcount",              MASK_NO_MCOUNT, "" },
126
127 /* This macro generates the assembly code for function entry.
128    FILE is a stdio stream to output the code to.
129    SIZE is an int: how many units of temporary storage to allocate.
130    Refer to the array `regs_ever_live' to determine which registers
131    to save; `regs_ever_live[I]' is nonzero if register number I
132    is ever used in the function.  This macro is responsible for
133    knowing which registers should not be saved even if used.
134
135    We override it here to allow for the new profiling code to go before
136    the prologue and the old mcount code to go after the prologue (and
137    after %ebx has been set up for ELF shared library support).  */
138 #if 0
139 #define OSF_PROFILE_BEFORE_PROLOGUE                                     \
140   (!TARGET_MCOUNT                                                       \
141    && !current_function_needs_context                                   \
142    && (!flag_pic                                                        \
143        || !frame_pointer_needed                                         \
144        || (!current_function_uses_pic_offset_table                      \
145            && !current_function_uses_const_pool)))
146 #else
147 #define OSF_PROFILE_BEFORE_PROLOGUE 0
148 #endif
149 #undef  FUNCTION_PROLOGUE
150 #define FUNCTION_PROLOGUE(FILE, SIZE)                                   \
151 do                                                                      \
152   {                                                                     \
153     char *prefix = "";                  \
154     char *lprefix = LPREFIX;                                            \
155     int labelno = profile_label_no;                                     \
156                                                                         \
157     if (profile_flag && OSF_PROFILE_BEFORE_PROLOGUE)                    \
158       {                                                                 \
159         if (!flag_pic)                          \
160           {                                                             \
161             fprintf (FILE, "\tmovl $%sP%d,%%edx\n", lprefix, labelno);  \
162             fprintf (FILE, "\tcall *%s_mcount_ptr\n", prefix);          \
163           }                                                             \
164                                                                         \
165         else                                                            \
166           {                                                             \
167             static int call_no = 0;                                     \
168                                                                         \
169             fprintf (FILE, "\tcall %sPc%d\n", lprefix, call_no);        \
170             fprintf (FILE, "%sPc%d:\tpopl %%eax\n", lprefix, call_no);  \
171             fprintf (FILE, "\taddl $_GLOBAL_OFFSET_TABLE_+[.-%sPc%d],%%eax\n", \
172                      lprefix, call_no++);                               \
173             fprintf (FILE, "\tleal %sP%d@GOTOFF(%%eax),%%edx\n",        \
174                      lprefix, labelno);                                 \
175             fprintf (FILE, "\tmovl %s_mcount_ptr@GOT(%%eax),%%eax\n",   \
176                      prefix);                                           \
177             fprintf (FILE, "\tcall *(%%eax)\n");                        \
178           }                                                             \
179       }                                                                 \
180                                                                         \
181     function_prologue (FILE, SIZE);                                     \
182   }                                                                     \
183 while (0)
184
185 /* A C statement or compound statement to output to FILE some assembler code to
186    call the profiling subroutine `mcount'.  Before calling, the assembler code
187    must load the address of a counter variable into a register where `mcount'
188    expects to find the address.  The name of this variable is `LP' followed by
189    the number LABELNO, so you would generate the name using `LP%d' in a
190    `fprintf'.
191
192    The details of how the address should be passed to `mcount' are determined
193    by your operating system environment, not by GNU CC.  To figure them out,
194    compile a small program for profiling using the system's installed C
195    compiler and look at the assembler code that results. */
196
197 #undef  FUNCTION_PROFILER
198 #define FUNCTION_PROFILER(FILE, LABELNO)                                \
199 do                                                                      \
200   {                                                                     \
201     if (!OSF_PROFILE_BEFORE_PROLOGUE)                                   \
202       {                                                                 \
203         char *prefix = "";                      \
204         char *lprefix = LPREFIX;                                        \
205         int labelno = LABELNO;                                  \
206                                                                         \
207         /* Note that OSF/rose blew it in terms of calling mcount,       \
208            since OSF/rose prepends a leading underscore, but mcount's   \
209            doesn't.  At present, we keep this kludge for ELF as well    \
210            to allow old kernels to build profiling.  */                 \
211                                                                         \
212         if (flag_pic                                                    \
213             && !current_function_uses_pic_offset_table                  \
214             && !current_function_uses_const_pool)                       \
215           abort ();                                                     \
216                                                                         \
217         if (TARGET_MCOUNT && flag_pic)                                  \
218           {                                                             \
219             fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%edx\n",        \
220                      lprefix, labelno);                                 \
221             fprintf (FILE, "\tcall *%smcount@GOT(%%ebx)\n", prefix);    \
222           }                                                             \
223                                                                         \
224         else if (TARGET_MCOUNT)                                         \
225           {                                                             \
226             fprintf (FILE, "\tmovl $%sP%d,%%edx\n", lprefix, labelno);  \
227             fprintf (FILE, "\tcall %smcount\n", prefix);                \
228           }                                                             \
229                                                                         \
230         else if (flag_pic && frame_pointer_needed)                      \
231           {                                                             \
232             fprintf (FILE, "\tmovl 4(%%ebp),%%ecx\n");                  \
233             fprintf (FILE, "\tpushl %%ecx\n");                          \
234             fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%edx\n",        \
235                      lprefix, labelno);                                 \
236             fprintf (FILE, "\tmovl _mcount_ptr@GOT(%%ebx),%%eax\n");    \
237             fprintf (FILE, "\tcall *(%%eax)\n");                        \
238             fprintf (FILE, "\tpopl %%eax\n");                           \
239           }                                                             \
240                                                                         \
241         else if (frame_pointer_needed)                                  \
242           {                                                             \
243             fprintf (FILE, "\tmovl 4(%%ebp),%%ecx\n");                  \
244             fprintf (FILE, "\tpushl %%ecx\n");                          \
245             fprintf (FILE, "\tmovl $%sP%d,%%edx\n", lprefix, labelno);  \
246             fprintf (FILE, "\tcall *_mcount_ptr\n");                    \
247             fprintf (FILE, "\tpopl %%eax\n");                           \
248           }                                                             \
249                                                                         \
250         else                                                            \
251           abort ();                                                     \
252       }                                                                 \
253   }                                                                     \
254 while (0)
255
256 #if defined (CROSS_COMPILE) && defined (HOST_BITS_PER_INT) && defined (HOST_BITS_PER_LONG) && defined (HOST_BITS_PER_LONGLONG)
257 #if (HOST_BITS_PER_INT==32) && (HOST_BITS_PER_LONG==64) && (HOST_BITS_PER_LONGLONG==64)
258 #define REAL_ARITHMETIC
259 #endif
260 #endif