OSDN Git Service

* defaults.h (ASM_OUTPUT_MEASURED_SIZE): Take only two
[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 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   ASM_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 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END)\
320   do                                                            \
321     {                                                           \
322       const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0);   \
323       HOST_WIDE_INT size;                                       \
324                                                                 \
325       if (!flag_inhibit_size_directive                          \
326           && DECL_SIZE (DECL)                                   \
327           && ! AT_END && TOP_LEVEL                              \
328           && DECL_INITIAL (DECL) == error_mark_node             \
329           && !size_directive_output)                            \
330         {                                                       \
331           size_directive_output = 1;                            \
332           size = int_size_in_bytes (TREE_TYPE (DECL));          \
333           ASM_OUTPUT_SIZE_DIRECTIVE (FILE, name, size);         \
334         }                                                       \
335     }                                                           \
336   while (0)
337
338 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL)            \
339   do                                                            \
340     {                                                           \
341       if (!flag_inhibit_size_directive)                         \
342         ASM_OUTPUT_MEASURED_SIZE (FILE, FNAME);                 \
343     }                                                           \
344   while (0)
345
346
347 /* Node: Alignment Output */
348
349 #define SKIP_ASM_OP     "\t.zero\t"
350
351 #undef  ASM_OUTPUT_SKIP
352 #define ASM_OUTPUT_SKIP(FILE, SIZE) \
353   fprintf (FILE, "%s%u\n", SKIP_ASM_OP, (SIZE))
354
355 /* Node: All Debuggers */
356
357 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
358
359
360 /* Node: Misc */
361
362 #define HANDLE_SYSV_PRAGMA
363
364 /* In theory, this one isn't necessary, but over time, external tools have
365    been primed on names with "." rather than "$".  */
366 #define NO_DOLLAR_IN_LABEL
367
368 /* These are undocumented, but to keep a single
369    CRIS_ASM_OUTPUT_ALIGNED_DECL_COMMON, we set this to an asm that will
370    emit an error if ever output.  It will not be emitted for a.out modulo
371    careless hacking.  */
372 #define COMMON_ASM_OP   "\t.err\t"
373 #define LOCAL_ASM_OP    "\t.err\t"
374
375 #if defined(__CRIS__) && defined (__AOUT__) && defined (IN_GCC)
376
377 #define CRIS_ABI_VERSION_SYMBOL_STRING ".$CRIS_ABI_V2"
378
379 /* Make all a.out library functions have undefined references to the
380    .$CRIS_ABI_V2 symbol, so it will be picked up.  Used by GDB.  GDB has
381    a bug with reading a.out symbols; it does not see the GNU weak
382    extensions, so we can't have .$CRIS_ABI_V2 weak.  Weak.  */
383 __asm__ (".set .$abi_referer," CRIS_ABI_VERSION_SYMBOL_STRING);
384 #endif
385
386 /*
387  * Local variables:
388  * eval: (c-set-style "gnu")
389  * indent-tabs-mode: t
390  * End:
391  */