gnu-user.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /* Definitions for systems using, at least optionally, a GNU
  2. (glibc-based) userspace or other userspace with libc derived from
  3. glibc (e.g. uClibc) or for which similar specs are appropriate.
  4. Copyright (C) 1995-2015 Free Software Foundation, Inc.
  5. Contributed by Eric Youngdale.
  6. Modified for stabs-in-ELF by H.J. Lu (hjl@lucon.org).
  7. This file is part of GCC.
  8. GCC is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 3, or (at your option)
  11. any later version.
  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.
  16. Under Section 7 of GPL version 3, you are granted additional
  17. permissions described in the GCC Runtime Library Exception, version
  18. 3.1, as published by the Free Software Foundation.
  19. You should have received a copy of the GNU General Public License and
  20. a copy of the GCC Runtime Library Exception along with this program;
  21. see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  22. <http://www.gnu.org/licenses/>. */
  23. /* Don't assume anything about the header files. */
  24. #define NO_IMPLICIT_EXTERN_C
  25. #undef ASM_APP_ON
  26. #define ASM_APP_ON "#APP\n"
  27. #undef ASM_APP_OFF
  28. #define ASM_APP_OFF "#NO_APP\n"
  29. /* Provide a STARTFILE_SPEC appropriate for GNU userspace. Here we add
  30. the GNU userspace magical crtbegin.o file (see crtstuff.c) which
  31. provides part of the support for getting C++ file-scope static
  32. object constructed before entering `main'. */
  33. #if defined HAVE_LD_PIE
  34. #define GNU_USER_TARGET_STARTFILE_SPEC \
  35. "%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} \
  36. crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s} \
  37. %{fvtable-verify=none:%s; \
  38. fvtable-verify=preinit:vtv_start_preinit.o%s; \
  39. fvtable-verify=std:vtv_start.o%s}"
  40. #else
  41. #define GNU_USER_TARGET_STARTFILE_SPEC \
  42. "%{!shared: %{pg|p|profile:gcrt1.o%s;:crt1.o%s}} \
  43. crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s} \
  44. %{fvtable-verify=none:%s; \
  45. fvtable-verify=preinit:vtv_start_preinit.o%s; \
  46. fvtable-verify=std:vtv_start.o%s}"
  47. #endif
  48. #undef STARTFILE_SPEC
  49. #define STARTFILE_SPEC GNU_USER_TARGET_STARTFILE_SPEC
  50. /* Provide a ENDFILE_SPEC appropriate for GNU userspace. Here we tack on
  51. the GNU userspace magical crtend.o file (see crtstuff.c) which
  52. provides part of the support for getting C++ file-scope static
  53. object constructed before entering `main', followed by a normal
  54. GNU userspace "finalizer" file, `crtn.o'. */
  55. #define GNU_USER_TARGET_ENDFILE_SPEC \
  56. "%{fvtable-verify=none:%s; \
  57. fvtable-verify=preinit:vtv_end_preinit.o%s; \
  58. fvtable-verify=std:vtv_end.o%s} \
  59. %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
  60. #undef ENDFILE_SPEC
  61. #define ENDFILE_SPEC GNU_USER_TARGET_ENDFILE_SPEC
  62. /* This is for -profile to use -lc_p instead of -lc. */
  63. #define GNU_USER_TARGET_CC1_SPEC "%{profile:-p}"
  64. #ifndef CC1_SPEC
  65. #define CC1_SPEC GNU_USER_TARGET_CC1_SPEC
  66. #endif
  67. /* The GNU C++ standard library requires that these macros be defined. */
  68. #undef CPLUSPLUS_CPP_SPEC
  69. #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
  70. #define GNU_USER_TARGET_NO_PTHREADS_LIB_SPEC \
  71. "%{shared:-lc} \
  72. %{!shared:%{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}}"
  73. #define GNU_USER_TARGET_LIB_SPEC \
  74. "%{pthread:-lpthread} " \
  75. GNU_USER_TARGET_NO_PTHREADS_LIB_SPEC
  76. #undef LIB_SPEC
  77. #define LIB_SPEC GNU_USER_TARGET_LIB_SPEC
  78. #if defined(HAVE_LD_EH_FRAME_HDR)
  79. #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
  80. #endif
  81. #undef LINK_GCC_C_SEQUENCE_SPEC
  82. #define LINK_GCC_C_SEQUENCE_SPEC \
  83. "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
  84. /* Use --as-needed -lgcc_s for eh support. */
  85. #ifdef HAVE_LD_AS_NEEDED
  86. #define USE_LD_AS_NEEDED 1
  87. #endif
  88. #define TARGET_POSIX_IO
  89. #undef TARGET_LIBC_HAS_FUNCTION
  90. #define TARGET_LIBC_HAS_FUNCTION gnu_libc_has_function
  91. /* Link -lasan early on the command line. For -static-libasan, don't link
  92. it for -shared link, the executable should be compiled with -static-libasan
  93. in that case, and for executable link link with --{,no-}whole-archive around
  94. it to force everything into the executable. And similarly for -ltsan
  95. and -llsan. */
  96. #if defined(HAVE_LD_STATIC_DYNAMIC)
  97. #undef LIBASAN_EARLY_SPEC
  98. #define LIBASAN_EARLY_SPEC "%{!shared:libasan_preinit%O%s} " \
  99. "%{static-libasan:%{!shared:" \
  100. LD_STATIC_OPTION " --whole-archive -lasan --no-whole-archive " \
  101. LD_DYNAMIC_OPTION "}}%{!static-libasan:-lasan}"
  102. #undef LIBTSAN_EARLY_SPEC
  103. #define LIBTSAN_EARLY_SPEC "%{static-libtsan:%{!shared:" \
  104. LD_STATIC_OPTION " --whole-archive -ltsan --no-whole-archive " \
  105. LD_DYNAMIC_OPTION "}}%{!static-libtsan:-ltsan}"
  106. #undef LIBLSAN_EARLY_SPEC
  107. #define LIBLSAN_EARLY_SPEC "%{static-liblsan:%{!shared:" \
  108. LD_STATIC_OPTION " --whole-archive -llsan --no-whole-archive " \
  109. LD_DYNAMIC_OPTION "}}%{!static-liblsan:-llsan}"
  110. #endif