linux.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /* Definitions for systems using the Linux kernel, with or without
  2. MMU, using ELF at the compiler level but possibly FLT for final
  3. linked executables and shared libraries in some no-MMU cases, and
  4. possibly with a choice of libc implementations.
  5. Copyright (C) 1995-2015 Free Software Foundation, Inc.
  6. Contributed by Eric Youngdale.
  7. Modified for stabs-in-ELF by H.J. Lu (hjl@lucon.org).
  8. This file is part of GCC.
  9. GCC is free software; you can redistribute it and/or modify
  10. it under the terms of the GNU General Public License as published by
  11. the Free Software Foundation; either version 3, or (at your option)
  12. any later version.
  13. GCC is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. GNU General Public License for more details.
  17. Under Section 7 of GPL version 3, you are granted additional
  18. permissions described in the GCC Runtime Library Exception, version
  19. 3.1, as published by the Free Software Foundation.
  20. You should have received a copy of the GNU General Public License and
  21. a copy of the GCC Runtime Library Exception along with this program;
  22. see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  23. <http://www.gnu.org/licenses/>. */
  24. /* C libraries supported on Linux. */
  25. #ifdef SINGLE_LIBC
  26. #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
  27. #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
  28. #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
  29. #else
  30. #define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
  31. #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
  32. #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
  33. #endif
  34. #define GNU_USER_TARGET_OS_CPP_BUILTINS() \
  35. do { \
  36. if (OPTION_GLIBC) \
  37. builtin_define ("__gnu_linux__"); \
  38. builtin_define_std ("linux"); \
  39. builtin_define_std ("unix"); \
  40. builtin_assert ("system=linux"); \
  41. builtin_assert ("system=unix"); \
  42. builtin_assert ("system=posix"); \
  43. } while (0)
  44. /* Determine which dynamic linker to use depending on whether GLIBC or
  45. uClibc or Bionic is the default C library and whether
  46. -muclibc or -mglibc or -mbionic has been passed to change the default. */
  47. #define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LD1, LD2, LD3) \
  48. "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:" LD1 "}}"
  49. #if DEFAULT_LIBC == LIBC_GLIBC
  50. #define CHOOSE_DYNAMIC_LINKER(G, U, B) \
  51. CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", G, U, B)
  52. #elif DEFAULT_LIBC == LIBC_UCLIBC
  53. #define CHOOSE_DYNAMIC_LINKER(G, U, B) \
  54. CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", U, G, B)
  55. #elif DEFAULT_LIBC == LIBC_BIONIC
  56. #define CHOOSE_DYNAMIC_LINKER(G, U, B) \
  57. CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", B, G, U)
  58. #else
  59. #error "Unsupported DEFAULT_LIBC"
  60. #endif /* DEFAULT_LIBC */
  61. /* For most targets the following definitions suffice;
  62. GLIBC_DYNAMIC_LINKER must be defined for each target using them, or
  63. GLIBC_DYNAMIC_LINKER32 and GLIBC_DYNAMIC_LINKER64 for targets
  64. supporting both 32-bit and 64-bit compilation. */
  65. #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
  66. #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
  67. #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
  68. #define UCLIBC_DYNAMIC_LINKERX32 "/lib/ldx32-uClibc.so.0"
  69. #define BIONIC_DYNAMIC_LINKER "/system/bin/linker"
  70. #define BIONIC_DYNAMIC_LINKER32 "/system/bin/linker"
  71. #define BIONIC_DYNAMIC_LINKER64 "/system/bin/linker64"
  72. #define BIONIC_DYNAMIC_LINKERX32 "/system/bin/linkerx32"
  73. #define GNU_USER_DYNAMIC_LINKER \
  74. CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \
  75. BIONIC_DYNAMIC_LINKER)
  76. #define GNU_USER_DYNAMIC_LINKER32 \
  77. CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, \
  78. BIONIC_DYNAMIC_LINKER32)
  79. #define GNU_USER_DYNAMIC_LINKER64 \
  80. CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \
  81. BIONIC_DYNAMIC_LINKER64)
  82. #define GNU_USER_DYNAMIC_LINKERX32 \
  83. CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERX32, UCLIBC_DYNAMIC_LINKERX32, \
  84. BIONIC_DYNAMIC_LINKERX32)
  85. /* Whether we have Bionic libc runtime */
  86. #undef TARGET_HAS_BIONIC
  87. #define TARGET_HAS_BIONIC (OPTION_BIONIC)
  88. #if (DEFAULT_LIBC == LIBC_UCLIBC) && defined (SINGLE_LIBC) /* uClinux */
  89. /* This is a *uclinux* target. We don't define below macros to normal linux
  90. versions, because doing so would require *uclinux* targets to include
  91. linux.c, linux-protos.h, linux.opt, etc. We could, alternatively, add
  92. these files to *uclinux* targets, but that would only pollute option list
  93. (add -mglibc, etc.) without adding any useful support. */
  94. /* Define TARGET_LIBC_HAS_FUNCTION for *uclinux* targets to
  95. no_c99_libc_has_function, because uclibc does not, normally, have
  96. c99 runtime. If, in special cases, uclibc does have c99 runtime,
  97. this should be defined to a new hook. Also please note that for targets
  98. like *-linux-uclibc that similar check will also need to be added to
  99. linux_libc_has_function. */
  100. # undef TARGET_LIBC_HAS_FUNCTION
  101. # define TARGET_LIBC_HAS_FUNCTION no_c99_libc_has_function
  102. #else /* !uClinux, i.e., normal Linux */
  103. /* Determine what functions are present at the runtime;
  104. this includes full c99 runtime and sincos. */
  105. # undef TARGET_LIBC_HAS_FUNCTION
  106. # define TARGET_LIBC_HAS_FUNCTION linux_libc_has_function
  107. #endif