203-musl_powerpc.patch 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. --- a/gcc/config.gcc
  2. +++ b/gcc/config.gcc
  3. @@ -2344,6 +2344,10 @@ powerpc*-*-linux*)
  4. powerpc*-*-linux*paired*)
  5. tm_file="${tm_file} rs6000/750cl.h" ;;
  6. esac
  7. + case ${target} in
  8. + *-linux*-musl*)
  9. + enable_secureplt=yes ;;
  10. + esac
  11. if test x${enable_secureplt} = xyes; then
  12. tm_file="rs6000/secureplt.h ${tm_file}"
  13. fi
  14. --- a/gcc/config/rs6000/linux64.h
  15. +++ b/gcc/config/rs6000/linux64.h
  16. @@ -371,17 +371,21 @@ extern int dot_symbols;
  17. #endif
  18. #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
  19. #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
  20. +#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-powerpc.so.1"
  21. +#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-powerpc64.so.1"
  22. #if DEFAULT_LIBC == LIBC_UCLIBC
  23. -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
  24. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
  25. #elif DEFAULT_LIBC == LIBC_GLIBC
  26. -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
  27. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
  28. +#elif DEFAULT_LIBC == LIBC_MUSL
  29. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
  30. #else
  31. #error "Unsupported DEFAULT_LIBC"
  32. #endif
  33. #define GNU_USER_DYNAMIC_LINKER32 \
  34. - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32)
  35. + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
  36. #define GNU_USER_DYNAMIC_LINKER64 \
  37. - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64)
  38. + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
  39. #undef DEFAULT_ASM_ENDIAN
  40. #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN)
  41. --- a/gcc/config/rs6000/secureplt.h
  42. +++ b/gcc/config/rs6000/secureplt.h
  43. @@ -18,3 +18,4 @@ along with GCC; see the file COPYING3.
  44. <http://www.gnu.org/licenses/>. */
  45. #define CC1_SECURE_PLT_DEFAULT_SPEC "-msecure-plt"
  46. +#define LINK_SECURE_PLT_DEFAULT_SPEC "--secure-plt"
  47. --- a/gcc/config/rs6000/sysv4.h
  48. +++ b/gcc/config/rs6000/sysv4.h
  49. @@ -537,6 +537,9 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF
  50. #ifndef CC1_SECURE_PLT_DEFAULT_SPEC
  51. #define CC1_SECURE_PLT_DEFAULT_SPEC ""
  52. #endif
  53. +#ifndef LINK_SECURE_PLT_DEFAULT_SPEC
  54. +#define LINK_SECURE_PLT_DEFAULT_SPEC ""
  55. +#endif
  56. /* Pass -G xxx to the compiler. */
  57. #define CC1_SPEC "%{G*} %(cc1_cpu)" \
  58. @@ -585,7 +588,8 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF
  59. /* Override the default target of the linker. */
  60. #define LINK_TARGET_SPEC \
  61. - ENDIAN_SELECT("", " --oformat elf32-powerpcle", "")
  62. + ENDIAN_SELECT("", " --oformat elf32-powerpcle", "") \
  63. + "%{!mbss-plt: %{!msecure-plt: %(link_secure_plt_default)}}"
  64. /* Any specific OS flags. */
  65. #define LINK_OS_SPEC "\
  66. @@ -763,15 +767,18 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF
  67. #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
  68. #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
  69. +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-powerpc.so.1"
  70. #if DEFAULT_LIBC == LIBC_UCLIBC
  71. -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
  72. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
  73. +#elif DEFAULT_LIBC == LIBC_MUSL
  74. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
  75. #elif !defined (DEFAULT_LIBC) || DEFAULT_LIBC == LIBC_GLIBC
  76. -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
  77. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
  78. #else
  79. #error "Unsupported DEFAULT_LIBC"
  80. #endif
  81. #define GNU_USER_DYNAMIC_LINKER \
  82. - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER)
  83. + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
  84. #define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \
  85. %{rdynamic:-export-dynamic} \
  86. @@ -894,6 +901,7 @@ ncrtn.o%s"
  87. { "link_os_openbsd", LINK_OS_OPENBSD_SPEC }, \
  88. { "link_os_default", LINK_OS_DEFAULT_SPEC }, \
  89. { "cc1_secure_plt_default", CC1_SECURE_PLT_DEFAULT_SPEC }, \
  90. + { "link_secure_plt_default", LINK_SECURE_PLT_DEFAULT_SPEC }, \
  91. { "cpp_os_ads", CPP_OS_ADS_SPEC }, \
  92. { "cpp_os_yellowknife", CPP_OS_YELLOWKNIFE_SPEC }, \
  93. { "cpp_os_mvme", CPP_OS_MVME_SPEC }, \