1 /* Base configuration file for all OpenBSD targets.
2 Copyright (C) 1999, 2000 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 /* Common OpenBSD configuration.
22 All OpenBSD architectures include this file, which is intended as
23 a repository for common defines.
25 Some defines are common to all architectures, a few of them are
26 triggered by OBSD_* guards, so that we won't override architecture
29 OBSD_HAS_CORRECT_SPECS:
30 another mechanism provides correct specs already.
31 OBSD_NO_DYNAMIC_LIBRARIES:
32 no implementation of dynamic libraries.
34 older flavor of gas which needs help for PIC.
35 OBSD_HAS_DECLARE_FUNCTION_NAME, OBSD_HAS_DECLARE_FUNCTION_SIZE,
36 OBSD_HAS_DECLARE_OBJECT:
37 PIC support, FUNCTION_NAME/FUNCTION_SIZE are independent, whereas
38 the corresponding logic for OBJECTS is necessarily coupled.
40 There are also a few `default' defines such as ASM_WEAKEN_LABEL,
41 intended as common ground for arch that don't provide
44 /* OPENBSD_NATIVE is defined only when gcc is configured as part of
45 the OpenBSD source tree, specifically through Makefile.bsd-wrapper.
47 In such a case the include path can be trimmed as there is no
48 distinction between system includes and gcc includes. */
50 /* This configuration method, namely Makefile.bsd-wrapper and
51 OPENBSD_NATIVE is NOT recommended for building cross-compilers. */
55 #undef GCC_INCLUDE_DIR
56 #define GCC_INCLUDE_DIR "/usr/include"
58 /* The compiler is configured with ONLY the gcc/g++ standard headers. */
59 #undef INCLUDE_DEFAULTS
60 #define INCLUDE_DEFAULTS \
62 { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1 }, \
63 { GCC_INCLUDE_DIR, "GCC", 0, 0 }, \
67 /* Under OpenBSD, the normal location of the various *crt*.o files is the
68 /usr/lib directory. */
69 #define STANDARD_STARTFILE_PREFIX "/usr/lib/"
74 /* Controlling the compilation driver. */
76 /* CPP_SPEC appropriate for OpenBSD. We deal with -posix and -pthread.
77 XXX the way threads are handling currently is not very satisfying,
78 since all code must be compiled with -pthread to work.
79 This two-stage defines makes it easy to pick that for targets that
82 #define OBSD_CPP_SPEC "%(cpp_cpu) %{posix:-D_POSIX_SOURCE} %{pthread:-D_POSIX_THREADS}"
84 #define OBSD_CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_POSIX_THREADS}"
87 /* LIB_SPEC appropriate for OpenBSD. Select the appropriate libc,
88 depending on profiling and threads. Basically,
89 -lc(_r)?(_p)?, select _r for threads, and _p for p or pg. */
90 #define OBSD_LIB_SPEC "%{!shared:-lc%{pthread:_r}%{p:_p}%{!p:%{pg:_p}}}"
92 #ifndef OBSD_HAS_CORRECT_SPECS
94 #ifndef OBSD_NO_DYNAMIC_LIBRARIES
95 #undef SWITCH_TAKES_ARG
96 #define SWITCH_TAKES_ARG(CHAR) \
97 (DEFAULT_SWITCH_TAKES_ARG (CHAR) \
102 #define CPP_SPEC OBSD_CPP_SPEC
105 /* ASM_SPEC appropriate for OpenBSD. For some architectures, OpenBSD
106 still uses a special flavor of gas that needs to be told when generating
109 #define ASM_SPEC "%{fpic:-k} %{fPIC:-k -K} %|"
112 /* Since we use gas, stdin -> - is a good idea, but we don't want to
113 override native specs just for that. */
115 #define ASM_SPEC "%|"
119 /* LINK_SPEC appropriate for OpenBSD. Support for GCC options
120 -static, -assert, and -nostdlib. */
122 #ifdef OBSD_NO_DYNAMIC_LIBRARIES
124 "%{g:%{!nostdlib:-L/usr/lib/debug}} %{!nostdlib:%{!r*:%{!e*:-e start}}} -dc -dp %{assert*}"
127 "%{g:%{!nostdlib:-L/usr/lib/debug}} %{!shared:%{!nostdlib:%{!r*:%{!e*:-e start}}}} %{shared:-Bshareable -x} -dc -dp %{R*} %{static:-Bstatic} %{assert*}"
131 #define LIB_SPEC OBSD_LIB_SPEC
135 /* Runtime target specification. */
137 /* You must redefine CPP_PREDEFINES in any arch specific file. */
138 #undef CPP_PREDEFINES
140 /* Implicit calls to library routines. */
142 /* Use memcpy and memset instead of bcopy and bzero. */
143 #ifndef TARGET_MEM_FUNCTIONS
144 #define TARGET_MEM_FUNCTIONS
147 /* Miscellaneous parameters. */
149 /* Controlling debugging info: dbx options. */
151 /* Don't use the `xsTAG;' construct in DBX output; OpenBSD systems that
152 use DBX don't support it. */
156 /* Support of shared libraries, mostly imported from svr4.h through netbsd. */
157 /* Two differences from svr4.h:
158 - we use . - _func instead of a local label,
159 - we put extra spaces in expressions such as
160 .type _func , @function
161 This is more readable for a human being and confuses c++filt less. */
163 /* Assembler format: output and generation of labels. */
165 /* Define the strings used for the .type and .size directives.
166 These strings generally do not vary from one system running OpenBSD
167 to another, but if a given system needs to use different pseudo-op
168 names for these, they may be overridden in the arch specific file. */
170 /* OpenBSD assembler is hacked to have .type & .size support even in a.out
171 format object files. Functions size are supported but not activated
172 yet (look for GRACE_PERIOD_EXPIRED in gas/config/obj-aout.c).
173 SET_ASM_OP is needed for attribute alias to work. */
180 #define TYPE_ASM_OP "\t.type\t"
181 #define SIZE_ASM_OP "\t.size\t"
182 #define SET_ASM_OP "\t.set\t"
183 #define GLOBAL_ASM_OP "\t.globl\t"
185 /* The following macro defines the format used to output the second
186 operand of the .type assembler directive. */
187 #undef TYPE_OPERAND_FMT
188 #define TYPE_OPERAND_FMT "@%s"
190 /* Provision if extra assembler code is needed to declare a function's result
191 (taken from svr4, not needed yet actually). */
192 #ifndef ASM_DECLARE_RESULT
193 #define ASM_DECLARE_RESULT(FILE, RESULT)
196 /* These macros generate the special .type and .size directives which
197 are used to set the corresponding fields of the linker symbol table
198 entries under OpenBSD. These macros also have to output the starting
199 labels for the relevant functions/objects. */
201 #ifndef OBSD_HAS_DECLARE_FUNCTION_NAME
202 /* Extra assembler code needed to declare a function properly.
203 Some assemblers may also need to also have something extra said
204 about the function's return value. We allow for that here. */
205 #undef ASM_DECLARE_FUNCTION_NAME
206 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
208 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function"); \
209 ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
210 ASM_OUTPUT_LABEL(FILE, NAME); \
214 #ifndef OBSD_HAS_DECLARE_FUNCTION_SIZE
215 /* Declare the size of a function. */
216 #undef ASM_DECLARE_FUNCTION_SIZE
217 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
219 if (!flag_inhibit_size_directive) \
220 ASM_OUTPUT_MEASURED_SIZE (FILE, FNAME); \
224 #ifndef OBSD_HAS_DECLARE_OBJECT
225 /* Extra assembler code needed to declare an object properly. */
226 #undef ASM_DECLARE_OBJECT_NAME
227 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
229 HOST_WIDE_INT size; \
230 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
231 size_directive_output = 0; \
232 if (!flag_inhibit_size_directive \
233 && (DECL) && DECL_SIZE (DECL)) \
235 size_directive_output = 1; \
236 size = int_size_in_bytes (TREE_TYPE (DECL)); \
237 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size); \
239 ASM_OUTPUT_LABEL (FILE, NAME); \
242 /* Output the size directive for a decl in rest_of_decl_compilation
243 in the case where we did not do so before the initializer.
244 Once we find the error_mark_node, we know that the value of
245 size_directive_output was set by ASM_DECLARE_OBJECT_NAME
246 when it was run for the same decl. */
247 #undef ASM_FINISH_DECLARE_OBJECT
248 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
250 const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
251 HOST_WIDE_INT size; \
252 if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \
253 && ! AT_END && TOP_LEVEL \
254 && DECL_INITIAL (DECL) == error_mark_node \
255 && !size_directive_output) \
257 size_directive_output = 1; \
258 size = int_size_in_bytes (TREE_TYPE (DECL)); \
259 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, name, size); \
265 /* Those are `generic' ways to weaken/globalize a label. We shouldn't need
266 to override a processor specific definition. Hence, #ifndef ASM_*
267 In case overriding turns out to be needed, one can always #undef ASM_*
268 before including this file. */
270 /* Tell the assembler that a symbol is weak. */
271 /* Note: netbsd arm32 assembler needs a .globl here. An override may
272 be needed when/if we go for arm32 support. */
273 #ifndef ASM_WEAKEN_LABEL
274 #define ASM_WEAKEN_LABEL(FILE,NAME) \
275 do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
276 fputc ('\n', FILE); } while (0)
279 /* Storage layout. */
282 /* Otherwise, since we support weak, gthr.h erroneously tries to use
284 #define GTHREAD_USE_WEAK 0
286 /* bug work around: we don't want to support #pragma weak, but the current
287 code layout needs HANDLE_PRAGMA_WEAK asserted for __attribute((weak)) to
288 work. On the other hand, we don't define HANDLE_PRAGMA_WEAK directly,
289 as this depends on a few other details as well... */
290 #define HANDLE_SYSV_PRAGMA