Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1 | From a6c649571d49c972e6d207577780ada7e9b6bad5 Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Tue, 8 Dec 2015 08:31:52 +0000 |
| 4 | Subject: [PATCH 45/57] Support for arm-linux-musl. |
| 5 | |
| 6 | Fix musl ldso for all arches |
| 7 | |
| 8 | Upstream-Status: backport [partial] |
| 9 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 10 | --- |
| 11 | gcc/config/aarch64/aarch64-linux.h | 1 + |
| 12 | gcc/config/arm/linux-eabi.h | 17 +++++++++++++++++ |
| 13 | gcc/config/i386/linux.h | 1 + |
| 14 | gcc/config/i386/linux64.h | 5 +++++ |
| 15 | gcc/config/mips/linux.h | 8 +++++++- |
| 16 | gcc/config/rs6000/linux64.h | 13 +++++++++---- |
| 17 | gcc/config/rs6000/sysv4.h | 10 +++++++--- |
| 18 | libitm/config/arm/hwcap.cc | 4 ++++ |
| 19 | libitm/config/linux/x86/tls.h | 8 ++++++-- |
| 20 | 9 files changed, 57 insertions(+), 10 deletions(-) |
| 21 | |
| 22 | diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h |
| 23 | index f9e65fc..1b2d0c0 100644 |
| 24 | --- a/gcc/config/aarch64/aarch64-linux.h |
| 25 | +++ b/gcc/config/aarch64/aarch64-linux.h |
| 26 | @@ -22,6 +22,7 @@ |
| 27 | #define GCC_AARCH64_LINUX_H |
| 28 | |
| 29 | #define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1" |
| 30 | +#define MUSL_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-musl-aarch64.so.1" |
| 31 | |
| 32 | #define MUSL_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-musl-aarch64.so.1" |
| 33 | |
| 34 | diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h |
| 35 | index 048a062..adb9c44 100644 |
| 36 | --- a/gcc/config/arm/linux-eabi.h |
| 37 | +++ b/gcc/config/arm/linux-eabi.h |
| 38 | @@ -81,6 +81,23 @@ |
| 39 | #undef TARGET_FIX_V4BX_SPEC |
| 40 | #define TARGET_FIX_V4BX_SPEC "%{mcpu=arm8|mcpu=arm810|mcpu=strongarm*|march=armv4: --fix-v4bx}" |
| 41 | |
| 42 | +/* For ARM musl currently supports four dynamic linkers: |
| 43 | + - ld-musl-arm.so.1 - for the EABI-derived soft-float ABI |
| 44 | + - ld-musl-armhf.so.1 - for the EABI-derived hard-float ABI |
| 45 | + - ld-musl-armeb.so.1 - for the EABI-derived soft-float ABI, EB |
| 46 | + - ld-musl-armebhf.so.1 - for the EABI-derived hard-float ABI, EB |
| 47 | + musl does not support the legacy OABI mode. |
| 48 | + All the dynamic linkers live in /lib. |
| 49 | + We default to soft-float, EL. */ |
| 50 | +#undef MUSL_DYNAMIC_LINKER |
| 51 | +#if TARGET_BIG_ENDIAN_DEFAULT |
| 52 | +#define MUSL_DYNAMIC_LINKER_E "%{mlittle-endian:;:eb}" |
| 53 | +#else |
| 54 | +#define MUSL_DYNAMIC_LINKER_E "%{mbig-endian:eb}" |
| 55 | +#endif |
| 56 | +#define MUSL_DYNAMIC_LINKER \ |
| 57 | + SYSTEMLIBS_DIR "ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}.so.1" |
| 58 | + |
| 59 | /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to |
| 60 | use the GNU/Linux version, not the generic BPABI version. */ |
| 61 | #undef LINK_SPEC |
| 62 | diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h |
| 63 | index 21ba2b2..e2b81e5 100644 |
| 64 | --- a/gcc/config/i386/linux.h |
| 65 | +++ b/gcc/config/i386/linux.h |
| 66 | @@ -21,3 +21,4 @@ along with GCC; see the file COPYING3. If not see |
| 67 | |
| 68 | #define GNU_USER_LINK_EMULATION "elf_i386" |
| 69 | #define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux.so.2" |
| 70 | +#define MUSL_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-musl-i386.so.1" |
| 71 | diff --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h |
| 72 | index 6185cce..5a3a977 100644 |
| 73 | --- a/gcc/config/i386/linux64.h |
| 74 | +++ b/gcc/config/i386/linux64.h |
| 75 | @@ -30,3 +30,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
| 76 | #define GLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-linux.so.2" |
| 77 | #define GLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld-linux-x86-64.so.2" |
| 78 | #define GLIBC_DYNAMIC_LINKERX32 SYSTEMLIBS_DIR "ld-linux-x32.so.2" |
| 79 | + |
| 80 | +#define MUSL_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-musl-i386.so.1" |
| 81 | +#define MUSL_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld-musl-x86_64.so.1" |
| 82 | +#define MUSL_DYNAMIC_LINKERX32 SYSTEMLIBS_DIR "ld-musl-x32.so.1" |
| 83 | + |
| 84 | diff --git a/gcc/config/mips/linux.h b/gcc/config/mips/linux.h |
| 85 | index c306afb..b899388 100644 |
| 86 | --- a/gcc/config/mips/linux.h |
| 87 | +++ b/gcc/config/mips/linux.h |
| 88 | @@ -21,6 +21,12 @@ along with GCC; see the file COPYING3. If not see |
| 89 | #define GNU_USER_LINK_EMULATION64 "elf64%{EB:b}%{EL:l}tsmip" |
| 90 | #define GNU_USER_LINK_EMULATIONN32 "elf32%{EB:b}%{EL:l}tsmipn32" |
| 91 | |
| 92 | +#undef MUSL_DYNAMIC_LINKER32 |
| 93 | +#define MUSL_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-musl-mips%{EL:el}%{msoft-float:-sf}.so.1" |
| 94 | +#undef MUSL_DYNAMIC_LINKER64 |
| 95 | +#define MUSL_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld-musl-mips64%{EL:el}%{msoft-float:-sf}.so.1" |
| 96 | +#define MUSL_DYNAMIC_LINKERN32 SYSTEMLIBS_DIR "ld-musl-mipsn32%{EL:el}%{msoft-float:-sf}.so.1" |
| 97 | + |
| 98 | #define GLIBC_DYNAMIC_LINKER32 \ |
| 99 | "%{mnan=2008:" SYSTEMLIBS_DIR "ld-linux-mipsn8.so.1;:" SYSTEMLIBS_DIR "ld.so.1}" |
| 100 | #define GLIBC_DYNAMIC_LINKER64 \ |
| 101 | @@ -40,4 +46,4 @@ along with GCC; see the file COPYING3. If not see |
| 102 | #define BIONIC_DYNAMIC_LINKERN32 "/system/bin/linker32" |
| 103 | #define GNU_USER_DYNAMIC_LINKERN32 \ |
| 104 | CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERN32, UCLIBC_DYNAMIC_LINKERN32, \ |
| 105 | - BIONIC_DYNAMIC_LINKERN32) |
| 106 | + BIONIC_DYNAMIC_LINKERN32, MUSL_DYNAMIC_LINKERN32) |
| 107 | diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h |
| 108 | index 31c4338..679da4b 100644 |
| 109 | --- a/gcc/config/rs6000/linux64.h |
| 110 | +++ b/gcc/config/rs6000/linux64.h |
| 111 | @@ -365,17 +365,22 @@ extern int dot_symbols; |
| 112 | #endif |
| 113 | #define UCLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-uClibc.so.0" |
| 114 | #define UCLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld64-uClibc.so.0" |
| 115 | +#define MUSL_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-musl-powerpc.so.1" |
| 116 | +#define MUSL_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld-musl-powerpc64.so.1" |
| 117 | + |
| 118 | #if DEFAULT_LIBC == LIBC_UCLIBC |
| 119 | -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}" |
| 120 | +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}" |
| 121 | #elif DEFAULT_LIBC == LIBC_GLIBC |
| 122 | -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}" |
| 123 | +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}" |
| 124 | +#elif DEFAULT_LIBC == LIBC_MUSL |
| 125 | +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}" |
| 126 | #else |
| 127 | #error "Unsupported DEFAULT_LIBC" |
| 128 | #endif |
| 129 | #define GNU_USER_DYNAMIC_LINKER32 \ |
| 130 | - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32) |
| 131 | + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32) |
| 132 | #define GNU_USER_DYNAMIC_LINKER64 \ |
| 133 | - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64) |
| 134 | + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64) |
| 135 | |
| 136 | #undef DEFAULT_ASM_ENDIAN |
| 137 | #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN) |
| 138 | diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h |
| 139 | index 7cd07e0..8794fa5 100644 |
| 140 | --- a/gcc/config/rs6000/sysv4.h |
| 141 | +++ b/gcc/config/rs6000/sysv4.h |
| 142 | @@ -763,15 +763,19 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN) |
| 143 | |
| 144 | #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1" |
| 145 | #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0" |
| 146 | +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-powerpc.so.1" |
| 147 | + |
| 148 | #if DEFAULT_LIBC == LIBC_UCLIBC |
| 149 | -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}" |
| 150 | +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}" |
| 151 | +#elif DEFAULT_LIBC == LIBC_MUSL |
| 152 | +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}" |
| 153 | #elif !defined (DEFAULT_LIBC) || DEFAULT_LIBC == LIBC_GLIBC |
| 154 | -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}" |
| 155 | +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}" |
| 156 | #else |
| 157 | #error "Unsupported DEFAULT_LIBC" |
| 158 | #endif |
| 159 | #define GNU_USER_DYNAMIC_LINKER \ |
| 160 | - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER) |
| 161 | + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER) |
| 162 | |
| 163 | #define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \ |
| 164 | %{rdynamic:-export-dynamic} \ |
| 165 | diff --git a/libitm/config/arm/hwcap.cc b/libitm/config/arm/hwcap.cc |
| 166 | index a1c2cfd..dd4fad2 100644 |
| 167 | --- a/libitm/config/arm/hwcap.cc |
| 168 | +++ b/libitm/config/arm/hwcap.cc |
| 169 | @@ -40,7 +40,11 @@ int GTM_hwcap HIDDEN = 0 |
| 170 | |
| 171 | #ifdef __linux__ |
| 172 | #include <unistd.h> |
| 173 | +#ifdef __GLIBC__ |
| 174 | #include <sys/fcntl.h> |
| 175 | +#else |
| 176 | +#include <fcntl.h> |
| 177 | +#endif |
| 178 | #include <elf.h> |
| 179 | |
| 180 | static void __attribute__((constructor)) |
| 181 | diff --git a/libitm/config/linux/x86/tls.h b/libitm/config/linux/x86/tls.h |
| 182 | index e731ab7..54ad8b6 100644 |
| 183 | --- a/libitm/config/linux/x86/tls.h |
| 184 | +++ b/libitm/config/linux/x86/tls.h |
| 185 | @@ -25,16 +25,19 @@ |
| 186 | #ifndef LIBITM_X86_TLS_H |
| 187 | #define LIBITM_X86_TLS_H 1 |
| 188 | |
| 189 | -#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10) |
| 190 | +#if defined(__GLIBC_PREREQ) |
| 191 | +#if __GLIBC_PREREQ(2, 10) |
| 192 | /* Use slots in the TCB head rather than __thread lookups. |
| 193 | GLIBC has reserved words 10 through 13 for TM. */ |
| 194 | #define HAVE_ARCH_GTM_THREAD 1 |
| 195 | #define HAVE_ARCH_GTM_THREAD_DISP 1 |
| 196 | #endif |
| 197 | +#endif |
| 198 | |
| 199 | #include "config/generic/tls.h" |
| 200 | |
| 201 | -#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10) |
| 202 | +#if defined(__GLIBC_PREREQ) |
| 203 | +#if __GLIBC_PREREQ(2, 10) |
| 204 | namespace GTM HIDDEN { |
| 205 | |
| 206 | #ifdef __x86_64__ |
| 207 | @@ -101,5 +104,6 @@ static inline void set_abi_disp(struct abi_dispatch *x) |
| 208 | |
| 209 | } // namespace GTM |
| 210 | #endif /* >= GLIBC 2.10 */ |
| 211 | +#endif |
| 212 | |
| 213 | #endif // LIBITM_X86_TLS_H |
| 214 | -- |
| 215 | 2.7.4 |
| 216 | |