]> gcc.gnu.org Git - gcc.git/blame - gcc/config/openbsd.h
re PR target/40483 (gcc 4.x needs to utilize better COMDAT mechanism under Solaris)
[gcc.git] / gcc / config / openbsd.h
CommitLineData
1b4a979b 1/* Base configuration file for all OpenBSD targets.
6d721f67
JM
2 Copyright (C) 1999, 2000, 2004, 2005, 2007, 2009, 2010
3 Free Software Foundation, Inc.
1b4a979b 4
7ec022b2 5This file is part of GCC.
1b4a979b 6
7ec022b2 7GCC is free software; you can redistribute it and/or modify
1b4a979b 8it under the terms of the GNU General Public License as published by
2f83c7d6 9the Free Software Foundation; either version 3, or (at your option)
1b4a979b
ME
10any later version.
11
7ec022b2 12GCC is distributed in the hope that it will be useful,
1b4a979b
ME
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
2f83c7d6
NC
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
1b4a979b
ME
20
21/* Common OpenBSD configuration.
22 All OpenBSD architectures include this file, which is intended as
23 a repository for common defines.
24
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
27 defaults by mistakes.
28
29 OBSD_HAS_CORRECT_SPECS:
30 another mechanism provides correct specs already.
31 OBSD_NO_DYNAMIC_LIBRARIES:
32 no implementation of dynamic libraries.
33 OBSD_OLD_GAS:
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.
39
40 There are also a few `default' defines such as ASM_WEAKEN_LABEL,
41 intended as common ground for arch that don't provide
42 anything suitable. */
43
44/* OPENBSD_NATIVE is defined only when gcc is configured as part of
45 the OpenBSD source tree, specifically through Makefile.bsd-wrapper.
46
47 In such a case the include path can be trimmed as there is no
48 distinction between system includes and gcc includes. */
49
50/* This configuration method, namely Makefile.bsd-wrapper and
51 OPENBSD_NATIVE is NOT recommended for building cross-compilers. */
52
53#ifdef OPENBSD_NATIVE
54
1b4a979b
ME
55/* The compiler is configured with ONLY the gcc/g++ standard headers. */
56#undef INCLUDE_DEFAULTS
57#define INCLUDE_DEFAULTS \
58 { \
59 { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1 }, \
378b66d4
ME
60 { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1 }, \
61 { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1 }, \
62 { STANDARD_INCLUDE_DIR, STANDARD_INCLUDE_COMPONENT, 0, 0 }, \
1b4a979b
ME
63 { 0, 0, 0, 0 } \
64 }
65
66/* Under OpenBSD, the normal location of the various *crt*.o files is the
67 /usr/lib directory. */
378b66d4
ME
68#undef STANDARD_STARTFILE_PREFIX
69#define STANDARD_STARTFILE_PREFIX "/usr/local/lib/"
1b4a979b
ME
70
71#endif
72
73\f
74/* Controlling the compilation driver. */
378b66d4
ME
75/* TARGET_OS_CPP_BUILTINS() common to all OpenBSD targets. */
76#define OPENBSD_OS_CPP_BUILTINS() \
77 do \
78 { \
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"); \
85 } \
86 while (0)
1b4a979b 87
aa58f943
JG
88/* TARGET_OS_CPP_BUILTINS() common to all OpenBSD ELF targets. */
89#define OPENBSD_OS_CPP_BUILTINS_ELF() \
90 do \
91 { \
92 OPENBSD_OS_CPP_BUILTINS(); \
93 builtin_define ("__ELF__"); \
94 } \
95while (0)
96
97/* TARGET_OS_CPP_BUILTINS() common to all LP64 OpenBSD targets. */
98#define OPENBSD_OS_CPP_BUILTINS_LP64() \
99 do \
100 { \
101 builtin_define ("_LP64"); \
102 builtin_define ("__LP64__"); \
103 } \
104 while (0)
105
1b4a979b 106/* CPP_SPEC appropriate for OpenBSD. We deal with -posix and -pthread.
378b66d4 107 XXX the way threads are handled currently is not very satisfying,
1b4a979b
ME
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
110 have subspecs. */
f1cf4606
ME
111#ifdef CPP_CPU_SPEC
112#define OBSD_CPP_SPEC "%(cpp_cpu) %{posix:-D_POSIX_SOURCE} %{pthread:-D_POSIX_THREADS}"
113#else
1b4a979b 114#define OBSD_CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_POSIX_THREADS}"
f1cf4606 115#endif
1b4a979b 116
aa58f943
JG
117#undef LIB_SPEC
118#define LIB_SPEC OBSD_LIB_SPEC
1b4a979b
ME
119
120#ifndef OBSD_HAS_CORRECT_SPECS
121
1b4a979b
ME
122#undef CPP_SPEC
123#define CPP_SPEC OBSD_CPP_SPEC
124
125#ifdef OBSD_OLD_GAS
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
128 pic code. */
129#undef ASM_SPEC
24a4dd31 130#define ASM_SPEC "%{fpic|fpie:-k} %{fPIC|fPIE:-k -K}"
1b4a979b
ME
131#endif
132
4977bab6
ZW
133/* Since we use gas, stdin -> - is a good idea. */
134#define AS_NEEDS_DASH_FOR_PIPED_INPUT
135
aa58f943
JG
136#undef LIB_SPEC
137#define LIB_SPEC OBSD_LIB_SPEC
138
139#if defined(HAVE_LD_EH_FRAME_HDR)
140#define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
1b4a979b
ME
141#endif
142
143#undef LIB_SPEC
144#define LIB_SPEC OBSD_LIB_SPEC
145#endif
146
9c0c4ec7 147#define TARGET_POSIX_IO
1b4a979b
ME
148\f
149/* Runtime target specification. */
150
1b4a979b
ME
151/* Miscellaneous parameters. */
152
1b4a979b
ME
153/* Controlling debugging info: dbx options. */
154
155/* Don't use the `xsTAG;' construct in DBX output; OpenBSD systems that
156 use DBX don't support it. */
157#define DBX_NO_XREFS
158
159\f
57809813 160/* - we use . - _func instead of a local label,
1b4a979b
ME
161 - we put extra spaces in expressions such as
162 .type _func , @function
163 This is more readable for a human being and confuses c++filt less. */
164
165/* Assembler format: output and generation of labels. */
166
167/* Define the strings used for the .type and .size directives.
168 These strings generally do not vary from one system running OpenBSD
169 to another, but if a given system needs to use different pseudo-op
170 names for these, they may be overridden in the arch specific file. */
171
172/* OpenBSD assembler is hacked to have .type & .size support even in a.out
173 format object files. Functions size are supported but not activated
203cb4ef
ME
174 yet (look for GRACE_PERIOD_EXPIRED in gas/config/obj-aout.c).
175 SET_ASM_OP is needed for attribute alias to work. */
1b4a979b
ME
176
177#undef TYPE_ASM_OP
178#undef SIZE_ASM_OP
203cb4ef 179#undef SET_ASM_OP
506a61b1 180#undef GLOBAL_ASM_OP
1b4a979b 181
e662a129
HPN
182#define TYPE_ASM_OP "\t.type\t"
183#define SIZE_ASM_OP "\t.size\t"
184#define SET_ASM_OP "\t.set\t"
506a61b1 185#define GLOBAL_ASM_OP "\t.globl\t"
1b4a979b
ME
186
187/* The following macro defines the format used to output the second
188 operand of the .type assembler directive. */
189#undef TYPE_OPERAND_FMT
190#define TYPE_OPERAND_FMT "@%s"
191
192/* Provision if extra assembler code is needed to declare a function's result
193 (taken from svr4, not needed yet actually). */
194#ifndef ASM_DECLARE_RESULT
195#define ASM_DECLARE_RESULT(FILE, RESULT)
196#endif
197
198/* These macros generate the special .type and .size directives which
199 are used to set the corresponding fields of the linker symbol table
200 entries under OpenBSD. These macros also have to output the starting
201 labels for the relevant functions/objects. */
202
203#ifndef OBSD_HAS_DECLARE_FUNCTION_NAME
204/* Extra assembler code needed to declare a function properly.
205 Some assemblers may also need to also have something extra said
206 about the function's return value. We allow for that here. */
207#undef ASM_DECLARE_FUNCTION_NAME
208#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
209 do { \
2be2ac70 210 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function"); \
1b4a979b 211 ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
135a687e 212 ASM_OUTPUT_FUNCTION_LABEL (FILE, NAME, DECL); \
1b4a979b
ME
213 } while (0)
214#endif
215
216#ifndef OBSD_HAS_DECLARE_FUNCTION_SIZE
217/* Declare the size of a function. */
218#undef ASM_DECLARE_FUNCTION_SIZE
99086d59
ZW
219#define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
220 do { \
221 if (!flag_inhibit_size_directive) \
222 ASM_OUTPUT_MEASURED_SIZE (FILE, FNAME); \
1b4a979b
ME
223 } while (0)
224#endif
225
226#ifndef OBSD_HAS_DECLARE_OBJECT
227/* Extra assembler code needed to declare an object properly. */
228#undef ASM_DECLARE_OBJECT_NAME
2be2ac70
ZW
229#define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
230 do { \
231 HOST_WIDE_INT size; \
232 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
233 size_directive_output = 0; \
234 if (!flag_inhibit_size_directive \
235 && (DECL) && DECL_SIZE (DECL)) \
236 { \
237 size_directive_output = 1; \
238 size = int_size_in_bytes (TREE_TYPE (DECL)); \
239 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size); \
240 } \
241 ASM_OUTPUT_LABEL (FILE, NAME); \
1b4a979b
ME
242 } while (0)
243
244/* Output the size directive for a decl in rest_of_decl_compilation
245 in the case where we did not do so before the initializer.
246 Once we find the error_mark_node, we know that the value of
247 size_directive_output was set by ASM_DECLARE_OBJECT_NAME
248 when it was run for the same decl. */
249#undef ASM_FINISH_DECLARE_OBJECT
250#define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
251do { \
3cce094d 252 const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
2be2ac70 253 HOST_WIDE_INT size; \
1b4a979b
ME
254 if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \
255 && ! AT_END && TOP_LEVEL \
256 && DECL_INITIAL (DECL) == error_mark_node \
257 && !size_directive_output) \
258 { \
259 size_directive_output = 1; \
2be2ac70
ZW
260 size = int_size_in_bytes (TREE_TYPE (DECL)); \
261 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, name, size); \
1b4a979b
ME
262 } \
263 } while (0)
264#endif
265
266\f
267/* Those are `generic' ways to weaken/globalize a label. We shouldn't need
268 to override a processor specific definition. Hence, #ifndef ASM_*
269 In case overriding turns out to be needed, one can always #undef ASM_*
270 before including this file. */
271
272/* Tell the assembler that a symbol is weak. */
273/* Note: netbsd arm32 assembler needs a .globl here. An override may
274 be needed when/if we go for arm32 support. */
275#ifndef ASM_WEAKEN_LABEL
276#define ASM_WEAKEN_LABEL(FILE,NAME) \
277 do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
278 fputc ('\n', FILE); } while (0)
279#endif
1b4a979b
ME
280\f
281/* Storage layout. */
282
1b4a979b 283\f
378b66d4
ME
284/* Stack is explicitly denied execution rights on OpenBSD platforms. */
285#define ENABLE_EXECUTE_STACK \
286extern void __enable_execute_stack (void *); \
287void \
288__enable_execute_stack (void *addr) \
289{ \
290 long size = getpagesize (); \
291 long mask = ~(size-1); \
292 char *page = (char *) (((long) addr) & mask); \
293 char *end = (char *) ((((long) (addr + TRAMPOLINE_SIZE)) & mask) + size); \
294 \
295 if (mprotect (page, end - page, PROT_READ | PROT_WRITE | PROT_EXEC) < 0) \
296 perror ("mprotect of trampoline code"); \
297}
298
299#include <sys/types.h>
300#include <sys/mman.h>
This page took 2.882209 seconds and 5 git commands to generate.