203-musl_powerpc.patch 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. gcc/Changelog:
  2. 2015-04-24 Gregor Richards <gregor.richards@uwaterloo.ca>
  3. Szabolcs Nagy <szabolcs.nagy@arm.com>
  4. * config.gcc (secure_plt): Add *-linux*-musl*.
  5. * config/rs6000/linux64.h (MUSL_DYNAMIC_LINKER32): Define.
  6. (MUSL_DYNAMIC_LINKER64): Define.
  7. (GNU_USER_DYNAMIC_LINKER32): Update.
  8. (GNU_USER_DYNAMIC_LINKER64): Update.
  9. (CHOOSE_DYNAMIC_LINKER): Update.
  10. * config/rs6000/secureplt.h (LINK_SECURE_PLT_DEFAULT_SPEC): Define.
  11. * config/rs6000/sysv4.h (GNU_USER_DYNAMIC_LINKER): Update.
  12. (MUSL_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER_E,)
  13. (INCLUDE_DEFAULTS_MUSL_GPP, INCLUDE_DEFAULTS_MUSL_LOCAL,)
  14. (INCLUDE_DEFAULTS_MUSL_PREFIX, INCLUDE_DEFAULTS_MUSL_CROSS,)
  15. (INCLUDE_DEFAULTS_MUSL_TOOL, INCLUDE_DEFAULTS_MUSL_NATIVE): Define.
  16. (LINK_SECURE_PLT_DEFAULT_SPEC): Define.
  17. (CHOOSE_DYNAMIC_LINKER, LINK_TARGET_SPEC, LINK_OS_LINUX_SPEC): Update.
  18. * config/rs6000/sysv4le.h (MUSL_DYNAMIC_LINKER_E): Define.
  19. --- a/gcc/config/rs6000/linux64.h
  20. +++ b/gcc/config/rs6000/linux64.h
  21. @@ -365,17 +365,21 @@ extern int dot_symbols;
  22. #endif
  23. #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
  24. #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
  25. +#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E ".so.1"
  26. +#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-powerpc64" MUSL_DYNAMIC_LINKER_E ".so.1"
  27. #if DEFAULT_LIBC == LIBC_UCLIBC
  28. -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
  29. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
  30. #elif DEFAULT_LIBC == LIBC_GLIBC
  31. -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
  32. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
  33. +#elif DEFAULT_LIBC == LIBC_MUSL
  34. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
  35. #else
  36. #error "Unsupported DEFAULT_LIBC"
  37. #endif
  38. #define GNU_USER_DYNAMIC_LINKER32 \
  39. - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32)
  40. + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
  41. #define GNU_USER_DYNAMIC_LINKER64 \
  42. - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64)
  43. + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
  44. #undef DEFAULT_ASM_ENDIAN
  45. #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN)
  46. --- a/gcc/config/rs6000/secureplt.h
  47. +++ b/gcc/config/rs6000/secureplt.h
  48. @@ -18,3 +18,4 @@ along with GCC; see the file COPYING3.
  49. <http://www.gnu.org/licenses/>. */
  50. #define CC1_SECURE_PLT_DEFAULT_SPEC "-msecure-plt"
  51. +#define LINK_SECURE_PLT_DEFAULT_SPEC "--secure-plt"
  52. --- a/gcc/config/rs6000/sysv4.h
  53. +++ b/gcc/config/rs6000/sysv4.h
  54. @@ -537,6 +537,9 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF
  55. #ifndef CC1_SECURE_PLT_DEFAULT_SPEC
  56. #define CC1_SECURE_PLT_DEFAULT_SPEC ""
  57. #endif
  58. +#ifndef LINK_SECURE_PLT_DEFAULT_SPEC
  59. +#define LINK_SECURE_PLT_DEFAULT_SPEC ""
  60. +#endif
  61. /* Pass -G xxx to the compiler. */
  62. #undef CC1_SPEC
  63. @@ -574,7 +577,8 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF
  64. %{R*} \
  65. %(link_shlib) \
  66. %{!T*: %(link_start) } \
  67. -%(link_os)"
  68. +%(link_os)" \
  69. +"%{!mbss-plt: %{!msecure-plt: %(link_secure_plt_default)}}"
  70. /* Shared libraries are not default. */
  71. #define LINK_SHLIB_SPEC "\
  72. @@ -757,17 +761,22 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF
  73. #define LINK_START_LINUX_SPEC ""
  74. +#define MUSL_DYNAMIC_LINKER_E ENDIAN_SELECT("","le","")
  75. +
  76. #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
  77. #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
  78. +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E ".so.1"
  79. #if DEFAULT_LIBC == LIBC_UCLIBC
  80. -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
  81. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
  82. +#elif DEFAULT_LIBC == LIBC_MUSL
  83. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
  84. #elif !defined (DEFAULT_LIBC) || DEFAULT_LIBC == LIBC_GLIBC
  85. -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
  86. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
  87. #else
  88. #error "Unsupported DEFAULT_LIBC"
  89. #endif
  90. #define GNU_USER_DYNAMIC_LINKER \
  91. - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER)
  92. + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
  93. #define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \
  94. %{rdynamic:-export-dynamic} \
  95. @@ -889,6 +898,7 @@ ncrtn.o%s"
  96. { "link_os_openbsd", LINK_OS_OPENBSD_SPEC }, \
  97. { "link_os_default", LINK_OS_DEFAULT_SPEC }, \
  98. { "cc1_secure_plt_default", CC1_SECURE_PLT_DEFAULT_SPEC }, \
  99. + { "link_secure_plt_default", LINK_SECURE_PLT_DEFAULT_SPEC }, \
  100. { "cpp_os_ads", CPP_OS_ADS_SPEC }, \
  101. { "cpp_os_yellowknife", CPP_OS_YELLOWKNIFE_SPEC }, \
  102. { "cpp_os_mvme", CPP_OS_MVME_SPEC }, \
  103. @@ -943,3 +953,72 @@ ncrtn.o%s"
  104. /* This target uses the sysv4.opt file. */
  105. #define TARGET_USES_SYSV4_OPT 1
  106. +/* Include order changes for musl, same as in generic linux.h. */
  107. +#if DEFAULT_LIBC == LIBC_MUSL
  108. +#define INCLUDE_DEFAULTS_MUSL_GPP \
  109. + { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, \
  110. + GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, \
  111. + { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, \
  112. + GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 }, \
  113. + { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, \
  114. + GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
  115. +
  116. +#ifdef LOCAL_INCLUDE_DIR
  117. +#define INCLUDE_DEFAULTS_MUSL_LOCAL \
  118. + { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, \
  119. + { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
  120. +#else
  121. +#define INCLUDE_DEFAULTS_MUSL_LOCAL
  122. +#endif
  123. +
  124. +#ifdef PREFIX_INCLUDE_DIR
  125. +#define INCLUDE_DEFAULTS_MUSL_PREFIX \
  126. + { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0},
  127. +#else
  128. +#define INCLUDE_DEFAULTS_MUSL_PREFIX
  129. +#endif
  130. +
  131. +#ifdef CROSS_INCLUDE_DIR
  132. +#define INCLUDE_DEFAULTS_MUSL_CROSS \
  133. + { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0},
  134. +#else
  135. +#define INCLUDE_DEFAULTS_MUSL_CROSS
  136. +#endif
  137. +
  138. +#ifdef TOOL_INCLUDE_DIR
  139. +#define INCLUDE_DEFAULTS_MUSL_TOOL \
  140. + { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0},
  141. +#else
  142. +#define INCLUDE_DEFAULTS_MUSL_TOOL
  143. +#endif
  144. +
  145. +#ifdef NATIVE_SYSTEM_HEADER_DIR
  146. +#define INCLUDE_DEFAULTS_MUSL_NATIVE \
  147. + { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \
  148. + { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 0 },
  149. +#else
  150. +#define INCLUDE_DEFAULTS_MUSL_NATIVE
  151. +#endif
  152. +
  153. +#if defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT)
  154. +# undef INCLUDE_DEFAULTS_MUSL_LOCAL
  155. +# define INCLUDE_DEFAULTS_MUSL_LOCAL
  156. +# undef INCLUDE_DEFAULTS_MUSL_NATIVE
  157. +# define INCLUDE_DEFAULTS_MUSL_NATIVE
  158. +#else
  159. +# undef INCLUDE_DEFAULTS_MUSL_CROSS
  160. +# define INCLUDE_DEFAULTS_MUSL_CROSS
  161. +#endif
  162. +
  163. +#undef INCLUDE_DEFAULTS
  164. +#define INCLUDE_DEFAULTS \
  165. + { \
  166. + INCLUDE_DEFAULTS_MUSL_GPP \
  167. + INCLUDE_DEFAULTS_MUSL_PREFIX \
  168. + INCLUDE_DEFAULTS_MUSL_CROSS \
  169. + INCLUDE_DEFAULTS_MUSL_TOOL \
  170. + INCLUDE_DEFAULTS_MUSL_NATIVE \
  171. + { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \
  172. + { 0, 0, 0, 0, 0, 0 } \
  173. + }
  174. +#endif
  175. --- a/gcc/config/rs6000/sysv4le.h
  176. +++ b/gcc/config/rs6000/sysv4le.h
  177. @@ -31,3 +31,5 @@
  178. /* Little-endian PowerPC64 Linux uses the ELF v2 ABI by default. */
  179. #define LINUX64_DEFAULT_ABI_ELFv2
  180. +#undef MUSL_DYNAMIC_LINKER_E
  181. +#define MUSL_DYNAMIC_LINKER_E ENDIAN_SELECT("","le","le")
  182. --- a/gcc/config.gcc
  183. +++ b/gcc/config.gcc
  184. @@ -2430,6 +2430,10 @@ powerpc*-*-linux*)
  185. powerpc*-*-linux*paired*)
  186. tm_file="${tm_file} rs6000/750cl.h" ;;
  187. esac
  188. + case ${target} in
  189. + *-linux*-musl*)
  190. + enable_secureplt=yes ;;
  191. + esac
  192. if test x${enable_secureplt} = xyes; then
  193. tm_file="rs6000/secureplt.h ${tm_file}"
  194. fi