patch-gcc_config_arm_openbsd_h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. $OpenBSD: patch-gcc_config_arm_openbsd_h,v 1.3 2016/09/20 21:51:54 pascal Exp $
  2. --- gcc/config/arm/openbsd.h.orig Sat Sep 10 02:11:09 2016
  3. +++ gcc/config/arm/openbsd.h Mon Sep 19 12:22:39 2016
  4. @@ -0,0 +1,252 @@
  5. +/* Definitions of target machine for GNU compiler, OpenBSD/arm ELF version.
  6. + Copyright (C) 2002 Free Software Foundation, Inc.
  7. + Contributed by Wasabi Systems, Inc.
  8. +
  9. +This file is part of GNU CC.
  10. +
  11. +GNU CC is free software; you can redistribute it and/or modify
  12. +it under the terms of the GNU General Public License as published by
  13. +the Free Software Foundation; either version 2, or (at your option)
  14. +any later version.
  15. +
  16. +GNU CC is distributed in the hope that it will be useful,
  17. +but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. +GNU General Public License for more details.
  20. +
  21. +You should have received a copy of the GNU General Public License
  22. +along with GNU CC; see the file COPYING. If not, write to
  23. +the Free Software Foundation, 59 Temple Place - Suite 330,
  24. +Boston, MA 02111-1307, USA. */
  25. +
  26. +/* Run-time Target Specification. */
  27. +//#undef TARGET_VERSION
  28. +//#define TARGET_VERSION fputs (" (OpenBSD/arm)", stderr);
  29. +
  30. +/* This is used in ASM_FILE_START. */
  31. +//#undef ARM_OS_NAME
  32. +//#define ARM_OS_NAME "OpenBSD"
  33. +
  34. +/* Unsigned chars produces much better code than signed. */
  35. +#define DEFAULT_SIGNED_CHAR 0
  36. +
  37. +
  38. +/* This defaults us to little-endian. */
  39. +#ifndef TARGET_ENDIAN_DEFAULT
  40. +#define TARGET_ENDIAN_DEFAULT 0
  41. +#endif
  42. +
  43. +#undef MULTILIB_DEFAULTS
  44. +
  45. +/* armv5te default cpu. */
  46. +#define SUBTARGET_CPU_DEFAULT TARGET_CPU_mpcore
  47. +
  48. +/* We default to a soft-float ABI so that binaries can run on all
  49. + target hardware. */
  50. +#undef TARGET_DEFAULT_FLOAT_ABI
  51. +#define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_SOFT
  52. +
  53. +/* We default to the "aapcs-linux" ABI so that enums are int-sized by
  54. + default. */
  55. +#undef ARM_DEFAULT_ABI
  56. +#define ARM_DEFAULT_ABI ARM_ABI_AAPCS_LINUX
  57. +
  58. +
  59. +#define TARGET_OS_CPP_BUILTINS() \
  60. + do \
  61. + { \
  62. + builtin_define ("__GXX_MERGED_TYPEINFO_NAMES=0"); \
  63. + OPENBSD_OS_CPP_BUILTINS_ELF(); \
  64. + } \
  65. + while (0)
  66. +
  67. +#undef SUBTARGET_CPP_SPEC
  68. +#define SUBTARGET_CPP_SPEC OBSD_CPP_SPEC
  69. +
  70. +/* OBSD_LINK_SPEC appropriate for OpenBSD. Support for GCC options
  71. + -static, -assert, and -nostdlib. */
  72. +#undef OBSD_LINK_SPEC
  73. +#ifdef OBSD_NO_DYNAMIC_LIBRARIES
  74. +#define OBSD_LINK_SPEC \
  75. + "%{!nostdlib:%{!r*:%{!e*:-e __start}}} %{assert*}"
  76. +#else
  77. +#define OBSD_LINK_SPEC \
  78. + "%{!shared:%{!nostdlib:%{!r*:%{!e*:-e __start}}}} \
  79. + %{shared:-shared} %{R*} \
  80. + %{static:-Bstatic} \
  81. + %{!static:-Bdynamic} \
  82. + %{rdynamic:-export-dynamic} \
  83. + %{assert*} \
  84. + %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}"
  85. +#endif
  86. +
  87. +#undef SUBTARGET_EXTRA_ASM_SPEC
  88. +#define SUBTARGET_EXTRA_ASM_SPEC \
  89. + "%{mabi=apcs-gnu|mabi=atpcs:-meabi=gnu;:-meabi=4} %{fpic|fPIC|fpie|fPIE:-k}"
  90. +
  91. +/* Default floating point model is soft-VFP.
  92. + FIXME: -mhard-float currently implies FPA. */
  93. +#undef SUBTARGET_ASM_FLOAT_SPEC
  94. +#define SUBTARGET_ASM_FLOAT_SPEC \
  95. + "%{mhard-float:-mfpu=fpa} \
  96. + %{msoft-float:-mfpu=softvfp} \
  97. + %{!mhard-float: \
  98. + %{!msoft-float:-mfpu=softvfp}}"
  99. +
  100. +#undef SUBTARGET_EXTRA_SPECS
  101. +#define SUBTARGET_EXTRA_SPECS \
  102. + { "subtarget_extra_asm_spec", SUBTARGET_EXTRA_ASM_SPEC }, \
  103. + { "subtarget_asm_float_spec", SUBTARGET_ASM_FLOAT_SPEC }, \
  104. + { "openbsd_link_spec", OBSD_LINK_SPEC }, \
  105. + { "openbsd_entry_point", OPENBSD_ENTRY_POINT },
  106. +
  107. +#define OPENBSD_ENTRY_POINT "__start"
  108. +
  109. +/* Pass -X to the linker so that it will strip symbols starting with 'L' */
  110. +#undef LINK_SPEC
  111. +#define LINK_SPEC \
  112. + "-X %{mbig-endian:-EB} %{mlittle-endian:-EL} \
  113. + %(openbsd_link_spec)"
  114. +
  115. +/* Make GCC agree with <machine/_types.h>. */
  116. +
  117. +#undef SIZE_TYPE
  118. +#define SIZE_TYPE "long unsigned int"
  119. +
  120. +#undef PTRDIFF_TYPE
  121. +#define PTRDIFF_TYPE "long int"
  122. +
  123. +#undef INTMAX_TYPE
  124. +#define INTMAX_TYPE "long long int"
  125. +
  126. +#undef UINTMAX_TYPE
  127. +#define UINTMAX_TYPE "long long unsigned int"
  128. +
  129. +#undef WCHAR_TYPE
  130. +#define WCHAR_TYPE "int"
  131. +
  132. +#undef WCHAR_TYPE_SIZE
  133. +#define WCHAR_TYPE_SIZE 32
  134. +
  135. +/* We don't have any limit on the length as out debugger is GDB. */
  136. +#undef DBX_CONTIN_LENGTH
  137. +
  138. +/* OpenBSD and NetBSD do their profiling differently to the Acorn compiler. We
  139. + don't need a word following the mcount call; and to skip it
  140. + requires either an assembly stub or use of fomit-frame-pointer when
  141. + compiling the profiling functions. Since we break Acorn CC
  142. + compatibility below a little more won't hurt. */
  143. +
  144. +#undef ARM_FUNCTION_PROFILER
  145. +#define ARM_FUNCTION_PROFILER(STREAM,LABELNO) \
  146. +{ \
  147. + asm_fprintf (STREAM, "\tmov\t%Rip, %Rlr\n"); \
  148. + asm_fprintf (STREAM, "\tbl\t__mcount%s\n", \
  149. + NEED_PLT_RELOC ? "(PLT)" : ""); \
  150. +}
  151. +
  152. +/* On the ARM `@' introduces a comment, so we must use something else
  153. + for .type directives. */
  154. +#undef TYPE_OPERAND_FMT
  155. +#define TYPE_OPERAND_FMT "%%%s"
  156. +
  157. +#undef FPUTYPE_DEFAULT
  158. +#define FPUTYPE_DEFAULT "vfp"
  159. +
  160. +/* VERY BIG NOTE: Change of structure alignment for OpenBSD|NetBSD/arm.
  161. + There are consequences you should be aware of...
  162. +
  163. + Normally GCC/arm uses a structure alignment of 32 for compatibility
  164. + with armcc. This means that structures are padded to a word
  165. + boundary. However this causes problems with bugged OpenBSD|NetBSD kernel
  166. + code (possibly userland code as well - I have not checked every
  167. + binary). The nature of this bugged code is to rely on sizeof()
  168. + returning the correct size of various structures rounded to the
  169. + nearest byte (SCSI and ether code are two examples, the vm system
  170. + is another). This code breaks when the structure alignment is 32
  171. + as sizeof() will report a word=rounded size. By changing the
  172. + structure alignment to 8. GCC will conform to what is expected by
  173. + OpenBSD|NetBSD.
  174. +
  175. + This has several side effects that should be considered.
  176. + 1. Structures will only be aligned to the size of the largest member.
  177. + i.e. structures containing only bytes will be byte aligned.
  178. + structures containing shorts will be half word alinged.
  179. + structures containing ints will be word aligned.
  180. +
  181. + This means structures should be padded to a word boundary if
  182. + alignment of 32 is required for byte structures etc.
  183. +
  184. + 2. A potential performance penalty may exist if strings are no longer
  185. + word aligned. GCC will not be able to use word load/stores to copy
  186. + short strings.
  187. +
  188. + This modification is not encouraged but with the present state of the
  189. + OpenBSD|NetBSD source tree it is currently the only solution that meets the
  190. + requirements. */
  191. +
  192. +#undef DEFAULT_STRUCTURE_SIZE_BOUNDARY
  193. +#define DEFAULT_STRUCTURE_SIZE_BOUNDARY 8
  194. +
  195. +/* Clear the instruction cache from `BEG' to `END'. This makes a
  196. + call to the ARM_SYNC_ICACHE architecture specific syscall. */
  197. +#define CLEAR_INSN_CACHE(BEG, END) \
  198. +do \
  199. + { \
  200. + extern int sysarch(int number, void *args); \
  201. + struct { \
  202. + unsigned int addr; \
  203. + int len; \
  204. + } s; \
  205. + s.addr = (unsigned int)(BEG); \
  206. + s.len = (END) - (BEG); \
  207. + (void) sysarch (0, &s); \
  208. + } \
  209. +while (0)
  210. +
  211. +/* Provide a STARTFILE_SPEC appropriate for OpenBSD ELF. Here we
  212. + provide support for the special GCC option -static. On ELF
  213. + targets, we also add the crtbegin.o file, which provides part
  214. + of the support for getting C++ file-scope static objects
  215. + constructed before entering "main". */
  216. +
  217. +#define OPENBSD_STARTFILE_SPEC \
  218. + "%{!shared: \
  219. + %{pg:gcrt0%O%s} \
  220. + %{!pg: \
  221. + %{p:gcrt0%O%s} \
  222. + %{!p:%{!static:crt0%O%s} %{static:%{nopie:crt0%O%s} \
  223. + %{!nopie:rcrt0%O%s}}}}} \
  224. + %:if-exists(crti%O%s) \
  225. + %{static:%:if-exists-else(crtbeginT%O%s crtbegin%O%s)} \
  226. + %{!static: \
  227. + %{!shared:crtbegin%O%s} %{shared:crtbeginS%O%s}}"
  228. +
  229. +#undef STARTFILE_SPEC
  230. +#define STARTFILE_SPEC OPENBSD_STARTFILE_SPEC
  231. +
  232. +/* Provide an ENDFILE_SPEC appropriate for OpenBSD ELF. Here we
  233. +add crtend.o, which provides part of the support for getting
  234. +C++ file-scope static objects deconstructed after exiting "main". */
  235. +
  236. +#define OPENBSD_ENDFILE_SPEC \
  237. + "%{!shared:crtend%O%s} %{shared:crtendS%O%s} \
  238. + %:if-exists(crtn%O%s)"
  239. +
  240. +#undef ENDFILE_SPEC
  241. +#define ENDFILE_SPEC OPENBSD_ENDFILE_SPEC
  242. +
  243. +/* Remove -mcpu=native handling which is Linux specific */
  244. +#undef DRIVER_SELF_SPECS
  245. +#define DRIVER_SELF_SPECS ""
  246. +
  247. +/* dito */
  248. +#undef EXTRA_SPEC_FUNCTIONS
  249. +
  250. +#define SUBTARGET_OVERRIDE_INTERNAL_OPTIONS \
  251. +do { \
  252. + if (opts_set->x_unaligned_access == 1) \
  253. + warning (0, "target OS does not support unaligned accesses"); \
  254. + if (opts->x_unaligned_access) \
  255. + opts->x_unaligned_access = 0; \
  256. +} while (0)