OSDN Git Service

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