61e94be6c3b6f7f9e4ee304c53181ece422f6e85
[openwrt/staging/yousong.git] / toolchain / gcc / patches / 4.8-linaro / 203-musl_powerpc.patch
1 --- a/gcc/config.gcc
2 +++ b/gcc/config.gcc
3 @@ -2122,6 +2122,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 @@ -354,17 +354,21 @@ extern int dot_symbols;
17 #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld64.so.1"
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%{msoft-float:-sf}.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
40 #undef DEFAULT_ASM_ENDIAN
41 #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN)
42 --- a/gcc/config/rs6000/secureplt.h
43 +++ b/gcc/config/rs6000/secureplt.h
44 @@ -18,3 +18,4 @@ along with GCC; see the file COPYING3.
45 <http://www.gnu.org/licenses/>. */
46
47 #define CC1_SECURE_PLT_DEFAULT_SPEC "-msecure-plt"
48 +#define LINK_SECURE_PLT_DEFAULT_SPEC "--secure-plt"
49 --- a/gcc/config/rs6000/sysv4.h
50 +++ b/gcc/config/rs6000/sysv4.h
51 @@ -550,6 +550,9 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF
52 #ifndef CC1_SECURE_PLT_DEFAULT_SPEC
53 #define CC1_SECURE_PLT_DEFAULT_SPEC ""
54 #endif
55 +#ifndef LINK_SECURE_PLT_DEFAULT_SPEC
56 +#define LINK_SECURE_PLT_DEFAULT_SPEC ""
57 +#endif
58
59 /* Pass -G xxx to the compiler and set correct endian mode. */
60 #define CC1_SPEC "%{G*} %(cc1_cpu)" \
61 @@ -600,7 +603,8 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF
62
63 /* Override the default target of the linker. */
64 #define LINK_TARGET_SPEC \
65 - ENDIAN_SELECT("", " --oformat elf32-powerpcle", "")
66 + ENDIAN_SELECT("", " --oformat elf32-powerpcle", "") \
67 + "%{!mbss-plt: %{!msecure-plt: %(link_secure_plt_default)}}"
68
69 /* Any specific OS flags. */
70 #define LINK_OS_SPEC "\
71 @@ -778,15 +782,18 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF
72
73 #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
74 #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
75 +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-powerpc%{msoft-float:-sf}.so.1"
76 #if DEFAULT_LIBC == LIBC_UCLIBC
77 -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
78 +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
79 +#elif DEFAULT_LIBC == LIBC_MUSL
80 +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
81 #elif !defined (DEFAULT_LIBC) || DEFAULT_LIBC == LIBC_GLIBC
82 -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
83 +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
84 #else
85 #error "Unsupported DEFAULT_LIBC"
86 #endif
87 #define GNU_USER_DYNAMIC_LINKER \
88 - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER)
89 + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
90
91 #define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \
92 %{rdynamic:-export-dynamic} \
93 @@ -912,6 +919,7 @@ ncrtn.o%s"
94 { "cc1_endian_little", CC1_ENDIAN_LITTLE_SPEC }, \
95 { "cc1_endian_default", CC1_ENDIAN_DEFAULT_SPEC }, \
96 { "cc1_secure_plt_default", CC1_SECURE_PLT_DEFAULT_SPEC }, \
97 + { "link_secure_plt_default", LINK_SECURE_PLT_DEFAULT_SPEC }, \
98 { "cpp_os_ads", CPP_OS_ADS_SPEC }, \
99 { "cpp_os_yellowknife", CPP_OS_YELLOWKNIFE_SPEC }, \
100 { "cpp_os_mvme", CPP_OS_MVME_SPEC }, \