summaryrefslogtreecommitdiff
path: root/patches
diff options
context:
space:
mode:
Diffstat (limited to 'patches')
-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
38 files changed, 1743 insertions, 111 deletions
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
+