OSDN Git Service

* defaults.h (ASM_OUTPUT_TYPE_DIRECTIVE, ASM_OUTPUT_SIZE_DIRECTIVE,
[pf3gnuchains/gcc-fork.git] / gcc / config / netbsd-aout.h
1 /* Common configuration file for NetBSD a.out targets.
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 GNU CC; 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 /* TARGET_OS_CPP_BUILTINS() common to all NetBSD a.out targets.  */
23 #define NETBSD_OS_CPP_BUILTINS_AOUT()           \
24   do                                            \
25     {                                           \
26       NETBSD_OS_CPP_BUILTINS_COMMON();          \
27     }                                           \
28   while (0)
29
30 /* This defines which switch letters take arguments. */
31
32 #undef SWITCH_TAKES_ARG
33 #define SWITCH_TAKES_ARG(CHAR)          \
34   (DEFAULT_SWITCH_TAKES_ARG(CHAR)       \
35    || (CHAR) == 'R')
36
37
38 /* Provide an ASM_SPEC appropriate for NetBSD.  Currently we only deal
39    with the options for generating PIC code.  */
40
41 #undef ASM_SPEC
42 #define ASM_SPEC " %| %{fpic:-k} %{fPIC:-k -K}"
43
44
45 /* Provide a STARTFILE_SPEC appropriate for NetBSD a.out.  Here we
46    provide support for the special GCC option -static.  */
47
48 #undef STARTFILE_SPEC
49 #define STARTFILE_SPEC                  \
50   "%{!shared:                           \
51      %{pg:gcrt0%O%s}                    \
52      %{!pg:                             \
53        %{p:mcrt0%O%s}                   \
54        %{!p:                            \
55          %{!static:crt0%O%s}            \
56          %{static:scrt0%O%s}}}}"
57
58 /* Provide a LINK_SPEC appropriate for NetBSD a.out.  Here we provide
59    support for the special GCC options -static, -assert, and -nostdlib.  */
60
61 #undef LINK_SPEC
62 #define LINK_SPEC                       \
63   "%{nostdlib:-nostdlib}                \
64    %{!shared:                           \
65      %{!nostdlib:                       \
66        %{!r*:                           \
67          %{!e*:-e start}}}              \
68      -dc -dp                            \
69      %{static:-Bstatic}}                \
70    %{shared:-Bshareable}                \
71    %{R*}                                \
72    %{assert*}"
73
74
75 /* Some imports from svr4.h in support of shared libraries.  */
76
77 /* Define the strings used for the .type, .size, and .set directives.
78    These strings generally do not vary from one system running NetBSD
79    to another, but if a given system needs to use different pseudo-op
80    names for these, they may be overridden in the file included after
81    this one.  */
82
83 #undef TYPE_ASM_OP
84 #undef SIZE_ASM_OP
85 #undef SET_ASM_OP                
86 #define TYPE_ASM_OP     "\t.type\t"
87 #define SIZE_ASM_OP     "\t.size\t"
88 #define SET_ASM_OP      "\t.set\t"
89
90
91 /* This is how we tell the assembler that a symbol is weak.  */
92
93 #undef ASM_WEAKEN_LABEL
94 #define ASM_WEAKEN_LABEL(FILE,NAME)                                     \
95   do                                                                    \
96     {                                                                   \
97       fputs ("\t.globl\t", FILE); assemble_name (FILE, NAME);           \
98       fputc ('\n', FILE);                                               \
99       fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME);            \
100       fputc ('\n', FILE);                                               \
101     }                                                                   \
102   while (0)
103
104
105 /* The following macro defines the format used to output the second
106    operand of the .type assembler directive.  Different svr4 assemblers
107    expect various different forms of this operand.  The one given here
108    is just a default.  You may need to override it in your machine-
109    specific tm.h file (depending on the particulars of your assembler).  */
110
111 #undef TYPE_OPERAND_FMT
112 #define TYPE_OPERAND_FMT        "@%s"
113
114
115 /* Write the extra assembler code needed to declare a function's result.
116    Most svr4 assemblers don't require any special declaration of the
117    result value, but there are exceptions.  */
118
119 #ifndef ASM_DECLARE_RESULT
120 #define ASM_DECLARE_RESULT(FILE, RESULT)
121 #endif
122
123
124 /* These macros generate the special .type and .size directives which
125    are used to set the corresponding fields of the linker symbol table
126    entries in an ELF object file under SVR4 (and a.out on NetBSD).
127    These macros also output the starting labels for the relevant
128    functions/objects.  */
129
130 /* Write the extra assembler code needed to declare a function properly.
131    Some svr4 assemblers need to also have something extra said about the
132    function's return value.  We allow for that here.  */
133
134 #undef ASM_DECLARE_FUNCTION_NAME
135 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)                     \
136   do                                                                    \
137     {                                                                   \
138       ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function");               \
139       ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL));                    \
140       ASM_OUTPUT_LABEL(FILE, NAME);                                     \
141     }                                                                   \
142   while (0)
143
144
145 /* Write the extra assembler code needed to declare an object properly.  */
146
147 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)               \
148   do                                                            \
149     {                                                           \
150       HOST_WIDE_INT size;                                       \
151                                                                 \
152       ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object");         \
153                                                                 \
154       size_directive_output = 0;                                \
155       if (!flag_inhibit_size_directive                          \
156           && (DECL) && DECL_SIZE (DECL))                        \
157         {                                                       \
158           size_directive_output = 1;                            \
159           size = int_size_in_bytes (TREE_TYPE (DECL));          \
160           ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size);         \
161         }                                                       \
162                                                                 \
163       ASM_OUTPUT_LABEL (FILE, NAME);                            \
164     }                                                           \
165   while (0)
166
167 /* Output the size directive for a decl in rest_of_decl_compilation
168    in the case where we did not do so before the initializer.
169    Once we find the error_mark_node, we know that the value of
170    size_directive_output was set
171    by ASM_DECLARE_OBJECT_NAME when it was run for the same decl.  */
172
173 #undef ASM_FINISH_DECLARE_OBJECT
174 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END)        \
175   do                                                                    \
176     {                                                                   \
177       const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0);           \
178       HOST_WIDE_INT size;                                               \
179       if (!flag_inhibit_size_directive && DECL_SIZE (DECL)              \
180           && ! AT_END && TOP_LEVEL                                      \
181           && DECL_INITIAL (DECL) == error_mark_node                     \
182           && !size_directive_output)                                    \
183         {                                                               \
184           size_directive_output = 1;                                    \
185           size = int_size_in_bytes (TREE_TYPE (DECL));                  \
186           ASM_OUTPUT_SIZE_DIRECTIVE (FILE, name, size);                 \
187         }                                                               \
188     }                                                                   \
189   while (0)
190
191
192 /* This is how to declare the size of a function.  */
193
194 #undef ASM_DECLARE_FUNCTION_SIZE
195 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL)                    \
196   do                                                                    \
197     {                                                                   \
198       if (!flag_inhibit_size_directive)                                 \
199         {                                                               \
200           char label[256];                                              \
201           static int labelno;                                           \
202           labelno++;                                                    \
203           ASM_GENERATE_INTERNAL_LABEL (label, "Lfe", labelno);          \
204           ASM_OUTPUT_INTERNAL_LABEL (FILE, "Lfe", labelno);             \
205           ASM_OUTPUT_MEASURED_SIZE (FILE, FNAME, label);                \
206         }                                                               \
207     }                                                                   \
208   while (0)