OSDN Git Service

2003-01-26 Steven Bosscher <s.bosscher@student.tudelft.nl>
[pf3gnuchains/gcc-fork.git] / gcc / config / cris / aout.h
1 /* Definitions for GCC.  Part of the machine description for CRIS.
2    Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
3    Contributed by Axis Communications.  Written by Hans-Peter Nilsson.
4
5 This file is part of GCC.
6
7 GCC 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 GCC 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 GCC; 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 /* After the first "Node:" comment comes all preprocessor directives and
23    attached declarations described in the info files, the "Using and
24    Porting GCC" manual (uapgcc), in the same order as found in the "Target
25    macros" section in the gcc-2.9x CVS edition of 2000-03-17.  FIXME: Not
26    really, but needs an update anyway.
27
28    There is no generic copy-of-uapgcc comment, you'll have to see uapgcc
29    for that.  If applicable, there is a CRIS-specific comment.  The order
30    of macro definitions follow the order in the manual.  Every section in
31    the manual (node in the info pages) has an introductory `Node:
32    <subchapter>' comment.  If no macros are defined for a section, only
33    the section-comment is present.  */
34
35 /* This file defines the macros for a.out that are not covered by cris.h.
36    Many macros are copied from elfos.h and should be in some generic
37    config/gas-aout.h.  */
38
39 /* Node: Driver */
40
41 #undef STARTFILE_SPEC
42 #define STARTFILE_SPEC \
43  "%{melinux:crt0.o%s}\
44   %{!melinux:\
45    %{sim2:s2crt0.o%s}\
46    %{!sim2:\
47     %{sim:scrt0.o%s}\
48     %{!sim:%{pg:gcrt0.o%s}\
49      %{!pg:%{p:mcrt0.o%s}%{!p:crt0.o%s}}}}}"
50
51 /* Which library to get.  The only difference from the default is to get
52    libsc.a if -sim is given to the driver.  Repeat -lc -lsysX
53    {X=sim,linux}, because libsysX needs (at least) errno from libc, and
54    then we want to resolve new unknowns in libc against libsysX, not
55    libnosys.  Assume everything is in libc for -mlinux.  */
56 #undef LIB_SPEC
57 #define LIB_SPEC \
58  "%{melinux:-lc -lsyslinux -lc -lsyslinux -lic}\
59   %{!melinux:\
60    %{sim*:-lc -lsyssim -lc -lsyssim}\
61    %{!sim*:%{g*:-lg}\
62      %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p} -lbsp}\
63    -lnosys}"
64
65 #undef CRIS_CPP_SUBTARGET_SPEC
66 #define CRIS_CPP_SUBTARGET_SPEC \
67  "-D__AOUT__\
68   %{melinux:-D__gnu_linux__ -D__linux__ -D__unix__ -D__elinux__ -D__uclinux__\
69     %{!nostdinc:\
70       %{!mbest-lib-options:%{isystem*}}\
71       -isystem elinux/include%s\
72       %{mbest-lib-options:%{isystem*}}}\
73     %{!ansi:%{!std=*:%{!undef:-Dlinux -Dunix -Delinux -Duclinux}}}}\
74   %{mbest-lib-options:\
75    %{!moverride-best-lib-options:\
76     %{!march=*:%{!metrax*:%{!mcpu=*:-D__tune_v8 -D__CRIS_arch_tune=8}}}}}"
77
78 #undef CRIS_CC1_SUBTARGET_SPEC
79 #define CRIS_CC1_SUBTARGET_SPEC \
80  "%{mbest-lib-options:\
81    %{!moverride-best-lib-options:\
82     %{!march=*:%{!mcpu=*:-mtune=v8}}}}"
83
84 #undef CRIS_ASM_SUBTARGET_SPEC
85 #define CRIS_ASM_SUBTARGET_SPEC "--em=crisaout"
86
87 #undef CRIS_LINK_SUBTARGET_SPEC
88 #define CRIS_LINK_SUBTARGET_SPEC \
89  "-mcrisaout\
90   %{sim2:%{!T*:-Tdata 0x4000000 -Tbss 0x8000000}}\
91   %{melinux:-Ur -d\
92    %{!shlib:%{!symbolic:-Bstatic}}\
93    %{shlib:-Bdynamic}\
94    %{symbolic:-Bdynamic}\
95    %{static:-Bstatic}}\
96   %{melinux-stacksize=*:-defsym __Stacksize=%*}"
97
98 #undef CRIS_SUBTARGET_SWITCHES
99 #define CRIS_SUBTARGET_SWITCHES                                         \
100   {"elinux", (TARGET_MASK_SVINTO                                        \
101               + TARGET_MASK_STACK_ALIGN                                 \
102               + TARGET_MASK_CONST_ALIGN                                 \
103               + TARGET_MASK_DATA_ALIGN                                  \
104               + TARGET_MASK_ETRAX4_ADD                                  \
105               + TARGET_MASK_ALIGN_BY_32),                               \
106    N_("Compile for the MMU-less Etrax 100-based elinux system")},       \
107   /* Legacy option.  */                                                 \
108   {"aout",   0, ""},
109
110 #undef CRIS_SUBTARGET_LONG_OPTIONS
111 #define CRIS_SUBTARGET_LONG_OPTIONS \
112   {"elinux-stacksize=", &cris_elinux_stacksize_str,                     \
113    N_("For elinux, request a specified stack-size for this program")},  \
114
115 #undef CRIS_SUBTARGET_VERSION
116 #define CRIS_SUBTARGET_VERSION " - a.out"
117
118 #undef CRIS_SUBTARGET_DEFAULT
119 #define CRIS_SUBTARGET_DEFAULT 0
120
121 /* Node: Storage Layout */
122
123 /* We can align to 16 bits (only) with CRIS a.out.  */
124 #define MAX_OFILE_ALIGNMENT 16
125
126
127 /* Node: Library Calls */
128
129 #define TARGET_MEM_FUNCTIONS
130
131
132 /* Node: Data Output */
133
134 #define ESCAPES \
135 "\1\1\1\1\1\1\1\1btn\1fr\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\
136 \0\0\"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
137 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\\\0\0\0\
138 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\
139 \1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\
140 \1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\
141 \1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\
142 \1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1"
143
144 /* Some svr4 assemblers have a limit on the number of characters which
145    can appear in the operand of a .string directive.  If your assembler
146    has such a limitation, you should define STRING_LIMIT to reflect that
147    limit.  Note that at least some svr4 assemblers have a limit on the
148    actual number of bytes in the double-quoted string, and that they
149    count each character in an escape sequence as one byte.  Thus, an
150    escape sequence like \377 would count as four bytes.
151
152    If your target assembler doesn't support the .string directive, you
153    should define this to zero.  */
154
155 #define STRING_LIMIT    ((unsigned) 256)
156
157 #define STRING_ASM_OP   "\t.string\t"
158 #define ASCII_DATA_ASM_OP       "\t.ascii\t"
159 #define TYPE_ASM_OP     "\t.type\t"
160 #define SIZE_ASM_OP     "\t.size\t"
161 #define TYPE_OPERAND_FMT        "@%s"
162
163 /* The routine used to output NUL terminated strings.  We use a special
164    version of this for most svr4 targets because doing so makes the
165    generated assembly code more compact (and thus faster to assemble)
166    as well as more readable, especially for targets like the i386
167    (where the only alternative is to output character sequences as
168    comma separated lists of numbers).  */
169
170 #define ASM_OUTPUT_LIMITED_STRING(FILE, STR)            \
171   do                                                    \
172     {                                                   \
173       register const unsigned char *_limited_str =      \
174         (const unsigned char *) (STR);                  \
175       register unsigned ch;                             \
176                                                         \
177       fprintf ((FILE), "%s\"", STRING_ASM_OP);          \
178                                                         \
179       for (; (ch = *_limited_str); _limited_str++)      \
180         {                                               \
181           register int escape;                          \
182                                                         \
183           switch (escape = ESCAPES[ch])                 \
184             {                                           \
185             case 0:                                     \
186               putc (ch, (FILE));                        \
187               break;                                    \
188             case 1:                                     \
189               fprintf ((FILE), "\\%03o", ch);           \
190               break;                                    \
191             default:                                    \
192               putc ('\\', (FILE));                      \
193               putc (escape, (FILE));                    \
194               break;                                    \
195             }                                           \
196         }                                               \
197                                                         \
198       fprintf ((FILE), "\"\n");                         \
199     }                                                   \
200   while (0)
201
202 /* The routine used to output sequences of byte values.  We use a special
203    version of this for most svr4 targets because doing so makes the
204    generated assembly code more compact (and thus faster to assemble)
205    as well as more readable.  Note that if we find subparts of the
206    character sequence which end with NUL (and which are shorter than
207    STRING_LIMIT) we output those using ASM_OUTPUT_LIMITED_STRING.  */
208
209 #undef  ASM_OUTPUT_ASCII
210 #define ASM_OUTPUT_ASCII(FILE, STR, LENGTH)                             \
211   do                                                                    \
212     {                                                                   \
213       register const unsigned char *_ascii_bytes =                      \
214         (const unsigned char *) (STR);                                  \
215       register const unsigned char *limit = _ascii_bytes + (LENGTH);    \
216       register unsigned bytes_in_chunk = 0;                             \
217                                                                         \
218       for (; _ascii_bytes < limit; _ascii_bytes++)                      \
219         {                                                               \
220           register const unsigned char *p;                              \
221                                                                         \
222           if (bytes_in_chunk >= 60)                                     \
223             {                                                           \
224               fprintf ((FILE), "\"\n");                                 \
225               bytes_in_chunk = 0;                                       \
226             }                                                           \
227                                                                         \
228           for (p = _ascii_bytes; p < limit && *p != '\0'; p++)          \
229             continue;                                                   \
230                                                                         \
231           if (p < limit && (p - _ascii_bytes) <= (long)STRING_LIMIT)    \
232             {                                                           \
233               if (bytes_in_chunk > 0)                                   \
234                 {                                                       \
235                   fprintf ((FILE), "\"\n");                             \
236                   bytes_in_chunk = 0;                                   \
237                 }                                                       \
238                                                                         \
239               ASM_OUTPUT_LIMITED_STRING ((FILE), _ascii_bytes);         \
240               _ascii_bytes = p;                                         \
241             }                                                           \
242           else                                                          \
243             {                                                           \
244               register int escape;                                      \
245               register unsigned ch;                                     \
246                                                                         \
247               if (bytes_in_chunk == 0)                                  \
248                 fprintf ((FILE), "%s\"", ASCII_DATA_ASM_OP);            \
249                                                                         \
250               switch (escape = ESCAPES[ch = *_ascii_bytes])             \
251                 {                                                       \
252                 case 0:                                                 \
253                   putc (ch, (FILE));                                    \
254                   bytes_in_chunk++;                                     \
255                   break;                                                \
256                 case 1:                                                 \
257                   fprintf ((FILE), "\\%03o", ch);                       \
258                   bytes_in_chunk += 4;                                  \
259                   break;                                                \
260                 default:                                                \
261                   putc ('\\', (FILE));                                  \
262                   putc (escape, (FILE));                                \
263                   bytes_in_chunk += 2;                                  \
264                   break;                                                \
265                 }                                                       \
266             }                                                           \
267         }                                                               \
268                                                                         \
269       if (bytes_in_chunk > 0)                                           \
270         fprintf ((FILE), "\"\n");                                       \
271     }                                                                   \
272   while (0)
273
274
275 /* Node: Label Output */
276
277 #define SET_ASM_OP      "\t.set\t"
278
279 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN)  \
280   (*targetm.asm_out.globalize_label) (FILE, XSTR (FUN, 0))
281
282 #define ASM_WEAKEN_LABEL(FILE, NAME)    \
283   do                                    \
284     {                                   \
285       fputs ("\t.weak\t", (FILE));      \
286       assemble_name ((FILE), (NAME));   \
287       fputc ('\n', (FILE));             \
288     }                                   \
289   while (0)
290
291 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)             \
292   do                                                            \
293     {                                                           \
294       ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function");       \
295       ASM_OUTPUT_LABEL(FILE, NAME);                             \
296     }                                                           \
297   while (0)
298
299 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)               \
300   do                                                            \
301     {                                                           \
302       HOST_WIDE_INT size;                                       \
303                                                                 \
304       ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object");         \
305                                                                 \
306       size_directive_output = 0;                                \
307       if (!flag_inhibit_size_directive                          \
308           && (DECL) && DECL_SIZE (DECL))                        \
309         {                                                       \
310           size_directive_output = 1;                            \
311           size = int_size_in_bytes (TREE_TYPE (DECL));          \
312           ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size);         \
313         }                                                       \
314                                                                 \
315       ASM_OUTPUT_LABEL (FILE, NAME);                            \
316     }                                                           \
317   while (0)
318
319 #undef ASM_FINISH_DECLARE_OBJECT
320 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END)\
321   do                                                            \
322     {                                                           \
323       const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0);   \
324       HOST_WIDE_INT size;                                       \
325                                                                 \
326       if (!flag_inhibit_size_directive                          \
327           && DECL_SIZE (DECL)                                   \
328           && ! AT_END && TOP_LEVEL                              \
329           && DECL_INITIAL (DECL) == error_mark_node             \
330           && !size_directive_output)                            \
331         {                                                       \
332           size_directive_output = 1;                            \
333           size = int_size_in_bytes (TREE_TYPE (DECL));          \
334           ASM_OUTPUT_SIZE_DIRECTIVE (FILE, name, size);         \
335         }                                                       \
336     }                                                           \
337   while (0)
338
339 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL)            \
340   do                                                            \
341     {                                                           \
342       if (!flag_inhibit_size_directive)                         \
343         ASM_OUTPUT_MEASURED_SIZE (FILE, FNAME);                 \
344     }                                                           \
345   while (0)
346
347
348 /* Node: Alignment Output */
349
350 #define SKIP_ASM_OP     "\t.zero\t"
351
352 #undef  ASM_OUTPUT_SKIP
353 #define ASM_OUTPUT_SKIP(FILE, SIZE) \
354   fprintf (FILE, "%s%u\n", SKIP_ASM_OP, (SIZE))
355
356 /* Node: All Debuggers */
357
358 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
359
360
361 /* Node: Misc */
362
363 #define HANDLE_SYSV_PRAGMA 1
364
365 /* In theory, this one isn't necessary, but over time, external tools have
366    been primed on names with "." rather than "$".  */
367 #define NO_DOLLAR_IN_LABEL
368
369 /* These are undocumented, but to keep a single
370    CRIS_ASM_OUTPUT_ALIGNED_DECL_COMMON, we set this to an asm that will
371    emit an error if ever output.  It will not be emitted for a.out modulo
372    careless hacking.  */
373 #define COMMON_ASM_OP   "\t.err\t"
374 #define LOCAL_ASM_OP    "\t.err\t"
375
376 #if defined(__CRIS__) && defined (__AOUT__) && defined (IN_GCC)
377
378 #define CRIS_ABI_VERSION_SYMBOL_STRING ".$CRIS_ABI_V2"
379
380 /* Make all a.out library functions have undefined references to the
381    .$CRIS_ABI_V2 symbol, so it will be picked up.  Used by GDB.  GDB has
382    a bug with reading a.out symbols; it does not see the GNU weak
383    extensions, so we can't have .$CRIS_ABI_V2 weak.  Weak.  */
384 __asm__ (".set .$abi_referer," CRIS_ABI_VERSION_SYMBOL_STRING);
385 #endif
386
387 /*
388  * Local variables:
389  * eval: (c-set-style "gnu")
390  * indent-tabs-mode: t
391  * End:
392  */