1 /* Base configuration file for all OpenBSD targets.
2 Copyright (C) 1999, 2000, 2004, 2005, 2007, 2009, 2010, 2011, 2012
3 Free Software Foundation, Inc.
5 This file is part of GCC.
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)
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.
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/>. */
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 /* The compiler is configured with ONLY the gcc/g++ standard headers. */
56 #undef INCLUDE_DEFAULTS
57 #define INCLUDE_DEFAULTS \
59 { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1 }, \
60 { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1 }, \
61 { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1 }, \
62 { NATIVE_SYSTEM_HEADER_DIR, NATIVE_SYSTEM_HEADER_COMPONENT, 0, 0 }, \
66 /* Under OpenBSD, the normal location of the various *crt*.o files is the
67 /usr/lib directory. */
68 #undef STANDARD_STARTFILE_PREFIX
69 #define STANDARD_STARTFILE_PREFIX "/usr/local/lib/"
74 /* Controlling the compilation driver. */
75 /* TARGET_OS_CPP_BUILTINS() common to all OpenBSD targets. */
76 #define OPENBSD_OS_CPP_BUILTINS() \
79 builtin_define ("__OpenBSD__"); \
80 builtin_define ("__unix__"); \
81 builtin_define ("__ANSI_COMPAT"); \
82 builtin_assert ("system=unix"); \
83 builtin_assert ("system=bsd"); \
84 builtin_assert ("system=OpenBSD"); \
88 /* TARGET_OS_CPP_BUILTINS() common to all OpenBSD ELF targets. */
89 #define OPENBSD_OS_CPP_BUILTINS_ELF() \
92 OPENBSD_OS_CPP_BUILTINS(); \
93 builtin_define ("__ELF__"); \
97 /* TARGET_OS_CPP_BUILTINS() common to all LP64 OpenBSD targets. */
98 #define OPENBSD_OS_CPP_BUILTINS_LP64() \
101 builtin_define ("_LP64"); \
102 builtin_define ("__LP64__"); \
106 /* CPP_SPEC appropriate for OpenBSD. We deal with -posix and -pthread.
107 XXX the way threads are handled currently is not very satisfying,
108 since all code must be compiled with -pthread to work.
109 This two-stage defines makes it easy to pick that for targets that
112 #define OBSD_CPP_SPEC "%(cpp_cpu) %{posix:-D_POSIX_SOURCE} %{pthread:-D_POSIX_THREADS}"
114 #define OBSD_CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_POSIX_THREADS}"
118 #define LIB_SPEC OBSD_LIB_SPEC
120 #ifndef OBSD_HAS_CORRECT_SPECS
123 #define CPP_SPEC OBSD_CPP_SPEC
126 /* ASM_SPEC appropriate for OpenBSD. For some architectures, OpenBSD
127 still uses a special flavor of gas that needs to be told when generating
130 #define ASM_SPEC "%{fpic|fpie:-k} %{fPIC|fPIE:-k -K}"
133 /* Since we use gas, stdin -> - is a good idea. */
134 #define AS_NEEDS_DASH_FOR_PIPED_INPUT
137 #define LIB_SPEC OBSD_LIB_SPEC
139 #if defined(HAVE_LD_EH_FRAME_HDR)
140 #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
144 #define LIB_SPEC OBSD_LIB_SPEC
147 #define TARGET_POSIX_IO
149 /* All new versions of OpenBSD have C99 functions. */
150 #define TARGET_C99_FUNCTIONS 1
153 /* Runtime target specification. */
155 /* Miscellaneous parameters. */
157 /* Controlling debugging info: dbx options. */
159 /* Don't use the `xsTAG;' construct in DBX output; OpenBSD systems that
160 use DBX don't support it. */
164 /* - we use . - _func instead of a local label,
165 - we put extra spaces in expressions such as
166 .type _func , @function
167 This is more readable for a human being and confuses c++filt less. */
169 /* Assembler format: output and generation of labels. */
171 /* Define the strings used for the .type and .size directives.
172 These strings generally do not vary from one system running OpenBSD
173 to another, but if a given system needs to use different pseudo-op
174 names for these, they may be overridden in the arch specific file. */
176 /* OpenBSD assembler is hacked to have .type & .size support even in a.out
177 format object files. Functions size are supported but not activated
178 yet (look for GRACE_PERIOD_EXPIRED in gas/config/obj-aout.c).
179 SET_ASM_OP is needed for attribute alias to work. */
186 #define TYPE_ASM_OP "\t.type\t"
187 #define SIZE_ASM_OP "\t.size\t"
188 #define SET_ASM_OP "\t.set\t"
189 #define GLOBAL_ASM_OP "\t.globl\t"
191 /* The following macro defines the format used to output the second
192 operand of the .type assembler directive. */
193 #undef TYPE_OPERAND_FMT
194 #define TYPE_OPERAND_FMT "@%s"
196 /* Provision if extra assembler code is needed to declare a function's result
197 (taken from svr4, not needed yet actually). */
198 #ifndef ASM_DECLARE_RESULT
199 #define ASM_DECLARE_RESULT(FILE, RESULT)
202 /* These macros generate the special .type and .size directives which
203 are used to set the corresponding fields of the linker symbol table
204 entries under OpenBSD. These macros also have to output the starting
205 labels for the relevant functions/objects. */
207 #ifndef OBSD_HAS_DECLARE_FUNCTION_NAME
208 /* Extra assembler code needed to declare a function properly.
209 Some assemblers may also need to also have something extra said
210 about the function's return value. We allow for that here. */
211 #undef ASM_DECLARE_FUNCTION_NAME
212 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
214 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function"); \
215 ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
216 ASM_OUTPUT_FUNCTION_LABEL (FILE, NAME, DECL); \
220 #ifndef OBSD_HAS_DECLARE_FUNCTION_SIZE
221 /* Declare the size of a function. */
222 #undef ASM_DECLARE_FUNCTION_SIZE
223 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
225 if (!flag_inhibit_size_directive) \
226 ASM_OUTPUT_MEASURED_SIZE (FILE, FNAME); \
230 #ifndef OBSD_HAS_DECLARE_OBJECT
231 /* Extra assembler code needed to declare an object properly. */
232 #undef ASM_DECLARE_OBJECT_NAME
233 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
235 HOST_WIDE_INT size; \
236 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
237 size_directive_output = 0; \
238 if (!flag_inhibit_size_directive \
239 && (DECL) && DECL_SIZE (DECL)) \
241 size_directive_output = 1; \
242 size = int_size_in_bytes (TREE_TYPE (DECL)); \
243 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size); \
245 ASM_OUTPUT_LABEL (FILE, NAME); \
248 /* Output the size directive for a decl in rest_of_decl_compilation
249 in the case where we did not do so before the initializer.
250 Once we find the error_mark_node, we know that the value of
251 size_directive_output was set by ASM_DECLARE_OBJECT_NAME
252 when it was run for the same decl. */
253 #undef ASM_FINISH_DECLARE_OBJECT
254 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
256 const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
257 HOST_WIDE_INT size; \
258 if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \
259 && ! AT_END && TOP_LEVEL \
260 && DECL_INITIAL (DECL) == error_mark_node \
261 && !size_directive_output) \
263 size_directive_output = 1; \
264 size = int_size_in_bytes (TREE_TYPE (DECL)); \
265 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, name, size); \
271 /* Those are `generic' ways to weaken/globalize a label. We shouldn't need
272 to override a processor specific definition. Hence, #ifndef ASM_*
273 In case overriding turns out to be needed, one can always #undef ASM_*
274 before including this file. */
276 /* Tell the assembler that a symbol is weak. */
277 /* Note: netbsd arm32 assembler needs a .globl here. An override may
278 be needed when/if we go for arm32 support. */
279 #ifndef ASM_WEAKEN_LABEL
280 #define ASM_WEAKEN_LABEL(FILE,NAME) \
281 do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
282 fputc ('\n', FILE); } while (0)
285 /* Storage layout. */
288 #define HAVE_ENABLE_EXECUTE_STACK