vxworks.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /* Common VxWorks target definitions for GNU compiler.
  2. Copyright (C) 1999-2015 Free Software Foundation, Inc.
  3. Contributed by Wind River Systems.
  4. Rewritten by CodeSourcery, LLC.
  5. This file is part of GCC.
  6. GCC is free software; you can redistribute it and/or modify it under
  7. the terms of the GNU General Public License as published by the Free
  8. Software Foundation; either version 3, or (at your option) any later
  9. version.
  10. GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  13. for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with GCC; see the file COPYING3. If not see
  16. <http://www.gnu.org/licenses/>. */
  17. /* Assert that we are targeting VxWorks. */
  18. #undef TARGET_VXWORKS
  19. #define TARGET_VXWORKS 1
  20. /* In kernel mode, VxWorks provides all the libraries itself, as well as
  21. the functionality of startup files, etc. In RTP mode, it behaves more
  22. like a traditional Unix, with more external files. Most of our specs
  23. must be aware of the difference. */
  24. /* We look for the VxWorks header files using the environment
  25. variables that are set in VxWorks to indicate the location of the
  26. system header files. We use -idirafter so that the GCC's own
  27. header-file directories (containing <stddef.h>, etc.) come before
  28. the VxWorks system header directories. */
  29. /* Since we provide a default -isystem, expand -isystem on the command
  30. line early. */
  31. #undef VXWORKS_ADDITIONAL_CPP_SPEC
  32. #define VXWORKS_ADDITIONAL_CPP_SPEC \
  33. "%{!nostdinc: \
  34. %{isystem*} -idirafter \
  35. %{mrtp: %:getenv(WIND_USR /h) \
  36. ;: %:getenv(WIND_BASE /target/h)}}"
  37. /* The references to __init and __fini will be satisfied by
  38. libc_internal.a. */
  39. #undef VXWORKS_LIB_SPEC
  40. #define VXWORKS_LIB_SPEC \
  41. "%{mrtp:%{shared:-u " USER_LABEL_PREFIX "__init -u " USER_LABEL_PREFIX "__fini} \
  42. %{!shared:%{non-static:-u " USER_LABEL_PREFIX "_STI__6__rtld -ldl} \
  43. --start-group -lc -lgcc -lc_internal -lnet -ldsi \
  44. --end-group}}"
  45. /* The no-op spec for "-shared" below is present because otherwise GCC
  46. will treat it as an unrecognized option. */
  47. #undef VXWORKS_LINK_SPEC
  48. #define VXWORKS_LINK_SPEC \
  49. "%{!mrtp:-r} \
  50. %{!shared: \
  51. %{mrtp:-q %{h*} \
  52. %{R*} %{!T*: %(link_start) } \
  53. %(link_target) %(link_os)}} \
  54. %{v:-v} \
  55. %{shared:-shared} \
  56. %{Bstatic:-Bstatic} \
  57. %{Bdynamic:-Bdynamic} \
  58. %{!Xbind-lazy:-z now} \
  59. %{Xbind-now:%{Xbind-lazy: \
  60. %e-Xbind-now and -Xbind-lazy are incompatible}} \
  61. %{mrtp:%{!shared:%{!non-static:-static} \
  62. %{non-static:--force-dynamic --export-dynamic}}}"
  63. /* For VxWorks, the system provides libc_internal.a. This is a superset
  64. of libgcc.a; we want to use it. Make sure not to dynamically export
  65. any of its symbols, though. Always look for libgcc.a first so that
  66. we get the latest versions of the GNU intrinsics during our builds. */
  67. #undef VXWORKS_LIBGCC_SPEC
  68. #define VXWORKS_LIBGCC_SPEC \
  69. "-lgcc %{mrtp:--exclude-libs=libc_internal,libgcc -lc_internal}"
  70. #undef VXWORKS_STARTFILE_SPEC
  71. #define VXWORKS_STARTFILE_SPEC "%{mrtp:%{!shared:-l:crt0.o}}"
  72. #define VXWORKS_ENDFILE_SPEC ""
  73. /* Do VxWorks-specific parts of TARGET_OPTION_OVERRIDE. */
  74. #undef VXWORKS_OVERRIDE_OPTIONS
  75. #define VXWORKS_OVERRIDE_OPTIONS vxworks_override_options ()
  76. extern void vxworks_override_options (void);
  77. /* Only RTPs support prioritized constructors and destructors:
  78. the implementation relies on numbered .ctors* sections. */
  79. #define SUPPORTS_INIT_PRIORITY TARGET_VXWORKS_RTP
  80. /* VxWorks requires special handling of constructors and destructors.
  81. All VxWorks configurations must use these functions. */
  82. #undef TARGET_ASM_CONSTRUCTOR
  83. #define TARGET_ASM_CONSTRUCTOR vxworks_asm_out_constructor
  84. #undef TARGET_ASM_DESTRUCTOR
  85. #define TARGET_ASM_DESTRUCTOR vxworks_asm_out_destructor
  86. extern void vxworks_asm_out_constructor (rtx symbol, int priority);
  87. extern void vxworks_asm_out_destructor (rtx symbol, int priority);
  88. /* Override the vxworks-dummy.h definitions. TARGET_VXWORKS_RTP
  89. is defined by vxworks.opt. */
  90. #undef VXWORKS_GOTT_BASE
  91. #define VXWORKS_GOTT_BASE "__GOTT_BASE__"
  92. #undef VXWORKS_GOTT_INDEX
  93. #define VXWORKS_GOTT_INDEX "__GOTT_INDEX__"
  94. #undef PTRDIFF_TYPE
  95. #define PTRDIFF_TYPE "int"
  96. #undef SIZE_TYPE
  97. #define SIZE_TYPE "unsigned int"
  98. #undef TARGET_LIBC_HAS_FUNCTION
  99. #define TARGET_LIBC_HAS_FUNCTION no_c99_libc_has_function
  100. /* Both kernels and RTPs have the facilities required by this macro. */
  101. #define TARGET_POSIX_IO
  102. /* A VxWorks implementation of TARGET_OS_CPP_BUILTINS. */
  103. #define VXWORKS_OS_CPP_BUILTINS() \
  104. do \
  105. { \
  106. builtin_define ("__vxworks"); \
  107. builtin_define ("__VXWORKS__"); \
  108. builtin_assert ("system=unix"); \
  109. if (TARGET_VXWORKS_RTP) \
  110. builtin_define ("__RTP__"); \
  111. else \
  112. builtin_define ("_WRS_KERNEL"); \
  113. } \
  114. while (0)
  115. #define VXWORKS_KIND VXWORKS_KIND_NORMAL
  116. /* The diab linker does not handle .gnu_attribute sections. */
  117. #undef HAVE_AS_GNU_ATTRIBUTE