summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config/binutils/binutils.in.22
-rw-r--r--config/debug/gdb.in.gdbserver19
-rw-r--r--config/debug/gdb.in.native17
-rw-r--r--config/libc/mingw.in35
-rw-r--r--config/target.in23
-rw-r--r--patches/binutils/2.24/700-Fix-library-paths-on-PowerPC.patch42
-rw-r--r--patches/binutils/2.25.1/700-Fix-library-paths-on-PowerPC.patch42
-rw-r--r--patches/binutils/2.26/700-Fix-library-paths-on-PowerPC.patch42
-rw-r--r--patches/binutils/2.27/700-Fix-library-paths-on-PowerPC.patch42
-rw-r--r--patches/binutils/2.28/700-Fix-library-paths-on-PowerPC.patch42
-rw-r--r--patches/elf2flt/a8bc69b882a55b1f1e437b50e33d3db8414eb68e/100-fix-cygwin-build.patch111
-rw-r--r--patches/glibc/2.12.1/101-Suppress-GCC-6-warning-about-ambiguous-else-with-Wpa.patch84
-rw-r--r--patches/glibc/2.12.1/102-fix-signed-shift-overlow.patch98
-rw-r--r--patches/glibc/2.12.1/104-unused-variables.patch165
-rw-r--r--patches/glibc/2.12.1/105-misleading-indentation.patch24
-rw-r--r--patches/glibc/2.12.1/106-dl-open-array-bounds.patch27
-rw-r--r--patches/glibc/2.13/101-Suppress-GCC-6-warning-about-ambiguous-else-with-Wpa.patch84
-rw-r--r--patches/glibc/2.13/102-fix-signed-shift-overlow.patch98
-rw-r--r--patches/glibc/2.13/104-unused-variables.patch165
-rw-r--r--patches/glibc/2.13/105-misleading-indentation.patch24
-rw-r--r--patches/glibc/2.13/106-dl-open-array-bounds.patch27
-rw-r--r--patches/glibc/ports-2.12.1/670-support-hard-float-eabi.patch22
-rw-r--r--patches/glibc/ports-2.13/670-support-hard-float-eabi.patch22
-rw-r--r--patches/mingw-w64/v2.0.7/100-mingw64-malloc.patch27
-rw-r--r--patches/mingw-w64/v2.0.8/100-mingw64-malloc.patch27
-rw-r--r--patches/mingw-w64/v2.0.9/100-mingw64-malloc.patch27
-rw-r--r--patches/mingw-w64/v3.0.0/100-mingw64-malloc.patch27
-rw-r--r--patches/mingw-w64/v3.1.0/100-mingw64-malloc.patch27
-rw-r--r--patches/mingw-w64/v3.2.0/100-mingw64-malloc.patch27
-rw-r--r--patches/mingw-w64/v3.3.0/100-mingw64-malloc.patch27
-rw-r--r--patches/mingw-w64/v4.0.0/100-mingw64-malloc.patch27
-rw-r--r--patches/mingw-w64/v4.0.1/100-mingw64-malloc.patch27
-rw-r--r--patches/mingw-w64/v4.0.2/100-mingw64-malloc.patch27
-rw-r--r--patches/mingw-w64/v4.0.4/100-mingw64-malloc.patch27
-rw-r--r--patches/mingw-w64/v4.0.5/100-mingw64-malloc.patch27
-rw-r--r--patches/mingw-w64/v4.0.6/100-mingw64-malloc.patch27
-rw-r--r--patches/mingw-w64/v5.0.0/100-mingw64-malloc.patch55
-rw-r--r--patches/mingw-w64/v5.0.1/100-mingw64-malloc.patch55
-rw-r--r--patches/uClibc-ng/1.0.20/600-prefer-multilib.patch46
-rw-r--r--patches/uClibc-ng/1.0.21/600-prefer-multilib.patch46
-rw-r--r--patches/uClibc-ng/1.0.22/600-prefer-multilib.patch46
-rw-r--r--patches/uClibc/0.9.33.2/600-prefer-multilib.patch38
-rw-r--r--patches/uClibc/0.9.33.2/998-dlopen-static.patch56
-rw-r--r--samples/arm-multilib-linux-uclibcgnueabi/crosstool.config3
-rw-r--r--samples/sh4-multilib-linux-gnu/crosstool.config1
-rw-r--r--samples/sh4-unknown-linux-gnu/crosstool.config1
-rw-r--r--scripts/build/cc/100-gcc.sh75
-rw-r--r--scripts/build/companion_tools/050-make.sh8
-rw-r--r--scripts/build/internals.sh52
-rw-r--r--scripts/build/libc/glibc.sh2
-rw-r--r--scripts/build/libc/musl.sh6
-rw-r--r--scripts/build/libc/uClibc.sh48
-rw-r--r--scripts/functions155
-rw-r--r--scripts/xldd.in56
54 files changed, 2135 insertions, 222 deletions
diff --git a/config/binutils/binutils.in.2 b/config/binutils/binutils.in.2
index 47ae94c..f913355 100644
--- a/config/binutils/binutils.in.2
+++ b/config/binutils/binutils.in.2
@@ -35,7 +35,7 @@ if ELF2FLT_GIT
config ELF2FLT_GIT_CSET
string
prompt "git cset"
- default "a8bc69b882a55b1f1e437b50e33d3db8414eb68e"
+ default "6d80ab6c93409e796f85da404bde84b841231531"
help
Enter the git changeset to use.
diff --git a/config/debug/gdb.in.gdbserver b/config/debug/gdb.in.gdbserver
index 2f5576b..07e6e13 100644
--- a/config/debug/gdb.in.gdbserver
+++ b/config/debug/gdb.in.gdbserver
@@ -15,15 +15,30 @@ config GDB_GDBSERVER_HAS_IPA_LIB
depends on GDB_7_2_or_later
default y
+# gdbserver is then linked with "-static -Wl,--dynamic-list=..." which
config GDB_GDBSERVER_STATIC
bool
prompt "Build a static gdbserver"
- depends on CONFIGURE_has_static_link
- default y
+ depends on EXPERIMENTAL
help
In case you have trouble with dynamic loading of shared libraries,
you will find that a static gdbserver comes in handy.
+ However, it has been noticed at least on x86 that enabling this
+ option produces an invalid gdbserver binary. It is linked with
+ "-static -Wl,--dynamic-list=..." which
+ # (a) requests invalid program interpreter
+ # (b) crashes glibc/uClibc-ng and does not work with musl
+ # See https://sourceware.org/ml/libc-alpha/2017-03/msg00267.html
+
+ It is possible it would work with other architectures, hence it is
+ not completely removed. Use with care and report to the mailing list
+ if the resulting gdbserver works.
+
+ For further details, see:
+ https://sourceware.org/bugzilla/show_bug.cgi?id=19617
+ https://sourceware.org/bugzilla/show_bug.cgi?id=21086
+
config GDB_GDBSERVER_BUILD_IPA_LIB
bool
prompt "Build the IPA library"
diff --git a/config/debug/gdb.in.native b/config/debug/gdb.in.native
index 915debd..8684c05 100644
--- a/config/debug/gdb.in.native
+++ b/config/debug/gdb.in.native
@@ -15,9 +15,24 @@ if GDB_NATIVE
config GDB_NATIVE_STATIC
bool
prompt "Build a static native gdb"
- depends on CONFIGURE_has_static_link
+ depends on EXPERIMENTAL
help
In case you have trouble with dynamic loading of shared libraries,
you will find that a static gdb comes in handy.
+ However, it has been noticed at least on x86 that enabling this
+ option produces an invalid gdb binary. It is linked with
+ "-static -Wl,--dynamic-list=..." which
+ # (a) requests invalid program interpreter
+ # (b) crashes glibc/uClibc-ng and does not work with musl
+ # See https://sourceware.org/ml/libc-alpha/2017-03/msg00267.html
+
+ It is possible it would work with other architectures, hence it is
+ not completely removed. Use with care and report to the mailing list
+ if the resulting gdbserver works.
+
+ For further details, see:
+ https://sourceware.org/bugzilla/show_bug.cgi?id=19617
+ https://sourceware.org/bugzilla/show_bug.cgi?id=21086
+
endif # GDB_NATIVE
diff --git a/config/libc/mingw.in b/config/libc/mingw.in
index 62e7a46..936fd67 100644
--- a/config/libc/mingw.in
+++ b/config/libc/mingw.in
@@ -28,9 +28,19 @@ config WINAPI_V_5_0_0
prompt "5.0.0 (OBSOLETE)"
depends on OBSOLETE
+config WINAPI_V_4_0_6
+ bool
+ prompt "4.0.6"
+
+config WINAPI_V_4_0_5
+ bool
+ prompt "4.0.5 (OBSOLETE)"
+ depends on OBSOLETE
+
config WINAPI_V_4_0_4
bool
- prompt "4.0.4"
+ prompt "4.0.4 (OBSOLETE)"
+ depends on OBSOLETE
config WINAPI_V_4_0_2
bool
@@ -47,15 +57,31 @@ config WINAPI_V_4_0_0
prompt "4.0.0 (OBSOLETE)"
depends on OBSOLETE
+config WINAPI_V_3_3_0
+ bool
+ prompt "3.3.0 (OBSOLETE)"
+ depends on OBSOLETE
+
+config WINAPI_V_3_2_0
+ bool
+ prompt "3.2.0 (OBSOLETE)"
+ depends on OBSOLETE
+
config WINAPI_V_3_1_0
bool
- prompt "3.1.0"
+ prompt "3.1.0 (OBSOLETE)"
+ depends on OBSOLETE
config WINAPI_V_3_0_0
bool
prompt "3.0.0 (OBSOLETE)"
depends on OBSOLETE
+config WINAPI_V_2_0_9
+ bool
+ prompt "2.0.9 (OBSOLETE)"
+ depends on OBSOLETE
+
config WINAPI_V_2_0_8
bool
prompt "2.0.8 (OBSOLETE)"
@@ -86,12 +112,17 @@ config WINAPI_VERSION
# CT_INSERT_VERSION_STRING_BELOW
default "5.0.1" if WINAPI_V_5_0_1
default "5.0.0" if WINAPI_V_5_0_0
+ default "4.0.6" if WINAPI_V_4_0_6
+ default "4.0.5" if WINAPI_V_4_0_5
default "4.0.4" if WINAPI_V_4_0_4
default "4.0.2" if WINAPI_V_4_0_2
default "4.0.1" if WINAPI_V_4_0_1
default "4.0.0" if WINAPI_V_4_0_0
+ default "3.3.0" if WINAPI_V_3_3_0
+ default "3.2.0" if WINAPI_V_3_2_0
default "3.1.0" if WINAPI_V_3_1_0
default "3.0.0" if WINAPI_V_3_0_0
+ default "2.0.9" if WINAPI_V_2_0_9
default "2.0.8" if WINAPI_V_2_0_8
default "2.0.7" if WINAPI_V_2_0_7
help
diff --git a/config/target.in b/config/target.in
index a905b23..485c587 100644
--- a/config/target.in
+++ b/config/target.in
@@ -51,6 +51,29 @@ config MULTILIB
NOTE: The multilib feature in crosstool-NG is not well-tested.
Use at your own risk, and report success and/or failure.
+config DEMULTILIB
+ bool "Attempt to combine libraries into a single directory"
+ default y if !MULTILIB
+ depends on !MULTILIB || EXPERIMENTAL
+ help
+ Normally, Crosstool-NG installs the libraries into the directories
+ as the configure for these libraries determines appropriate. For
+ example, for AArch64 glibc wants to install the libraries into
+ /lib64 but the default dynamic linker path is /lib/ld-linux-aarch64.so.1
+ (which is installed as a symlink to ../lib64/ld-VER.so).
+
+ However, not all consumers of the toolchain can handle the libraries
+ residing in multiple directories. To appease them, crosstool-NG can
+ attempt to combine the libraries back into a single /lib directory and
+ create all other directories as symlinks to /lib. This requires all
+ the library names to be unique within each sysroot.
+
+ Note that GCC may also use separate sysroots for different multilibs.
+ Hence it may make sense to enable this option even for multilib toolchains.
+ However, separate roots are rare (any other architecture aside from
+ SuperH using them?) and hence not well tested in crosstool-NG; therefore,
+ this option is experimental when MULTILIB is enabled.
+
#--------------------------------------
config ARCH_SUPPORTS_BOTH_MMU
bool
diff --git a/patches/binutils/2.24/700-Fix-library-paths-on-PowerPC.patch b/patches/binutils/2.24/700-Fix-library-paths-on-PowerPC.patch
new file mode 100644
index 0000000..cea92f3
--- /dev/null
+++ b/patches/binutils/2.24/700-Fix-library-paths-on-PowerPC.patch
@@ -0,0 +1,42 @@
+From 1b967f3cb0682dd05128ef13495c2dca2a04dc4e Mon Sep 17 00:00:00 2001
+From: Alexey Neyman <stilor@att.net>
+Date: Sat, 11 Mar 2017 17:27:09 -0800
+Subject: [PATCH] Fix library paths on PowerPC
+
+First, need to match against just the CPU name, not the whole triplet.
+Otherwise, the test picks up "*le-*" pattern from x86_64-apple-darwin
+triplet.
+
+Second, it should be testing for $target, not $host. Host may be
+little endian by default, and the sysroot directory layout shouldn't
+depend on whether it is built on LE or BE machine.
+
+Signed-off-by: Alexey Neyman <stilor@att.net>
+---
+ ld/emulparams/elf32ppccommon.sh | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/ld/emulparams/elf32ppccommon.sh b/ld/emulparams/elf32ppccommon.sh
+index 1f54ef8..d00cf68 100644
+--- a/ld/emulparams/elf32ppccommon.sh
++++ b/ld/emulparams/elf32ppccommon.sh
+@@ -44,11 +44,11 @@ fi
+
+ # Look for 64 bit target libraries in /lib64, /usr/lib64 etc., first.
+ # Similarly, look for 32 bit libraries in /lib32, /usr/lib32 etc.
+-case "$host":"$EMULATION_NAME" in
+- *le-*:*64lppc*) LIBPATH_SUFFIX=64 ;;
+- *le-*:*32lppc*) LIBPATH_SUFFIX=32 ;;
+- *le-*:*64*) LIBPATH_SUFFIX=64be ;;
+- *le-*:*32*) LIBPATH_SUFFIX=32be ;;
++case `echo "$target" | sed -e 's/-.*//'`:"$EMULATION_NAME" in
++ *le:*64lppc*) LIBPATH_SUFFIX=64 ;;
++ *le:*32lppc*) LIBPATH_SUFFIX=32 ;;
++ *le:*64*) LIBPATH_SUFFIX=64be ;;
++ *le:*32*) LIBPATH_SUFFIX=32be ;;
+ *:*64lppc*) LIBPATH_SUFFIX=64le ;;
+ *:*32lppc*) LIBPATH_SUFFIX=32le ;;
+ *:*64*) LIBPATH_SUFFIX=64 ;;
+--
+2.9.3
+
diff --git a/patches/binutils/2.25.1/700-Fix-library-paths-on-PowerPC.patch b/patches/binutils/2.25.1/700-Fix-library-paths-on-PowerPC.patch
new file mode 100644
index 0000000..cea92f3
--- /dev/null
+++ b/patches/binutils/2.25.1/700-Fix-library-paths-on-PowerPC.patch
@@ -0,0 +1,42 @@
+From 1b967f3cb0682dd05128ef13495c2dca2a04dc4e Mon Sep 17 00:00:00 2001
+From: Alexey Neyman <stilor@att.net>
+Date: Sat, 11 Mar 2017 17:27:09 -0800
+Subject: [PATCH] Fix library paths on PowerPC
+
+First, need to match against just the CPU name, not the whole triplet.
+Otherwise, the test picks up "*le-*" pattern from x86_64-apple-darwin
+triplet.
+
+Second, it should be testing for $target, not $host. Host may be
+little endian by default, and the sysroot directory layout shouldn't
+depend on whether it is built on LE or BE machine.
+
+Signed-off-by: Alexey Neyman <stilor@att.net>
+---
+ ld/emulparams/elf32ppccommon.sh | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/ld/emulparams/elf32ppccommon.sh b/ld/emulparams/elf32ppccommon.sh
+index 1f54ef8..d00cf68 100644
+--- a/ld/emulparams/elf32ppccommon.sh
++++ b/ld/emulparams/elf32ppccommon.sh
+@@ -44,11 +44,11 @@ fi
+
+ # Look for 64 bit target libraries in /lib64, /usr/lib64 etc., first.
+ # Similarly, look for 32 bit libraries in /lib32, /usr/lib32 etc.
+-case "$host":"$EMULATION_NAME" in
+- *le-*:*64lppc*) LIBPATH_SUFFIX=64 ;;
+- *le-*:*32lppc*) LIBPATH_SUFFIX=32 ;;
+- *le-*:*64*) LIBPATH_SUFFIX=64be ;;
+- *le-*:*32*) LIBPATH_SUFFIX=32be ;;
++case `echo "$target" | sed -e 's/-.*//'`:"$EMULATION_NAME" in
++ *le:*64lppc*) LIBPATH_SUFFIX=64 ;;
++ *le:*32lppc*) LIBPATH_SUFFIX=32 ;;
++ *le:*64*) LIBPATH_SUFFIX=64be ;;
++ *le:*32*) LIBPATH_SUFFIX=32be ;;
+ *:*64lppc*) LIBPATH_SUFFIX=64le ;;
+ *:*32lppc*) LIBPATH_SUFFIX=32le ;;
+ *:*64*) LIBPATH_SUFFIX=64 ;;
+--
+2.9.3
+
diff --git a/patches/binutils/2.26/700-Fix-library-paths-on-PowerPC.patch b/patches/binutils/2.26/700-Fix-library-paths-on-PowerPC.patch
new file mode 100644
index 0000000..cea92f3
--- /dev/null
+++ b/patches/binutils/2.26/700-Fix-library-paths-on-PowerPC.patch
@@ -0,0 +1,42 @@
+From 1b967f3cb0682dd05128ef13495c2dca2a04dc4e Mon Sep 17 00:00:00 2001
+From: Alexey Neyman <stilor@att.net>
+Date: Sat, 11 Mar 2017 17:27:09 -0800
+Subject: [PATCH] Fix library paths on PowerPC
+
+First, need to match against just the CPU name, not the whole triplet.
+Otherwise, the test picks up "*le-*" pattern from x86_64-apple-darwin
+triplet.
+
+Second, it should be testing for $target, not $host. Host may be
+little endian by default, and the sysroot directory layout shouldn't
+depend on whether it is built on LE or BE machine.
+
+Signed-off-by: Alexey Neyman <stilor@att.net>
+---
+ ld/emulparams/elf32ppccommon.sh | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/ld/emulparams/elf32ppccommon.sh b/ld/emulparams/elf32ppccommon.sh
+index 1f54ef8..d00cf68 100644
+--- a/ld/emulparams/elf32ppccommon.sh
++++ b/ld/emulparams/elf32ppccommon.sh
+@@ -44,11 +44,11 @@ fi
+
+ # Look for 64 bit target libraries in /lib64, /usr/lib64 etc., first.
+ # Similarly, look for 32 bit libraries in /lib32, /usr/lib32 etc.
+-case "$host":"$EMULATION_NAME" in
+- *le-*:*64lppc*) LIBPATH_SUFFIX=64 ;;
+- *le-*:*32lppc*) LIBPATH_SUFFIX=32 ;;
+- *le-*:*64*) LIBPATH_SUFFIX=64be ;;
+- *le-*:*32*) LIBPATH_SUFFIX=32be ;;
++case `echo "$target" | sed -e 's/-.*//'`:"$EMULATION_NAME" in
++ *le:*64lppc*) LIBPATH_SUFFIX=64 ;;
++ *le:*32lppc*) LIBPATH_SUFFIX=32 ;;
++ *le:*64*) LIBPATH_SUFFIX=64be ;;
++ *le:*32*) LIBPATH_SUFFIX=32be ;;
+ *:*64lppc*) LIBPATH_SUFFIX=64le ;;
+ *:*32lppc*) LIBPATH_SUFFIX=32le ;;
+ *:*64*) LIBPATH_SUFFIX=64 ;;
+--
+2.9.3
+
diff --git a/patches/binutils/2.27/700-Fix-library-paths-on-PowerPC.patch b/patches/binutils/2.27/700-Fix-library-paths-on-PowerPC.patch
new file mode 100644
index 0000000..cea92f3
--- /dev/null
+++ b/patches/binutils/2.27/700-Fix-library-paths-on-PowerPC.patch
@@ -0,0 +1,42 @@
+From 1b967f3cb0682dd05128ef13495c2dca2a04dc4e Mon Sep 17 00:00:00 2001
+From: Alexey Neyman <stilor@att.net>
+Date: Sat, 11 Mar 2017 17:27:09 -0800
+Subject: [PATCH] Fix library paths on PowerPC
+
+First, need to match against just the CPU name, not the whole triplet.
+Otherwise, the test picks up "*le-*" pattern from x86_64-apple-darwin
+triplet.
+
+Second, it should be testing for $target, not $host. Host may be
+little endian by default, and the sysroot directory layout shouldn't
+depend on whether it is built on LE or BE machine.
+
+Signed-off-by: Alexey Neyman <stilor@att.net>
+---
+ ld/emulparams/elf32ppccommon.sh | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/ld/emulparams/elf32ppccommon.sh b/ld/emulparams/elf32ppccommon.sh
+index 1f54ef8..d00cf68 100644
+--- a/ld/emulparams/elf32ppccommon.sh
++++ b/ld/emulparams/elf32ppccommon.sh
+@@ -44,11 +44,11 @@ fi
+
+ # Look for 64 bit target libraries in /lib64, /usr/lib64 etc., first.
+ # Similarly, look for 32 bit libraries in /lib32, /usr/lib32 etc.
+-case "$host":"$EMULATION_NAME" in
+- *le-*:*64lppc*) LIBPATH_SUFFIX=64 ;;
+- *le-*:*32lppc*) LIBPATH_SUFFIX=32 ;;
+- *le-*:*64*) LIBPATH_SUFFIX=64be ;;
+- *le-*:*32*) LIBPATH_SUFFIX=32be ;;
++case `echo "$target" | sed -e 's/-.*//'`:"$EMULATION_NAME" in
++ *le:*64lppc*) LIBPATH_SUFFIX=64 ;;
++ *le:*32lppc*) LIBPATH_SUFFIX=32 ;;
++ *le:*64*) LIBPATH_SUFFIX=64be ;;
++ *le:*32*) LIBPATH_SUFFIX=32be ;;
+ *:*64lppc*) LIBPATH_SUFFIX=64le ;;
+ *:*32lppc*) LIBPATH_SUFFIX=32le ;;
+ *:*64*) LIBPATH_SUFFIX=64 ;;
+--
+2.9.3
+
diff --git a/patches/binutils/2.28/700-Fix-library-paths-on-PowerPC.patch b/patches/binutils/2.28/700-Fix-library-paths-on-PowerPC.patch
new file mode 100644
index 0000000..cea92f3
--- /dev/null
+++ b/patches/binutils/2.28/700-Fix-library-paths-on-PowerPC.patch
@@ -0,0 +1,42 @@
+From 1b967f3cb0682dd05128ef13495c2dca2a04dc4e Mon Sep 17 00:00:00 2001
+From: Alexey Neyman <stilor@att.net>
+Date: Sat, 11 Mar 2017 17:27:09 -0800
+Subject: [PATCH] Fix library paths on PowerPC
+
+First, need to match against just the CPU name, not the whole triplet.
+Otherwise, the test picks up "*le-*" pattern from x86_64-apple-darwin
+triplet.
+
+Second, it should be testing for $target, not $host. Host may be
+little endian by default, and the sysroot directory layout shouldn't
+depend on whether it is built on LE or BE machine.
+
+Signed-off-by: Alexey Neyman <stilor@att.net>
+---
+ ld/emulparams/elf32ppccommon.sh | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/ld/emulparams/elf32ppccommon.sh b/ld/emulparams/elf32ppccommon.sh
+index 1f54ef8..d00cf68 100644
+--- a/ld/emulparams/elf32ppccommon.sh
++++ b/ld/emulparams/elf32ppccommon.sh
+@@ -44,11 +44,11 @@ fi
+
+ # Look for 64 bit target libraries in /lib64, /usr/lib64 etc., first.
+ # Similarly, look for 32 bit libraries in /lib32, /usr/lib32 etc.
+-case "$host":"$EMULATION_NAME" in
+- *le-*:*64lppc*) LIBPATH_SUFFIX=64 ;;
+- *le-*:*32lppc*) LIBPATH_SUFFIX=32 ;;
+- *le-*:*64*) LIBPATH_SUFFIX=64be ;;
+- *le-*:*32*) LIBPATH_SUFFIX=32be ;;
++case `echo "$target" | sed -e 's/-.*//'`:"$EMULATION_NAME" in
++ *le:*64lppc*) LIBPATH_SUFFIX=64 ;;
++ *le:*32lppc*) LIBPATH_SUFFIX=32 ;;
++ *le:*64*) LIBPATH_SUFFIX=64be ;;
++ *le:*32*) LIBPATH_SUFFIX=32be ;;
+ *:*64lppc*) LIBPATH_SUFFIX=64le ;;
+ *:*32lppc*) LIBPATH_SUFFIX=32le ;;
+ *:*64*) LIBPATH_SUFFIX=64 ;;
+--
+2.9.3
+
diff --git a/patches/elf2flt/a8bc69b882a55b1f1e437b50e33d3db8414eb68e/100-fix-cygwin-build.patch b/patches/elf2flt/a8bc69b882a55b1f1e437b50e33d3db8414eb68e/100-fix-cygwin-build.patch
deleted file mode 100644
index 53311bf..0000000
--- a/patches/elf2flt/a8bc69b882a55b1f1e437b50e33d3db8414eb68e/100-fix-cygwin-build.patch
+++ /dev/null
@@ -1,111 +0,0 @@
-From 4e5250f8319e72b739932b87193fa29f4a5b96b1 Mon Sep 17 00:00:00 2001
-From: Alexey Neyman <stilor@att.net>
-Date: Mon, 27 Feb 2017 01:20:10 -0800
-Subject: [PATCH] Symlink required binutils/BFD headers to local dir
-
-... to minimize the chance of clashes with system headers.
-
-Also, remove the -lcygwin from Makefile.in: this breaks canadian
-build on cygwin, as it tries to pass -lcygwin into non-Cygwin host
-CC. This chunk pre-dates the addition of -lc into configure.ac and
-passing -lc should be sufficient (it works for me).
-
-Signed-off-by: Alexey Neyman <stilor@att.net>
----
- Makefile.in | 21 +++++++++++++--------
- configure | 4 ++--
- configure.ac | 4 ++--
- 3 files changed, 17 insertions(+), 12 deletions(-)
-
-diff --git a/Makefile.in b/Makefile.in
-index a6feea6..46d904b 100644
---- a/Makefile.in
-+++ b/Makefile.in
-@@ -14,7 +14,9 @@ CPU = @target_cpu@
- TARGET = @target_alias@
- SYMBOL_PREFIX = @SYMBOL_PREFIX@
- CFLAGS = @CFLAGS@
--INCLUDES = -I$(srcdir) @bfd_include_dir@ @binutils_include_dir@ @zlib_include_dir@
-+INCLUDES = -I$(srcdir) -I. @zlib_include_dir@
-+BFD_INCLUDE_DIR = @bfd_include_dir@
-+BINUTILS_INCLUDE_DIR = @binutils_include_dir@
- CPPFLAGS = @CPPFLAGS@ $(DEFS) $(INCLUDES)
- LDFLAGS = @LDFLAGS@
- LDLIBS = @LIBS@
-@@ -38,11 +40,6 @@ ifneq (,$(findstring mingw32,$(HOST)))
- LDLIBS += -lws2_32
- endif
-
--# force link order under cygwin to avoid getopts / libiberty clash
--ifneq ($(strip $(shell gcc -v 2>&1 | grep "cygwin")),)
-- LDLIBS := -lcygwin $(LDLIBS)
--endif
--
- LDFILE= elf2flt.ld
- ifeq ($(strip $(CPU)),e1)
- SRC_LDFILE= $(srcdir)/$(CPU)-elf2flt.ld
-@@ -101,7 +98,7 @@ check-flthdr:
- check: check-flthdr
-
- clean:
-- -rm -f $(PROGS) *.$(OBJEXT) .deps
-+ -rm -f $(PROGS) *.$(OBJEXT) *.h elf .deps .stamp-local-include
-
- distclean: clean
- -rm -f Makefile config.log config.status config.cache ld-elf2flt
-@@ -121,5 +118,13 @@ install:
- $(INSTALL) -m 644 $(SRC_LDFILE) $(DESTDIR)$(target_libdir)/$(LDFILE)
-
- sinclude .deps
--.deps:
-+.deps: .stamp-local-include
- $(CC) -MM $(CPPFLAGS) $(srcdir)/*.c > .deps
-+
-+.stamp-local-include:
-+ ln -sf $(BFD_INCLUDE_DIR)/bfd.h bfd.h
-+ for f in ansidecl filenames hashtab libiberty symcat; do \
-+ ln -sf $(BINUTILS_INCLUDE_DIR)/$$f.h $$f.h; \
-+ done
-+ ln -sf $(BINUTILS_INCLUDE_DIR)/elf elf
-+ touch $@
-diff --git a/configure b/configure
-index 3a4e8d6..af64990 100755
---- a/configure
-+++ b/configure
-@@ -3931,12 +3931,12 @@ fi
-
- bfd_include_dir=
- if test "$ac_bfd_include_dir" != "NONE"; then
-- bfd_include_dir="-I$ac_bfd_include_dir"
-+ bfd_include_dir="$ac_bfd_include_dir"
- fi
-
- binutils_include_dir=
- if test "$ac_binutils_include_dir" != "NONE"; then
-- binutils_include_dir="-I$ac_binutils_include_dir"
-+ binutils_include_dir="$ac_binutils_include_dir"
- fi
-
- zlib_include_dir=
-diff --git a/configure.ac b/configure.ac
-index 6002894..b7fb790 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -135,12 +135,12 @@ fi
-
- bfd_include_dir=
- if test "$ac_bfd_include_dir" != "NONE"; then
-- bfd_include_dir="-I$ac_bfd_include_dir"
-+ bfd_include_dir="$ac_bfd_include_dir"
- fi
-
- binutils_include_dir=
- if test "$ac_binutils_include_dir" != "NONE"; then
-- binutils_include_dir="-I$ac_binutils_include_dir"
-+ binutils_include_dir="$ac_binutils_include_dir"
- fi
-
- zlib_include_dir=
---
-2.9.3
-
diff --git a/patches/glibc/2.12.1/101-Suppress-GCC-6-warning-about-ambiguous-else-with-Wpa.patch b/patches/glibc/2.12.1/101-Suppress-GCC-6-warning-about-ambiguous-else-with-Wpa.patch
new file mode 100644
index 0000000..6fd663a
--- /dev/null
+++ b/patches/glibc/2.12.1/101-Suppress-GCC-6-warning-about-ambiguous-else-with-Wpa.patch
@@ -0,0 +1,84 @@
+From df1cf48777fe4cd81ad7fb09ecbe5b31432b7c1c Mon Sep 17 00:00:00 2001
+From: Yvan Roux <yvan.roux@linaro.org>
+Date: Fri, 15 Apr 2016 13:29:26 +0200
+Subject: [PATCH] Suppress GCC 6 warning about ambiguous 'else' with
+ -Wparentheses
+
+---
+ ChangeLog | 5 +++++
+ nis/nis_call.c | 20 +++++++++++---------
+ stdlib/setenv.c | 26 ++++++++++++++------------
+ 3 files changed, 30 insertions(+), 21 deletions(-)
+
+diff --git a/nis/nis_call.c b/nis/nis_call.c
+index 3fa37e4..cb7839a 100644
+--- a/nis/nis_call.c
++++ b/nis/nis_call.c
+@@ -680,16 +680,18 @@ nis_server_cache_add (const_nis_name name, int search_parent,
+ /* Choose which entry should be evicted from the cache. */
+ loc = &nis_server_cache[0];
+ if (*loc != NULL)
+- for (i = 1; i < 16; ++i)
+- if (nis_server_cache[i] == NULL)
+- {
++ {
++ for (i = 1; i < 16; ++i)
++ if (nis_server_cache[i] == NULL)
++ {
++ loc = &nis_server_cache[i];
++ break;
++ }
++ else if ((*loc)->uses > nis_server_cache[i]->uses
++ || ((*loc)->uses == nis_server_cache[i]->uses
++ && (*loc)->expires > nis_server_cache[i]->expires))
+ loc = &nis_server_cache[i];
+- break;
+- }
+- else if ((*loc)->uses > nis_server_cache[i]->uses
+- || ((*loc)->uses == nis_server_cache[i]->uses
+- && (*loc)->expires > nis_server_cache[i]->expires))
+- loc = &nis_server_cache[i];
++ }
+ old = *loc;
+ *loc = new;
+
+diff --git a/stdlib/setenv.c b/stdlib/setenv.c
+index da61ee0..e66045f 100644
+--- a/stdlib/setenv.c
++++ b/stdlib/setenv.c
+@@ -278,18 +278,20 @@ unsetenv (const char *name)
+ ep = __environ;
+ if (ep != NULL)
+ while (*ep != NULL)
+- if (!strncmp (*ep, name, len) && (*ep)[len] == '=')
+- {
+- /* Found it. Remove this pointer by moving later ones back. */
+- char **dp = ep;
+-
+- do
+- dp[0] = dp[1];
+- while (*dp++);
+- /* Continue the loop in case NAME appears again. */
+- }
+- else
+- ++ep;
++ {
++ if (!strncmp (*ep, name, len) && (*ep)[len] == '=')
++ {
++ /* Found it. Remove this pointer by moving later ones back. */
++ char **dp = ep;
++
++ do
++ dp[0] = dp[1];
++ while (*dp++);
++ /* Continue the loop in case NAME appears again. */
++ }
++ else
++ ++ep;
++ }
+
+ UNLOCK;
+
+--
+2.7.4
+
diff --git a/patches/glibc/2.12.1/102-fix-signed-shift-overlow.patch b/patches/glibc/2.12.1/102-fix-signed-shift-overlow.patch
new file mode 100644
index 0000000..ef49f83
--- /dev/null
+++ b/patches/glibc/2.12.1/102-fix-signed-shift-overlow.patch
@@ -0,0 +1,98 @@
+commit 5542236837c5c41435f8282ec92799f480c36f18
+Author: Paul Eggert <eggert@cs.ucla.edu>
+Date: Tue Jul 21 22:50:29 2015 -0700
+
+ Port the 0x7efe...feff pattern to GCC 6.
+
+ See Steve Ellcey's bug report in:
+ https://sourceware.org/ml/libc-alpha/2015-07/msg00673.html
+ * string/memrchr.c (MEMRCHR):
+ * string/rawmemchr.c (RAWMEMCHR):
+ * string/strchr.c (strchr):
+ * string/strchrnul.c (STRCHRNUL):
+ Rewrite code to avoid issues with signed shift overflow.
+
+diff --git a/string/memrchr.c b/string/memrchr.c
+index 0c8fd84..86cd5b9 100644
+--- a/string/memrchr.c
++++ b/string/memrchr.c
+@@ -96,15 +96,8 @@ MEMRCHR
+
+ The 1-bits make sure that carries propagate to the next 0-bit.
+ The 0-bits provide holes for carries to fall into. */
+-
+- if (sizeof (longword) != 4 && sizeof (longword) != 8)
+- abort ();
+-
+-#if LONG_MAX <= LONG_MAX_32_BITS
+- magic_bits = 0x7efefeff;
+-#else
+- magic_bits = ((unsigned long int) 0x7efefefe << 32) | 0xfefefeff;
+-#endif
++ magic_bits = -1;
++ magic_bits = magic_bits / 0xff * 0xfe << 1 >> 1 | 1;
+
+ /* Set up a longword, each of whose bytes is C. */
+ charmask = c | (c << 8);
+diff --git a/string/rawmemchr.c b/string/rawmemchr.c
+index 05b22be..228ca9d 100644
+--- a/string/rawmemchr.c
++++ b/string/rawmemchr.c
+@@ -86,15 +86,8 @@ RAWMEMCHR (s, c_in)
+
+ The 1-bits make sure that carries propagate to the next 0-bit.
+ The 0-bits provide holes for carries to fall into. */
+-
+- if (sizeof (longword) != 4 && sizeof (longword) != 8)
+- abort ();
+-
+-#if LONG_MAX <= LONG_MAX_32_BITS
+- magic_bits = 0x7efefeff;
+-#else
+- magic_bits = ((unsigned long int) 0x7efefefe << 32) | 0xfefefeff;
+-#endif
++ magic_bits = -1;
++ magic_bits = magic_bits / 0xff * 0xfe << 1 >> 1 | 1;
+
+ /* Set up a longword, each of whose bytes is C. */
+ charmask = c | (c << 8);
+diff --git a/string/strchr.c b/string/strchr.c
+index 5f90075..f13b2b3 100644
+--- a/string/strchr.c
++++ b/string/strchr.c
+@@ -60,13 +60,8 @@ strchr (const char *s, int c_in)
+
+ The 1-bits make sure that carries propagate to the next 0-bit.
+ The 0-bits provide holes for carries to fall into. */
+- switch (sizeof (longword))
+- {
+- case 4: magic_bits = 0x7efefeffL; break;
+- case 8: magic_bits = ((0x7efefefeL << 16) << 16) | 0xfefefeffL; break;
+- default:
+- abort ();
+- }
++ magic_bits = -1;
++ magic_bits = magic_bits / 0xff * 0xfe << 1 >> 1 | 1;
+
+ /* Set up a longword, each of whose bytes is C. */
+ charmask = c | (c << 8);
+diff --git a/string/strchrnul.c b/string/strchrnul.c
+index 2678f1d..daf0b3f 100644
+--- a/string/strchrnul.c
++++ b/string/strchrnul.c
+@@ -66,13 +66,8 @@ STRCHRNUL (s, c_in)
+
+ The 1-bits make sure that carries propagate to the next 0-bit.
+ The 0-bits provide holes for carries to fall into. */
+- switch (sizeof (longword))
+- {
+- case 4: magic_bits = 0x7efefeffL; break;
+- case 8: magic_bits = ((0x7efefefeL << 16) << 16) | 0xfefefeffL; break;
+- default:
+- abort ();
+- }
++ magic_bits = -1;
++ magic_bits = magic_bits / 0xff * 0xfe << 1 >> 1 | 1;
+
+ /* Set up a longword, each of whose bytes is C. */
+ charmask = c | (c << 8);
diff --git a/patches/glibc/2.12.1/104-unused-variables.patch b/patches/glibc/2.12.1/104-unused-variables.patch
new file mode 100644
index 0000000..e063675
--- /dev/null
+++ b/patches/glibc/2.12.1/104-unused-variables.patch
@@ -0,0 +1,165 @@
+commit 6565fcb6e189d67b5a3f321453daebb805056d73
+Author: Wilco Dijkstra <wdijkstr@arm.com>
+Date: Fri Sep 18 20:27:20 2015 +0100
+
+ Fix several build failures with GCC6 due to unused static variables.
+
+ 2015-09-18 Wilco Dijkstra <wdijkstr@arm.com>
+
+ * resolv/base64.c (rcsid): Remove unused static.
+ * sysdeps/ieee754/dbl-64/atnat2.h (qpi1): Remove unused
+ static. (tqpi1): Likewise.
+ * sysdeps/ieee754/dbl-64/uexp.h (one): Likewise.
+ * sysdeps/ieee754/dbl-64/upow.h (sqrt_2): Likewise.
+ * sysdeps/ieee754/flt-32/e_log10f.c (one): Likewise.
+ * sysdeps/ieee754/flt-32/s_cosf.c (one): Likewise.
+ * sysdeps/ieee754/ldbl-128/e_lgammal_r.c (zero): Likewise.
+ * sysdeps/ieee754/ldbl-128/s_erfl.c (half): Likewise.
+ * sysdeps/ieee754/ldbl-128/s_log1pl.c (maxlog): Likewise.
+ * timezone/private.h (time_t_min): Likewise. (time_t_max):
+ Likewise.
+
+diff --git a/resolv/base64.c b/resolv/base64.c
+index ea584ed..519e5d2 100644
+--- a/resolv/base64.c
++++ b/resolv/base64.c
+@@ -40,10 +40,6 @@
+ * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+-#if !defined(LINT) && !defined(CODECENTER)
+-static const char rcsid[] = "$BINDId: base64.c,v 8.7 1999/10/13 16:39:33 vixie Exp $";
+-#endif /* not lint */
+-
+ #include <sys/types.h>
+ #include <sys/param.h>
+ #include <sys/socket.h>
+diff --git a/sysdeps/ieee754/dbl-64/atnat2.h b/sysdeps/ieee754/dbl-64/atnat2.h
+index e0d65af..82943f9 100644
+--- a/sysdeps/ieee754/dbl-64/atnat2.h
++++ b/sysdeps/ieee754/dbl-64/atnat2.h
+@@ -65,10 +65,8 @@
+ /**/ hpi1 = {{0x3c91a626, 0x33145c07} }, /* pi/2-hpi */
+ /**/ mhpi = {{0xbff921fb, 0x54442d18} }, /* -pi/2 */
+ /**/ qpi = {{0x3fe921fb, 0x54442d18} }, /* pi/4 */
+-/**/ qpi1 = {{0x3c81a626, 0x33145c07} }, /* pi/4-qpi */
+ /**/ mqpi = {{0xbfe921fb, 0x54442d18} }, /* -pi/4 */
+ /**/ tqpi = {{0x4002d97c, 0x7f3321d2} }, /* 3pi/4 */
+-/**/ tqpi1 = {{0x3c9a7939, 0x4c9e8a0a} }, /* 3pi/4-tqpi */
+ /**/ mtqpi = {{0xc002d97c, 0x7f3321d2} }, /* -3pi/4 */
+ /**/ u1 = {{0x3c314c2a, 0x00000000} }, /* 9.377e-19 */
+ /**/ u2 = {{0x3bf955e4, 0x00000000} }, /* 8.584e-20 */
+@@ -129,10 +127,8 @@
+ /**/ hpi1 = {{0x33145c07, 0x3c91a626} }, /* pi/2-hpi */
+ /**/ mhpi = {{0x54442d18, 0xbff921fb} }, /* -pi/2 */
+ /**/ qpi = {{0x54442d18, 0x3fe921fb} }, /* pi/4 */
+-/**/ qpi1 = {{0x33145c07, 0x3c81a626} }, /* pi/4-qpi */
+ /**/ mqpi = {{0x54442d18, 0xbfe921fb} }, /* -pi/4 */
+ /**/ tqpi = {{0x7f3321d2, 0x4002d97c} }, /* 3pi/4 */
+-/**/ tqpi1 = {{0x4c9e8a0a, 0x3c9a7939} }, /* 3pi/4-tqpi */
+ /**/ mtqpi = {{0x7f3321d2, 0xc002d97c} }, /* -3pi/4 */
+ /**/ u1 = {{0x00000000, 0x3c314c2a} }, /* 9.377e-19 */
+ /**/ u2 = {{0x00000000, 0x3bf955e4} }, /* 8.584e-20 */
+diff --git a/sysdeps/ieee754/dbl-64/uexp.h b/sysdeps/ieee754/dbl-64/uexp.h
+index 6817eaf..42b21f2 100644
+--- a/sysdeps/ieee754/dbl-64/uexp.h
++++ b/sysdeps/ieee754/dbl-64/uexp.h
+@@ -29,7 +29,7 @@
+
+ #include "mydefs.h"
+
+-const static double one = 1.0, zero = 0.0, hhuge = 1.0e300, tiny = 1.0e-300,
++const static double zero = 0.0, hhuge = 1.0e300, tiny = 1.0e-300,
+ err_0 = 1.000014, err_1 = 0.000016;
+ const static int4 bigint = 0x40862002,
+ badint = 0x40876000,smallint = 0x3C8fffff;
+diff --git a/sysdeps/ieee754/dbl-64/upow.h b/sysdeps/ieee754/dbl-64/upow.h
+index c8569a9..b4911e5 100644
+--- a/sysdeps/ieee754/dbl-64/upow.h
++++ b/sysdeps/ieee754/dbl-64/upow.h
+@@ -34,7 +34,6 @@
+ /**/ INF = {{0x7ff00000, 0x00000000}}, /* INF */
+ /**/ nINF = {{0xfff00000, 0x00000000}}, /* -INF */
+ /**/ NaNQ = {{0x7ff80000, 0x00000000}}, /* NaNQ */
+-/**/ sqrt_2 = {{0x3ff6a09e, 0x667f3bcc}}, /* sqrt(2) */
+ /**/ ln2a = {{0x3fe62e42, 0xfefa3800}}, /* ln(2) 43 bits */
+ /**/ ln2b = {{0x3d2ef357, 0x93c76730}}, /* ln(2)-ln2a */
+ /**/ bigu = {{0x4297ffff, 0xfffffd2c}}, /* 1.5*2**42 -724*2**-10 */
+@@ -48,7 +47,6 @@
+ /**/ INF = {{0x00000000, 0x7ff00000}}, /* INF */
+ /**/ nINF = {{0x00000000, 0xfff00000}}, /* -INF */
+ /**/ NaNQ = {{0x00000000, 0x7ff80000}}, /* NaNQ */
+-/**/ sqrt_2 = {{0x667f3bcc, 0x3ff6a09e}}, /* sqrt(2) */
+ /**/ ln2a = {{0xfefa3800, 0x3fe62e42}}, /* ln(2) 43 bits */
+ /**/ ln2b = {{0x93c76730, 0x3d2ef357}}, /* ln(2)-ln2a */
+ /**/ bigu = {{0xfffffd2c, 0x4297ffff}}, /* 1.5*2**42 -724*2**-10 */
+diff --git a/sysdeps/ieee754/flt-32/e_log10f.c b/sysdeps/ieee754/flt-32/e_log10f.c
+index 96f0e81..1daeef7 100644
+--- a/sysdeps/ieee754/flt-32/e_log10f.c
++++ b/sysdeps/ieee754/flt-32/e_log10f.c
+@@ -22,12 +22,6 @@ ivln10 = 4.3429449201e-01, /* 0x3ede5bd9 */
+ log10_2hi = 3.0102920532e-01, /* 0x3e9a2080 */
+ log10_2lo = 7.9034151668e-07; /* 0x355427db */
+
+-#ifdef __STDC__
+-static const float zero = 0.0;
+-#else
+-static float zero = 0.0;
+-#endif
+-
+ #ifdef __STDC__
+ float __ieee754_log10f(float x)
+ #else
+diff --git a/sysdeps/ieee754/flt-32/s_cosf.c b/sysdeps/ieee754/flt-32/s_cosf.c
+index 864ab27..0affd40 100644
+--- a/sysdeps/ieee754/flt-32/s_cosf.c
++++ b/sysdeps/ieee754/flt-32/s_cosf.c
+@@ -21,12 +21,6 @@ static char rcsid[] = "$NetBSD: s_cosf.c,v 1.4 1995/05/10 20:47:03 jtc Exp $";
+ #include "math.h"
+ #include "math_private.h"
+
+-#ifdef __STDC__
+-static const float one=1.0;
+-#else
+-static float one=1.0;
+-#endif
+-
+ #ifdef __STDC__
+ float __cosf(float x)
+ #else
+diff --git a/sysdeps/ieee754/ldbl-128/e_lgammal_r.c b/sysdeps/ieee754/ldbl-128/e_lgammal_r.c
+index 500aacc..ab5a96e 100644
+--- a/sysdeps/ieee754/ldbl-128/e_lgammal_r.c
++++ b/sysdeps/ieee754/ldbl-128/e_lgammal_r.c
+@@ -82,7 +82,6 @@ DIAG_IGNORE_NEEDS_COMMENT (4.6, "-Woverflow");
+ static const long double PIL = 3.1415926535897932384626433832795028841972E0L;
+ static const long double MAXLGM = 1.0485738685148938358098967157129705071571E4928L;
+ static const long double one = 1.0L;
+-static const long double zero = 0.0L;
+ static const long double huge = 1.0e4000L;
+
+ /* log gamma(x) = ( x - 0.5 ) * log(x) - x + LS2PI + 1/x P(1/x^2)
+diff --git a/sysdeps/ieee754/ldbl-128/s_erfl.c b/sysdeps/ieee754/ldbl-128/s_erfl.c
+index fa4609f..08c80a3 100644
+--- a/sysdeps/ieee754/ldbl-128/s_erfl.c
++++ b/sysdeps/ieee754/ldbl-128/s_erfl.c
+@@ -140,7 +140,6 @@ deval (long double x, const long double *p, int n)
+ static long double
+ #endif
+ tiny = 1e-4931L,
+- half = 0.5L,
+ one = 1.0L,
+ two = 2.0L,
+ /* 2/sqrt(pi) - 1 */
+diff --git a/sysdeps/ieee754/ldbl-128/s_log1pl.c b/sysdeps/ieee754/ldbl-128/s_log1pl.c
+index ff759bc..9609550 100644
+--- a/sysdeps/ieee754/ldbl-128/s_log1pl.c
++++ b/sysdeps/ieee754/ldbl-128/s_log1pl.c
+@@ -117,7 +117,6 @@ static const long double C2 = 1.428606820309417232121458176568075500134E-6L;
+
+ static const long double sqrth = 0.7071067811865475244008443621048490392848L;
+ /* ln (2^16384 * (1 - 2^-113)) */
+-static const long double maxlog = 1.1356523406294143949491931077970764891253E4L;
+ static const long double zero = 0.0L;
+
+ long double
diff --git a/patches/glibc/2.12.1/105-misleading-indentation.patch b/patches/glibc/2.12.1/105-misleading-indentation.patch
new file mode 100644
index 0000000..1dd8d85
--- /dev/null
+++ b/patches/glibc/2.12.1/105-misleading-indentation.patch
@@ -0,0 +1,24 @@
+commit 976ef870542580cf5fed896c2c652b3e1a95f9da
+Author: Steve Ellcey <sellcey@mips.com>
+Date: Fri Dec 11 09:19:37 2015 -0800
+
+ Fix indentation.
+
+ * sysdeps/ieee754/flt-32/k_rem_pio2f.c (__kernel_rem_pio2f):
+ Fix indentation.
+
+diff --git a/sysdeps/ieee754/flt-32/k_rem_pio2f.c b/sysdeps/ieee754/flt-32/k_rem_pio2f.c
+index 0c7685c..392afdb 100644
+--- a/sysdeps/ieee754/flt-32/k_rem_pio2f.c
++++ b/sysdeps/ieee754/flt-32/k_rem_pio2f.c
+@@ -65,7 +65,9 @@ int __kernel_rem_pio2f(float *x, float *y, int e0, int nx, int prec, const int32
+
+ /* compute q[0],q[1],...q[jk] */
+ for (i=0;i<=jk;i++) {
+- for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; q[i] = fw;
++ for(j=0,fw=0.0;j<=jx;j++)
++ fw += x[j]*f[jx+i-j];
++ q[i] = fw;
+ }
+
+ jz = jk;
diff --git a/patches/glibc/2.12.1/106-dl-open-array-bounds.patch b/patches/glibc/2.12.1/106-dl-open-array-bounds.patch
new file mode 100644
index 0000000..bdb5c19
--- /dev/null
+++ b/patches/glibc/2.12.1/106-dl-open-array-bounds.patch
@@ -0,0 +1,27 @@
+commit 328c44c3670ebf6c1bd790acddce65a12998cd6c
+Author: Roland McGrath <roland@hack.frob.com>
+Date: Fri Apr 17 12:11:58 2015 -0700
+
+ Fuller check for invalid NSID in _dl_open.
+
+diff --git a/elf/dl-open.c b/elf/dl-open.c
+index 0dbe07f..2d0e082 100644
+--- a/elf/dl-open.c
++++ b/elf/dl-open.c
+@@ -619,8 +619,14 @@ no more namespaces available for dlmopen()"));
+ /* Never allow loading a DSO in a namespace which is empty. Such
+ direct placements is only causing problems. Also don't allow
+ loading into a namespace used for auditing. */
+- else if (__builtin_expect (nsid != LM_ID_BASE && nsid != __LM_ID_CALLER, 0)
+- && (GL(dl_ns)[nsid]._ns_nloaded == 0
++ else if ((nsid != LM_ID_BASE && nsid != __LM_ID_CALLER)
++ && ((nsid < 0 || nsid >= GL(dl_nns))
++ /* This prevents the [NSID] index expressions from being
++ evaluated, so the compiler won't think that we are
++ accessing an invalid index here in the !SHARED case where
++ DL_NNS is 1 and so any NSID != 0 is invalid. */
++ || DL_NNS == 1
++ || GL(dl_ns)[nsid]._ns_nloaded == 0
+ || GL(dl_ns)[nsid]._ns_loaded->l_auditing))
+ _dl_signal_error (EINVAL, file, NULL,
+ N_("invalid target namespace in dlmopen()"));
diff --git a/patches/glibc/2.13/101-Suppress-GCC-6-warning-about-ambiguous-else-with-Wpa.patch b/patches/glibc/2.13/101-Suppress-GCC-6-warning-about-ambiguous-else-with-Wpa.patch
new file mode 100644
index 0000000..6fd663a
--- /dev/null
+++ b/patches/glibc/2.13/101-Suppress-GCC-6-warning-about-ambiguous-else-with-Wpa.patch
@@ -0,0 +1,84 @@
+From df1cf48777fe4cd81ad7fb09ecbe5b31432b7c1c Mon Sep 17 00:00:00 2001
+From: Yvan Roux <yvan.roux@linaro.org>
+Date: Fri, 15 Apr 2016 13:29:26 +0200
+Subject: [PATCH] Suppress GCC 6 warning about ambiguous 'else' with
+ -Wparentheses
+
+---
+ ChangeLog | 5 +++++
+ nis/nis_call.c | 20 +++++++++++---------
+ stdlib/setenv.c | 26 ++++++++++++++------------
+ 3 files changed, 30 insertions(+), 21 deletions(-)
+
+diff --git a/nis/nis_call.c b/nis/nis_call.c
+index 3fa37e4..cb7839a 100644
+--- a/nis/nis_call.c
++++ b/nis/nis_call.c
+@@ -680,16 +680,18 @@ nis_server_cache_add (const_nis_name name, int search_parent,
+ /* Choose which entry should be evicted from the cache. */
+ loc = &nis_server_cache[0];
+ if (*loc != NULL)
+- for (i = 1; i < 16; ++i)
+- if (nis_server_cache[i] == NULL)
+- {
++ {
++ for (i = 1; i < 16; ++i)
++ if (nis_server_cache[i] == NULL)
++ {
++ loc = &nis_server_cache[i];
++ break;
++ }
++ else if ((*loc)->uses > nis_server_cache[i]->uses
++ || ((*loc)->uses == nis_server_cache[i]->uses
++ && (*loc)->expires > nis_server_cache[i]->expires))
+ loc = &nis_server_cache[i];
+- break;
+- }
+- else if ((*loc)->uses > nis_server_cache[i]->uses
+- || ((*loc)->uses == nis_server_cache[i]->uses
+- && (*loc)->expires > nis_server_cache[i]->expires))
+- loc = &nis_server_cache[i];
++ }
+ old = *loc;
+ *loc = new;
+
+diff --git a/stdlib/setenv.c b/stdlib/setenv.c
+index da61ee0..e66045f 100644
+--- a/stdlib/setenv.c
++++ b/stdlib/setenv.c
+@@ -278,18 +278,20 @@ unsetenv (const char *name)
+ ep = __environ;
+ if (ep != NULL)
+ while (*ep != NULL)
+- if (!strncmp (*ep, name, len) && (*ep)[len] == '=')
+- {
+- /* Found it. Remove this pointer by moving later ones back. */
+- char **dp = ep;
+-
+- do
+- dp[0] = dp[1];
+- while (*dp++);
+- /* Continue the loop in case NAME appears again. */
+- }
+- else
+- ++ep;
++ {
++ if (!strncmp (*ep, name, len) && (*ep)[len] == '=')
++ {
++ /* Found it. Remove this pointer by moving later ones back. */
++ char **dp = ep;
++
++ do
++ dp[0] = dp[1];
++ while (*dp++);
++ /* Continue the loop in case NAME appears again. */
++ }
++ else
++ ++ep;
++ }
+
+ UNLOCK;
+
+--
+2.7.4
+
diff --git a/patches/glibc/2.13/102-fix-signed-shift-overlow.patch b/patches/glibc/2.13/102-fix-signed-shift-overlow.patch
new file mode 100644
index 0000000..ef49f83
--- /dev/null
+++ b/patches/glibc/2.13/102-fix-signed-shift-overlow.patch
@@ -0,0 +1,98 @@
+commit 5542236837c5c41435f8282ec92799f480c36f18
+Author: Paul Eggert <eggert@cs.ucla.edu>
+Date: Tue Jul 21 22:50:29 2015 -0700
+
+ Port the 0x7efe...feff pattern to GCC 6.
+
+ See Steve Ellcey's bug report in:
+ https://sourceware.org/ml/libc-alpha/2015-07/msg00673.html
+ * string/memrchr.c (MEMRCHR):
+ * string/rawmemchr.c (RAWMEMCHR):
+ * string/strchr.c (strchr):
+ * string/strchrnul.c (STRCHRNUL):
+ Rewrite code to avoid issues with signed shift overflow.
+
+diff --git a/string/memrchr.c b/string/memrchr.c
+index 0c8fd84..86cd5b9 100644
+--- a/string/memrchr.c
++++ b/string/memrchr.c
+@@ -96,15 +96,8 @@ MEMRCHR
+
+ The 1-bits make sure that carries propagate to the next 0-bit.
+ The 0-bits provide holes for carries to fall into. */
+-
+- if (sizeof (longword) != 4 && sizeof (longword) != 8)
+- abort ();
+-
+-#if LONG_MAX <= LONG_MAX_32_BITS
+- magic_bits = 0x7efefeff;
+-#else
+- magic_bits = ((unsigned long int) 0x7efefefe << 32) | 0xfefefeff;
+-#endif
++ magic_bits = -1;
++ magic_bits = magic_bits / 0xff * 0xfe << 1 >> 1 | 1;
+
+ /* Set up a longword, each of whose bytes is C. */
+ charmask = c | (c << 8);
+diff --git a/string/rawmemchr.c b/string/rawmemchr.c
+index 05b22be..228ca9d 100644
+--- a/string/rawmemchr.c
++++ b/string/rawmemchr.c
+@@ -86,15 +86,8 @@ RAWMEMCHR (s, c_in)
+
+ The 1-bits make sure that carries propagate to the next 0-bit.
+ The 0-bits provide holes for carries to fall into. */
+-
+- if (sizeof (longword) != 4 && sizeof (longword) != 8)
+- abort ();
+-
+-#if LONG_MAX <= LONG_MAX_32_BITS
+- magic_bits = 0x7efefeff;
+-#else
+- magic_bits = ((unsigned long int) 0x7efefefe << 32) | 0xfefefeff;
+-#endif
++ magic_bits = -1;
++ magic_bits = magic_bits / 0xff * 0xfe << 1 >> 1 | 1;
+
+ /* Set up a longword, each of whose bytes is C. */
+ charmask = c | (c << 8);
+diff --git a/string/strchr.c b/string/strchr.c
+index 5f90075..f13b2b3 100644
+--- a/string/strchr.c
++++ b/string/strchr.c
+@@ -60,13 +60,8 @@ strchr (const char *s, int c_in)
+
+ The 1-bits make sure that carries propagate to the next 0-bit.
+ The 0-bits provide holes for carries to fall into. */
+- switch (sizeof (longword))
+- {
+- case 4: magic_bits = 0x7efefeffL; break;
+- case 8: magic_bits = ((0x7efefefeL << 16) << 16) | 0xfefefeffL; break;
+- default:
+- abort ();
+- }
++ magic_bits = -1;
++ magic_bits = magic_bits / 0xff * 0xfe << 1 >> 1 | 1;
+
+ /* Set up a longword, each of whose bytes is C. */
+ charmask = c | (c << 8);
+diff --git a/string/strchrnul.c b/string/strchrnul.c
+index 2678f1d..daf0b3f 100644
+--- a/string/strchrnul.c
++++ b/string/strchrnul.c
+@@ -66,13 +66,8 @@ STRCHRNUL (s, c_in)
+
+ The 1-bits make sure that carries propagate to the next 0-bit.
+ The 0-bits provide holes for carries to fall into. */
+- switch (sizeof (longword))
+- {
+- case 4: magic_bits = 0x7efefeffL; break;
+- case 8: magic_bits = ((0x7efefefeL << 16) << 16) | 0xfefefeffL; break;
+- default:
+- abort ();
+- }
++ magic_bits = -1;
++ magic_bits = magic_bits / 0xff * 0xfe << 1 >> 1 | 1;
+
+ /* Set up a longword, each of whose bytes is C. */
+ charmask = c | (c << 8);
diff --git a/patches/glibc/2.13/104-unused-variables.patch b/patches/glibc/2.13/104-unused-variables.patch
new file mode 100644
index 0000000..e063675
--- /dev/null
+++ b/patches/glibc/2.13/104-unused-variables.patch
@@ -0,0 +1,165 @@
+commit 6565fcb6e189d67b5a3f321453daebb805056d73
+Author: Wilco Dijkstra <wdijkstr@arm.com>
+Date: Fri Sep 18 20:27:20 2015 +0100
+
+ Fix several build failures with GCC6 due to unused static variables.
+
+ 2015-09-18 Wilco Dijkstra <wdijkstr@arm.com>
+
+ * resolv/base64.c (rcsid): Remove unused static.
+ * sysdeps/ieee754/dbl-64/atnat2.h (qpi1): Remove unused
+ static. (tqpi1): Likewise.
+ * sysdeps/ieee754/dbl-64/uexp.h (one): Likewise.
+ * sysdeps/ieee754/dbl-64/upow.h (sqrt_2): Likewise.
+ * sysdeps/ieee754/flt-32/e_log10f.c (one): Likewise.
+ * sysdeps/ieee754/flt-32/s_cosf.c (one): Likewise.
+ * sysdeps/ieee754/ldbl-128/e_lgammal_r.c (zero): Likewise.
+ * sysdeps/ieee754/ldbl-128/s_erfl.c (half): Likewise.
+ * sysdeps/ieee754/ldbl-128/s_log1pl.c (maxlog): Likewise.
+ * timezone/private.h (time_t_min): Likewise. (time_t_max):
+ Likewise.
+
+diff --git a/resolv/base64.c b/resolv/base64.c
+index ea584ed..519e5d2 100644
+--- a/resolv/base64.c
++++ b/resolv/base64.c
+@@ -40,10 +40,6 @@
+ * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+-#if !defined(LINT) && !defined(CODECENTER)
+-static const char rcsid[] = "$BINDId: base64.c,v 8.7 1999/10/13 16:39:33 vixie Exp $";
+-#endif /* not lint */
+-
+ #include <sys/types.h>
+ #include <sys/param.h>
+ #include <sys/socket.h>
+diff --git a/sysdeps/ieee754/dbl-64/atnat2.h b/sysdeps/ieee754/dbl-64/atnat2.h
+index e0d65af..82943f9 100644
+--- a/sysdeps/ieee754/dbl-64/atnat2.h
++++ b/sysdeps/ieee754/dbl-64/atnat2.h
+@@ -65,10 +65,8 @@
+ /**/ hpi1 = {{0x3c91a626, 0x33145c07} }, /* pi/2-hpi */
+ /**/ mhpi = {{0xbff921fb, 0x54442d18} }, /* -pi/2 */
+ /**/ qpi = {{0x3fe921fb, 0x54442d18} }, /* pi/4 */
+-/**/ qpi1 = {{0x3c81a626, 0x33145c07} }, /* pi/4-qpi */
+ /**/ mqpi = {{0xbfe921fb, 0x54442d18} }, /* -pi/4 */
+ /**/ tqpi = {{0x4002d97c, 0x7f3321d2} }, /* 3pi/4 */
+-/**/ tqpi1 = {{0x3c9a7939, 0x4c9e8a0a} }, /* 3pi/4-tqpi */
+ /**/ mtqpi = {{0xc002d97c, 0x7f3321d2} }, /* -3pi/4 */
+ /**/ u1 = {{0x3c314c2a, 0x00000000} }, /* 9.377e-19 */
+ /**/ u2 = {{0x3bf955e4, 0x00000000} }, /* 8.584e-20 */
+@@ -129,10 +127,8 @@
+ /**/ hpi1 = {{0x33145c07, 0x3c91a626} }, /* pi/2-hpi */
+ /**/ mhpi = {{0x54442d18, 0xbff921fb} }, /* -pi/2 */
+ /**/ qpi = {{0x54442d18, 0x3fe921fb} }, /* pi/4 */
+-/**/ qpi1 = {{0x33145c07, 0x3c81a626} }, /* pi/4-qpi */
+ /**/ mqpi = {{0x54442d18, 0xbfe921fb} }, /* -pi/4 */
+ /**/ tqpi = {{0x7f3321d2, 0x4002d97c} }, /* 3pi/4 */
+-/**/ tqpi1 = {{0x4c9e8a0a, 0x3c9a7939} }, /* 3pi/4-tqpi */
+ /**/ mtqpi = {{0x7f3321d2, 0xc002d97c} }, /* -3pi/4 */
+ /**/ u1 = {{0x00000000, 0x3c314c2a} }, /* 9.377e-19 */
+ /**/ u2 = {{0x00000000, 0x3bf955e4} }, /* 8.584e-20 */
+diff --git a/sysdeps/ieee754/dbl-64/uexp.h b/sysdeps/ieee754/dbl-64/uexp.h
+index 6817eaf..42b21f2 100644
+--- a/sysdeps/ieee754/dbl-64/uexp.h
++++ b/sysdeps/ieee754/dbl-64/uexp.h
+@@ -29,7 +29,7 @@
+
+ #include "mydefs.h"
+
+-const static double one = 1.0, zero = 0.0, hhuge = 1.0e300, tiny = 1.0e-300,
++const static double zero = 0.0, hhuge = 1.0e300, tiny = 1.0e-300,
+ err_0 = 1.000014, err_1 = 0.000016;
+ const static int4 bigint = 0x40862002,
+ badint = 0x40876000,smallint = 0x3C8fffff;
+diff --git a/sysdeps/ieee754/dbl-64/upow.h b/sysdeps/ieee754/dbl-64/upow.h
+index c8569a9..b4911e5 100644
+--- a/sysdeps/ieee754/dbl-64/upow.h
++++ b/sysdeps/ieee754/dbl-64/upow.h
+@@ -34,7 +34,6 @@
+ /**/ INF = {{0x7ff00000, 0x00000000}}, /* INF */
+ /**/ nINF = {{0xfff00000, 0x00000000}}, /* -INF */
+ /**/ NaNQ = {{0x7ff80000, 0x00000000}}, /* NaNQ */
+-/**/ sqrt_2 = {{0x3ff6a09e, 0x667f3bcc}}, /* sqrt(2) */
+ /**/ ln2a = {{0x3fe62e42, 0xfefa3800}}, /* ln(2) 43 bits */
+ /**/ ln2b = {{0x3d2ef357, 0x93c76730}}, /* ln(2)-ln2a */
+ /**/ bigu = {{0x4297ffff, 0xfffffd2c}}, /* 1.5*2**42 -724*2**-10 */
+@@ -48,7 +47,6 @@
+ /**/ INF = {{0x00000000, 0x7ff00000}}, /* INF */
+ /**/ nINF = {{0x00000000, 0xfff00000}}, /* -INF */
+ /**/ NaNQ = {{0x00000000, 0x7ff80000}}, /* NaNQ */
+-/**/ sqrt_2 = {{0x667f3bcc, 0x3ff6a09e}}, /* sqrt(2) */
+ /**/ ln2a = {{0xfefa3800, 0x3fe62e42}}, /* ln(2) 43 bits */
+ /**/ ln2b = {{0x93c76730, 0x3d2ef357}}, /* ln(2)-ln2a */
+ /**/ bigu = {{0xfffffd2c, 0x4297ffff}}, /* 1.5*2**42 -724*2**-10 */
+diff --git a/sysdeps/ieee754/flt-32/e_log10f.c b/sysdeps/ieee754/flt-32/e_log10f.c
+index 96f0e81..1daeef7 100644
+--- a/sysdeps/ieee754/flt-32/e_log10f.c
++++ b/sysdeps/ieee754/flt-32/e_log10f.c
+@@ -22,12 +22,6 @@ ivln10 = 4.3429449201e-01, /* 0x3ede5bd9 */
+ log10_2hi = 3.0102920532e-01, /* 0x3e9a2080 */
+ log10_2lo = 7.9034151668e-07; /* 0x355427db */
+
+-#ifdef __STDC__
+-static const float zero = 0.0;
+-#else
+-static float zero = 0.0;
+-#endif
+-
+ #ifdef __STDC__
+ float __ieee754_log10f(float x)
+ #else
+diff --git a/sysdeps/ieee754/flt-32/s_cosf.c b/sysdeps/ieee754/flt-32/s_cosf.c
+index 864ab27..0affd40 100644
+--- a/sysdeps/ieee754/flt-32/s_cosf.c
++++ b/sysdeps/ieee754/flt-32/s_cosf.c
+@@ -21,12 +21,6 @@ static char rcsid[] = "$NetBSD: s_cosf.c,v 1.4 1995/05/10 20:47:03 jtc Exp $";
+ #include "math.h"
+ #include "math_private.h"
+
+-#ifdef __STDC__
+-static const float one=1.0;
+-#else
+-static float one=1.0;
+-#endif
+-
+ #ifdef __STDC__
+ float __cosf(float x)
+ #else
+diff --git a/sysdeps/ieee754/ldbl-128/e_lgammal_r.c b/sysdeps/ieee754/ldbl-128/e_lgammal_r.c
+index 500aacc..ab5a96e 100644
+--- a/sysdeps/ieee754/ldbl-128/e_lgammal_r.c
++++ b/sysdeps/ieee754/ldbl-128/e_lgammal_r.c
+@@ -82,7 +82,6 @@ DIAG_IGNORE_NEEDS_COMMENT (4.6, "-Woverflow");
+ static const long double PIL = 3.1415926535897932384626433832795028841972E0L;
+ static const long double MAXLGM = 1.0485738685148938358098967157129705071571E4928L;
+ static const long double one = 1.0L;
+-static const long double zero = 0.0L;
+ static const long double huge = 1.0e4000L;
+
+ /* log gamma(x) = ( x - 0.5 ) * log(x) - x + LS2PI + 1/x P(1/x^2)
+diff --git a/sysdeps/ieee754/ldbl-128/s_erfl.c b/sysdeps/ieee754/ldbl-128/s_erfl.c
+index fa4609f..08c80a3 100644
+--- a/sysdeps/ieee754/ldbl-128/s_erfl.c
++++ b/sysdeps/ieee754/ldbl-128/s_erfl.c
+@@ -140,7 +140,6 @@ deval (long double x, const long double *p, int n)
+ static long double
+ #endif
+ tiny = 1e-4931L,
+- half = 0.5L,
+ one = 1.0L,
+ two = 2.0L,
+ /* 2/sqrt(pi) - 1 */
+diff --git a/sysdeps/ieee754/ldbl-128/s_log1pl.c b/sysdeps/ieee754/ldbl-128/s_log1pl.c
+index ff759bc..9609550 100644
+--- a/sysdeps/ieee754/ldbl-128/s_log1pl.c
++++ b/sysdeps/ieee754/ldbl-128/s_log1pl.c
+@@ -117,7 +117,6 @@ static const long double C2 = 1.428606820309417232121458176568075500134E-6L;
+
+ static const long double sqrth = 0.7071067811865475244008443621048490392848L;
+ /* ln (2^16384 * (1 - 2^-113)) */
+-static const long double maxlog = 1.1356523406294143949491931077970764891253E4L;
+ static const long double zero = 0.0L;
+
+ long double
diff --git a/patches/glibc/2.13/105-misleading-indentation.patch b/patches/glibc/2.13/105-misleading-indentation.patch
new file mode 100644
index 0000000..1dd8d85
--- /dev/null
+++ b/patches/glibc/2.13/105-misleading-indentation.patch
@@ -0,0 +1,24 @@
+commit 976ef870542580cf5fed896c2c652b3e1a95f9da
+Author: Steve Ellcey <sellcey@mips.com>
+Date: Fri Dec 11 09:19:37 2015 -0800
+
+ Fix indentation.
+
+ * sysdeps/ieee754/flt-32/k_rem_pio2f.c (__kernel_rem_pio2f):
+ Fix indentation.
+
+diff --git a/sysdeps/ieee754/flt-32/k_rem_pio2f.c b/sysdeps/ieee754/flt-32/k_rem_pio2f.c
+index 0c7685c..392afdb 100644
+--- a/sysdeps/ieee754/flt-32/k_rem_pio2f.c
++++ b/sysdeps/ieee754/flt-32/k_rem_pio2f.c
+@@ -65,7 +65,9 @@ int __kernel_rem_pio2f(float *x, float *y, int e0, int nx, int prec, const int32
+
+ /* compute q[0],q[1],...q[jk] */
+ for (i=0;i<=jk;i++) {
+- for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; q[i] = fw;
++ for(j=0,fw=0.0;j<=jx;j++)
++ fw += x[j]*f[jx+i-j];
++ q[i] = fw;
+ }
+
+ jz = jk;
diff --git a/patches/glibc/2.13/106-dl-open-array-bounds.patch b/patches/glibc/2.13/106-dl-open-array-bounds.patch
new file mode 100644
index 0000000..bdb5c19
--- /dev/null
+++ b/patches/glibc/2.13/106-dl-open-array-bounds.patch
@@ -0,0 +1,27 @@
+commit 328c44c3670ebf6c1bd790acddce65a12998cd6c
+Author: Roland McGrath <roland@hack.frob.com>
+Date: Fri Apr 17 12:11:58 2015 -0700
+
+ Fuller check for invalid NSID in _dl_open.
+
+diff --git a/elf/dl-open.c b/elf/dl-open.c
+index 0dbe07f..2d0e082 100644
+--- a/elf/dl-open.c
++++ b/elf/dl-open.c
+@@ -619,8 +619,14 @@ no more namespaces available for dlmopen()"));
+ /* Never allow loading a DSO in a namespace which is empty. Such
+ direct placements is only causing problems. Also don't allow
+ loading into a namespace used for auditing. */
+- else if (__builtin_expect (nsid != LM_ID_BASE && nsid != __LM_ID_CALLER, 0)
+- && (GL(dl_ns)[nsid]._ns_nloaded == 0
++ else if ((nsid != LM_ID_BASE && nsid != __LM_ID_CALLER)
++ && ((nsid < 0 || nsid >= GL(dl_nns))
++ /* This prevents the [NSID] index expressions from being
++ evaluated, so the compiler won't think that we are
++ accessing an invalid index here in the !SHARED case where
++ DL_NNS is 1 and so any NSID != 0 is invalid. */
++ || DL_NNS == 1
++ || GL(dl_ns)[nsid]._ns_nloaded == 0
+ || GL(dl_ns)[nsid]._ns_loaded->l_auditing))
+ _dl_signal_error (EINVAL, file, NULL,
+ N_("invalid target namespace in dlmopen()"));
diff --git a/patches/glibc/ports-2.12.1/670-support-hard-float-eabi.patch b/patches/glibc/ports-2.12.1/670-support-hard-float-eabi.patch
new file mode 100644
index 0000000..3f2bc0f
--- /dev/null
+++ b/patches/glibc/ports-2.12.1/670-support-hard-float-eabi.patch
@@ -0,0 +1,22 @@
+diff -ur glibc-2.12.1/ports/sysdeps/arm/preconfigure glibc-2.12.1-patched/ports/sysdeps/arm/preconfigure
+--- glibc-2.12.1/ports/sysdeps/arm/preconfigure 2017-03-07 15:33:56.410265000 -0700
++++ glibc-2.12.1-patched/ports/sysdeps/arm/preconfigure 2017-03-07 15:34:42.016840000 -0700
+@@ -2,7 +2,7 @@
+ arm*)
+ base_machine=arm
+ case $config_os in
+- linux-gnueabi)
++ linux-gnueabi*)
+ machine=arm/eabi/$machine
+ ;;
+ *)
+diff -ur glibc-2.12.1/ports/sysdeps/arm/shlib-versions glibc-2.12.1-patched/ports/sysdeps/arm/shlib-versions
+--- glibc-2.12.1/ports/sysdeps/arm/shlib-versions 2017-03-07 15:33:56.439267000 -0700
++++ glibc-2.12.1-patched/ports/sysdeps/arm/shlib-versions 2017-03-07 15:34:42.018837000 -0700
+@@ -1,4 +1,4 @@
+-arm.*-.*-linux-gnueabi DEFAULT GLIBC_2.4
++arm.*-.*-linux-gnueabi.* DEFAULT GLIBC_2.4
+
+-arm.*-.*-linux-gnueabi ld=ld-linux.so.3
++arm.*-.*-linux-gnueabi.* ld=ld-linux.so.3
+ arm.*-.*-linux.* ld=ld-linux.so.2
diff --git a/patches/glibc/ports-2.13/670-support-hard-float-eabi.patch b/patches/glibc/ports-2.13/670-support-hard-float-eabi.patch
new file mode 100644
index 0000000..589f11e
--- /dev/null
+++ b/patches/glibc/ports-2.13/670-support-hard-float-eabi.patch
@@ -0,0 +1,22 @@
+diff -ur glibc-2.13/ports/sysdeps/arm/preconfigure glibc-2.13-patched/ports/sysdeps/arm/preconfigure
+--- glibc-2.13/ports/sysdeps/arm/preconfigure 2011-01-25 14:00:16.000000000 -0700
++++ glibc-2.13-patched/ports/sysdeps/arm/preconfigure 2017-03-07 15:36:50.310454000 -0700
+@@ -2,7 +2,7 @@
+ arm*)
+ base_machine=arm
+ case $config_os in
+- linux-gnueabi)
++ linux-gnueabi*)
+ machine=arm/eabi/$machine
+ if [ "${CFLAGS+set}" != "set" ]; then
+ CFLAGS="-g -O2"
+diff -ur glibc-2.13/ports/sysdeps/arm/shlib-versions glibc-2.13-patched/ports/sysdeps/arm/shlib-versions
+--- glibc-2.13/ports/sysdeps/arm/shlib-versions 2011-01-25 14:00:16.000000000 -0700
++++ glibc-2.13-patched/ports/sysdeps/arm/shlib-versions 2017-03-07 15:36:50.312457000 -0700
+@@ -1,4 +1,4 @@
+-arm.*-.*-linux-gnueabi DEFAULT GLIBC_2.4
++arm.*-.*-linux-gnueabi.* DEFAULT GLIBC_2.4
+
+-arm.*-.*-linux-gnueabi ld=ld-linux.so.3
++arm.*-.*-linux-gnueabi.* ld=ld-linux.so.3
+ arm.*-.*-linux.* ld=ld-linux.so.2
diff --git a/patches/mingw-w64/v2.0.7/100-mingw64-malloc.patch b/patches/mingw-w64/v2.0.7/100-mingw64-malloc.patch
new file mode 100644
index 0000000..d9d5a61
--- /dev/null
+++ b/patches/mingw-w64/v2.0.7/100-mingw64-malloc.patch
@@ -0,0 +1,27 @@
+diff -urpN mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_cfg.h mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_cfg.h
+--- mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_cfg.h 2017-03-10 16:20:09.000000000 -0800
++++ mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_cfg.h 2017-03-10 16:25:26.000000000 -0800
+@@ -26,7 +26,9 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#if defined(HAVE_MALLOC_H)
+ #include <malloc.h>
++#endif
+ #include <memory.h>
+ #include <stdarg.h>
+ #include <stdint.h>
+diff -urpN mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_typinfo.c mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_typinfo.c
+--- mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_typinfo.c 2017-03-10 16:20:09.000000000 -0800
++++ mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_typinfo.c 2017-03-10 16:25:49.000000000 -0800
+@@ -21,7 +21,10 @@
+ #include "genidl_cfg.h"
+ #include "genidl_typeinfo.h"
+ #include "genidl_typinfo.h"
++#if defined(HAVE_MALLOC_H)
+ #include <malloc.h>
++#endif
++#include <stdlib.h>
+ #include <string.h>
+ #include <memory.h>
+
diff --git a/patches/mingw-w64/v2.0.8/100-mingw64-malloc.patch b/patches/mingw-w64/v2.0.8/100-mingw64-malloc.patch
new file mode 100644
index 0000000..d9d5a61
--- /dev/null
+++ b/patches/mingw-w64/v2.0.8/100-mingw64-malloc.patch
@@ -0,0 +1,27 @@
+diff -urpN mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_cfg.h mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_cfg.h
+--- mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_cfg.h 2017-03-10 16:20:09.000000000 -0800
++++ mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_cfg.h 2017-03-10 16:25:26.000000000 -0800
+@@ -26,7 +26,9 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#if defined(HAVE_MALLOC_H)
+ #include <malloc.h>
++#endif
+ #include <memory.h>
+ #include <stdarg.h>
+ #include <stdint.h>
+diff -urpN mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_typinfo.c mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_typinfo.c
+--- mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_typinfo.c 2017-03-10 16:20:09.000000000 -0800
++++ mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_typinfo.c 2017-03-10 16:25:49.000000000 -0800
+@@ -21,7 +21,10 @@
+ #include "genidl_cfg.h"
+ #include "genidl_typeinfo.h"
+ #include "genidl_typinfo.h"
++#if defined(HAVE_MALLOC_H)
+ #include <malloc.h>
++#endif
++#include <stdlib.h>
+ #include <string.h>
+ #include <memory.h>
+
diff --git a/patches/mingw-w64/v2.0.9/100-mingw64-malloc.patch b/patches/mingw-w64/v2.0.9/100-mingw64-malloc.patch
new file mode 100644
index 0000000..d9d5a61
--- /dev/null
+++ b/patches/mingw-w64/v2.0.9/100-mingw64-malloc.patch
@@ -0,0 +1,27 @@
+diff -urpN mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_cfg.h mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_cfg.h
+--- mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_cfg.h 2017-03-10 16:20:09.000000000 -0800
++++ mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_cfg.h 2017-03-10 16:25:26.000000000 -0800
+@@ -26,7 +26,9 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#if defined(HAVE_MALLOC_H)
+ #include <malloc.h>
++#endif
+ #include <memory.h>
+ #include <stdarg.h>
+ #include <stdint.h>
+diff -urpN mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_typinfo.c mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_typinfo.c
+--- mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_typinfo.c 2017-03-10 16:20:09.000000000 -0800
++++ mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_typinfo.c 2017-03-10 16:25:49.000000000 -0800
+@@ -21,7 +21,10 @@
+ #include "genidl_cfg.h"
+ #include "genidl_typeinfo.h"
+ #include "genidl_typinfo.h"
++#if defined(HAVE_MALLOC_H)
+ #include <malloc.h>
++#endif
++#include <stdlib.h>
+ #include <string.h>
+ #include <memory.h>
+
diff --git a/patches/mingw-w64/v3.0.0/100-mingw64-malloc.patch b/patches/mingw-w64/v3.0.0/100-mingw64-malloc.patch
new file mode 100644
index 0000000..d9d5a61
--- /dev/null
+++ b/patches/mingw-w64/v3.0.0/100-mingw64-malloc.patch
@@ -0,0 +1,27 @@
+diff -urpN mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_cfg.h mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_cfg.h
+--- mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_cfg.h 2017-03-10 16:20:09.000000000 -0800
++++ mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_cfg.h 2017-03-10 16:25:26.000000000 -0800
+@@ -26,7 +26,9 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#if defined(HAVE_MALLOC_H)
+ #include <malloc.h>
++#endif
+ #include <memory.h>
+ #include <stdarg.h>
+ #include <stdint.h>
+diff -urpN mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_typinfo.c mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_typinfo.c
+--- mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_typinfo.c 2017-03-10 16:20:09.000000000 -0800
++++ mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_typinfo.c 2017-03-10 16:25:49.000000000 -0800
+@@ -21,7 +21,10 @@
+ #include "genidl_cfg.h"
+ #include "genidl_typeinfo.h"
+ #include "genidl_typinfo.h"
++#if defined(HAVE_MALLOC_H)
+ #include <malloc.h>
++#endif
++#include <stdlib.h>
+ #include <string.h>
+ #include <memory.h>
+
diff --git a/patches/mingw-w64/v3.1.0/100-mingw64-malloc.patch b/patches/mingw-w64/v3.1.0/100-mingw64-malloc.patch
new file mode 100644
index 0000000..d9d5a61
--- /dev/null
+++ b/patches/mingw-w64/v3.1.0/100-mingw64-malloc.patch
@@ -0,0 +1,27 @@
+diff -urpN mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_cfg.h mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_cfg.h
+--- mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_cfg.h 2017-03-10 16:20:09.000000000 -0800
++++ mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_cfg.h 2017-03-10 16:25:26.000000000 -0800
+@@ -26,7 +26,9 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#if defined(HAVE_MALLOC_H)
+ #include <malloc.h>
++#endif
+ #include <memory.h>
+ #include <stdarg.h>
+ #include <stdint.h>
+diff -urpN mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_typinfo.c mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_typinfo.c
+--- mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_typinfo.c 2017-03-10 16:20:09.000000000 -0800
++++ mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_typinfo.c 2017-03-10 16:25:49.000000000 -0800
+@@ -21,7 +21,10 @@
+ #include "genidl_cfg.h"
+ #include "genidl_typeinfo.h"
+ #include "genidl_typinfo.h"
++#if defined(HAVE_MALLOC_H)
+ #include <malloc.h>
++#endif
++#include <stdlib.h>
+ #include <string.h>
+ #include <memory.h>
+
diff --git a/patches/mingw-w64/v3.2.0/100-mingw64-malloc.patch b/patches/mingw-w64/v3.2.0/100-mingw64-malloc.patch
new file mode 100644
index 0000000..d9d5a61
--- /dev/null
+++ b/patches/mingw-w64/v3.2.0/100-mingw64-malloc.patch
@@ -0,0 +1,27 @@
+diff -urpN mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_cfg.h mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_cfg.h
+--- mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_cfg.h 2017-03-10 16:20:09.000000000 -0800
++++ mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_cfg.h 2017-03-10 16:25:26.000000000 -0800
+@@ -26,7 +26,9 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#if defined(HAVE_MALLOC_H)
+ #include <malloc.h>
++#endif
+ #include <memory.h>
+ #include <stdarg.h>
+ #include <stdint.h>
+diff -urpN mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_typinfo.c mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_typinfo.c
+--- mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_typinfo.c 2017-03-10 16:20:09.000000000 -0800
++++ mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_typinfo.c 2017-03-10 16:25:49.000000000 -0800
+@@ -21,7 +21,10 @@
+ #include "genidl_cfg.h"
+ #include "genidl_typeinfo.h"
+ #include "genidl_typinfo.h"
++#if defined(HAVE_MALLOC_H)
+ #include <malloc.h>
++#endif
++#include <stdlib.h>
+ #include <string.h>
+ #include <memory.h>
+
diff --git a/patches/mingw-w64/v3.3.0/100-mingw64-malloc.patch b/patches/mingw-w64/v3.3.0/100-mingw64-malloc.patch
new file mode 100644
index 0000000..d9d5a61
--- /dev/null
+++ b/patches/mingw-w64/v3.3.0/100-mingw64-malloc.patch
@@ -0,0 +1,27 @@
+diff -urpN mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_cfg.h mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_cfg.h
+--- mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_cfg.h 2017-03-10 16:20:09.000000000 -0800
++++ mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_cfg.h 2017-03-10 16:25:26.000000000 -0800
+@@ -26,7 +26,9 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#if defined(HAVE_MALLOC_H)
+ #include <malloc.h>
++#endif
+ #include <memory.h>
+ #include <stdarg.h>
+ #include <stdint.h>
+diff -urpN mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_typinfo.c mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_typinfo.c
+--- mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_typinfo.c 2017-03-10 16:20:09.000000000 -0800
++++ mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_typinfo.c 2017-03-10 16:25:49.000000000 -0800
+@@ -21,7 +21,10 @@
+ #include "genidl_cfg.h"
+ #include "genidl_typeinfo.h"
+ #include "genidl_typinfo.h"
++#if defined(HAVE_MALLOC_H)
+ #include <malloc.h>
++#endif
++#include <stdlib.h>
+ #include <string.h>
+ #include <memory.h>
+
diff --git a/patches/mingw-w64/v4.0.0/100-mingw64-malloc.patch b/patches/mingw-w64/v4.0.0/100-mingw64-malloc.patch
new file mode 100644
index 0000000..d9d5a61
--- /dev/null
+++ b/patches/mingw-w64/v4.0.0/100-mingw64-malloc.patch
@@ -0,0 +1,27 @@
+diff -urpN mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_cfg.h mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_cfg.h
+--- mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_cfg.h 2017-03-10 16:20:09.000000000 -0800
++++ mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_cfg.h 2017-03-10 16:25:26.000000000 -0800
+@@ -26,7 +26,9 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#if defined(HAVE_MALLOC_H)
+ #include <malloc.h>
++#endif
+ #include <memory.h>
+ #include <stdarg.h>
+ #include <stdint.h>
+diff -urpN mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_typinfo.c mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_typinfo.c
+--- mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_typinfo.c 2017-03-10 16:20:09.000000000 -0800
++++ mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_typinfo.c 2017-03-10 16:25:49.000000000 -0800
+@@ -21,7 +21,10 @@
+ #include "genidl_cfg.h"
+ #include "genidl_typeinfo.h"
+ #include "genidl_typinfo.h"
++#if defined(HAVE_MALLOC_H)
+ #include <malloc.h>
++#endif
++#include <stdlib.h>
+ #include <string.h>
+ #include <memory.h>
+
diff --git a/patches/mingw-w64/v4.0.1/100-mingw64-malloc.patch b/patches/mingw-w64/v4.0.1/100-mingw64-malloc.patch
new file mode 100644
index 0000000..d9d5a61
--- /dev/null
+++ b/patches/mingw-w64/v4.0.1/100-mingw64-malloc.patch
@@ -0,0 +1,27 @@
+diff -urpN mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_cfg.h mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_cfg.h
+--- mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_cfg.h 2017-03-10 16:20:09.000000000 -0800
++++ mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_cfg.h 2017-03-10 16:25:26.000000000 -0800
+@@ -26,7 +26,9 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#if defined(HAVE_MALLOC_H)
+ #include <malloc.h>
++#endif
+ #include <memory.h>
+ #include <stdarg.h>
+ #include <stdint.h>
+diff -urpN mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_typinfo.c mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_typinfo.c
+--- mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_typinfo.c 2017-03-10 16:20:09.000000000 -0800
++++ mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_typinfo.c 2017-03-10 16:25:49.000000000 -0800
+@@ -21,7 +21,10 @@
+ #include "genidl_cfg.h"
+ #include "genidl_typeinfo.h"
+ #include "genidl_typinfo.h"
++#if defined(HAVE_MALLOC_H)
+ #include <malloc.h>
++#endif
++#include <stdlib.h>
+ #include <string.h>
+ #include <memory.h>
+
diff --git a/patches/mingw-w64/v4.0.2/100-mingw64-malloc.patch b/patches/mingw-w64/v4.0.2/100-mingw64-malloc.patch
new file mode 100644
index 0000000..d9d5a61
--- /dev/null
+++ b/patches/mingw-w64/v4.0.2/100-mingw64-malloc.patch
@@ -0,0 +1,27 @@
+diff -urpN mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_cfg.h mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_cfg.h
+--- mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_cfg.h 2017-03-10 16:20:09.000000000 -0800
++++ mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_cfg.h 2017-03-10 16:25:26.000000000 -0800
+@@ -26,7 +26,9 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#if defined(HAVE_MALLOC_H)
+ #include <malloc.h>
++#endif
+ #include <memory.h>
+ #include <stdarg.h>
+ #include <stdint.h>
+diff -urpN mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_typinfo.c mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_typinfo.c
+--- mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_typinfo.c 2017-03-10 16:20:09.000000000 -0800
++++ mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_typinfo.c 2017-03-10 16:25:49.000000000 -0800
+@@ -21,7 +21,10 @@
+ #include "genidl_cfg.h"
+ #include "genidl_typeinfo.h"
+ #include "genidl_typinfo.h"
++#if defined(HAVE_MALLOC_H)
+ #include <malloc.h>
++#endif
++#include <stdlib.h>
+ #include <string.h>
+ #include <memory.h>
+
diff --git a/patches/mingw-w64/v4.0.4/100-mingw64-malloc.patch b/patches/mingw-w64/v4.0.4/100-mingw64-malloc.patch
new file mode 100644
index 0000000..d9d5a61
--- /dev/null
+++ b/patches/mingw-w64/v4.0.4/100-mingw64-malloc.patch
@@ -0,0 +1,27 @@
+diff -urpN mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_cfg.h mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_cfg.h
+--- mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_cfg.h 2017-03-10 16:20:09.000000000 -0800
++++ mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_cfg.h 2017-03-10 16:25:26.000000000 -0800
+@@ -26,7 +26,9 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#if defined(HAVE_MALLOC_H)
+ #include <malloc.h>
++#endif
+ #include <memory.h>
+ #include <stdarg.h>
+ #include <stdint.h>
+diff -urpN mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_typinfo.c mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_typinfo.c
+--- mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_typinfo.c 2017-03-10 16:20:09.000000000 -0800
++++ mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_typinfo.c 2017-03-10 16:25:49.000000000 -0800
+@@ -21,7 +21,10 @@
+ #include "genidl_cfg.h"
+ #include "genidl_typeinfo.h"
+ #include "genidl_typinfo.h"
++#if defined(HAVE_MALLOC_H)
+ #include <malloc.h>
++#endif
++#include <stdlib.h>
+ #include <string.h>
+ #include <memory.h>
+
diff --git a/patches/mingw-w64/v4.0.5/100-mingw64-malloc.patch b/patches/mingw-w64/v4.0.5/100-mingw64-malloc.patch
new file mode 100644
index 0000000..d9d5a61
--- /dev/null
+++ b/patches/mingw-w64/v4.0.5/100-mingw64-malloc.patch
@@ -0,0 +1,27 @@
+diff -urpN mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_cfg.h mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_cfg.h
+--- mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_cfg.h 2017-03-10 16:20:09.000000000 -0800
++++ mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_cfg.h 2017-03-10 16:25:26.000000000 -0800
+@@ -26,7 +26,9 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#if defined(HAVE_MALLOC_H)
+ #include <malloc.h>
++#endif
+ #include <memory.h>
+ #include <stdarg.h>
+ #include <stdint.h>
+diff -urpN mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_typinfo.c mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_typinfo.c
+--- mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_typinfo.c 2017-03-10 16:20:09.000000000 -0800
++++ mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_typinfo.c 2017-03-10 16:25:49.000000000 -0800
+@@ -21,7 +21,10 @@
+ #include "genidl_cfg.h"
+ #include "genidl_typeinfo.h"
+ #include "genidl_typinfo.h"
++#if defined(HAVE_MALLOC_H)
+ #include <malloc.h>
++#endif
++#include <stdlib.h>
+ #include <string.h>
+ #include <memory.h>
+
diff --git a/patches/mingw-w64/v4.0.6/100-mingw64-malloc.patch b/patches/mingw-w64/v4.0.6/100-mingw64-malloc.patch
new file mode 100644
index 0000000..d9d5a61
--- /dev/null
+++ b/patches/mingw-w64/v4.0.6/100-mingw64-malloc.patch
@@ -0,0 +1,27 @@
+diff -urpN mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_cfg.h mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_cfg.h
+--- mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_cfg.h 2017-03-10 16:20:09.000000000 -0800
++++ mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_cfg.h 2017-03-10 16:25:26.000000000 -0800
+@@ -26,7 +26,9 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#if defined(HAVE_MALLOC_H)
+ #include <malloc.h>
++#endif
+ #include <memory.h>
+ #include <stdarg.h>
+ #include <stdint.h>
+diff -urpN mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_typinfo.c mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_typinfo.c
+--- mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_typinfo.c 2017-03-10 16:20:09.000000000 -0800
++++ mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_typinfo.c 2017-03-10 16:25:49.000000000 -0800
+@@ -21,7 +21,10 @@
+ #include "genidl_cfg.h"
+ #include "genidl_typeinfo.h"
+ #include "genidl_typinfo.h"
++#if defined(HAVE_MALLOC_H)
+ #include <malloc.h>
++#endif
++#include <stdlib.h>
+ #include <string.h>
+ #include <memory.h>
+
diff --git a/patches/mingw-w64/v5.0.0/100-mingw64-malloc.patch b/patches/mingw-w64/v5.0.0/100-mingw64-malloc.patch
new file mode 100644
index 0000000..3d05b63
--- /dev/null
+++ b/patches/mingw-w64/v5.0.0/100-mingw64-malloc.patch
@@ -0,0 +1,55 @@
+diff -urpN mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_cfg.h mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_cfg.h
+--- mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_cfg.h 2017-03-10 16:20:09.000000000 -0800
++++ mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_cfg.h 2017-03-10 16:25:26.000000000 -0800
+@@ -26,7 +26,9 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#if defined(HAVE_MALLOC_H)
+ #include <malloc.h>
++#endif
+ #include <memory.h>
+ #include <stdarg.h>
+ #include <stdint.h>
+diff -urpN mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_typinfo.c mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_typinfo.c
+--- mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_typinfo.c 2017-03-10 16:20:09.000000000 -0800
++++ mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_typinfo.c 2017-03-10 16:25:49.000000000 -0800
+@@ -21,7 +21,10 @@
+ #include "genidl_cfg.h"
+ #include "genidl_typeinfo.h"
+ #include "genidl_typinfo.h"
++#if defined(HAVE_MALLOC_H)
+ #include <malloc.h>
++#endif
++#include <stdlib.h>
+ #include <string.h>
+ #include <memory.h>
+
+diff -urpN mingw-w64-v5.0.1.orig/mingw-w64-tools/widl/include/pathtools.h mingw-w64-v5.0.1/mingw-w64-tools/widl/include/pathtools.h
+--- mingw-w64-v5.0.1.orig/mingw-w64-tools/widl/include/pathtools.h 2017-03-10 16:20:09.000000000 -0800
++++ mingw-w64-v5.0.1/mingw-w64-tools/widl/include/pathtools.h 2017-03-10 16:26:21.000000000 -0800
+@@ -12,9 +12,8 @@
+ #define PATHTOOLS_H
+
+ #include <unistd.h>
+-#if defined(__APPLE__)
+ #include <stdlib.h>
+-#else
++#if defined(HAVE_MALLOC_H)
+ #include <malloc.h>
+ #endif
+ #include <stdio.h>
+diff -urpN mingw-w64-v5.0.1.orig/mingw-w64-tools/widl/src/pathtools.c mingw-w64-v5.0.1/mingw-w64-tools/widl/src/pathtools.c
+--- mingw-w64-v5.0.1.orig/mingw-w64-tools/widl/src/pathtools.c 2017-03-10 16:20:09.000000000 -0800
++++ mingw-w64-v5.0.1/mingw-w64-tools/widl/src/pathtools.c 2017-03-10 16:26:40.000000000 -0800
+@@ -8,9 +8,8 @@
+ .email: <mingw.android@gmail.com>.
+ */
+
+-#if defined(__APPLE__)
+ #include <stdlib.h>
+-#else
++#if defined(HAVE_MALLOC_H)
+ #include <malloc.h>
+ #endif
+ #include <limits.h>
diff --git a/patches/mingw-w64/v5.0.1/100-mingw64-malloc.patch b/patches/mingw-w64/v5.0.1/100-mingw64-malloc.patch
new file mode 100644
index 0000000..3d05b63
--- /dev/null
+++ b/patches/mingw-w64/v5.0.1/100-mingw64-malloc.patch
@@ -0,0 +1,55 @@
+diff -urpN mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_cfg.h mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_cfg.h
+--- mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_cfg.h 2017-03-10 16:20:09.000000000 -0800
++++ mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_cfg.h 2017-03-10 16:25:26.000000000 -0800
+@@ -26,7 +26,9 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#if defined(HAVE_MALLOC_H)
+ #include <malloc.h>
++#endif
+ #include <memory.h>
+ #include <stdarg.h>
+ #include <stdint.h>
+diff -urpN mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_typinfo.c mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_typinfo.c
+--- mingw-w64-v5.0.1.orig/mingw-w64-tools/genidl/src/genidl_typinfo.c 2017-03-10 16:20:09.000000000 -0800
++++ mingw-w64-v5.0.1/mingw-w64-tools/genidl/src/genidl_typinfo.c 2017-03-10 16:25:49.000000000 -0800
+@@ -21,7 +21,10 @@
+ #include "genidl_cfg.h"
+ #include "genidl_typeinfo.h"
+ #include "genidl_typinfo.h"
++#if defined(HAVE_MALLOC_H)
+ #include <malloc.h>
++#endif
++#include <stdlib.h>
+ #include <string.h>
+ #include <memory.h>
+
+diff -urpN mingw-w64-v5.0.1.orig/mingw-w64-tools/widl/include/pathtools.h mingw-w64-v5.0.1/mingw-w64-tools/widl/include/pathtools.h
+--- mingw-w64-v5.0.1.orig/mingw-w64-tools/widl/include/pathtools.h 2017-03-10 16:20:09.000000000 -0800
++++ mingw-w64-v5.0.1/mingw-w64-tools/widl/include/pathtools.h 2017-03-10 16:26:21.000000000 -0800
+@@ -12,9 +12,8 @@
+ #define PATHTOOLS_H
+
+ #include <unistd.h>
+-#if defined(__APPLE__)
+ #include <stdlib.h>
+-#else
++#if defined(HAVE_MALLOC_H)
+ #include <malloc.h>
+ #endif
+ #include <stdio.h>
+diff -urpN mingw-w64-v5.0.1.orig/mingw-w64-tools/widl/src/pathtools.c mingw-w64-v5.0.1/mingw-w64-tools/widl/src/pathtools.c
+--- mingw-w64-v5.0.1.orig/mingw-w64-tools/widl/src/pathtools.c 2017-03-10 16:20:09.000000000 -0800
++++ mingw-w64-v5.0.1/mingw-w64-tools/widl/src/pathtools.c 2017-03-10 16:26:40.000000000 -0800
+@@ -8,9 +8,8 @@
+ .email: <mingw.android@gmail.com>.
+ */
+
+-#if defined(__APPLE__)
+ #include <stdlib.h>
+-#else
++#if defined(HAVE_MALLOC_H)
+ #include <malloc.h>
+ #endif
+ #include <limits.h>
diff --git a/patches/uClibc-ng/1.0.20/600-prefer-multilib.patch b/patches/uClibc-ng/1.0.20/600-prefer-multilib.patch
new file mode 100644
index 0000000..4338f9f
--- /dev/null
+++ b/patches/uClibc-ng/1.0.20/600-prefer-multilib.patch
@@ -0,0 +1,46 @@
+diff -urpN uClibc-ng-1.0.22.orig/ldso/ldso/dl-elf.c uClibc-ng-1.0.22/ldso/ldso/dl-elf.c
+--- uClibc-ng-1.0.22.orig/ldso/ldso/dl-elf.c 2017-03-14 12:17:57.754063532 -0700
++++ uClibc-ng-1.0.22/ldso/ldso/dl-elf.c 2017-03-14 17:14:21.846398236 -0700
+@@ -307,6 +307,19 @@ struct elf_resolve *_dl_load_shared_libr
+ }
+ }
+ #endif
++
++#ifdef LDSO_MULTILIB_DIR
++ /* If multilib directory is selected, search it before falling back to
++ standard lib directories. */
++ _dl_if_debug_dprint("\tsearching multilib lib path list\n");
++ tpnt1 = search_for_named_library(libname, rflags,
++ UCLIBC_RUNTIME_PREFIX LDSO_MULTILIB_DIR ":"
++ UCLIBC_RUNTIME_PREFIX "usr" LDSO_MULTILIB_DIR,
++ rpnt, NULL);
++ if (tpnt1 != NULL)
++ return tpnt1;
++#endif
++
+ #if defined SHARED && defined __LDSO_SEARCH_INTERP_PATH__
+ /* Look for libraries wherever the shared library loader
+ * was installed */
+@@ -315,6 +328,7 @@ struct elf_resolve *_dl_load_shared_libr
+ if (tpnt1 != NULL)
+ return tpnt1;
+ #endif
++
+ /* Lastly, search the standard list of paths for the library.
+ This list must exactly match the list in uClibc/ldso/util/ldd.c */
+ _dl_if_debug_dprint("\tsearching full lib path list\n");
+diff -urpN uClibc-ng-1.0.22.orig/ldso/ldso/Makefile.in uClibc-ng-1.0.22/ldso/ldso/Makefile.in
+--- uClibc-ng-1.0.22.orig/ldso/ldso/Makefile.in 2017-03-14 12:17:57.754063532 -0700
++++ uClibc-ng-1.0.22/ldso/ldso/Makefile.in 2017-03-14 15:35:35.277104175 -0700
+@@ -34,6 +34,11 @@ CFLAGS-$(DODEBUG)-ldso/ldso := -O2 -g
+
+ CFLAGS-ldso.c := -DLDSO_ELFINTERP=\"$(TARGET_ARCH)/elfinterp.c\"
+
++# Search non-default multilib directories
++ifneq ($(MULTILIB_DIR),lib)
++CFLAGS-ldso.c += -DLDSO_MULTILIB_DIR=\"$(MULTILIB_DIR)\"
++endif
++
+ ifeq ($(TARGET_ARCH),arc)
+ CFLAGS-ldso.c += -mno-long-calls
+ endif
diff --git a/patches/uClibc-ng/1.0.21/600-prefer-multilib.patch b/patches/uClibc-ng/1.0.21/600-prefer-multilib.patch
new file mode 100644
index 0000000..4338f9f
--- /dev/null
+++ b/patches/uClibc-ng/1.0.21/600-prefer-multilib.patch
@@ -0,0 +1,46 @@
+diff -urpN uClibc-ng-1.0.22.orig/ldso/ldso/dl-elf.c uClibc-ng-1.0.22/ldso/ldso/dl-elf.c
+--- uClibc-ng-1.0.22.orig/ldso/ldso/dl-elf.c 2017-03-14 12:17:57.754063532 -0700
++++ uClibc-ng-1.0.22/ldso/ldso/dl-elf.c 2017-03-14 17:14:21.846398236 -0700
+@@ -307,6 +307,19 @@ struct elf_resolve *_dl_load_shared_libr
+ }
+ }
+ #endif
++
++#ifdef LDSO_MULTILIB_DIR
++ /* If multilib directory is selected, search it before falling back to
++ standard lib directories. */
++ _dl_if_debug_dprint("\tsearching multilib lib path list\n");
++ tpnt1 = search_for_named_library(libname, rflags,
++ UCLIBC_RUNTIME_PREFIX LDSO_MULTILIB_DIR ":"
++ UCLIBC_RUNTIME_PREFIX "usr" LDSO_MULTILIB_DIR,
++ rpnt, NULL);
++ if (tpnt1 != NULL)
++ return tpnt1;
++#endif
++
+ #if defined SHARED && defined __LDSO_SEARCH_INTERP_PATH__
+ /* Look for libraries wherever the shared library loader
+ * was installed */
+@@ -315,6 +328,7 @@ struct elf_resolve *_dl_load_shared_libr
+ if (tpnt1 != NULL)
+ return tpnt1;
+ #endif
++
+ /* Lastly, search the standard list of paths for the library.
+ This list must exactly match the list in uClibc/ldso/util/ldd.c */
+ _dl_if_debug_dprint("\tsearching full lib path list\n");
+diff -urpN uClibc-ng-1.0.22.orig/ldso/ldso/Makefile.in uClibc-ng-1.0.22/ldso/ldso/Makefile.in
+--- uClibc-ng-1.0.22.orig/ldso/ldso/Makefile.in 2017-03-14 12:17:57.754063532 -0700
++++ uClibc-ng-1.0.22/ldso/ldso/Makefile.in 2017-03-14 15:35:35.277104175 -0700
+@@ -34,6 +34,11 @@ CFLAGS-$(DODEBUG)-ldso/ldso := -O2 -g
+
+ CFLAGS-ldso.c := -DLDSO_ELFINTERP=\"$(TARGET_ARCH)/elfinterp.c\"
+
++# Search non-default multilib directories
++ifneq ($(MULTILIB_DIR),lib)
++CFLAGS-ldso.c += -DLDSO_MULTILIB_DIR=\"$(MULTILIB_DIR)\"
++endif
++
+ ifeq ($(TARGET_ARCH),arc)
+ CFLAGS-ldso.c += -mno-long-calls
+ endif
diff --git a/patches/uClibc-ng/1.0.22/600-prefer-multilib.patch b/patches/uClibc-ng/1.0.22/600-prefer-multilib.patch
new file mode 100644
index 0000000..4338f9f
--- /dev/null
+++ b/patches/uClibc-ng/1.0.22/600-prefer-multilib.patch
@@ -0,0 +1,46 @@
+diff -urpN uClibc-ng-1.0.22.orig/ldso/ldso/dl-elf.c uClibc-ng-1.0.22/ldso/ldso/dl-elf.c
+--- uClibc-ng-1.0.22.orig/ldso/ldso/dl-elf.c 2017-03-14 12:17:57.754063532 -0700
++++ uClibc-ng-1.0.22/ldso/ldso/dl-elf.c 2017-03-14 17:14:21.846398236 -0700
+@@ -307,6 +307,19 @@ struct elf_resolve *_dl_load_shared_libr
+ }
+ }
+ #endif
++
++#ifdef LDSO_MULTILIB_DIR
++ /* If multilib directory is selected, search it before falling back to
++ standard lib directories. */
++ _dl_if_debug_dprint("\tsearching multilib lib path list\n");
++ tpnt1 = search_for_named_library(libname, rflags,
++ UCLIBC_RUNTIME_PREFIX LDSO_MULTILIB_DIR ":"
++ UCLIBC_RUNTIME_PREFIX "usr" LDSO_MULTILIB_DIR,
++ rpnt, NULL);
++ if (tpnt1 != NULL)
++ return tpnt1;
++#endif
++
+ #if defined SHARED && defined __LDSO_SEARCH_INTERP_PATH__
+ /* Look for libraries wherever the shared library loader
+ * was installed */
+@@ -315,6 +328,7 @@ struct elf_resolve *_dl_load_shared_libr
+ if (tpnt1 != NULL)
+ return tpnt1;
+ #endif
++
+ /* Lastly, search the standard list of paths for the library.
+ This list must exactly match the list in uClibc/ldso/util/ldd.c */
+ _dl_if_debug_dprint("\tsearching full lib path list\n");
+diff -urpN uClibc-ng-1.0.22.orig/ldso/ldso/Makefile.in uClibc-ng-1.0.22/ldso/ldso/Makefile.in
+--- uClibc-ng-1.0.22.orig/ldso/ldso/Makefile.in 2017-03-14 12:17:57.754063532 -0700
++++ uClibc-ng-1.0.22/ldso/ldso/Makefile.in 2017-03-14 15:35:35.277104175 -0700
+@@ -34,6 +34,11 @@ CFLAGS-$(DODEBUG)-ldso/ldso := -O2 -g
+
+ CFLAGS-ldso.c := -DLDSO_ELFINTERP=\"$(TARGET_ARCH)/elfinterp.c\"
+
++# Search non-default multilib directories
++ifneq ($(MULTILIB_DIR),lib)
++CFLAGS-ldso.c += -DLDSO_MULTILIB_DIR=\"$(MULTILIB_DIR)\"
++endif
++
+ ifeq ($(TARGET_ARCH),arc)
+ CFLAGS-ldso.c += -mno-long-calls
+ endif
diff --git a/patches/uClibc/0.9.33.2/600-prefer-multilib.patch b/patches/uClibc/0.9.33.2/600-prefer-multilib.patch
new file mode 100644
index 0000000..677c599
--- /dev/null
+++ b/patches/uClibc/0.9.33.2/600-prefer-multilib.patch
@@ -0,0 +1,38 @@
+diff -urpN uClibc-0.9.33.2.orig/ldso/ldso/dl-elf.c uClibc-0.9.33.2/ldso/ldso/dl-elf.c
+--- uClibc-0.9.33.2.orig/ldso/ldso/dl-elf.c 2017-03-14 23:40:57.527113741 -0700
++++ uClibc-0.9.33.2/ldso/ldso/dl-elf.c 2017-03-14 23:42:19.308005691 -0700
+@@ -284,6 +284,19 @@ struct elf_resolve *_dl_load_shared_libr
+ }
+ }
+ #endif
++
++#ifdef LDSO_MULTILIB_DIR
++ /* If multilib directory is selected, search it before falling back to
++ standard lib directories. */
++ _dl_if_debug_dprint("\tsearching multilib lib path list\n");
++ tpnt1 = search_for_named_library(libname, rflags,
++ UCLIBC_RUNTIME_PREFIX LDSO_MULTILIB_DIR ":"
++ UCLIBC_RUNTIME_PREFIX "usr" LDSO_MULTILIB_DIR,
++ rpnt);
++ if (tpnt1 != NULL)
++ return tpnt1;
++#endif
++
+ #if defined SHARED && defined __LDSO_SEARCH_INTERP_PATH__
+ /* Look for libraries wherever the shared library loader
+ * was installed */
+diff -urpN uClibc-0.9.33.2.orig/ldso/ldso/Makefile.in uClibc-0.9.33.2/ldso/ldso/Makefile.in
+--- uClibc-0.9.33.2.orig/ldso/ldso/Makefile.in 2017-03-14 23:40:57.527113741 -0700
++++ uClibc-0.9.33.2/ldso/ldso/Makefile.in 2017-03-14 23:41:45.215634328 -0700
+@@ -30,6 +30,11 @@ CFLAGS-ldso/ldso/$(TARGET_ARCH)/ := $(CF
+
+ CFLAGS-ldso.c := -DLDSO_ELFINTERP=\"$(TARGET_ARCH)/elfinterp.c\" $(CFLAGS-ldso)
+
++# Search non-default multilib directories
++ifneq ($(MULTILIB_DIR),lib)
++CFLAGS-ldso.c += -DLDSO_MULTILIB_DIR=\"$(MULTILIB_DIR)\"
++endif
++
+ LDFLAGS-$(UCLIBC_FORMAT_DSBT_ELF)-$(UCLIBC_LDSO_NAME).so := -Wl,--dsbt-index=1
+ ifneq ($(SUPPORT_LD_DEBUG),y)
+ LDFLAGS-$(UCLIBC_LDSO_NAME).so := $(LDFLAGS)
diff --git a/patches/uClibc/0.9.33.2/998-dlopen-static.patch b/patches/uClibc/0.9.33.2/998-dlopen-static.patch
new file mode 100644
index 0000000..9d2fa55
--- /dev/null
+++ b/patches/uClibc/0.9.33.2/998-dlopen-static.patch
@@ -0,0 +1,56 @@
+From 231e4a9b4b972662a6832f714a05525a3754892d Mon Sep 17 00:00:00 2001
+From: Filippo Arcidiacono <filippo.arcidiacono@st.com>
+Date: Thu, 9 May 2013 09:04:20 +0200
+Subject: libdl: fix dlopen implementation from statically linked application
+
+Calling dlopen from statically linked application is actually broken,
+because _dl_find_hash enters into an infinite loop when trying to
+resolve symbols. In this case it doesn't need to extend the global
+scope, it is readyto be used as it is, because _dl_loaded_modules already points
+to the dlopened library.
+
+The patch also fixesi a typo in __LDSO_LD_LIBRARY_PATH__ macro, that was
+preventing to get the actual value of the LD_LIBRARY_PATH.
+
+Signed-off-by: Filippo Arcidiacono <filippo.arcidiacono@st.com>
+Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
+---
+ ldso/libdl/libdl.c | 11 +++++++++--
+ 1 file changed, 9 insertions(+), 2 deletions(-)
+
+diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c
+index 4630a59..3a78696 100644
+--- a/ldso/libdl/libdl.c
++++ b/ldso/libdl/libdl.c
+@@ -374,7 +374,7 @@ static void *do_dlopen(const char *libname, int flag, ElfW(Addr) from)
+ if (getenv("LD_BIND_NOW"))
+ now_flag = RTLD_NOW;
+
+-#if !defined SHARED && defined __LDSO_LIBRARY_PATH__
++#if !defined SHARED && defined __LDSO_LD_LIBRARY_PATH__
+ /* When statically linked, the _dl_library_path is not yet initialized */
+ _dl_library_path = getenv("LD_LIBRARY_PATH");
+ #endif
+@@ -541,11 +541,18 @@ static void *do_dlopen(const char *libname, int flag, ElfW(Addr) from)
+ * to the GOT tables. We need to do this in reverse order so that COPY
+ * directives work correctly */
+
+- /* Get the tail of the list */
++#ifdef SHARED
++ /*
++ * Get the tail of the list.
++ * In the static case doesn't need to extend the global scope, it is
++ * ready to be used as it is, because _dl_loaded_modules already points
++ * to the dlopened library.
++ */
+ for (ls = &_dl_loaded_modules->symbol_scope; ls && ls->next; ls = ls->next);
+
+ /* Extend the global scope by adding the local scope of the dlopened DSO. */
+ ls->next = &dyn_chain->dyn->symbol_scope;
++#endif
+ #ifdef __mips__
+ /*
+ * Relocation of the GOT entries for MIPS have to be done
+--
+cgit v0.12
+
diff --git a/samples/arm-multilib-linux-uclibcgnueabi/crosstool.config b/samples/arm-multilib-linux-uclibcgnueabi/crosstool.config
index e01942d..00ac47b 100644
--- a/samples/arm-multilib-linux-uclibcgnueabi/crosstool.config
+++ b/samples/arm-multilib-linux-uclibcgnueabi/crosstool.config
@@ -1,8 +1,9 @@
-CT_ARCH_FLOAT_SW=y
CT_ARCH_arm=y
CT_MULTILIB=y
+CT_ARCH_FLOAT_SW=y
CT_TARGET_VENDOR="multilib"
CT_KERNEL_linux=y
+# CT_SHARED_LIBS is not set
CT_BINUTILS_LINKER_LD_GOLD=y
CT_BINUTILS_GOLD_THREADS=y
CT_BINUTILS_LD_WRAPPER=y
diff --git a/samples/sh4-multilib-linux-gnu/crosstool.config b/samples/sh4-multilib-linux-gnu/crosstool.config
index e8c40f4..56af7bf 100644
--- a/samples/sh4-multilib-linux-gnu/crosstool.config
+++ b/samples/sh4-multilib-linux-gnu/crosstool.config
@@ -3,7 +3,6 @@ CT_ARCH_SH_SH4=y
CT_TARGET_VENDOR="multilib"
CT_KERNEL_linux=y
CT_BINUTILS_PLUGINS=y
-CT_CC_GCC_V_4_9_4=y
CT_CC_GCC_MULTILIB_LIST="m4,m4a"
CT_CC_LANG_CXX=y
CT_DEBUG_gdb=y
diff --git a/samples/sh4-unknown-linux-gnu/crosstool.config b/samples/sh4-unknown-linux-gnu/crosstool.config
index ba17f06..0972f31 100644
--- a/samples/sh4-unknown-linux-gnu/crosstool.config
+++ b/samples/sh4-unknown-linux-gnu/crosstool.config
@@ -2,7 +2,6 @@ CT_ARCH_sh=y
CT_ARCH_SH_SH4=y
CT_KERNEL_linux=y
CT_BINUTILS_PLUGINS=y
-CT_CC_GCC_V_4_9_4=y
CT_CC_LANG_CXX=y
CT_DEBUG_gdb=y
# CT_GDB_CROSS_PYTHON is not set
diff --git a/scripts/build/cc/100-gcc.sh b/scripts/build/cc/100-gcc.sh
index 56517d3..e3ae783 100644
--- a/scripts/build/cc/100-gcc.sh
+++ b/scripts/build/cc/100-gcc.sh
@@ -129,6 +129,40 @@ cc_gcc_classify_opt() {
echo "unknown"
}
+evaluate_multilib_cflags()
+{
+ local multi_dir multi_os_dir multi_os_dir_gcc multi_root multi_flags multi_index multi_count
+ local mdir mdir_os dirtop
+ local f
+
+ for arg in "$@"; do
+ eval "${arg// /\\ }"
+ done
+
+ mdir="lib/${multi_dir}"
+ mdir_os="lib/${multi_os_dir_gcc}"
+ CT_SanitizeVarDir mdir mdir_os
+ CT_DoLog EXTRA " '${multi_flags}' --> ${mdir} (gcc) ${mdir_os} (os)"
+ for f in ${multi_flags}; do
+ eval ml_`cc_gcc_classify_opt ${f}`=seen
+ done
+ if [ "${CT_DEMULTILIB}" = "y" ]; then
+ case "${mdir_os}" in
+ lib/*)
+ ;;
+ *)
+ dirtop="${mdir_os%%/*}"
+ if [ ! -e "${multi_root}/${mdir_os}" ]; then
+ CT_DoExecLog ALL ln -sfv lib "${multi_root}/${mdir_os}"
+ fi
+ if [ ! -e "${multi_root}/usr/${mdir_os}" ]; then
+ CT_DoExecLog ALL ln -sfv lib "${multi_root}/usr/${mdir_os}"
+ fi
+ ;;
+ esac
+ fi
+}
+
#------------------------------------------------------------------------------
# This function lists the multilibs configured in the compiler (even if multilib
# is disabled - so that it lists the default GCC/OS directory, which may differ
@@ -151,9 +185,11 @@ cc_gcc_classify_opt() {
# work, but 'gcc -mabi=32 -mabi=n32' produces an internal error in ld. Thus we do
# not supply target's CFLAGS in multilib builds - and after compiling pass-1 gcc,
# attempt to determine which CFLAGS need to be filtered out.
+#
+# 3. If "demultilibing" is in effect, create top-level directories for any
+# multilibs not in lib/ as symlinks to lib.
cc_gcc_multilib_housekeeping() {
local cc host
- local flags osdir dir multilibs i f
local multilib_defaults
local suffix sysroot base lnk
local ml_arch ml_abi ml_cpu ml_tune ml_fpu ml_float ml_endian ml_mode ml_unknown ml
@@ -175,25 +211,7 @@ cc_gcc_multilib_housekeeping() {
multilib_defaults=( $( cc_gcc_get_spec multilib_defaults "${cc}" | \
sed 's/\(^\|[[:space:]]\+\)\([^[:space:]]\)/ -\2/g' ) )
CT_DoLog EXTRA "gcc default flags: '${multilib_defaults}'"
-
- multilibs=( $( "${cc}" -print-multi-lib ) )
- if [ ${#multilibs[@]} -ne 0 ]; then
- CT_DoLog EXTRA "gcc configured with these multilibs (including the default):"
- for i in "${multilibs[@]}"; do
- dir="lib/${i%%;*}"
- flags="${i#*;}"
- flags=${flags//@/ -}
- flags=$( echo ${flags} )
- osdir="lib/"$( "${cc}" -print-multi-os-directory ${flags} )
- CT_SanitizeVarDir dir osdir
- CT_DoLog EXTRA " '${flags}' --> ${dir} (gcc) ${osdir} (os)"
- for f in ${flags}; do
- eval ml_`cc_gcc_classify_opt ${f}`=seen
- done
- done
- else
- CT_DoLog WARN "no multilib configuration: GCC unusable?"
- fi
+ CT_IterateMultilibs evaluate_multilib_cflags evaluate_cflags
# Filtering out some of the options provided in CT-NG config. Then *prepend*
# them to CT_TARGET_CFLAGS, like scripts/crosstool-NG.sh does. Zero out
@@ -789,8 +807,8 @@ do_gcc_for_build() {
}
gcc_movelibs() {
- local multi_flags multi_dir multi_os_dir multi_root multi_index multi_count
- local gcc_dir
+ local multi_flags multi_dir multi_os_dir multi_os_dir_gcc multi_root multi_index multi_count
+ local gcc_dir dst_dir
for arg in "$@"; do
eval "${arg// /\\ }"
@@ -803,6 +821,15 @@ gcc_movelibs() {
# GCC didn't install anything outside of sysroot
return
fi
+ # Depending on the selected libc, we may or may not have the ${multi_os_dir_gcc}
+ # created by libc installation. If we do, use it. If we don't, use ${multi_os_dir}
+ # to avoid creating an otherwise empty directory.
+ dst_dir="${multi_root}/lib/${multi_os_dir_gcc}"
+ if [ ! -d "${dst_dir}" ]; then
+ dst_dir="${multi_root}/lib/${multi_os_dir}"
+ fi
+ CT_SanitizeVarDir dst_dir gcc_dir
+
ls "${gcc_dir}" | while read f; do
case "${f}" in
*.ld)
@@ -812,8 +839,8 @@ gcc_movelibs() {
;;
esac
if [ -f "${gcc_dir}/${f}" ]; then
- CT_DoExecLog ALL mkdir -p "${multi_root}/lib/${multi_os_dir}"
- CT_DoExecLog ALL mv "${gcc_dir}/${f}" "${multi_root}/lib/${multi_os_dir}/${f}"
+ CT_DoExecLog ALL mkdir -p "${dst_dir}"
+ CT_DoExecLog ALL mv "${gcc_dir}/${f}" "${dst_dir}/${f}"
fi
done
}
diff --git a/scripts/build/companion_tools/050-make.sh b/scripts/build/companion_tools/050-make.sh
index 44487c1..76b24aa 100644
--- a/scripts/build/companion_tools/050-make.sh
+++ b/scripts/build/companion_tools/050-make.sh
@@ -46,11 +46,16 @@ do_make_backend() {
local prefix
local cflags
local ldflags
+ local -a extra_config
for arg in "$@"; do
eval "${arg// /\\ }"
done
+ if [ "${host}" != "${CT_BUILD}" ]; then
+ extra_config+=( --without-guile )
+ fi
+
CT_DoLog EXTRA "Configuring make"
CT_DoExecLog CFG \
CFLAGS="${cflags}" \
@@ -58,7 +63,8 @@ do_make_backend() {
${CONFIG_SHELL} \
"${CT_SRC_DIR}/make-${CT_MAKE_VERSION}/configure" \
--host="${host}" \
- --prefix="${prefix}"
+ --prefix="${prefix}" \
+ "${extra_config[@]}"
CT_DoLog EXTRA "Building make"
CT_DoExecLog ALL make
diff --git a/scripts/build/internals.sh b/scripts/build/internals.sh
index 95fb72b..a1c9b55 100644
--- a/scripts/build/internals.sh
+++ b/scripts/build/internals.sh
@@ -1,5 +1,27 @@
# This file contains crosstool-NG internal steps
+create_ldso_conf()
+{
+ local multi_dir multi_os_dir multi_os_dir_gcc multi_root multi_flags multi_index multi_count multi_target
+ local b d
+
+ for arg in "$@"; do
+ eval "${arg// /\\ }"
+ done
+
+ CT_DoExecLog ALL mkdir -p "${multi_root}/etc"
+ for b in /lib /usr/lib /usr/local/lib; do
+ d="${b}/${multi_os_dir}"
+ CT_SanitizeVarDir d
+ echo "${d}" >> "${multi_root}/etc/ld.so.conf"
+ if [ "${multi_os_dir}" != "${multi_os_dir_gcc}" ]; then
+ d="${b}/${multi_os_dir_gcc}"
+ CT_SanitizeVarDir d
+ echo "${d}" >> "${multi_root}/etc/ld.so.conf"
+ fi
+ done
+}
+
# This step is called once all components were built, to remove
# un-wanted files, to add tuple aliases, and to add the final
# crosstool-NG-provided files.
@@ -10,7 +32,14 @@ do_finish() {
local gcc_version
local exe_suffix
- CT_DoStep INFO "Cleaning-up the toolchain's directory"
+ CT_DoStep INFO "Finalizing the toolchain's directory"
+
+ if [ "${CT_SHARED_LIBS}" = "y" ]; then
+ # Create /etc/ld.so.conf
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-create-ldso"
+ CT_IterateMultilibs create_ldso_conf create-ldso
+ CT_Popd
+ fi
if [ "${CT_STRIP_HOST_TOOLCHAIN_EXECUTABLES}" = "y" ]; then
case "$CT_HOST" in
@@ -103,25 +132,8 @@ do_finish() {
# Create the aliases to the target tools
CT_DoLog EXTRA "Creating toolchain aliases"
- CT_Pushd "${CT_PREFIX_DIR}/bin"
- for t in "${CT_TARGET}-"*; do
- if [ -n "${CT_TARGET_ALIAS}" ]; then
- _t=$(echo "$t" |sed -r -e 's/^'"${CT_TARGET}"'-/'"${CT_TARGET_ALIAS}"'-/;')
- CT_DoExecLog ALL ln -sfv "${t}" "${_t}"
- fi
- if [ -n "${CT_TARGET_ALIAS_SED_EXPR}" ]; then
- _t=$(echo "$t" |sed -r -e "${CT_TARGET_ALIAS_SED_EXPR}")
- if [ "${_t}" = "${t}" ]; then
- CT_DoLog WARN "The sed expression '${CT_TARGET_ALIAS_SED_EXPR}' has no effect on '${t}'"
- else
- CT_DoExecLog ALL ln -sfv "${t}" "${_t}"
- fi
- fi
- done
- CT_Popd
-
- CT_DoLog EXTRA "Removing access to the build system tools"
- CT_DoExecLog DEBUG rm -rf "${CT_PREFIX_DIR}/buildtools"
+ CT_SymlinkTools "${CT_PREFIX_DIR}/bin" "${CT_PREFIX_DIR}/bin" \
+ "${CT_TARGET_ALIAS}" "${CT_TARGET_ALIAS_SED_EXPR}"
# Remove the generated documentation files
if [ "${CT_REMOVE_DOCS}" = "y" ]; then
diff --git a/scripts/build/libc/glibc.sh b/scripts/build/libc/glibc.sh
index 569183a..a630633 100644
--- a/scripts/build/libc/glibc.sh
+++ b/scripts/build/libc/glibc.sh
@@ -297,6 +297,8 @@ do_libc_backend_once() {
# or even after they get installed...
echo "ac_cv_path_BASH_SHELL=/bin/bash" >>config.cache
+ CT_SymlinkToolsMultilib
+
# Configure with --prefix the way we want it on the target...
# There are a whole lot of settings here. You'll probably want
# to read up on what they all mean, and customize a bit, possibly
diff --git a/scripts/build/libc/musl.sh b/scripts/build/libc/musl.sh
index 4ccb84c..5a53fd0 100644
--- a/scripts/build/libc/musl.sh
+++ b/scripts/build/libc/musl.sh
@@ -29,7 +29,9 @@ do_libc() {
}
do_libc_post_cc() {
- :
+ # MUSL creates dynamic linker symlink with absolute path - which works on the
+ # target but not on the host. We want our cross-ldd tool to work.
+ CT_MultilibFixupLDSO
}
do_libc_backend() {
@@ -102,6 +104,8 @@ do_libc_backend_once() {
extra_config+=( "--includedir=/usr/include/${hdr_install_subdir}" )
fi
+ CT_SymlinkToolsMultilib
+
# NOTE: musl handles the build/host/target a little bit differently
# then one would expect:
# build : not used
diff --git a/scripts/build/libc/uClibc.sh b/scripts/build/libc/uClibc.sh
index fcabee8..9f1eb37 100644
--- a/scripts/build/libc/uClibc.sh
+++ b/scripts/build/libc/uClibc.sh
@@ -453,51 +453,5 @@ do_libc_post_cc() {
# file in /lib. Thus, need to do this after all the variants are built.
# Moreover, need to do this after the final compiler is built: on targets
# that use elf2flt, the core compilers cannot find ld when running elf2flt.
- CT_DoStep INFO "Checking dynamic linker symlinks"
- CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-post_cc"
- echo "int main(void) { return 0; }" > test-ldso.c
- CT_IterateMultilibs do_libc_ldso_fixup ldso_fixup
- CT_Popd
- CT_EndStep
-}
-
-do_libc_ldso_fixup() {
- local multi_dir multi_os_dir multi_root multi_flags multi_index multi_count
- local binary
- local ldso ldso_f ldso_d multilib_dir
-
- for arg in "$@"; do
- eval "${arg// /\\ }"
- done
-
- CT_DoLog EXTRA "Checking dynamic linker for multilib '${multi_flags}'"
-
- multilib_dir="/lib/${multi_os_dir}"
- CT_SanitizeVarDir multilib_dir
-
- CT_DoExecLog ALL "${CT_TARGET}-${CT_CC}" -o test-ldso ../test-ldso.c ${multi_flags}
- if [ -r "test-ldso.gdb" ]; then
- binary="test-ldso.gdb"
- else
- binary="test-ldso"
- fi
- if ${CT_TARGET}-readelf -Wl "${binary}" | grep -q 'Requesting program interpreter: '; then
- ldso=$( ${CT_TARGET}-readelf -Wl "${binary}" | \
- grep 'Requesting program interpreter: ' | \
- sed -e 's,.*: ,,' -e 's,\].*,,' )
- fi
- CT_DoLog DEBUG "Detected dynamic linker for multilib '${multi_flags}': '${ldso}'"
-
- ldso_d="${ldso%/ld*.so.*}"
- ldso_f="${ldso##*/}"
- # Create symlink if GCC produced an executable, dynamically linked, it was requesting
- # a linker not in the current directory, and there is no such file in the expected
- # ldso dir.
- if [ -n "${ldso}" -a "${ldso_d}" != "${multilib_dir}" -a ! -r "${multi_root}${ldso}" ]; then
- # Convert ldso_d to "how many levels we need to go up" and remove
- # leading slash.
- ldso_d=$( echo "${ldso_d#/}" | sed 's,[^/]\+,..,g' )
- CT_DoExecLog ALL ln -sf "${ldso_d}${multilib_dir}/${ldso_f}" \
- "${multi_root}${ldso}"
- fi
+ CT_MultilibFixupLDSO
}
diff --git a/scripts/functions b/scripts/functions
index 969e9bf..ab141d5 100644
--- a/scripts/functions
+++ b/scripts/functions
@@ -1750,15 +1750,156 @@ CT_IterateMultilibs() {
dir_postfix=_${multi_dir//\//_}
dir_postfix=${dir_postfix%_.}
CT_mkdir_pushd "${prefix}${dir_postfix}"
- $func multi_dir="${multi_dir}" \
- multi_os_dir="${multi_os_dir}" \
- multi_flags="${multi_flags}" \
- multi_root="${multi_root}" \
- multi_target="${multi_target}" \
- multi_index="${multi_index}" \
- multi_count="${#multilibs[@]}" \
+ $func multi_dir="${multi_dir}" \
+ multi_os_dir="${multi_os_dir}" \
+ multi_os_dir_gcc="${multi_os_dir_gcc}" \
+ multi_flags="${multi_flags}" \
+ multi_root="${multi_root}" \
+ multi_target="${multi_target}" \
+ multi_index="${multi_index}" \
+ multi_count="${#multilibs[@]}" \
"$@"
CT_Popd
multi_index=$((multi_index+1))
done
}
+
+# Create symbolic links in buildtools for binutils using a different
+# target name.
+# Usage:
+# CT_SymlinkTools BIN-DIR SRC-DIR NEW-PREFIX SED-EXPR
+CT_SymlinkTools()
+{
+ local bindir="$1"
+ local srcdir="$2"
+ local newpfx="$3"
+ local sedexpr="$4"
+ local dirpfx
+ local t _t
+
+ # if bindir==srcdir, create symlinks just with the filename
+ if [ "${bindir}" != "${srcdir}" ]; then
+ dirpfx="${srcdir}/"
+ fi
+
+ CT_Pushd "${srcdir}"
+ for t in "${CT_TARGET}-"*; do
+ if [ -n "${newpfx}" -a "${newpfx}" != "${CT_TARGET}" ]; then
+ _t="${newpfx}-${t#${CT_TARGET}-}"
+ CT_DoExecLog ALL ln -sfv "${dirpfx}${t}" "${bindir}/${_t}"
+ fi
+ if [ -n "${sedexpr}" ]; then
+ _t=$( echo "${t}" | sed -r -e "${sedexpr}" )
+ if [ "${_t}" = "${t}" ]; then
+ CT_DoLog WARN "The sed expression '${sedexpr}' has no effect on '${t}'"
+ else
+ CT_DoExecLog ALL ln -sfv "${dirpfx}${t}" "${bindir}/${_t}"
+ fi
+ fi
+ done
+ CT_Popd
+}
+
+# Create symbolic links for multilib iterator. Expects ${multi_target}
+# variable to indicate the desired triplet for the tools.
+CT_SymlinkToolsMultilib()
+{
+ # Make configure detect ${target}-tool binaries even if it is different
+ # from configured tuple. Only symlink to final tools if they're executable
+ # on build.
+ CT_SymlinkTools "${CT_BUILDTOOLS_PREFIX_DIR}/bin" \
+ "${CT_BUILDTOOLS_PREFIX_DIR}/bin" "${multi_target}"
+ case "${CT_TOOLCHAIN_TYPE}" in
+ native|cross)
+ CT_SymlinkTools "${CT_BUILDTOOLS_PREFIX_DIR}/bin" \
+ "${CT_PREFIX_DIR}/bin" "${multi_target}"
+ ;;
+ esac
+}
+
+# Helper (iterator) for CT_MultilibFixupLDSO
+CT__FixupLDSO()
+{
+ local multi_dir multi_os_dir multi_root multi_flags multi_index multi_count multi_target
+ local binary
+ local ldso ldso_l ldso_f ldso_d ldso_u multilib_dir
+
+ for arg in "$@"; do
+ eval "${arg// /\\ }"
+ done
+
+ CT_DoLog EXTRA "Checking dynamic linker for multilib '${multi_flags}'"
+
+ multilib_dir="/lib/${multi_os_dir}"
+ CT_SanitizeVarDir multilib_dir
+
+ CT_DoExecLog ALL "${CT_TARGET}-${CT_CC}" -o test-ldso ../test-ldso.c ${multi_flags}
+ if [ -r "test-ldso.gdb" ]; then
+ binary="test-ldso.gdb"
+ else
+ binary="test-ldso"
+ fi
+ if ${CT_TARGET}-readelf -Wl "${binary}" | grep -q 'Requesting program interpreter: '; then
+ ldso=$( ${CT_TARGET}-readelf -Wl "${binary}" | \
+ grep 'Requesting program interpreter: ' | \
+ sed -e 's,.*: ,,' -e 's,\].*,,' )
+ fi
+ CT_DoLog DEBUG "Detected dynamic linker for multilib '${multi_flags}': '${ldso}'"
+
+ # Create symlink if GCC produced a dynamically linked executable.
+ if [ -z "${ldso}" ]; then
+ return # Probably, we're building a static toolchain.
+ fi
+
+ ldso_d="${ldso%/ld*.so.*}"
+ ldso_f="${ldso##*/}"
+
+ # Convert ldso_d to "how many levels we need to go up" and remove
+ # leading slash.
+ ldso_u=$( echo "${ldso_d#/}" | sed 's,[^/]\+,..,g' )
+
+ # If the requested dynamic linker exists, but is a symlink - check that it is either
+ # relative (in which case, if it is readable, we trust libc to have created it properly)
+ # or otherwise, convert it from absolute (target) path to a relative path that works on
+ # both host & target.
+ if [ -L "${multi_root}${ldso}" ]; then
+ ldso_l=`readlink "${multi_root}${ldso}"`
+ case "${ldso_l}" in
+ /*) # Absolute, convert to relative
+ if [ -r "${multi_root}${ldso_l}" ]; then
+ CT_DoExecLog ALL ln -sfv "${ldso_u}${ldso_l}" "${multi_root}${ldso}"
+ else
+ CT_DoLog WARN "Compiler selects '${ldso}' as dynamic linker for '${multi_flags}'"
+ CT_DoLog WARN "but '${ldso}' is a symlink to '${ldso_l}' which is not valid on target."
+ fi
+ ;;
+ *) # Relative, must be readable
+ if [ ! -r "${multi_root}${ldso}" ]; then
+ CT_DoLog WARN "Compiler selects '${ldso}' as dynamic linker for '${multi_flags}'"
+ CT_DoLog WARN "but '${ldso}' is a symlink to '${ldso_l}' which is invalid relative symlink."
+ fi
+ ;;
+ esac
+ return
+ elif [ -r "${multi_root}${ldso}" ]; then
+ return # Not a symlink but readable - looks like libc installed a real executable.
+ fi
+
+ # Is it requesting a linker not in the current directory? uClibc case.
+ if [ "${ldso_d}" != "${multilib_dir}" ]; then
+ CT_DoExecLog ALL ln -sfv "${ldso_u}${multilib_dir}/${ldso_f}" \
+ "${multi_root}${ldso}"
+ fi
+}
+
+# Go over multilib variants and check that the requested dynamic linker
+# is present and resolves on both target and host.
+CT_MultilibFixupLDSO()
+{
+ CT_DoStep INFO "Checking dynamic linker symlinks"
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-check-ldso"
+ echo "int main(void) { return 0; }" > test-ldso.c
+ CT_IterateMultilibs CT__FixupLDSO ldso_fixup
+ CT_Popd
+ CT_EndStep
+}
diff --git a/scripts/xldd.in b/scripts/xldd.in
index 0e8c0d0..d575e3c 100644
--- a/scripts/xldd.in
+++ b/scripts/xldd.in
@@ -16,6 +16,10 @@ fake_load_addr_rpath="$((0xdeadc0de))"
fake_load_addr_sysroot="$((0x8badf00d))"
ld_library_path="/lib:/usr/lib"
+need_e_class=
+need_e_flags=
+need_e_mach=
+
do_error() {
printf "%s: %s\n" "${my_name}" "$*" >&2
}
@@ -200,6 +204,35 @@ do_report_needed_found() {
"${sys}"
}
+do_check_compat() {
+ local file="${1}"
+ local info e_mach e_class e_flags
+
+ if [ ! -r "${file}" ]; then
+ return 1
+ fi
+ info=`${readelf} -Wh "${file}"`
+ e_class=`echo "${info}" | "${sed}" -nr 's/.*Class:[[:space:]]*//p'`
+ e_mach=`echo "${info}" | "${sed}" -nr 's/.*Machine:[[:space:]]*//p'`
+ e_flags=`echo "${info}" | "${sed}" -nr 's/.*Flags:[[:space:]]*//p'`
+ if [ "${e_class}" != "${need_e_class}" ]; then
+ do_trace "-> skip incompatible '%s' (class '%s', need '%s')\n" \
+ "${base}${d}/${needed}" "${e_class}" "${need_e_class}"
+ return 1
+ fi
+ if [ "${e_mach}" != "${need_e_mach}" ]; then
+ do_trace "-> skip incompatible '%s' (machine '%s', need '%s')\n" \
+ "${base}${d}/${needed}" "${e_mach}" "${need_e_mach}"
+ return 1
+ fi
+ if [ "${e_flags}" != "${need_e_flags}" ]; then
+ do_trace "-> skip incompatible '%s' (flags '%s', need '%s')\n" \
+ "${base}${d}/${needed}" "${e_flags}" "${need_e_flags}"
+ return 1
+ fi
+ return 0
+}
+
# Search a needed file, scanning ${lib_dir} in the root directory
do_find_needed() {
local needed="${1}"
@@ -229,7 +262,7 @@ do_find_needed() {
fi
for d in "${dirs[@]}"; do
do_trace "-> looking in '%s' (%s)\n" "${d}" "${where}"
- if [ -f "${base}${d}/${needed}" ]; then
+ if do_check_compat "${base}${d}/${needed}"; then
found="${d}/${needed}"
do_trace "---> found\n"
break 2
@@ -250,9 +283,11 @@ do_find_needed() {
# Scan a file for all NEEDED tags
do_process_file() {
local file="${1}"
+ local initial="${2}"
local -a save_search_rpath
local n m
local found
+ local info
do_trace "Parsing file '%s'\n" "${file}"
@@ -270,6 +305,17 @@ do_process_file() {
done
do_trace ": end search path\n"
+ if [ -n "${initial}" ]; then
+ if ! "${readelf}" -Wl "${file}" |
+ "${grep}" 'Requesting program interpreter: ' >/dev/null; then
+ printf " not a dynamic executable\n"
+ exit 1
+ fi
+ info=`${readelf} -Wh "${file}"`
+ need_e_class=`echo "${info}" | "${sed}" -nr 's/.*Class:[[:space:]]*//p'`
+ need_e_mach=`echo "${info}" | "${sed}" -nr 's/.*Machine:[[:space:]]*//p'`
+ need_e_flags=`echo "${info}" | "${sed}" -nr 's/.*Flags:[[:space:]]*//p'`
+ fi
for n in $( "${readelf}" -d "${file}" \
|"${grep}" -E '\(NEEDED\)' \
|"${sed}" -r -e 's/^.*Shared library:[[:space:]]+\[([^]]+)\].*/\1/;' \
@@ -324,6 +370,12 @@ do_scan_etc_ldsoconf() {
do_trace "Finished parsing ld.so.conf: '%s'\n" "${ldsoconf}"
}
+if [ -z "${1}" ]; then
+ show_help
+elif [ ! -r "${1}" ]; then
+ do_error "${1}: No such file or directory"
+fi
+
# Build up the full list of search directories
declare -a needed_search_path
do_trace "Adding basic lib dirs\n"
@@ -348,5 +400,5 @@ done
declare -a needed_list
declare -a search_rpath
do_trace "Scanning file '%s'\n" "${1}"
-do_process_file "${1}"
+do_process_file "${1}" initial
do_trace "Done scanning file '%s'\n" "${1}"