OSDN Git Service

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