OSDN Git Service

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