* config/i386/netbsd-elf.h (TARGET_OS_CPP_BUILTINS): Define.
[official-gcc.git] / gcc / config / netbsd-aout.h
blob5d2386a6fb1a39a6ecfc4d0cfad23ab0dc688b2e
1 /* Common configuration file for NetBSD a.out targets.
2 Copyright (C) 2002 Free Software Foundation, Inc.
3 Contributed by Wasabi Systems, Inc.
5 This file is part of GNU CC.
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.
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.
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. */
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)
30 /* This defines which switch letters take arguments. */
32 #undef SWITCH_TAKES_ARG
33 #define SWITCH_TAKES_ARG(CHAR) \
34 (DEFAULT_SWITCH_TAKES_ARG(CHAR) \
35 || (CHAR) == 'R')
38 /* Provide an ASM_SPEC appropriate for NetBSD. Currently we only deal
39 with the options for generating PIC code. */
41 #undef ASM_SPEC
42 #define ASM_SPEC " %| %{fpic:-k} %{fPIC:-k -K}"
45 /* Provide a STARTFILE_SPEC appropriate for NetBSD a.out. Here we
46 provide support for the special GCC option -static. */
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}}}}"
58 /* Provide a LINK_SPEC appropriate for NetBSD a.out. Here we provide
59 support for the special GCC options -static, -assert, and -nostdlib. */
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*}"
75 /* Some imports from svr4.h in support of shared libraries. */
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. */
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"
91 /* This is how we tell the assembler that a symbol is weak. */
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); \
102 while (0)
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). */
111 #undef TYPE_OPERAND_FMT
112 #define TYPE_OPERAND_FMT "@%s"
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. */
119 #ifndef ASM_DECLARE_RESULT
120 #define ASM_DECLARE_RESULT(FILE, RESULT)
121 #endif
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. */
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. */
134 #undef ASM_DECLARE_FUNCTION_NAME
135 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
136 do \
138 fprintf (FILE, "%s", TYPE_ASM_OP); \
139 assemble_name (FILE, NAME); \
140 putc (',', FILE); \
141 fprintf (FILE, TYPE_OPERAND_FMT, "function"); \
142 putc ('\n', FILE); \
143 ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
144 ASM_OUTPUT_LABEL(FILE, NAME); \
146 while (0)
149 /* Write the extra assembler code needed to declare an object properly. */
151 #undef ASM_DECLARE_OBJECT_NAME
152 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
153 do \
155 fprintf (FILE, "%s", TYPE_ASM_OP); \
156 assemble_name (FILE, NAME); \
157 putc (',', FILE); \
158 fprintf (FILE, TYPE_OPERAND_FMT, "object"); \
159 putc ('\n', FILE); \
160 size_directive_output = 0; \
161 if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \
163 size_directive_output = 1; \
164 fprintf (FILE, "%s", SIZE_ASM_OP); \
165 assemble_name (FILE, NAME); \
166 fprintf (FILE, ",%d\n", \
167 int_size_in_bytes (TREE_TYPE (DECL))); \
169 ASM_OUTPUT_LABEL(FILE, NAME); \
171 while (0)
174 /* Output the size directive for a decl in rest_of_decl_compilation
175 in the case where we did not do so before the initializer.
176 Once we find the error_mark_node, we know that the value of
177 size_directive_output was set
178 by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
180 #undef ASM_FINISH_DECLARE_OBJECT
181 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
182 do \
184 const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
185 if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \
186 && ! AT_END && TOP_LEVEL \
187 && DECL_INITIAL (DECL) == error_mark_node \
188 && !size_directive_output) \
190 size_directive_output = 1; \
191 fprintf (FILE, "%s", SIZE_ASM_OP); \
192 assemble_name (FILE, name); \
193 fprintf (FILE, ",%d\n", \
194 int_size_in_bytes (TREE_TYPE (DECL))); \
197 while (0)
200 /* This is how to declare the size of a function. */
202 #undef ASM_DECLARE_FUNCTION_SIZE
203 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
204 do \
206 if (!flag_inhibit_size_directive) \
208 char label[256]; \
209 static int labelno; \
210 labelno++; \
211 ASM_GENERATE_INTERNAL_LABEL (label, "Lfe", labelno); \
212 ASM_OUTPUT_INTERNAL_LABEL (FILE, "Lfe", labelno); \
213 fprintf (FILE, "%s", SIZE_ASM_OP); \
214 assemble_name (FILE, (FNAME)); \
215 fprintf (FILE, ","); \
216 assemble_name (FILE, label); \
217 fprintf (FILE, "-"); \
218 assemble_name (FILE, (FNAME)); \
219 putc ('\n', FILE); \
222 while (0)