openbsd.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. /* Base configuration file for all OpenBSD targets.
  2. Copyright (C) 1999-2015 Free Software Foundation, Inc.
  3. This file is part of GCC.
  4. GCC is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3, or (at your option)
  7. any later version.
  8. GCC is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GCC; see the file COPYING3. If not see
  14. <http://www.gnu.org/licenses/>. */
  15. /* Common OpenBSD configuration.
  16. All OpenBSD architectures include this file, which is intended as
  17. a repository for common defines.
  18. Some defines are common to all architectures, a few of them are
  19. triggered by OBSD_* guards, so that we won't override architecture
  20. defaults by mistakes.
  21. OBSD_HAS_CORRECT_SPECS:
  22. another mechanism provides correct specs already.
  23. OBSD_NO_DYNAMIC_LIBRARIES:
  24. no implementation of dynamic libraries.
  25. OBSD_OLD_GAS:
  26. older flavor of gas which needs help for PIC.
  27. OBSD_HAS_DECLARE_FUNCTION_NAME, OBSD_HAS_DECLARE_FUNCTION_SIZE,
  28. OBSD_HAS_DECLARE_OBJECT:
  29. PIC support, FUNCTION_NAME/FUNCTION_SIZE are independent, whereas
  30. the corresponding logic for OBJECTS is necessarily coupled.
  31. There are also a few `default' defines such as ASM_WEAKEN_LABEL,
  32. intended as common ground for arch that don't provide
  33. anything suitable. */
  34. /* OPENBSD_NATIVE is defined only when gcc is configured as part of
  35. the OpenBSD source tree, specifically through Makefile.bsd-wrapper.
  36. In such a case the include path can be trimmed as there is no
  37. distinction between system includes and gcc includes. */
  38. /* This configuration method, namely Makefile.bsd-wrapper and
  39. OPENBSD_NATIVE is NOT recommended for building cross-compilers. */
  40. #ifdef OPENBSD_NATIVE
  41. /* The compiler is configured with ONLY the gcc/g++ standard headers. */
  42. #undef INCLUDE_DEFAULTS
  43. #define INCLUDE_DEFAULTS \
  44. { \
  45. { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1 }, \
  46. { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1 }, \
  47. { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1 }, \
  48. { NATIVE_SYSTEM_HEADER_DIR, NATIVE_SYSTEM_HEADER_COMPONENT, 0, 0 }, \
  49. { 0, 0, 0, 0 } \
  50. }
  51. /* Under OpenBSD, the normal location of the various *crt*.o files is the
  52. /usr/lib directory. */
  53. #undef STANDARD_STARTFILE_PREFIX
  54. #define STANDARD_STARTFILE_PREFIX "/usr/local/lib/"
  55. #endif
  56. /* Controlling the compilation driver. */
  57. /* TARGET_OS_CPP_BUILTINS() common to all OpenBSD targets. */
  58. #define OPENBSD_OS_CPP_BUILTINS() \
  59. do \
  60. { \
  61. builtin_define ("__OpenBSD__"); \
  62. builtin_define ("__unix__"); \
  63. builtin_define ("__ANSI_COMPAT"); \
  64. builtin_assert ("system=unix"); \
  65. builtin_assert ("system=bsd"); \
  66. builtin_assert ("system=OpenBSD"); \
  67. } \
  68. while (0)
  69. /* TARGET_OS_CPP_BUILTINS() common to all OpenBSD ELF targets. */
  70. #define OPENBSD_OS_CPP_BUILTINS_ELF() \
  71. do \
  72. { \
  73. OPENBSD_OS_CPP_BUILTINS(); \
  74. builtin_define ("__ELF__"); \
  75. } \
  76. while (0)
  77. /* TARGET_OS_CPP_BUILTINS() common to all LP64 OpenBSD targets. */
  78. #define OPENBSD_OS_CPP_BUILTINS_LP64() \
  79. do \
  80. { \
  81. builtin_define ("_LP64"); \
  82. builtin_define ("__LP64__"); \
  83. } \
  84. while (0)
  85. /* CPP_SPEC appropriate for OpenBSD. We deal with -posix and -pthread.
  86. XXX the way threads are handled currently is not very satisfying,
  87. since all code must be compiled with -pthread to work.
  88. This two-stage defines makes it easy to pick that for targets that
  89. have subspecs. */
  90. #ifdef CPP_CPU_SPEC
  91. #define OBSD_CPP_SPEC "%(cpp_cpu) %{posix:-D_POSIX_SOURCE} %{pthread:-D_POSIX_THREADS}"
  92. #else
  93. #define OBSD_CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_POSIX_THREADS}"
  94. #endif
  95. #undef LIB_SPEC
  96. #define LIB_SPEC OBSD_LIB_SPEC
  97. #ifndef OBSD_HAS_CORRECT_SPECS
  98. #undef CPP_SPEC
  99. #define CPP_SPEC OBSD_CPP_SPEC
  100. #ifdef OBSD_OLD_GAS
  101. /* ASM_SPEC appropriate for OpenBSD. For some architectures, OpenBSD
  102. still uses a special flavor of gas that needs to be told when generating
  103. pic code. */
  104. #undef ASM_SPEC
  105. #define ASM_SPEC "%{fpic|fpie:-k} %{fPIC|fPIE:-k -K}"
  106. #endif
  107. /* Since we use gas, stdin -> - is a good idea. */
  108. #define AS_NEEDS_DASH_FOR_PIPED_INPUT
  109. #undef LIB_SPEC
  110. #define LIB_SPEC OBSD_LIB_SPEC
  111. #if defined(HAVE_LD_EH_FRAME_HDR)
  112. #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
  113. #endif
  114. #undef LIB_SPEC
  115. #define LIB_SPEC OBSD_LIB_SPEC
  116. #endif
  117. #define TARGET_POSIX_IO
  118. /* All new versions of OpenBSD have C99 functions. We redefine this hook
  119. so the version from elfos.h header won't be used. */
  120. #undef TARGET_LIBC_HAS_FUNCTION
  121. #define TARGET_LIBC_HAS_FUNCTION default_libc_has_function
  122. /* Runtime target specification. */
  123. /* Miscellaneous parameters. */
  124. /* Controlling debugging info: dbx options. */
  125. /* Don't use the `xsTAG;' construct in DBX output; OpenBSD systems that
  126. use DBX don't support it. */
  127. #define DBX_NO_XREFS
  128. /* - we use . - _func instead of a local label,
  129. - we put extra spaces in expressions such as
  130. .type _func , @function
  131. This is more readable for a human being and confuses c++filt less. */
  132. /* Assembler format: output and generation of labels. */
  133. /* Define the strings used for the .type and .size directives.
  134. These strings generally do not vary from one system running OpenBSD
  135. to another, but if a given system needs to use different pseudo-op
  136. names for these, they may be overridden in the arch specific file. */
  137. /* OpenBSD assembler is hacked to have .type & .size support even in a.out
  138. format object files. Functions size are supported but not activated
  139. yet (look for GRACE_PERIOD_EXPIRED in gas/config/obj-aout.c).
  140. SET_ASM_OP is needed for attribute alias to work. */
  141. #undef TYPE_ASM_OP
  142. #undef SIZE_ASM_OP
  143. #undef SET_ASM_OP
  144. #undef GLOBAL_ASM_OP
  145. #define TYPE_ASM_OP "\t.type\t"
  146. #define SIZE_ASM_OP "\t.size\t"
  147. #define SET_ASM_OP "\t.set\t"
  148. #define GLOBAL_ASM_OP "\t.globl\t"
  149. /* The following macro defines the format used to output the second
  150. operand of the .type assembler directive. */
  151. #undef TYPE_OPERAND_FMT
  152. #define TYPE_OPERAND_FMT "@%s"
  153. /* Provision if extra assembler code is needed to declare a function's result
  154. (taken from svr4, not needed yet actually). */
  155. #ifndef ASM_DECLARE_RESULT
  156. #define ASM_DECLARE_RESULT(FILE, RESULT)
  157. #endif
  158. /* These macros generate the special .type and .size directives which
  159. are used to set the corresponding fields of the linker symbol table
  160. entries under OpenBSD. These macros also have to output the starting
  161. labels for the relevant functions/objects. */
  162. #ifndef OBSD_HAS_DECLARE_FUNCTION_NAME
  163. /* Extra assembler code needed to declare a function properly.
  164. Some assemblers may also need to also have something extra said
  165. about the function's return value. We allow for that here. */
  166. #undef ASM_DECLARE_FUNCTION_NAME
  167. #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
  168. do { \
  169. ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function"); \
  170. ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
  171. ASM_OUTPUT_FUNCTION_LABEL (FILE, NAME, DECL); \
  172. } while (0)
  173. #endif
  174. #ifndef OBSD_HAS_DECLARE_FUNCTION_SIZE
  175. /* Declare the size of a function. */
  176. #undef ASM_DECLARE_FUNCTION_SIZE
  177. #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
  178. do { \
  179. if (!flag_inhibit_size_directive) \
  180. ASM_OUTPUT_MEASURED_SIZE (FILE, FNAME); \
  181. } while (0)
  182. #endif
  183. #ifndef OBSD_HAS_DECLARE_OBJECT
  184. /* Extra assembler code needed to declare an object properly. */
  185. #undef ASM_DECLARE_OBJECT_NAME
  186. #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
  187. do { \
  188. HOST_WIDE_INT size; \
  189. ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
  190. size_directive_output = 0; \
  191. if (!flag_inhibit_size_directive \
  192. && (DECL) && DECL_SIZE (DECL)) \
  193. { \
  194. size_directive_output = 1; \
  195. size = int_size_in_bytes (TREE_TYPE (DECL)); \
  196. ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size); \
  197. } \
  198. ASM_OUTPUT_LABEL (FILE, NAME); \
  199. } while (0)
  200. /* Output the size directive for a decl in rest_of_decl_compilation
  201. in the case where we did not do so before the initializer.
  202. Once we find the error_mark_node, we know that the value of
  203. size_directive_output was set by ASM_DECLARE_OBJECT_NAME
  204. when it was run for the same decl. */
  205. #undef ASM_FINISH_DECLARE_OBJECT
  206. #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
  207. do { \
  208. const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
  209. HOST_WIDE_INT size; \
  210. if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \
  211. && ! AT_END && TOP_LEVEL \
  212. && DECL_INITIAL (DECL) == error_mark_node \
  213. && !size_directive_output) \
  214. { \
  215. size_directive_output = 1; \
  216. size = int_size_in_bytes (TREE_TYPE (DECL)); \
  217. ASM_OUTPUT_SIZE_DIRECTIVE (FILE, name, size); \
  218. } \
  219. } while (0)
  220. #endif
  221. /* Those are `generic' ways to weaken/globalize a label. We shouldn't need
  222. to override a processor specific definition. Hence, #ifndef ASM_*
  223. In case overriding turns out to be needed, one can always #undef ASM_*
  224. before including this file. */
  225. /* Tell the assembler that a symbol is weak. */
  226. /* Note: netbsd arm32 assembler needs a .globl here. An override may
  227. be needed when/if we go for arm32 support. */
  228. #ifndef ASM_WEAKEN_LABEL
  229. #define ASM_WEAKEN_LABEL(FILE,NAME) \
  230. do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
  231. fputc ('\n', FILE); } while (0)
  232. #endif
  233. /* Storage layout. */
  234. #define HAVE_ENABLE_EXECUTE_STACK