diff options
author | Khem Raj <raj.khem@gmail.com> | 2019-12-20 15:40:20 -0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-01-19 13:24:31 +0000 |
commit | b22626d996e153d6094e1f76ed33ee1bb3eea751 (patch) | |
tree | a5b50ac84c9e8c88c3880238018584ab96c57538 /meta/recipes-core/glibc | |
parent | eae63df5524b681897ff7831fa32f16f1b2f792e (diff) | |
download | openembedded-core-contrib-b22626d996e153d6094e1f76ed33ee1bb3eea751.tar.gz |
glibc: Upgrade to 2.31
License-Update: Prefer https to http for gnu.org and fsf.org URLs [1]
[1] https://sourceware.org/git/?p=glibc.git;a=commit;h=5a82c74822d3272df2f5929133680478c0cfb4bd
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core/glibc')
-rw-r--r-- | meta/recipes-core/glibc/cross-localedef-native_2.31.bb (renamed from meta/recipes-core/glibc/cross-localedef-native_2.30.bb) | 29 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc-common.inc | 4 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc-locale_2.31.bb (renamed from meta/recipes-core/glibc/glibc-locale_2.30.bb) | 0 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc-mtrace_2.31.bb (renamed from meta/recipes-core/glibc/glibc-mtrace_2.30.bb) | 0 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc-scripts_2.31.bb (renamed from meta/recipes-core/glibc/glibc-scripts_2.30.bb) | 0 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc-testsuite_2.31.bb (renamed from meta/recipes-core/glibc/glibc-testsuite_2.30.bb) | 0 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc-version.inc | 6 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc/0001-localedef-Add-hardlink-resolver-from-util-linux.patch (renamed from meta/recipes-core/glibc/glibc/0029-Add-hardlink-resolver-from-util-linux.patch) | 4 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc/0001-localedef-Add-hardlink-resolver-to-build.patch (renamed from meta/recipes-core/glibc/glibc/0031-Add-hardlink-resolver-to-build.patch) | 13 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc/0002-localedef-fix-ups-hardlink-to-make-it-compile.patch (renamed from meta/recipes-core/glibc/glibc/0030-hardlink-fix-ups-to-make-it-compile.patch) | 4 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc/0003-nativesdk-glibc-Look-for-host-system-ld.so.cache-as-.patch (renamed from meta/recipes-core/glibc/glibc/0001-nativesdk-glibc-Look-for-host-system-ld.so.cache-as-.patch) | 14 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc/0004-nativesdk-glibc-Fix-buffer-overrun-with-a-relocated-.patch (renamed from meta/recipes-core/glibc/glibc/0002-nativesdk-glibc-Fix-buffer-overrun-with-a-relocated-.patch) | 12 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc/0005-nativesdk-glibc-Raise-the-size-of-arrays-containing-.patch (renamed from meta/recipes-core/glibc/glibc/0003-nativesdk-glibc-Raise-the-size-of-arrays-containing-.patch) | 26 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc/0006-nativesdk-glibc-Allow-64-bit-atomics-for-x86.patch (renamed from meta/recipes-core/glibc/glibc/0004-nativesdk-glibc-Allow-64-bit-atomics-for-x86.patch) | 9 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc/0007-nativesdk-glibc-Make-relocatable-install-for-locales.patch (renamed from meta/recipes-core/glibc/glibc/0005-nativesdk-glibc-Make-relocatable-install-for-locales.patch) | 17 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc/0008-fsl-e500-e5500-e6500-603e-fsqrt-implementation.patch (renamed from meta/recipes-core/glibc/glibc/0006-fsl-e500-e5500-e6500-603e-fsqrt-implementation.patch) | 7 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc/0009-readlib-Add-OECORE_KNOWN_INTERPRETER_NAMES-to-known-.patch (renamed from meta/recipes-core/glibc/glibc/0007-readlib-Add-OECORE_KNOWN_INTERPRETER_NAMES-to-known-.patch) | 10 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc/0010-ppc-sqrt-Fix-undefined-reference-to-__sqrt_finite.patch (renamed from meta/recipes-core/glibc/glibc/0008-ppc-sqrt-Fix-undefined-reference-to-__sqrt_finite.patch) | 7 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc/0011-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch (renamed from meta/recipes-core/glibc/glibc/0009-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch) | 9 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc/0012-Quote-from-bug-1443-which-explains-what-the-patch-do.patch (renamed from meta/recipes-core/glibc/glibc/0010-Quote-from-bug-1443-which-explains-what-the-patch-do.patch) | 10 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc/0013-eglibc-run-libm-err-tab.pl-with-specific-dirs-in-S.patch (renamed from meta/recipes-core/glibc/glibc/0011-eglibc-run-libm-err-tab.pl-with-specific-dirs-in-S.patch) | 9 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc/0014-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch (renamed from meta/recipes-core/glibc/glibc/0012-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch) | 9 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc/0015-sysdeps-gnu-configure.ac-handle-correctly-libc_cv_ro.patch (renamed from meta/recipes-core/glibc/glibc/0013-sysdeps-gnu-configure.ac-handle-correctly-libc_cv_ro.patch) | 7 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc/0016-Add-unused-attribute.patch (renamed from meta/recipes-core/glibc/glibc/0014-Add-unused-attribute.patch) | 9 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc/0017-yes-within-the-path-sets-wrong-config-variables.patch (renamed from meta/recipes-core/glibc/glibc/0015-yes-within-the-path-sets-wrong-config-variables.patch) | 11 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc/0018-timezone-re-written-tzselect-as-posix-sh.patch (renamed from meta/recipes-core/glibc/glibc/0016-timezone-re-written-tzselect-as-posix-sh.patch) | 9 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc/0019-Remove-bash-dependency-for-nscd-init-script.patch (renamed from meta/recipes-core/glibc/glibc/0017-Remove-bash-dependency-for-nscd-init-script.patch) | 7 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc/0020-eglibc-Cross-building-and-testing-instructions.patch (renamed from meta/recipes-core/glibc/glibc/0018-eglibc-Cross-building-and-testing-instructions.patch) | 7 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc/0021-eglibc-Help-bootstrap-cross-toolchain.patch (renamed from meta/recipes-core/glibc/glibc/0019-eglibc-Help-bootstrap-cross-toolchain.patch) | 15 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc/0022-eglibc-Clear-cache-lines-on-ppc8xx.patch (renamed from meta/recipes-core/glibc/glibc/0020-eglibc-Clear-cache-lines-on-ppc8xx.patch) | 11 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc/0023-eglibc-Resolve-__fpscr_values-on-SH4.patch (renamed from meta/recipes-core/glibc/glibc/0021-eglibc-Resolve-__fpscr_values-on-SH4.patch) | 9 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc/0024-eglibc-Forward-port-cross-locale-generation-support.patch (renamed from meta/recipes-core/glibc/glibc/0022-eglibc-Forward-port-cross-locale-generation-support.patch) | 62 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc/0025-Define-DUMMY_LOCALE_T-if-not-defined.patch (renamed from meta/recipes-core/glibc/glibc/0023-Define-DUMMY_LOCALE_T-if-not-defined.patch) | 9 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc/0026-localedef-add-to-archive-uses-a-hard-coded-locale-pa.patch (renamed from meta/recipes-core/glibc/glibc/0024-localedef-add-to-archive-uses-a-hard-coded-locale-pa.patch) | 10 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc/0027-elf-dl-deps.c-Make-_dl_build_local_scope-breadth-fir.patch (renamed from meta/recipes-core/glibc/glibc/0025-elf-dl-deps.c-Make-_dl_build_local_scope-breadth-fir.patch) | 9 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc/0028-intl-Emit-no-lines-in-bison-generated-files.patch (renamed from meta/recipes-core/glibc/glibc/0026-intl-Emit-no-lines-in-bison-generated-files.patch) | 9 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc/0029-inject-file-assembly-directives.patch (renamed from meta/recipes-core/glibc/glibc/0027-inject-file-assembly-directives.patch) | 43 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc/0030-locale-prevent-maybe-uninitialized-errors-with-Os-BZ.patch (renamed from meta/recipes-core/glibc/glibc/0028-locale-prevent-maybe-uninitialized-errors-with-Os-BZ.patch) | 9 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc/0031-Refactor-FORTIFY-in-glibc.patch | 2780 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc/CVE-2019-19126.patch | 32 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc_2.31.bb (renamed from meta/recipes-core/glibc/glibc_2.30.bb) | 58 |
41 files changed, 2980 insertions, 325 deletions
diff --git a/meta/recipes-core/glibc/cross-localedef-native_2.30.bb b/meta/recipes-core/glibc/cross-localedef-native_2.31.bb index 99c3d303979..a267a591d42 100644 --- a/meta/recipes-core/glibc/cross-localedef-native_2.30.bb +++ b/meta/recipes-core/glibc/cross-localedef-native_2.31.bb @@ -3,7 +3,7 @@ HOMEPAGE = "http://www.gnu.org/software/libc/libc.html" SECTION = "libs" LICENSE = "LGPL-2.1" -LIC_FILES_CHKSUM = "file://LICENSES;md5=cfc0ed77a9f62fa62eded042ebe31d72 \ +LIC_FILES_CHKSUM = "file://LICENSES;md5=1541fd8f5e8f1579512bf05f533371ba \ file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \ file://posix/rxspencer/COPYRIGHT;md5=dc5485bb394a13b2332ec1c785f5d83a \ file://COPYING.LIB;md5=4fbd65380cdd255951079008b364516c" @@ -21,18 +21,21 @@ FILESEXTRAPATHS =. "${FILE_DIRNAME}/${PN}:${FILE_DIRNAME}/glibc:" SRC_URI = "${GLIBC_GIT_URI};branch=${SRCBRANCH};name=glibc \ git://github.com/kraj/localedef;branch=master;name=localedef;destsuffix=git/localedef \ - file://0016-timezone-re-written-tzselect-as-posix-sh.patch \ - file://0017-Remove-bash-dependency-for-nscd-init-script.patch \ - file://0018-eglibc-Cross-building-and-testing-instructions.patch \ - file://0019-eglibc-Help-bootstrap-cross-toolchain.patch \ - file://0020-eglibc-Clear-cache-lines-on-ppc8xx.patch \ - file://0021-eglibc-Resolve-__fpscr_values-on-SH4.patch \ - file://0022-eglibc-Forward-port-cross-locale-generation-support.patch \ - file://0023-Define-DUMMY_LOCALE_T-if-not-defined.patch \ - file://0024-localedef-add-to-archive-uses-a-hard-coded-locale-pa.patch \ - file://0029-Add-hardlink-resolver-from-util-linux.patch \ - file://0030-hardlink-fix-ups-to-make-it-compile.patch \ - file://0031-Add-hardlink-resolver-to-build.patch \ + \ + file://0001-localedef-Add-hardlink-resolver-to-build.patch;patchdir=localedef \ + \ + file://0001-localedef-Add-hardlink-resolver-from-util-linux.patch \ + file://0002-localedef-fix-ups-hardlink-to-make-it-compile.patch \ + \ + file://0018-timezone-re-written-tzselect-as-posix-sh.patch \ + file://0019-Remove-bash-dependency-for-nscd-init-script.patch \ + file://0020-eglibc-Cross-building-and-testing-instructions.patch \ + file://0021-eglibc-Help-bootstrap-cross-toolchain.patch \ + file://0022-eglibc-Clear-cache-lines-on-ppc8xx.patch \ + file://0023-eglibc-Resolve-__fpscr_values-on-SH4.patch \ + file://0024-eglibc-Forward-port-cross-locale-generation-support.patch \ + file://0025-Define-DUMMY_LOCALE_T-if-not-defined.patch \ + file://0026-localedef-add-to-archive-uses-a-hard-coded-locale-pa.patch \ " # Makes for a rather long rev (22 characters), but... # diff --git a/meta/recipes-core/glibc/glibc-common.inc b/meta/recipes-core/glibc/glibc-common.inc index fa46fd89f10..27534d999f6 100644 --- a/meta/recipes-core/glibc/glibc-common.inc +++ b/meta/recipes-core/glibc/glibc-common.inc @@ -4,7 +4,7 @@ HOMEPAGE = "http://www.gnu.org/software/libc/libc.html" SECTION = "libs" LICENSE = "GPLv2 & LGPLv2.1" -LIC_FILES_CHKSUM ?= "file://LICENSES;md5=cfc0ed77a9f62fa62eded042ebe31d72 \ +LIC_FILES_CHKSUM ?= "file://LICENSES;md5=1541fd8f5e8f1579512bf05f533371ba \ file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \ file://posix/rxspencer/COPYRIGHT;md5=dc5485bb394a13b2332ec1c785f5d83a \ file://COPYING.LIB;md5=4fbd65380cdd255951079008b364516c" @@ -22,4 +22,4 @@ ARM_INSTRUCTION_SET_armv6 = "arm" # COMPATIBLE_HOST_libc-musl_class-target = "null" -PV = "2.30" +PV = "2.30.9000" diff --git a/meta/recipes-core/glibc/glibc-locale_2.30.bb b/meta/recipes-core/glibc/glibc-locale_2.31.bb index f7702e0358c..f7702e0358c 100644 --- a/meta/recipes-core/glibc/glibc-locale_2.30.bb +++ b/meta/recipes-core/glibc/glibc-locale_2.31.bb diff --git a/meta/recipes-core/glibc/glibc-mtrace_2.30.bb b/meta/recipes-core/glibc/glibc-mtrace_2.31.bb index 0b69bad46a3..0b69bad46a3 100644 --- a/meta/recipes-core/glibc/glibc-mtrace_2.30.bb +++ b/meta/recipes-core/glibc/glibc-mtrace_2.31.bb diff --git a/meta/recipes-core/glibc/glibc-scripts_2.30.bb b/meta/recipes-core/glibc/glibc-scripts_2.31.bb index 5a89bd8022a..5a89bd8022a 100644 --- a/meta/recipes-core/glibc/glibc-scripts_2.30.bb +++ b/meta/recipes-core/glibc/glibc-scripts_2.31.bb diff --git a/meta/recipes-core/glibc/glibc-testsuite_2.30.bb b/meta/recipes-core/glibc/glibc-testsuite_2.31.bb index 657fd4dbc1b..657fd4dbc1b 100644 --- a/meta/recipes-core/glibc/glibc-testsuite_2.30.bb +++ b/meta/recipes-core/glibc/glibc-testsuite_2.31.bb diff --git a/meta/recipes-core/glibc/glibc-version.inc b/meta/recipes-core/glibc/glibc-version.inc index c18c5833992..dca1916e801 100644 --- a/meta/recipes-core/glibc/glibc-version.inc +++ b/meta/recipes-core/glibc/glibc-version.inc @@ -1,6 +1,6 @@ -SRCBRANCH ?= "release/2.30/master" -PV = "2.30" -SRCREV_glibc ?= "be9a328c93834648e0bec106a1f86357d1a8c7e1" +SRCBRANCH ?= "master" +PV = "2.30.9000" +SRCREV_glibc ?= "def9c08c94da60bfb746644d56cffbe7a9de3477" SRCREV_localedef ?= "cd9f958c4c94a638fa7b2b4e21627364f1a1a655" GLIBC_GIT_URI ?= "git://sourceware.org/git/glibc.git" diff --git a/meta/recipes-core/glibc/glibc/0029-Add-hardlink-resolver-from-util-linux.patch b/meta/recipes-core/glibc/glibc/0001-localedef-Add-hardlink-resolver-from-util-linux.patch index b7fb0321c4a..9b75f2a62f2 100644 --- a/meta/recipes-core/glibc/glibc/0029-Add-hardlink-resolver-from-util-linux.patch +++ b/meta/recipes-core/glibc/glibc/0001-localedef-Add-hardlink-resolver-from-util-linux.patch @@ -1,7 +1,7 @@ -From 9e5e5297d9a5ef66b3920313356bf7f25955dff3 Mon Sep 17 00:00:00 2001 +From 169720859cf8f9133882a13f588b15f44b7b8ae6 Mon Sep 17 00:00:00 2001 From: Jason Wessel <jason.wessel@windriver.com> Date: Sat, 7 Dec 2019 09:59:22 -0800 -Subject: [PATCH] Add hardlink resolver from util-linux +Subject: [PATCH] localedef: Add hardlink resolver from util-linux The hard link resolver that is built into localedef cannot be run in parallel. It will search sibling directories (which are be processed diff --git a/meta/recipes-core/glibc/glibc/0031-Add-hardlink-resolver-to-build.patch b/meta/recipes-core/glibc/glibc/0001-localedef-Add-hardlink-resolver-to-build.patch index e87a3bfb6fe..d6652981a87 100644 --- a/meta/recipes-core/glibc/glibc/0031-Add-hardlink-resolver-to-build.patch +++ b/meta/recipes-core/glibc/glibc/0001-localedef-Add-hardlink-resolver-to-build.patch @@ -1,7 +1,7 @@ -From 1ef58f566e6ed575f7caee35308025e2b0f4101c Mon Sep 17 00:00:00 2001 +From 56ae260ac24ade94e2e0e77c81751312372d253f Mon Sep 17 00:00:00 2001 From: Jason Wessel <jason.wessel@windriver.com> Date: Sat, 7 Dec 2019 09:56:23 -0800 -Subject: [PATCH] Add hardlink resolver to build +Subject: [PATCH] localedef: Add hardlink resolver to build The sourcecode for this is imported from util-linux and is kept with glibc sources @@ -13,10 +13,10 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com> Makefile.in | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) -diff --git a/localedef/Makefile.in b/localedef/Makefile.in +diff --git a/Makefile.in b/Makefile.in index 77fbded..a87e5b2 100644 ---- a/localedef/Makefile.in -+++ b/localedef/Makefile.in +--- a/Makefile.in ++++ b/Makefile.in @@ -40,6 +40,8 @@ WARNFLAGS = -Wall -Wno-format FULLCC = $(CC) $(CPPFLAGS) $(CFLAGS) \ $(DEFINES) $(INCLUDES) $(WARNFLAGS) @@ -50,6 +50,3 @@ index 77fbded..a87e5b2 100644 charmap.o: glibc/locale/programs/charmap.c charmap-dir.o: glibc/locale/programs/charmap-dir.c ld-address.o: glibc/locale/programs/ld-address.c --- -2.24.0 - diff --git a/meta/recipes-core/glibc/glibc/0030-hardlink-fix-ups-to-make-it-compile.patch b/meta/recipes-core/glibc/glibc/0002-localedef-fix-ups-hardlink-to-make-it-compile.patch index 1a5f6b68258..029292fe360 100644 --- a/meta/recipes-core/glibc/glibc/0030-hardlink-fix-ups-to-make-it-compile.patch +++ b/meta/recipes-core/glibc/glibc/0002-localedef-fix-ups-hardlink-to-make-it-compile.patch @@ -1,7 +1,7 @@ -From d08f436635cb9d627ebae4512105708d28fc36fe Mon Sep 17 00:00:00 2001 +From 9b966b758d0c96ef6654251689318614ef10becc Mon Sep 17 00:00:00 2001 From: Jason Wessel <jason.wessel@windriver.com> Date: Sat, 7 Dec 2019 10:01:37 -0800 -Subject: [PATCH] hardlink: fix-ups to make it compile +Subject: [PATCH] localedef: fix-ups hardlink to make it compile Upstream-Status: Pending Signed-off-by: Jason Wessel <jason.wessel@windriver.com> diff --git a/meta/recipes-core/glibc/glibc/0001-nativesdk-glibc-Look-for-host-system-ld.so.cache-as-.patch b/meta/recipes-core/glibc/glibc/0003-nativesdk-glibc-Look-for-host-system-ld.so.cache-as-.patch index d86d1d8dc7d..e1c3512e4e2 100644 --- a/meta/recipes-core/glibc/glibc/0001-nativesdk-glibc-Look-for-host-system-ld.so.cache-as-.patch +++ b/meta/recipes-core/glibc/glibc/0003-nativesdk-glibc-Look-for-host-system-ld.so.cache-as-.patch @@ -1,8 +1,7 @@ -From f6984c923b41155979764bfa3f44609572be5414 Mon Sep 17 00:00:00 2001 +From 14ddf13b7fc2e39a1ae657ceb3963e35731e95d0 Mon Sep 17 00:00:00 2001 From: Khem Raj <raj.khem@gmail.com> Date: Wed, 18 Mar 2015 01:48:24 +0000 -Subject: [PATCH 01/28] nativesdk-glibc: Look for host system ld.so.cache as - well +Subject: [PATCH] nativesdk-glibc: Look for host system ld.so.cache as well Upstream-Status: Inappropriate [embedded specific] @@ -31,10 +30,10 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com> 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/elf/dl-load.c b/elf/dl-load.c -index 5abeb867f1..981bd5b4af 100644 +index a6b80f9395..3226f2e531 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c -@@ -2080,6 +2080,14 @@ _dl_map_object (struct link_map *loader, const char *name, +@@ -2073,6 +2073,14 @@ _dl_map_object (struct link_map *loader, const char *name, } } @@ -49,7 +48,7 @@ index 5abeb867f1..981bd5b4af 100644 #ifdef USE_LDCONFIG if (fd == -1 && (__glibc_likely ((mode & __RTLD_SECURE) == 0) -@@ -2138,14 +2146,6 @@ _dl_map_object (struct link_map *loader, const char *name, +@@ -2131,14 +2139,6 @@ _dl_map_object (struct link_map *loader, const char *name, } #endif @@ -64,6 +63,3 @@ index 5abeb867f1..981bd5b4af 100644 /* Add another newline when we are tracing the library loading. */ if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_LIBS)) _dl_debug_printf ("\n"); --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0002-nativesdk-glibc-Fix-buffer-overrun-with-a-relocated-.patch b/meta/recipes-core/glibc/glibc/0004-nativesdk-glibc-Fix-buffer-overrun-with-a-relocated-.patch index 63531082a46..523b6da8971 100644 --- a/meta/recipes-core/glibc/glibc/0002-nativesdk-glibc-Fix-buffer-overrun-with-a-relocated-.patch +++ b/meta/recipes-core/glibc/glibc/0004-nativesdk-glibc-Fix-buffer-overrun-with-a-relocated-.patch @@ -1,8 +1,7 @@ -From b91c323d809039bf9b8c445418579a8b5fe61aea Mon Sep 17 00:00:00 2001 +From 3ac58bf1028841cc0a8fa7f258cbf21466740360 Mon Sep 17 00:00:00 2001 From: Khem Raj <raj.khem@gmail.com> Date: Wed, 18 Mar 2015 01:50:00 +0000 -Subject: [PATCH 02/28] nativesdk-glibc: Fix buffer overrun with a relocated - SDK +Subject: [PATCH] nativesdk-glibc: Fix buffer overrun with a relocated SDK When ld-linux-*.so.2 is relocated to a path that is longer than the original fixed location, the dynamic loader will crash in open_path @@ -22,10 +21,10 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com> 1 file changed, 12 insertions(+) diff --git a/elf/dl-load.c b/elf/dl-load.c -index 981bd5b4af..c7a0fa58cb 100644 +index 3226f2e531..7cb8a86fab 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c -@@ -1780,7 +1780,19 @@ open_path (const char *name, size_t namelen, int mode, +@@ -1773,7 +1773,19 @@ open_path (const char *name, size_t namelen, int mode, given on the command line when rtld is run directly. */ return -1; @@ -45,6 +44,3 @@ index 981bd5b4af..c7a0fa58cb 100644 do { struct r_search_path_elem *this_dir = *dirs; --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0003-nativesdk-glibc-Raise-the-size-of-arrays-containing-.patch b/meta/recipes-core/glibc/glibc/0005-nativesdk-glibc-Raise-the-size-of-arrays-containing-.patch index 48f5a787166..4d88d9b4134 100644 --- a/meta/recipes-core/glibc/glibc/0003-nativesdk-glibc-Raise-the-size-of-arrays-containing-.patch +++ b/meta/recipes-core/glibc/glibc/0005-nativesdk-glibc-Raise-the-size-of-arrays-containing-.patch @@ -1,8 +1,7 @@ -From 3aceb84e2bc0f796204fe059beede91179b1bc6e Mon Sep 17 00:00:00 2001 +From 702d68cbdf405e086f72e2a062127cbea43045ec Mon Sep 17 00:00:00 2001 From: Khem Raj <raj.khem@gmail.com> Date: Wed, 18 Mar 2015 01:51:38 +0000 -Subject: [PATCH 03/28] nativesdk-glibc: Raise the size of arrays containing dl - paths +Subject: [PATCH] nativesdk-glibc: Raise the size of arrays containing dl paths This patch puts the dynamic loader path in the binaries, SYSTEM_DIRS strings and lengths as well as ld.so.cache path in the dynamic loader to specific @@ -26,7 +25,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com> 7 files changed, 14 insertions(+), 10 deletions(-) diff --git a/elf/dl-cache.c b/elf/dl-cache.c -index d8d1e2344e..d2247bfc4f 100644 +index 3eedd9afcf..efdfe5cae7 100644 --- a/elf/dl-cache.c +++ b/elf/dl-cache.c @@ -133,6 +133,10 @@ do \ @@ -41,7 +40,7 @@ index d8d1e2344e..d2247bfc4f 100644 _dl_cache_libcmp (const char *p1, const char *p2) { diff --git a/elf/dl-load.c b/elf/dl-load.c -index c7a0fa58cb..4b87505d45 100644 +index 7cb8a86fab..e32d4aa936 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -110,8 +110,8 @@ static size_t max_capstrlen attribute_relro; @@ -56,7 +55,7 @@ index c7a0fa58cb..4b87505d45 100644 SYSTEM_DIRS_LEN }; diff --git a/elf/interp.c b/elf/interp.c -index 243829f5f7..0e74241703 100644 +index 331cc1df48..885b2d9476 100644 --- a/elf/interp.c +++ b/elf/interp.c @@ -18,5 +18,5 @@ @@ -67,7 +66,7 @@ index 243829f5f7..0e74241703 100644 +const char __invoke_dynamic_linker__[4096] __attribute__ ((section (".interp"))) = RUNTIME_LINKER; diff --git a/elf/ldconfig.c b/elf/ldconfig.c -index 3bc9e61891..6a23096435 100644 +index 681ed78496..8833ed0a6b 100644 --- a/elf/ldconfig.c +++ b/elf/ldconfig.c @@ -168,6 +168,9 @@ static struct argp argp = @@ -81,10 +80,10 @@ index 3bc9e61891..6a23096435 100644 a platform. */ static int diff --git a/elf/rtld.c b/elf/rtld.c -index c9490ff694..3962373ebb 100644 +index 553cfbd1b7..39347c2c03 100644 --- a/elf/rtld.c +++ b/elf/rtld.c -@@ -173,6 +173,7 @@ dso_name_valid_for_suid (const char *p) +@@ -175,6 +175,7 @@ dso_name_valid_for_suid (const char *p) } return *p != '\0'; } @@ -92,7 +91,7 @@ index c9490ff694..3962373ebb 100644 /* LD_AUDIT variable contents. Must be processed before the audit_list below. */ -@@ -1220,13 +1221,13 @@ of this helper program; chances are you did not intend to run this program.\n\ +@@ -1222,13 +1223,13 @@ of this helper program; chances are you did not intend to run this program.\n\ --list list all dependencies and how they are resolved\n\ --verify verify that given object really is a dynamically linked\n\ object we can handle\n\ @@ -109,7 +108,7 @@ index c9490ff694..3962373ebb 100644 ++_dl_skip_args; --_dl_argc; diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c -index ae8937cba0..f321ee419e 100644 +index 735bd1f2d5..25100ba666 100644 --- a/iconv/gconv_conf.c +++ b/iconv/gconv_conf.c @@ -36,7 +36,7 @@ @@ -122,7 +121,7 @@ index ae8937cba0..f321ee419e 100644 /* Type to represent search path. */ struct path_elem diff --git a/sysdeps/generic/dl-cache.h b/sysdeps/generic/dl-cache.h -index bc8b40331d..b0fdd2144b 100644 +index 6b310e9e15..3877311df4 100644 --- a/sysdeps/generic/dl-cache.h +++ b/sysdeps/generic/dl-cache.h @@ -27,10 +27,6 @@ @@ -136,6 +135,3 @@ index bc8b40331d..b0fdd2144b 100644 #ifndef add_system_dir # define add_system_dir(dir) add_dir (dir) #endif --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0004-nativesdk-glibc-Allow-64-bit-atomics-for-x86.patch b/meta/recipes-core/glibc/glibc/0006-nativesdk-glibc-Allow-64-bit-atomics-for-x86.patch index a43f2943452..0d070a93b99 100644 --- a/meta/recipes-core/glibc/glibc/0004-nativesdk-glibc-Allow-64-bit-atomics-for-x86.patch +++ b/meta/recipes-core/glibc/glibc/0006-nativesdk-glibc-Allow-64-bit-atomics-for-x86.patch @@ -1,7 +1,7 @@ -From e41e042149eac349e09fa629fcac4c64e574322c Mon Sep 17 00:00:00 2001 +From f9993e652bd4a0f03402d0c527cf24b83d0ff7ea Mon Sep 17 00:00:00 2001 From: Khem Raj <raj.khem@gmail.com> Date: Thu, 31 Dec 2015 14:35:35 -0800 -Subject: [PATCH 04/28] nativesdk-glibc: Allow 64 bit atomics for x86 +Subject: [PATCH] nativesdk-glibc: Allow 64 bit atomics for x86 The fix consist of allowing 64bit atomic ops for x86. This should be safe for i586 and newer CPUs. @@ -17,7 +17,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com> 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sysdeps/x86/atomic-machine.h b/sysdeps/x86/atomic-machine.h -index aa60ca4cd6..3e42e00183 100644 +index bb49648374..aa08d3c0a7 100644 --- a/sysdeps/x86/atomic-machine.h +++ b/sysdeps/x86/atomic-machine.h @@ -58,15 +58,14 @@ typedef uintmax_t uatomic_max_t; @@ -37,6 +37,3 @@ index aa60ca4cd6..3e42e00183 100644 # define SP_REG "esp" # define SEG_REG "gs" # define BR_CONSTRAINT "r" --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0005-nativesdk-glibc-Make-relocatable-install-for-locales.patch b/meta/recipes-core/glibc/glibc/0007-nativesdk-glibc-Make-relocatable-install-for-locales.patch index 3aad603ada9..66abcce3ce6 100644 --- a/meta/recipes-core/glibc/glibc/0005-nativesdk-glibc-Make-relocatable-install-for-locales.patch +++ b/meta/recipes-core/glibc/glibc/0007-nativesdk-glibc-Make-relocatable-install-for-locales.patch @@ -1,7 +1,7 @@ -From 50ab0b0c116f4ae3d975ec1b15ed4595fd9147f6 Mon Sep 17 00:00:00 2001 +From ee9d5e423e4a709ae5a62abfb476863b3b57378f Mon Sep 17 00:00:00 2001 From: Khem Raj <raj.khem@gmail.com> Date: Fri, 3 Aug 2018 09:55:12 -0700 -Subject: [PATCH 05/28] nativesdk-glibc: Make relocatable install for locales +Subject: [PATCH] nativesdk-glibc: Make relocatable install for locales The glibc locale path is hard-coded to the install prefix, but in SDKs we need to be able to relocate the binaries. Expand the strings to 4K and put them in a @@ -18,7 +18,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com> 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/locale/findlocale.c b/locale/findlocale.c -index 9af605bd64..b2b0a3f93b 100644 +index 9cd3b71a6d..84272310e0 100644 --- a/locale/findlocale.c +++ b/locale/findlocale.c @@ -56,7 +56,7 @@ struct __locale_data *const _nl_C[] attribute_hidden = @@ -30,7 +30,7 @@ index 9af605bd64..b2b0a3f93b 100644 /* Checks if the name is actually present, that is, not NULL and not empty. */ -@@ -167,7 +167,7 @@ _nl_find_locale (const char *locale_path, size_t locale_path_len, +@@ -166,7 +166,7 @@ _nl_find_locale (const char *locale_path, size_t locale_path_len, /* Nothing in the archive. Set the default path to search below. */ locale_path = _nl_default_locale_path; @@ -40,7 +40,7 @@ index 9af605bd64..b2b0a3f93b 100644 else /* We really have to load some data. First see whether the name is diff --git a/locale/loadarchive.c b/locale/loadarchive.c -index 803c1cf2a4..9023f475b8 100644 +index ba0fe45648..9737fd4cda 100644 --- a/locale/loadarchive.c +++ b/locale/loadarchive.c @@ -42,7 +42,7 @@ @@ -53,10 +53,10 @@ index 803c1cf2a4..9023f475b8 100644 /* Size of initial mapping window, optimal if large enough to cover the header plus the initial locale. */ diff --git a/locale/localeinfo.h b/locale/localeinfo.h -index 7c1cc3eecb..53cb8bfc59 100644 +index 1bfe22aa7f..fdc283c69a 100644 --- a/locale/localeinfo.h +++ b/locale/localeinfo.h -@@ -325,7 +325,7 @@ _nl_lookup_word (locale_t l, int category, int item) +@@ -331,7 +331,7 @@ _nl_lookup_word (locale_t l, int category, int item) } /* Default search path if no LOCPATH environment variable. */ @@ -65,6 +65,3 @@ index 7c1cc3eecb..53cb8bfc59 100644 /* Load the locale data for CATEGORY from the file specified by *NAME. If *NAME is "", use environment variables as specified by POSIX, and --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0006-fsl-e500-e5500-e6500-603e-fsqrt-implementation.patch b/meta/recipes-core/glibc/glibc/0008-fsl-e500-e5500-e6500-603e-fsqrt-implementation.patch index 5e1c5914328..4f3ed380659 100644 --- a/meta/recipes-core/glibc/glibc/0006-fsl-e500-e5500-e6500-603e-fsqrt-implementation.patch +++ b/meta/recipes-core/glibc/glibc/0008-fsl-e500-e5500-e6500-603e-fsqrt-implementation.patch @@ -1,7 +1,7 @@ -From 7cccf5cec09f2a42cc3fe5d82ce21b7309330b33 Mon Sep 17 00:00:00 2001 +From 2cc7b79157ce17144791dda1a2e3a6dc4902c736 Mon Sep 17 00:00:00 2001 From: Khem Raj <raj.khem@gmail.com> Date: Wed, 18 Mar 2015 00:01:50 +0000 -Subject: [PATCH 06/28] fsl e500/e5500/e6500/603e fsqrt implementation +Subject: [PATCH] fsl e500/e5500/e6500/603e fsqrt implementation Upstream-Status: Pending Signed-off-by: Edmar Wienskoski <edmar@freescale.com> @@ -1579,6 +1579,3 @@ index 0000000000..04ff8cc181 +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/e6500/fpu/Implies @@ -0,0 +1 @@ +powerpc/powerpc64/e6500/fpu --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0007-readlib-Add-OECORE_KNOWN_INTERPRETER_NAMES-to-known-.patch b/meta/recipes-core/glibc/glibc/0009-readlib-Add-OECORE_KNOWN_INTERPRETER_NAMES-to-known-.patch index ae6fb268a55..6e4259f4ffe 100644 --- a/meta/recipes-core/glibc/glibc/0007-readlib-Add-OECORE_KNOWN_INTERPRETER_NAMES-to-known-.patch +++ b/meta/recipes-core/glibc/glibc/0009-readlib-Add-OECORE_KNOWN_INTERPRETER_NAMES-to-known-.patch @@ -1,8 +1,7 @@ -From dc715f6c70d01e9c3b31c1825fa5bc447967c847 Mon Sep 17 00:00:00 2001 +From e6ff3960d9e4ed6a9a4be70732313127f0e6d0e0 Mon Sep 17 00:00:00 2001 From: Khem Raj <raj.khem@gmail.com> Date: Wed, 18 Mar 2015 00:11:22 +0000 -Subject: [PATCH 07/28] readlib: Add OECORE_KNOWN_INTERPRETER_NAMES to known - names +Subject: [PATCH] readlib: Add OECORE_KNOWN_INTERPRETER_NAMES to known names This bolts in a hook for OE to pass its own version of interpreter names into glibc especially for multilib case, where it differs from any @@ -17,7 +16,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com> 1 file changed, 1 insertion(+) diff --git a/elf/readlib.c b/elf/readlib.c -index c9743e6692..6307f918fc 100644 +index 994a4426a1..baabf099b1 100644 --- a/elf/readlib.c +++ b/elf/readlib.c @@ -51,6 +51,7 @@ static struct known_names interpreters[] = @@ -28,6 +27,3 @@ index c9743e6692..6307f918fc 100644 }; static struct known_names known_libs[] = --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0008-ppc-sqrt-Fix-undefined-reference-to-__sqrt_finite.patch b/meta/recipes-core/glibc/glibc/0010-ppc-sqrt-Fix-undefined-reference-to-__sqrt_finite.patch index 8bed20306e0..91da344089a 100644 --- a/meta/recipes-core/glibc/glibc/0008-ppc-sqrt-Fix-undefined-reference-to-__sqrt_finite.patch +++ b/meta/recipes-core/glibc/glibc/0010-ppc-sqrt-Fix-undefined-reference-to-__sqrt_finite.patch @@ -1,7 +1,7 @@ -From 42a01c55786a9472934e12e0bf0c40983579b607 Mon Sep 17 00:00:00 2001 +From ad055d58bd99b80e41face63bf20db3f04afa4e3 Mon Sep 17 00:00:00 2001 From: Khem Raj <raj.khem@gmail.com> Date: Wed, 18 Mar 2015 00:15:07 +0000 -Subject: [PATCH 08/28] ppc/sqrt: Fix undefined reference to `__sqrt_finite' +Subject: [PATCH] ppc/sqrt: Fix undefined reference to `__sqrt_finite' on ppc fixes the errors like below | ./.libs/libpulsecore-1.1.so: undefined reference to `__sqrt_finite' @@ -203,6 +203,3 @@ index 26fa067abf..9d175122a8 100644 return f_washf (b); } +strong_alias (__ieee754_sqrtf, __sqrtf_finite) --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0009-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch b/meta/recipes-core/glibc/glibc/0011-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch index 8a5d6d8b7f3..6a5a44af9dc 100644 --- a/meta/recipes-core/glibc/glibc/0009-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch +++ b/meta/recipes-core/glibc/glibc/0011-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch @@ -1,8 +1,8 @@ -From a0fcb9135bc8c2b9d8a161d166b6f9d56d7af245 Mon Sep 17 00:00:00 2001 +From ac4450bc74dc0754a3724f1bebb2290c4dc29d72 Mon Sep 17 00:00:00 2001 From: Khem Raj <raj.khem@gmail.com> Date: Wed, 18 Mar 2015 00:16:38 +0000 -Subject: [PATCH 09/28] __ieee754_sqrt{,f} are now inline functions and call - out __slow versions +Subject: [PATCH] __ieee754_sqrt{,f} are now inline functions and call out + __slow versions Upstream-Status: Pending @@ -382,6 +382,3 @@ index 9d175122a8..10de1f0cc3 100644 +} + strong_alias (__ieee754_sqrtf, __sqrtf_finite) --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0010-Quote-from-bug-1443-which-explains-what-the-patch-do.patch b/meta/recipes-core/glibc/glibc/0012-Quote-from-bug-1443-which-explains-what-the-patch-do.patch index a140a154793..e8eaa4d90bb 100644 --- a/meta/recipes-core/glibc/glibc/0010-Quote-from-bug-1443-which-explains-what-the-patch-do.patch +++ b/meta/recipes-core/glibc/glibc/0012-Quote-from-bug-1443-which-explains-what-the-patch-do.patch @@ -1,8 +1,7 @@ -From 9c1f2229c48c37b38628c485ef16e01f6780160c Mon Sep 17 00:00:00 2001 +From 0c73e17d5ea7c88247c1bfbb03511b0ccb6ba6b4 Mon Sep 17 00:00:00 2001 From: Khem Raj <raj.khem@gmail.com> Date: Wed, 18 Mar 2015 00:20:09 +0000 -Subject: [PATCH 10/28] Quote from bug 1443 which explains what the patch does - : +Subject: [PATCH] Quote from bug 1443 which explains what the patch does : We build some random program and link it with -lust. When we run it, it dies with a SIGSEGV before reaching main(). @@ -45,7 +44,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com> 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysdeps/arm/dl-machine.h b/sysdeps/arm/dl-machine.h -index 7a2f9d9b78..36a1dd1888 100644 +index 90856779b1..a29bb86c56 100644 --- a/sysdeps/arm/dl-machine.h +++ b/sysdeps/arm/dl-machine.h @@ -510,7 +510,7 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc, @@ -57,6 +56,3 @@ index 7a2f9d9b78..36a1dd1888 100644 break; case R_ARM_TLS_TPOFF32: --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0011-eglibc-run-libm-err-tab.pl-with-specific-dirs-in-S.patch b/meta/recipes-core/glibc/glibc/0013-eglibc-run-libm-err-tab.pl-with-specific-dirs-in-S.patch index cb99092eeff..3b3611f4483 100644 --- a/meta/recipes-core/glibc/glibc/0011-eglibc-run-libm-err-tab.pl-with-specific-dirs-in-S.patch +++ b/meta/recipes-core/glibc/glibc/0013-eglibc-run-libm-err-tab.pl-with-specific-dirs-in-S.patch @@ -1,7 +1,7 @@ -From 171d2afb930917b0cfbe9df770774da1c92dd185 Mon Sep 17 00:00:00 2001 +From 6a1ebbab0643fb2169314bcf1a0850b0f06dd27e Mon Sep 17 00:00:00 2001 From: Ting Liu <b28495@freescale.com> Date: Wed, 19 Dec 2012 04:39:57 -0600 -Subject: [PATCH 11/28] eglibc: run libm-err-tab.pl with specific dirs in ${S} +Subject: [PATCH] eglibc: run libm-err-tab.pl with specific dirs in ${S} libm-err-tab.pl will parse all the files named "libm-test-ulps" in the given dir recursively. To avoid parsing the one in @@ -18,7 +18,7 @@ Signed-off-by: Ting Liu <b28495@freescale.com> 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manual/Makefile b/manual/Makefile -index 4f76ee85d2..04b8c8c320 100644 +index c61e11dcd7..5d859e6f84 100644 --- a/manual/Makefile +++ b/manual/Makefile @@ -103,7 +103,8 @@ $(objpfx)stamp-libm-err: $(..)math/gen-libm-test.py \ @@ -31,6 +31,3 @@ index 4f76ee85d2..04b8c8c320 100644 $(move-if-change) $(objpfx)libm-err-tmp $(objpfx)libm-err.texi touch $@ --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0012-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch b/meta/recipes-core/glibc/glibc/0014-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch index e233fbe542f..b35de40eea0 100644 --- a/meta/recipes-core/glibc/glibc/0012-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch +++ b/meta/recipes-core/glibc/glibc/0014-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch @@ -1,8 +1,8 @@ -From 376be7b96152ef501c8cf95ed6dc52c0318bd26a Mon Sep 17 00:00:00 2001 +From 106aee1de5c95fc9e02f10c05537dcc39f8478f4 Mon Sep 17 00:00:00 2001 From: Khem Raj <raj.khem@gmail.com> Date: Wed, 18 Mar 2015 00:24:46 +0000 -Subject: [PATCH 12/28] __ieee754_sqrt{,f} are now inline functions and call - out __slow versions +Subject: [PATCH] __ieee754_sqrt{,f} are now inline functions and call out + __slow versions Upstream-Status: Pending @@ -56,6 +56,3 @@ index 812653558f..10de1f0cc3 100644 float b; #endif { --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0013-sysdeps-gnu-configure.ac-handle-correctly-libc_cv_ro.patch b/meta/recipes-core/glibc/glibc/0015-sysdeps-gnu-configure.ac-handle-correctly-libc_cv_ro.patch index 9ba52e6e10c..56693419161 100644 --- a/meta/recipes-core/glibc/glibc/0013-sysdeps-gnu-configure.ac-handle-correctly-libc_cv_ro.patch +++ b/meta/recipes-core/glibc/glibc/0015-sysdeps-gnu-configure.ac-handle-correctly-libc_cv_ro.patch @@ -1,7 +1,7 @@ -From 1ba4e9577437632856d719cbd5d63b5a76cbb4c4 Mon Sep 17 00:00:00 2001 +From 6c07d094556606ce7c1dc08f4dd3bc6af483364f Mon Sep 17 00:00:00 2001 From: Khem Raj <raj.khem@gmail.com> Date: Wed, 18 Mar 2015 00:27:10 +0000 -Subject: [PATCH 13/28] sysdeps/gnu/configure.ac: handle correctly +Subject: [PATCH] sysdeps/gnu/configure.ac: handle correctly $libc_cv_rootsbindir Upstream-Status:Pending @@ -37,6 +37,3 @@ index 634fe4de2a..3db1697f4f 100644 + test -n "$libc_cv_rootsbindir" || libc_cv_rootsbindir=/sbin ;; esac --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0014-Add-unused-attribute.patch b/meta/recipes-core/glibc/glibc/0016-Add-unused-attribute.patch index 0a602bb38cb..3e5bba5a59a 100644 --- a/meta/recipes-core/glibc/glibc/0014-Add-unused-attribute.patch +++ b/meta/recipes-core/glibc/glibc/0016-Add-unused-attribute.patch @@ -1,7 +1,7 @@ -From b84999dcf642b07e6c14e6ff507be14743349949 Mon Sep 17 00:00:00 2001 +From 8a8c81ba4e652dddb730d3dad2fecab1ee65fd9c Mon Sep 17 00:00:00 2001 From: Khem Raj <raj.khem@gmail.com> Date: Wed, 18 Mar 2015 00:28:41 +0000 -Subject: [PATCH 14/28] Add unused attribute +Subject: [PATCH] Add unused attribute Helps in avoiding gcc warning when header is is included in a source file which does not use both functions @@ -17,7 +17,7 @@ Upstream-Status: Pending 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iconv/gconv_charset.h b/iconv/gconv_charset.h -index 91e0ad3141..2e9549fe49 100644 +index 348acc089b..fa92465d89 100644 --- a/iconv/gconv_charset.h +++ b/iconv/gconv_charset.h @@ -21,7 +21,7 @@ @@ -29,6 +29,3 @@ index 91e0ad3141..2e9549fe49 100644 strip (char *wp, const char *s) { int slash_count = 0; --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0015-yes-within-the-path-sets-wrong-config-variables.patch b/meta/recipes-core/glibc/glibc/0017-yes-within-the-path-sets-wrong-config-variables.patch index dd6562a6319..0b626bdfaca 100644 --- a/meta/recipes-core/glibc/glibc/0015-yes-within-the-path-sets-wrong-config-variables.patch +++ b/meta/recipes-core/glibc/glibc/0017-yes-within-the-path-sets-wrong-config-variables.patch @@ -1,7 +1,7 @@ -From 7c57f84bef4aaffe4204a7a354411ab3ea7e5273 Mon Sep 17 00:00:00 2001 +From 601b2d11b6ddd974f0e1685f70e0d368e706d976 Mon Sep 17 00:00:00 2001 From: Khem Raj <raj.khem@gmail.com> Date: Wed, 18 Mar 2015 00:31:06 +0000 -Subject: [PATCH 15/28] 'yes' within the path sets wrong config variables +Subject: [PATCH] 'yes' within the path sets wrong config variables It seems that the 'AC_EGREP_CPP(yes...' example is quite popular but being such a short word to grep it is likely to produce @@ -165,7 +165,7 @@ index f05f43802b..dc8639902d 100644 ], libc_cv_nios2_be=yes, libc_cv_nios2_be=no)]) if test $libc_cv_nios2_be = yes; then diff --git a/sysdeps/unix/sysv/linux/mips/configure b/sysdeps/unix/sysv/linux/mips/configure -index 1ee7f41a36..77e38bebde 100644 +index 25f98e0c7b..e95bfae359 100644 --- a/sysdeps/unix/sysv/linux/mips/configure +++ b/sysdeps/unix/sysv/linux/mips/configure @@ -414,11 +414,11 @@ else @@ -183,7 +183,7 @@ index 1ee7f41a36..77e38bebde 100644 else libc_cv_mips_nan2008=no diff --git a/sysdeps/unix/sysv/linux/mips/configure.ac b/sysdeps/unix/sysv/linux/mips/configure.ac -index 9147aa4582..7898e24738 100644 +index 3db1b32b08..f8cd375ebc 100644 --- a/sysdeps/unix/sysv/linux/mips/configure.ac +++ b/sysdeps/unix/sysv/linux/mips/configure.ac @@ -105,9 +105,9 @@ AC_COMPILE_IFELSE( @@ -258,6 +258,3 @@ index f9cba6e15d..b21f72f1e4 100644 #endif ], libc_cv_ppc64_def_call_elf=yes, libc_cv_ppc64_def_call_elf=no)]) if test $libc_cv_ppc64_def_call_elf = no; then --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0016-timezone-re-written-tzselect-as-posix-sh.patch b/meta/recipes-core/glibc/glibc/0018-timezone-re-written-tzselect-as-posix-sh.patch index 4d1cf319731..f18c7a11077 100644 --- a/meta/recipes-core/glibc/glibc/0016-timezone-re-written-tzselect-as-posix-sh.patch +++ b/meta/recipes-core/glibc/glibc/0018-timezone-re-written-tzselect-as-posix-sh.patch @@ -1,7 +1,7 @@ -From a74f31ea9edf105f1a6dc26497aa2a12ae736660 Mon Sep 17 00:00:00 2001 +From 8678c584bca244fe9a3f8926eabb6b6c7e9784f1 Mon Sep 17 00:00:00 2001 From: Khem Raj <raj.khem@gmail.com> Date: Wed, 18 Mar 2015 00:33:03 +0000 -Subject: [PATCH 16/28] timezone: re-written tzselect as posix sh +Subject: [PATCH] timezone: re-written tzselect as posix sh To avoid the bash dependency. @@ -15,7 +15,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com> 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/timezone/Makefile b/timezone/Makefile -index 493deca790..36e559e16c 100644 +index 75f38df527..74e1ab7ff7 100644 --- a/timezone/Makefile +++ b/timezone/Makefile @@ -122,7 +122,7 @@ $(testdata)/XT%: testdata/XT% @@ -40,6 +40,3 @@ index 18fce27e24..70745f9d36 100755 # Output one argument as-is to standard output. # Safer than 'echo', which can mishandle '\' or leading '-'. --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0017-Remove-bash-dependency-for-nscd-init-script.patch b/meta/recipes-core/glibc/glibc/0019-Remove-bash-dependency-for-nscd-init-script.patch index e4f8a135d30..82026694de9 100644 --- a/meta/recipes-core/glibc/glibc/0017-Remove-bash-dependency-for-nscd-init-script.patch +++ b/meta/recipes-core/glibc/glibc/0019-Remove-bash-dependency-for-nscd-init-script.patch @@ -1,7 +1,7 @@ -From 95882b9864ff20e476d15c6825c83728eb99597f Mon Sep 17 00:00:00 2001 +From a78f21f2f9b9246cd12b310833313328e8f646ed Mon Sep 17 00:00:00 2001 From: Khem Raj <raj.khem@gmail.com> Date: Thu, 31 Dec 2015 14:33:02 -0800 -Subject: [PATCH 17/28] Remove bash dependency for nscd init script +Subject: [PATCH] Remove bash dependency for nscd init script The nscd init script uses #! /bin/bash but only really uses one bashism (translated strings), so remove them and switch the shell to #!/bin/sh. @@ -70,6 +70,3 @@ index a882da7d8b..b02986ec15 100644 RETVAL=1 ;; esac --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0018-eglibc-Cross-building-and-testing-instructions.patch b/meta/recipes-core/glibc/glibc/0020-eglibc-Cross-building-and-testing-instructions.patch index b5efc43042f..f8f3efe582f 100644 --- a/meta/recipes-core/glibc/glibc/0018-eglibc-Cross-building-and-testing-instructions.patch +++ b/meta/recipes-core/glibc/glibc/0020-eglibc-Cross-building-and-testing-instructions.patch @@ -1,7 +1,7 @@ -From 6b603d25cc5723ba631dfc60b544774db1147d81 Mon Sep 17 00:00:00 2001 +From 7c48f61b0c5ef6274df4b03609991d383adc5df0 Mon Sep 17 00:00:00 2001 From: Khem Raj <raj.khem@gmail.com> Date: Wed, 18 Mar 2015 00:42:58 +0000 -Subject: [PATCH 18/28] eglibc: Cross building and testing instructions +Subject: [PATCH] eglibc: Cross building and testing instructions Ported from eglibc Upstream-Status: Pending @@ -614,6 +614,3 @@ index 0000000000..b67b468466 +- Some tests require access to libstdc++.so.6 and libgcc_s.so.1; we + simply place copies of these libraries in the top GLIBC build + directory. --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0019-eglibc-Help-bootstrap-cross-toolchain.patch b/meta/recipes-core/glibc/glibc/0021-eglibc-Help-bootstrap-cross-toolchain.patch index 0333db2814e..02e5def3395 100644 --- a/meta/recipes-core/glibc/glibc/0019-eglibc-Help-bootstrap-cross-toolchain.patch +++ b/meta/recipes-core/glibc/glibc/0021-eglibc-Help-bootstrap-cross-toolchain.patch @@ -1,7 +1,7 @@ -From 2864aaae984d945445f3f79869c703e0b791df88 Mon Sep 17 00:00:00 2001 +From 86a6e94e86664976b305c24e5a52093fe962240a Mon Sep 17 00:00:00 2001 From: Khem Raj <raj.khem@gmail.com> Date: Wed, 18 Mar 2015 00:49:28 +0000 -Subject: [PATCH 19/28] eglibc: Help bootstrap cross toolchain +Subject: [PATCH] eglibc: Help bootstrap cross toolchain Taken from EGLIBC, r1484 + r1525 @@ -29,10 +29,10 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com> create mode 100644 include/stubs-bootstrap.h diff --git a/Makefile b/Makefile -index 9fbf705200..64bfd455bc 100644 +index 8f0a93aceb..8eba23a868 100644 --- a/Makefile +++ b/Makefile -@@ -70,9 +70,18 @@ subdir-dirs = include +@@ -79,9 +79,18 @@ subdir-dirs = include vpath %.h $(subdir-dirs) # What to install. @@ -52,7 +52,7 @@ index 9fbf705200..64bfd455bc 100644 ifeq (yes,$(build-shared)) headers += gnu/lib-names.h endif -@@ -196,6 +205,16 @@ others: $(common-objpfx)testrun.sh +@@ -407,6 +416,16 @@ others: $(common-objpfx)testrun.sh $(common-objpfx)debugglibc.sh subdir-stubs := $(foreach dir,$(subdirs),$(common-objpfx)$(dir)/stubs) @@ -69,7 +69,7 @@ index 9fbf705200..64bfd455bc 100644 ifndef abi-variants installed-stubs = $(inst_includedir)/gnu/stubs.h else -@@ -222,6 +241,7 @@ $(inst_includedir)/gnu/stubs.h: $(+force) +@@ -433,6 +452,7 @@ $(inst_includedir)/gnu/stubs.h: $(+force) install-others-nosubdir: $(installed-stubs) endif @@ -95,6 +95,3 @@ index 0000000000..1d2b669aff + difficult headers. The <gnu/stubs.h> header depends, via the + EGLIBC subdir 'stubs' make targets, on every .o file in EGLIBC, but + an empty stubs.h like this will do fine for GCC. */ --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0020-eglibc-Clear-cache-lines-on-ppc8xx.patch b/meta/recipes-core/glibc/glibc/0022-eglibc-Clear-cache-lines-on-ppc8xx.patch index 965ad6578e3..913aea95634 100644 --- a/meta/recipes-core/glibc/glibc/0020-eglibc-Clear-cache-lines-on-ppc8xx.patch +++ b/meta/recipes-core/glibc/glibc/0022-eglibc-Clear-cache-lines-on-ppc8xx.patch @@ -1,7 +1,7 @@ -From e2667086bf984de4d3f1226b9467761cd5a4c39f Mon Sep 17 00:00:00 2001 +From b397d653670dd02d8310e1d6f0f19a8da90ebafa Mon Sep 17 00:00:00 2001 From: Khem Raj <raj.khem@gmail.com> Date: Thu, 31 Dec 2015 15:15:09 -0800 -Subject: [PATCH 20/28] eglibc: Clear cache lines on ppc8xx +Subject: [PATCH] eglibc: Clear cache lines on ppc8xx 2007-06-13 Nathan Sidwell <nathan@codesourcery.com> Mark Shinwell <shinwell@codesourcery.com> @@ -21,7 +21,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com> 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/sysdeps/unix/sysv/linux/powerpc/dl-sysdep.c b/sysdeps/unix/sysv/linux/powerpc/dl-sysdep.c -index b04ecc4a4c..75bda97241 100644 +index 5d65bc6303..c786f9aa7e 100644 --- a/sysdeps/unix/sysv/linux/powerpc/dl-sysdep.c +++ b/sysdeps/unix/sysv/linux/powerpc/dl-sysdep.c @@ -24,9 +24,21 @@ int __cache_line_size attribute_hidden; @@ -48,7 +48,7 @@ index b04ecc4a4c..75bda97241 100644 break; diff --git a/sysdeps/unix/sysv/linux/powerpc/libc-start.c b/sysdeps/unix/sysv/linux/powerpc/libc-start.c -index 4fd5f70700..1a21e4675c 100644 +index 93f8659fa6..9bb07b36be 100644 --- a/sysdeps/unix/sysv/linux/powerpc/libc-start.c +++ b/sysdeps/unix/sysv/linux/powerpc/libc-start.c @@ -73,11 +73,25 @@ __libc_start_main (int argc, char **argv, @@ -78,6 +78,3 @@ index 4fd5f70700..1a21e4675c 100644 __cache_line_size = av->a_un.a_val; break; #ifndef SHARED --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0021-eglibc-Resolve-__fpscr_values-on-SH4.patch b/meta/recipes-core/glibc/glibc/0023-eglibc-Resolve-__fpscr_values-on-SH4.patch index 76551cf5597..cc8ddeea6fd 100644 --- a/meta/recipes-core/glibc/glibc/0021-eglibc-Resolve-__fpscr_values-on-SH4.patch +++ b/meta/recipes-core/glibc/glibc/0023-eglibc-Resolve-__fpscr_values-on-SH4.patch @@ -1,7 +1,7 @@ -From b7290e54a1bda7a0212131655bc27926fc22de22 Mon Sep 17 00:00:00 2001 +From 02b69fc14ae1d6309e4e17081842b1f89bd40338 Mon Sep 17 00:00:00 2001 From: Khem Raj <raj.khem@gmail.com> Date: Wed, 18 Mar 2015 00:55:53 +0000 -Subject: [PATCH 21/28] eglibc: Resolve __fpscr_values on SH4 +Subject: [PATCH] eglibc: Resolve __fpscr_values on SH4 2010-09-29 Nobuhiro Iwamatsu <iwamatsu@nigauri.org> Andrew Stubbs <ams@codesourcery.com> @@ -33,7 +33,7 @@ index e0938c4165..ca1d7da339 100644 # a* alphasort64; diff --git a/sysdeps/unix/sysv/linux/sh/sysdep.S b/sysdeps/unix/sysv/linux/sh/sysdep.S -index 6ce36d6dd5..425811cc77 100644 +index 85ff3f900e..7743b8d57a 100644 --- a/sysdeps/unix/sysv/linux/sh/sysdep.S +++ b/sysdeps/unix/sysv/linux/sh/sysdep.S @@ -30,3 +30,14 @@ ENTRY (__syscall_error) @@ -51,6 +51,3 @@ index 6ce36d6dd5..425811cc77 100644 + .long 0x80000 +weak_alias (___fpscr_values, __fpscr_values) + --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0022-eglibc-Forward-port-cross-locale-generation-support.patch b/meta/recipes-core/glibc/glibc/0024-eglibc-Forward-port-cross-locale-generation-support.patch index c46021a4784..72278a6822f 100644 --- a/meta/recipes-core/glibc/glibc/0022-eglibc-Forward-port-cross-locale-generation-support.patch +++ b/meta/recipes-core/glibc/glibc/0024-eglibc-Forward-port-cross-locale-generation-support.patch @@ -1,14 +1,14 @@ -From be382b4e0c6de52573f7e037f2d4ff9b1b5bbb6b Mon Sep 17 00:00:00 2001 +From 42fc64ee872491667749499db50e3c51d6a4bfb3 Mon Sep 17 00:00:00 2001 From: Khem Raj <raj.khem@gmail.com> Date: Wed, 18 Mar 2015 01:33:49 +0000 -Subject: [PATCH 22/28] eglibc: Forward port cross locale generation support +Subject: [PATCH] eglibc: Forward port cross locale generation support Upstream-Status: Pending Signed-off-by: Khem Raj <raj.khem@gmail.com> --- locale/Makefile | 3 +- - locale/catnames.c | 48 ++++++++++++++++++++++++++++ + locale/catnames.c | 46 +++++++++++++++++++++++++++ locale/localeinfo.h | 2 +- locale/programs/charmap-dir.c | 6 ++++ locale/programs/ld-collate.c | 17 +++++----- @@ -18,12 +18,12 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com> locale/programs/localedef.c | 8 +++++ locale/programs/locfile.c | 5 ++- locale/programs/locfile.h | 59 +++++++++++++++++++++++++++++++++-- - locale/setlocale.c | 30 ------------------ - 12 files changed, 169 insertions(+), 69 deletions(-) + locale/setlocale.c | 29 ----------------- + 12 files changed, 167 insertions(+), 68 deletions(-) create mode 100644 locale/catnames.c diff --git a/locale/Makefile b/locale/Makefile -index d78cf9b83a..e166f5252e 100644 +index c9694e236e..ba7105fad6 100644 --- a/locale/Makefile +++ b/locale/Makefile @@ -26,7 +26,8 @@ headers = langinfo.h locale.h bits/locale.h \ @@ -38,10 +38,10 @@ index d78cf9b83a..e166f5252e 100644 address telephone measurement identification collate diff --git a/locale/catnames.c b/locale/catnames.c new file mode 100644 -index 0000000000..9fad357db1 +index 0000000000..538f3f5edb --- /dev/null +++ b/locale/catnames.c -@@ -0,0 +1,48 @@ +@@ -0,0 +1,46 @@ +/* Copyright (C) 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + @@ -63,20 +63,18 @@ index 0000000000..9fad357db1 +#include "localeinfo.h" + +/* Define an array of category names (also the environment variable names). */ -+const union catnamestr_t _nl_category_names attribute_hidden = ++const struct catnamestr_t _nl_category_names attribute_hidden = + { -+ { +#define DEFINE_CATEGORY(category, category_name, items, a) \ -+ category_name, ++ category_name, +#include "categories.def" +#undef DEFINE_CATEGORY -+ } + }; + +const uint8_t _nl_category_name_idxs[__LC_LAST] attribute_hidden = + { +#define DEFINE_CATEGORY(category, category_name, items, a) \ -+ [category] = offsetof (union catnamestr_t, CATNAMEMF (__LINE__)), ++ [category] = offsetof (struct catnamestr_t, CATNAMEMF (__LINE__)), +#include "categories.def" +#undef DEFINE_CATEGORY + }; @@ -91,10 +89,10 @@ index 0000000000..9fad357db1 + [LC_ALL] = sizeof ("LC_ALL") - 1 + }; diff --git a/locale/localeinfo.h b/locale/localeinfo.h -index 53cb8bfc59..92c466200c 100644 +index fdc283c69a..4eeed35f90 100644 --- a/locale/localeinfo.h +++ b/locale/localeinfo.h -@@ -224,7 +224,7 @@ __libc_tsd_define (extern, locale_t, LOCALE) +@@ -230,7 +230,7 @@ __libc_tsd_define (extern, locale_t, LOCALE) unused. We can manage this playing some tricks with weak references. But with thread-local locale settings, it becomes quite ungainly unless we can use __thread variables. So only in that case do we attempt this. */ @@ -104,7 +102,7 @@ index 53cb8bfc59..92c466200c 100644 # define NL_CURRENT_INDIRECT 1 #endif diff --git a/locale/programs/charmap-dir.c b/locale/programs/charmap-dir.c -index 94c122df68..80e53e12c8 100644 +index 1a526a240d..0fb2daf936 100644 --- a/locale/programs/charmap-dir.c +++ b/locale/programs/charmap-dir.c @@ -18,7 +18,9 @@ @@ -150,7 +148,7 @@ index 94c122df68..80e53e12c8 100644 return NULL; } diff --git a/locale/programs/ld-collate.c b/locale/programs/ld-collate.c -index 6baab6cfb0..b12a2fceab 100644 +index feb1a11258..5a8e522470 100644 --- a/locale/programs/ld-collate.c +++ b/locale/programs/ld-collate.c @@ -349,7 +349,7 @@ new_element (struct locale_collate_t *collate, const char *mbs, size_t mbslen, @@ -199,7 +197,7 @@ index 6baab6cfb0..b12a2fceab 100644 == runp->wcnext->wcs[runp->nwcs - 1] + 1)); diff --git a/locale/programs/ld-ctype.c b/locale/programs/ld-ctype.c -index cfc9c43fd5..6572cc199c 100644 +index 3328093d0e..d58fb0f4b7 100644 --- a/locale/programs/ld-ctype.c +++ b/locale/programs/ld-ctype.c @@ -915,7 +915,7 @@ ctype_output (struct localedef_t *locale, const struct charmap_t *charmap, @@ -281,7 +279,7 @@ index cfc9c43fd5..6572cc199c 100644 srunp = srunp->next; } diff --git a/locale/programs/ld-time.c b/locale/programs/ld-time.c -index 8e9849fdba..028d3efa9f 100644 +index f7db873adb..fec3773c9d 100644 --- a/locale/programs/ld-time.c +++ b/locale/programs/ld-time.c @@ -220,8 +220,10 @@ No definition for %s category found"), "LC_TIME"); @@ -350,7 +348,7 @@ index 8e9849fdba..028d3efa9f 100644 diff --git a/locale/programs/linereader.c b/locale/programs/linereader.c -index ed3a9731d0..3178ea057a 100644 +index 7ebd933801..5753750756 100644 --- a/locale/programs/linereader.c +++ b/locale/programs/linereader.c @@ -595,7 +595,7 @@ get_string (struct linereader *lr, const struct charmap_t *charmap, @@ -363,7 +361,7 @@ index ed3a9731d0..3178ea057a 100644 size_t bufmax = 56; diff --git a/locale/programs/localedef.c b/locale/programs/localedef.c -index b7bcef8248..efeced1e0f 100644 +index dbbb0145c0..097a8b6193 100644 --- a/locale/programs/localedef.c +++ b/locale/programs/localedef.c @@ -109,6 +109,7 @@ void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version; @@ -409,7 +407,7 @@ index b7bcef8248..efeced1e0f 100644 force_output = 1; break; diff --git a/locale/programs/locfile.c b/locale/programs/locfile.c -index e4ba48e968..e7b0efe887 100644 +index eb2f4634da..d387147323 100644 --- a/locale/programs/locfile.c +++ b/locale/programs/locfile.c @@ -544,6 +544,9 @@ compare_files (const char *filename1, const char *filename2, size_t size, @@ -432,7 +430,7 @@ index e4ba48e968..e7b0efe887 100644 /* Record that FILE's next element is the 32-bit integer VALUE. */ diff --git a/locale/programs/locfile.h b/locale/programs/locfile.h -index c063fc097d..4e7465e55a 100644 +index 7ea10038b4..0888c09762 100644 --- a/locale/programs/locfile.h +++ b/locale/programs/locfile.h @@ -71,6 +71,8 @@ extern void write_all_categories (struct localedef_t *definitions, @@ -521,28 +519,27 @@ index c063fc097d..4e7465e55a 100644 + #endif /* locfile.h */ diff --git a/locale/setlocale.c b/locale/setlocale.c -index 9bd35454b9..2a67dc6589 100644 +index 030f1727bd..096d8ed895 100644 --- a/locale/setlocale.c +++ b/locale/setlocale.c -@@ -64,36 +64,6 @@ static char *const _nl_current_used[] = - #endif +@@ -63,35 +63,6 @@ static char *const _nl_current_used[] = + #endif +- -/* Define an array of category names (also the environment variable names). */ --const union catnamestr_t _nl_category_names attribute_hidden = +-const struct catnamestr_t _nl_category_names attribute_hidden = - { -- { -#define DEFINE_CATEGORY(category, category_name, items, a) \ -- category_name, +- category_name, -#include "categories.def" -#undef DEFINE_CATEGORY -- } - }; - -const uint8_t _nl_category_name_idxs[__LC_LAST] attribute_hidden = - { -#define DEFINE_CATEGORY(category, category_name, items, a) \ -- [category] = offsetof (union catnamestr_t, CATNAMEMF (__LINE__)), +- [category] = offsetof (struct catnamestr_t, CATNAMEMF (__LINE__)), -#include "categories.def" -#undef DEFINE_CATEGORY - }; @@ -561,6 +558,3 @@ index 9bd35454b9..2a67dc6589 100644 #ifdef NL_CURRENT_INDIRECT # define WEAK_POSTLOAD(postload) weak_extern (postload) #else --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0023-Define-DUMMY_LOCALE_T-if-not-defined.patch b/meta/recipes-core/glibc/glibc/0025-Define-DUMMY_LOCALE_T-if-not-defined.patch index 17667da99fa..d3595187510 100644 --- a/meta/recipes-core/glibc/glibc/0023-Define-DUMMY_LOCALE_T-if-not-defined.patch +++ b/meta/recipes-core/glibc/glibc/0025-Define-DUMMY_LOCALE_T-if-not-defined.patch @@ -1,7 +1,7 @@ -From afa8d6faeddeb80aca318b33edf49d9f8ce65761 Mon Sep 17 00:00:00 2001 +From 5e565710aa061ffffd34d8400910c35a8d50a4ec Mon Sep 17 00:00:00 2001 From: Khem Raj <raj.khem@gmail.com> Date: Wed, 20 Apr 2016 21:11:00 -0700 -Subject: [PATCH 23/28] Define DUMMY_LOCALE_T if not defined +Subject: [PATCH] Define DUMMY_LOCALE_T if not defined This is a hack to fix building the locale bits on an older CentOs 5.X machine @@ -14,7 +14,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com> 1 file changed, 3 insertions(+) diff --git a/locale/programs/config.h b/locale/programs/config.h -index a1e6e0ec3c..7f75528eae 100644 +index d76d9f7e8b..92b56d7df3 100644 --- a/locale/programs/config.h +++ b/locale/programs/config.h @@ -19,6 +19,9 @@ @@ -27,6 +27,3 @@ index a1e6e0ec3c..7f75528eae 100644 /* Use the internal textdomain used for libc messages. */ #define PACKAGE _libc_intl_domainname #ifndef VERSION --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0024-localedef-add-to-archive-uses-a-hard-coded-locale-pa.patch b/meta/recipes-core/glibc/glibc/0026-localedef-add-to-archive-uses-a-hard-coded-locale-pa.patch index f68e4f4fa65..8df09d82eed 100644 --- a/meta/recipes-core/glibc/glibc/0024-localedef-add-to-archive-uses-a-hard-coded-locale-pa.patch +++ b/meta/recipes-core/glibc/glibc/0026-localedef-add-to-archive-uses-a-hard-coded-locale-pa.patch @@ -1,8 +1,7 @@ -From c13e18adb634a6fd59129150ab7f9468f64dc931 Mon Sep 17 00:00:00 2001 +From c5b63c8eafc00e01556edd2acff4c541448924cf Mon Sep 17 00:00:00 2001 From: Khem Raj <raj.khem@gmail.com> Date: Fri, 3 Aug 2018 09:42:06 -0700 -Subject: [PATCH 24/28] localedef --add-to-archive uses a hard-coded locale - path +Subject: [PATCH] localedef --add-to-archive uses a hard-coded locale path it doesn't exist in normal use, and there's no way to pass an alternative filename. @@ -19,7 +18,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com> 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/locale/programs/locarchive.c b/locale/programs/locarchive.c -index e6310b18be..f54a76eade 100644 +index dccaf04e3b..ae0b7fe155 100644 --- a/locale/programs/locarchive.c +++ b/locale/programs/locarchive.c @@ -340,12 +340,24 @@ enlarge_archive (struct locarhandle *ah, const struct locarhead *head) @@ -79,6 +78,3 @@ index e6310b18be..f54a76eade 100644 { if (readonly) { --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0025-elf-dl-deps.c-Make-_dl_build_local_scope-breadth-fir.patch b/meta/recipes-core/glibc/glibc/0027-elf-dl-deps.c-Make-_dl_build_local_scope-breadth-fir.patch index 76a9eb25634..55250d8d8e0 100644 --- a/meta/recipes-core/glibc/glibc/0025-elf-dl-deps.c-Make-_dl_build_local_scope-breadth-fir.patch +++ b/meta/recipes-core/glibc/glibc/0027-elf-dl-deps.c-Make-_dl_build_local_scope-breadth-fir.patch @@ -1,7 +1,7 @@ -From 7c9ebe966bb97dd14de5719905b61311211ae3c8 Mon Sep 17 00:00:00 2001 +From d3349ae8d9b17fecf6ef560b845d04d682db291c Mon Sep 17 00:00:00 2001 From: Mark Hatle <mark.hatle@windriver.com> Date: Thu, 18 Aug 2016 14:07:58 -0500 -Subject: [PATCH 25/28] elf/dl-deps.c: Make _dl_build_local_scope breadth first +Subject: [PATCH] elf/dl-deps.c: Make _dl_build_local_scope breadth first According to the ELF specification: @@ -24,7 +24,7 @@ Signed-off-by: Mark Hatle <mark.hatle@windriver.com> 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/elf/dl-deps.c b/elf/dl-deps.c -index e12c353158..9234daac05 100644 +index 5103a8a111..54cd80aaff 100644 --- a/elf/dl-deps.c +++ b/elf/dl-deps.c @@ -73,13 +73,19 @@ _dl_build_local_scope (struct link_map **list, struct link_map *map) @@ -51,6 +51,3 @@ index e12c353158..9234daac05 100644 return p - list; } --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0026-intl-Emit-no-lines-in-bison-generated-files.patch b/meta/recipes-core/glibc/glibc/0028-intl-Emit-no-lines-in-bison-generated-files.patch index 7589e11d577..06d23c988db 100644 --- a/meta/recipes-core/glibc/glibc/0026-intl-Emit-no-lines-in-bison-generated-files.patch +++ b/meta/recipes-core/glibc/glibc/0028-intl-Emit-no-lines-in-bison-generated-files.patch @@ -1,7 +1,7 @@ -From aa5c758fbb7dbb026df33fc6bdc05548547bdb17 Mon Sep 17 00:00:00 2001 +From 3650ad7f01509138aa72f235e680c9d4f6c09a7d Mon Sep 17 00:00:00 2001 From: Khem Raj <raj.khem@gmail.com> Date: Fri, 3 Aug 2018 09:44:00 -0700 -Subject: [PATCH 26/28] intl: Emit no lines in bison generated files +Subject: [PATCH] intl: Emit no lines in bison generated files Improve reproducibility: Do not put any #line preprocessor commands in bison generated files. @@ -17,7 +17,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com> 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intl/Makefile b/intl/Makefile -index 9eea8d57e3..627dce4cf1 100644 +index ce3072420f..58457840d9 100644 --- a/intl/Makefile +++ b/intl/Makefile @@ -155,7 +155,7 @@ $(objpfx)tst-gettext6.out: $(objpfx)tst-gettext.out @@ -29,6 +29,3 @@ index 9eea8d57e3..627dce4cf1 100644 $(inst_localedir)/locale.alias: locale.alias $(+force) $(do-install) --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0027-inject-file-assembly-directives.patch b/meta/recipes-core/glibc/glibc/0029-inject-file-assembly-directives.patch index dc205a833f8..62e615786d9 100644 --- a/meta/recipes-core/glibc/glibc/0027-inject-file-assembly-directives.patch +++ b/meta/recipes-core/glibc/glibc/0029-inject-file-assembly-directives.patch @@ -1,7 +1,7 @@ -From fecd98040a2ae1bc5943a40a1623d76a696e0785 Mon Sep 17 00:00:00 2001 +From a9be0c7c67e67d870e2c5e0ece4f6ac76e5c0fe2 Mon Sep 17 00:00:00 2001 From: Khem Raj <raj.khem@gmail.com> Date: Thu, 29 Nov 2018 17:29:35 -0800 -Subject: [PATCH 27/28] inject file assembly directives +Subject: [PATCH] inject file assembly directives Currently, non-IA builds are not reproducibile since build paths are being injected into the debug symbols. These are coming from the use of @@ -48,7 +48,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com> 20 files changed, 40 insertions(+) diff --git a/csu/abi-note.S b/csu/abi-note.S -index fa1f014a88..098731362a 100644 +index 2b4b5f8824..964843016c 100644 --- a/csu/abi-note.S +++ b/csu/abi-note.S @@ -56,6 +56,8 @@ offset length contents @@ -61,7 +61,7 @@ index fa1f014a88..098731362a 100644 name begins with `.note' and creates a PT_NOTE program header entry pointing at it. */ diff --git a/sysdeps/aarch64/crti.S b/sysdeps/aarch64/crti.S -index d4e7dfcf5c..e0218df30c 100644 +index 1728eac37a..76a8ab590b 100644 --- a/sysdeps/aarch64/crti.S +++ b/sysdeps/aarch64/crti.S @@ -50,6 +50,8 @@ @@ -74,7 +74,7 @@ index d4e7dfcf5c..e0218df30c 100644 weak_extern (PREINIT_FUNCTION) #else diff --git a/sysdeps/aarch64/crtn.S b/sysdeps/aarch64/crtn.S -index 363f752460..2fb06fba62 100644 +index c3e97cc449..fc2e5c2df8 100644 --- a/sysdeps/aarch64/crtn.S +++ b/sysdeps/aarch64/crtn.S @@ -37,6 +37,8 @@ @@ -87,7 +87,7 @@ index 363f752460..2fb06fba62 100644 ldp x29, x30, [sp], 16 RET diff --git a/sysdeps/aarch64/dl-tlsdesc.S b/sysdeps/aarch64/dl-tlsdesc.S -index 4abe6b82a3..8c44b2ff8a 100644 +index 557ad1d505..194a8531da 100644 --- a/sysdeps/aarch64/dl-tlsdesc.S +++ b/sysdeps/aarch64/dl-tlsdesc.S @@ -22,6 +22,8 @@ @@ -100,7 +100,7 @@ index 4abe6b82a3..8c44b2ff8a 100644 #define SAVE_Q_REGISTERS \ stp q0, q1, [sp, #-32*NSAVEDQREGPAIRS]!; \ diff --git a/sysdeps/aarch64/dl-trampoline.S b/sysdeps/aarch64/dl-trampoline.S -index 19b117e8f9..38c78b5409 100644 +index 94e965c096..ba18742f3e 100644 --- a/sysdeps/aarch64/dl-trampoline.S +++ b/sysdeps/aarch64/dl-trampoline.S @@ -21,6 +21,8 @@ @@ -113,7 +113,7 @@ index 19b117e8f9..38c78b5409 100644 #define ip0l PTR_REG (16) #define ip1 x17 diff --git a/sysdeps/aarch64/start.S b/sysdeps/aarch64/start.S -index f5e9b9c223..ae3e22a6a5 100644 +index d96cf57e2d..07a523978a 100644 --- a/sysdeps/aarch64/start.S +++ b/sysdeps/aarch64/start.S @@ -18,6 +18,8 @@ @@ -136,7 +136,7 @@ index 07bd4c4619..7213b16f27 100644 alignment in any callee. */ .eabi_attribute 25, 1 diff --git a/sysdeps/arm/crti.S b/sysdeps/arm/crti.S -index 26dbba66a3..dd84ecd566 100644 +index 8169783267..f56e0c85a6 100644 --- a/sysdeps/arm/crti.S +++ b/sysdeps/arm/crti.S @@ -57,6 +57,8 @@ @@ -149,7 +149,7 @@ index 26dbba66a3..dd84ecd566 100644 .p2align 2 .type call_weak_fn, %function diff --git a/sysdeps/arm/crtn.S b/sysdeps/arm/crtn.S -index 8f91c8d88b..a87fe49e07 100644 +index d60f9f05de..1e10ec439f 100644 --- a/sysdeps/arm/crtn.S +++ b/sysdeps/arm/crtn.S @@ -37,6 +37,8 @@ @@ -162,7 +162,7 @@ index 8f91c8d88b..a87fe49e07 100644 corresponding to the prologues in crti.S. */ diff --git a/sysdeps/arm/dl-tlsdesc.S b/sysdeps/arm/dl-tlsdesc.S -index a929340b42..b724c9776d 100644 +index 8415e47607..29c2cb8128 100644 --- a/sysdeps/arm/dl-tlsdesc.S +++ b/sysdeps/arm/dl-tlsdesc.S @@ -21,6 +21,8 @@ @@ -175,7 +175,7 @@ index a929340b42..b724c9776d 100644 @ emit debug information with cfi @ use arm-specific pseudos for unwinding itself diff --git a/sysdeps/arm/dl-trampoline.S b/sysdeps/arm/dl-trampoline.S -index 325cfcd2ce..4bfdcbce51 100644 +index a20baf555e..2dd3bef04e 100644 --- a/sysdeps/arm/dl-trampoline.S +++ b/sysdeps/arm/dl-trampoline.S @@ -21,6 +21,8 @@ @@ -188,7 +188,7 @@ index 325cfcd2ce..4bfdcbce51 100644 .globl _dl_runtime_resolve .type _dl_runtime_resolve, #function diff --git a/sysdeps/arm/start.S b/sysdeps/arm/start.S -index a05f8a4651..2f4374fcaa 100644 +index 2ff56179d2..c118046ec6 100644 --- a/sysdeps/arm/start.S +++ b/sysdeps/arm/start.S @@ -57,6 +57,8 @@ @@ -201,7 +201,7 @@ index a05f8a4651..2f4374fcaa 100644 alignment in any callee. */ .eabi_attribute 25, 1 diff --git a/sysdeps/mips/start.S b/sysdeps/mips/start.S -index 8638e5b545..93f6564aec 100644 +index fabc8080df..83c6b91d7d 100644 --- a/sysdeps/mips/start.S +++ b/sysdeps/mips/start.S @@ -38,6 +38,8 @@ @@ -214,7 +214,7 @@ index 8638e5b545..93f6564aec 100644 #error ENTRY_POINT needs to be defined for start.S on MIPS/ELF. #endif diff --git a/sysdeps/powerpc/powerpc32/dl-start.S b/sysdeps/powerpc/powerpc32/dl-start.S -index 99a10d643a..e47fc0d245 100644 +index c15242d3bc..6ca27715a4 100644 --- a/sysdeps/powerpc/powerpc32/dl-start.S +++ b/sysdeps/powerpc/powerpc32/dl-start.S @@ -18,6 +18,8 @@ @@ -227,7 +227,7 @@ index 99a10d643a..e47fc0d245 100644 The C function `_dl_start' is the real entry point; its return value is the user program's entry point. */ diff --git a/sysdeps/powerpc/powerpc32/start.S b/sysdeps/powerpc/powerpc32/start.S -index 172fb5a56b..ef1471b861 100644 +index b7b9a133a2..8df714f81a 100644 --- a/sysdeps/powerpc/powerpc32/start.S +++ b/sysdeps/powerpc/powerpc32/start.S @@ -35,6 +35,8 @@ @@ -240,7 +240,7 @@ index 172fb5a56b..ef1471b861 100644 before crtbegin.o, the file defining __EH_FRAME_BEGIN__. */ #undef cfi_startproc diff --git a/sysdeps/powerpc/powerpc64/start.S b/sysdeps/powerpc/powerpc64/start.S -index 55fae68ad6..0cb608fe0f 100644 +index 94bf771e83..cffb99500a 100644 --- a/sysdeps/powerpc/powerpc64/start.S +++ b/sysdeps/powerpc/powerpc64/start.S @@ -35,6 +35,8 @@ @@ -253,7 +253,7 @@ index 55fae68ad6..0cb608fe0f 100644 before crtbegin.o, the file defining __EH_FRAME_BEGIN__. */ #undef cfi_startproc diff --git a/sysdeps/unix/sysv/linux/aarch64/__read_tp.S b/sysdeps/unix/sysv/linux/aarch64/__read_tp.S -index 30a29b9fb0..07892b383f 100644 +index 12e1131fe7..767e0d043b 100644 --- a/sysdeps/unix/sysv/linux/aarch64/__read_tp.S +++ b/sysdeps/unix/sysv/linux/aarch64/__read_tp.S @@ -18,6 +18,8 @@ @@ -266,7 +266,7 @@ index 30a29b9fb0..07892b383f 100644 ENTRY (__read_tp) mrs x0, tpidr_el0 diff --git a/sysdeps/unix/sysv/linux/arm/aeabi_read_tp.S b/sysdeps/unix/sysv/linux/arm/aeabi_read_tp.S -index f64c4ffe8a..2da315ab08 100644 +index 3b0d611039..4a7e476c37 100644 --- a/sysdeps/unix/sysv/linux/arm/aeabi_read_tp.S +++ b/sysdeps/unix/sysv/linux/arm/aeabi_read_tp.S @@ -39,6 +39,8 @@ @@ -279,7 +279,7 @@ index f64c4ffe8a..2da315ab08 100644 ENTRY (__aeabi_read_tp) #ifdef ARCH_HAS_HARD_TP diff --git a/sysdeps/unix/sysv/linux/arm/libc-do-syscall.S b/sysdeps/unix/sysv/linux/arm/libc-do-syscall.S -index 0b6237ac55..8cda491c28 100644 +index fb5e0c7d97..bd07bdb38b 100644 --- a/sysdeps/unix/sysv/linux/arm/libc-do-syscall.S +++ b/sysdeps/unix/sysv/linux/arm/libc-do-syscall.S @@ -27,6 +27,8 @@ @@ -299,6 +299,3 @@ index eeb96544e3..da182b28f8 100644 + .file "dl-brk.S" + #include <brk.S> --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0028-locale-prevent-maybe-uninitialized-errors-with-Os-BZ.patch b/meta/recipes-core/glibc/glibc/0030-locale-prevent-maybe-uninitialized-errors-with-Os-BZ.patch index 6c49066fd1b..195b1b00814 100644 --- a/meta/recipes-core/glibc/glibc/0028-locale-prevent-maybe-uninitialized-errors-with-Os-BZ.patch +++ b/meta/recipes-core/glibc/glibc/0030-locale-prevent-maybe-uninitialized-errors-with-Os-BZ.patch @@ -1,7 +1,7 @@ -From d934788e3221c28c9a1892235cbe4cfd1b28ced0 Mon Sep 17 00:00:00 2001 +From eaa1e89df6d760c3719e7060662c60b41ab6e87b Mon Sep 17 00:00:00 2001 From: Martin Jansa <martin.jansa@gmail.com> Date: Mon, 17 Dec 2018 21:36:18 +0000 -Subject: [PATCH 28/28] locale: prevent maybe-uninitialized errors with -Os [BZ +Subject: [PATCH] locale: prevent maybe-uninitialized errors with -Os [BZ #19444] Fixes following error when building for aarch64 with -Os: @@ -33,7 +33,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com> 1 file changed, 7 insertions(+) diff --git a/locale/weight.h b/locale/weight.h -index 7ca81498b2..d608ca70bb 100644 +index e071253f85..2889c395f1 100644 --- a/locale/weight.h +++ b/locale/weight.h @@ -28,7 +28,14 @@ findidx (const int32_t *table, @@ -51,6 +51,3 @@ index 7ca81498b2..d608ca70bb 100644 const unsigned char *cp; const unsigned char *usrc; --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0031-Refactor-FORTIFY-in-glibc.patch b/meta/recipes-core/glibc/glibc/0031-Refactor-FORTIFY-in-glibc.patch new file mode 100644 index 00000000000..fe10218c31a --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0031-Refactor-FORTIFY-in-glibc.patch @@ -0,0 +1,2780 @@ +From 4a6f67ae2438c5e7f9cd627d5cf4a7148b9ad18d Mon Sep 17 00:00:00 2001 +From: George Burgess IV <gbiv@google.com> +Date: Sat, 11 Jan 2020 10:33:19 -0800 +Subject: [PATCH] Refactor FORTIFY in glibc + +Upstream-Status: Submitted [https://sourceware.org/ml/libc-alpha/2017-09/msg00434.html] + +Signed-off-by: George Burgess IV <gbiv@google.com> +Signed-off-by: Khem Raj <raj.khem@gmail.com> +--- + io/bits/fcntl2.h | 125 ++++++-- + io/bits/poll2.h | 54 ++-- + io/fcntl.h | 2 +- + libio/bits/stdio2.h | 303 +++++++++++--------- + misc/bits/syslog.h | 38 ++- + misc/sys/cdefs.h | 164 ++++++++++- + posix/bits/unistd.h | 366 ++++++++++-------------- + rt/bits/mqueue2.h | 44 ++- + rt/mqueue.h | 2 +- + socket/bits/socket2.h | 56 ++-- + stdlib/bits/stdlib.h | 117 ++++---- + string/bits/string_fortified.h | 136 ++++++--- + string/bits/strings_fortified.h | 36 ++- + wcsmbs/bits/wchar2.h | 487 ++++++++++++++------------------ + 14 files changed, 1093 insertions(+), 837 deletions(-) + +--- a/io/bits/fcntl2.h ++++ b/io/bits/fcntl2.h +@@ -32,10 +32,28 @@ extern int __REDIRECT (__open_2, (const + extern int __REDIRECT (__open_alias, (const char *__path, int __oflag, ...), + open64) __nonnull ((1)); + #endif +-__errordecl (__open_too_many_args, +- "open can be called either with 2 or 3 arguments, not more"); +-__errordecl (__open_missing_mode, +- "open with O_CREAT or O_TMPFILE in second argument needs 3 arguments"); ++ ++#define __warn_open_too_many_args \ ++ "open can be called either with 2 or 3 arguments, not more" ++#define __warn_open_missing_mode \ ++ "open with O_CREAT in second argument needs 3 arguments" ++#ifdef __use_clang_fortify ++__fortify_overload __clang_prefer_this_overload int ++open (const char *const __clang_pass_object_size __path, int __oflag) ++ __clang_error_if (__OPEN_NEEDS_MODE (__oflag), __warn_open_missing_mode) ++{ ++ return __open_2 (__path, __oflag); ++} ++ ++__fortify_overload int ++open (const char *const __clang_pass_object_size __path, int __oflag, ++ mode_t __mode) ++{ ++ return __open_alias (__path, __oflag, __mode); ++} ++#else ++__errordecl (__open_too_many_args, __warn_open_too_many_args); ++__errordecl (__open_missing_mode, __warn_open_missing_mode); + + __fortify_function int + open (const char *__path, int __oflag, ...) +@@ -58,16 +76,37 @@ open (const char *__path, int __oflag, . + + return __open_alias (__path, __oflag, __va_arg_pack ()); + } ++#endif ++#undef __warn_open_too_many_args ++#undef __warn_open_missing_mode + + + #ifdef __USE_LARGEFILE64 + extern int __open64_2 (const char *__path, int __oflag) __nonnull ((1)); + extern int __REDIRECT (__open64_alias, (const char *__path, int __oflag, + ...), open64) __nonnull ((1)); +-__errordecl (__open64_too_many_args, +- "open64 can be called either with 2 or 3 arguments, not more"); +-__errordecl (__open64_missing_mode, +- "open64 with O_CREAT or O_TMPFILE in second argument needs 3 arguments"); ++ ++# define __warn_open64_too_many_args \ ++ "open64 can be called either with 2 or 3 arguments, not more" ++# define __warn_open64_missing_mode \ ++ "open64 with O_CREAT in second argument needs 3 arguments" ++# ifdef __use_clang_fortify ++__fortify_overload __clang_prefer_this_overload int ++open64 (const char *const __clang_pass_object_size __path, int __oflag) ++ __clang_error_if (__OPEN_NEEDS_MODE (__oflag), __warn_open64_missing_mode) ++{ ++ return __open64_2 (__path, __oflag); ++} ++ ++__fortify_overload __clang_prefer_this_overload int ++open64 (const char *const __clang_pass_object_size __path, int __oflag, ++ int __mode) ++{ ++ return __open64_alias (__path, __oflag, __mode); ++} ++# else ++__errordecl (__open64_too_many_args, __warn_open64_too_many_args); ++__errordecl (__open64_missing_mode, __warn_open64_missing_mode); + + __fortify_function int + open64 (const char *__path, int __oflag, ...) +@@ -90,6 +129,9 @@ open64 (const char *__path, int __oflag, + + return __open64_alias (__path, __oflag, __va_arg_pack ()); + } ++# endif ++# undef __warn_open64_too_many_args ++# undef __warn_open64_missing_mode + #endif + + +@@ -108,10 +150,32 @@ extern int __REDIRECT (__openat_alias, ( + int __oflag, ...), openat64) + __nonnull ((2)); + # endif +-__errordecl (__openat_too_many_args, +- "openat can be called either with 3 or 4 arguments, not more"); +-__errordecl (__openat_missing_mode, +- "openat with O_CREAT or O_TMPFILE in third argument needs 4 arguments"); ++ ++# define __warn_openat_too_many_args "openat can be called either with 3 or " \ ++ "4 arguments, not more" ++# define __warn_openat_missing_mode "openat with O_CREAT in third argument " \ ++ "needs 4 arguments" ++# ifdef __use_clang_fortify ++__fortify_error_function __clang_error (__warn_openat_too_many_args) int ++openat (int __fd, const char *__path, int __oflag, int __mode, ...); ++ ++__fortify_overload __clang_prefer_this_overload int ++openat (int __fd, const char *const __clang_pass_object_size __path, ++ int __oflag) ++ __clang_error_if (__OPEN_NEEDS_MODE (__oflag), __warn_openat_missing_mode) ++{ ++ return __openat_2 (__fd, __path, __oflag); ++} ++ ++__fortify_overload __clang_prefer_this_overload int ++openat (int __fd, const char *const __clang_pass_object_size __path, ++ int __oflag, int __mode) ++{ ++ return __openat_alias (__fd, __path, __oflag, __mode); ++} ++# else ++__errordecl (__openat_too_many_args, __warn_openat_too_many_args); ++__errordecl (__openat_missing_mode, __warn_openat_missing_mode); + + __fortify_function int + openat (int __fd, const char *__path, int __oflag, ...) +@@ -134,6 +198,9 @@ openat (int __fd, const char *__path, in + + return __openat_alias (__fd, __path, __oflag, __va_arg_pack ()); + } ++# endif ++# undef __warn_openat_too_many_args ++# undef __warn_openat_missing_mode + + + # ifdef __USE_LARGEFILE64 +@@ -142,11 +209,34 @@ extern int __openat64_2 (int __fd, const + extern int __REDIRECT (__openat64_alias, (int __fd, const char *__path, + int __oflag, ...), openat64) + __nonnull ((2)); +-__errordecl (__openat64_too_many_args, +- "openat64 can be called either with 3 or 4 arguments, not more"); +-__errordecl (__openat64_missing_mode, +- "openat64 with O_CREAT or O_TMPFILE in third argument needs 4 arguments"); + ++# define __warn_openat64_too_many_args "openat64 can be called either with " \ ++ "3 or 4 arguments, not more" ++# define __warn_openat64_missing_mode "openat64 with O_CREAT in third " \ ++ "argument needs 4 arguments" ++ ++# ifdef __use_clang_fortify ++__fortify_error_function __clang_error (__warn_openat64_too_many_args) int ++openat64 (int __fd, const char *__path, int __oflag, int __mode, ...); ++ ++__fortify_overload __clang_prefer_this_overload int ++openat64 (int __fd, const char *const __clang_pass_object_size __path, ++ int __oflag) ++ __clang_error_if (__OPEN_NEEDS_MODE (__oflag), ++ __warn_openat64_missing_mode) ++{ ++ return __openat64_2 (__fd, __path, __oflag); ++} ++ ++__fortify_overload __clang_prefer_this_overload int ++openat64 (int __fd, const char *const __clang_pass_object_size __path, ++ int __oflag, int __mode) ++{ ++ return __openat64_alias (__fd, __path, __oflag, __mode); ++} ++# else ++__errordecl (__openat64_too_many_args, __warn_openat64_too_many_args); ++__errordecl (__openat64_missing_mode, __warn_openat64_missing_mode); + __fortify_function int + openat64 (int __fd, const char *__path, int __oflag, ...) + { +@@ -168,5 +258,8 @@ openat64 (int __fd, const char *__path, + + return __openat64_alias (__fd, __path, __oflag, __va_arg_pack ()); + } ++# endif ++# undef __warn_openat64_too_many_args ++# undef __warn_openat64_missing_mode + # endif + #endif +--- a/io/bits/poll2.h ++++ b/io/bits/poll2.h +@@ -27,25 +27,20 @@ extern int __REDIRECT (__poll_alias, (st + int __timeout), poll); + extern int __poll_chk (struct pollfd *__fds, nfds_t __nfds, int __timeout, + __SIZE_TYPE__ __fdslen); +-extern int __REDIRECT (__poll_chk_warn, (struct pollfd *__fds, nfds_t __nfds, +- int __timeout, __SIZE_TYPE__ __fdslen), +- __poll_chk) +- __warnattr ("poll called with fds buffer too small file nfds entries"); + +-__fortify_function int +-poll (struct pollfd *__fds, nfds_t __nfds, int __timeout) ++__fortify_potential_overload int ++poll (struct pollfd *const __clang_pass_object_size __fds, nfds_t __nfds, ++ int __timeout) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_ONLY_IF_BOS_LT2 (__poll_warn, __nfds, __fds, ++ sizeof (*__fds), ++ "poll called with fds buffer too small") + { +- if (__bos (__fds) != (__SIZE_TYPE__) -1) +- { +- if (! __builtin_constant_p (__nfds)) +- return __poll_chk (__fds, __nfds, __timeout, __bos (__fds)); +- else if (__bos (__fds) / sizeof (*__fds) < __nfds) +- return __poll_chk_warn (__fds, __nfds, __timeout, __bos (__fds)); +- } +- ++ if (__FORTIFY_CALL_CHK && __bos (__fds) != (__SIZE_TYPE__) -1) ++ return __poll_chk (__fds, __nfds, __timeout, __bos (__fds)); + return __poll_alias (__fds, __nfds, __timeout); + } +- ++__FORTIFY_FUNCTION_END + + #ifdef __USE_GNU + extern int __REDIRECT (__ppoll_alias, (struct pollfd *__fds, nfds_t __nfds, +@@ -54,28 +49,21 @@ extern int __REDIRECT (__ppoll_alias, (s + extern int __ppoll_chk (struct pollfd *__fds, nfds_t __nfds, + const struct timespec *__timeout, + const __sigset_t *__ss, __SIZE_TYPE__ __fdslen); +-extern int __REDIRECT (__ppoll_chk_warn, (struct pollfd *__fds, nfds_t __nfds, +- const struct timespec *__timeout, +- const __sigset_t *__ss, +- __SIZE_TYPE__ __fdslen), +- __ppoll_chk) +- __warnattr ("ppoll called with fds buffer too small file nfds entries"); + +-__fortify_function int +-ppoll (struct pollfd *__fds, nfds_t __nfds, const struct timespec *__timeout, +- const __sigset_t *__ss) ++__fortify_potential_overload int ++ppoll (struct pollfd *const __clang_pass_object_size __fds, nfds_t __nfds, ++ const struct timespec *__timeout, const __sigset_t *__ss) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_ONLY_IF_BOS_LT2 (__ppoll_warn, __nfds, __fds, ++ sizeof (*__fds), ++ "ppoll called with fds buffer too " ++ "small file nfds entries") + { +- if (__bos (__fds) != (__SIZE_TYPE__) -1) +- { +- if (! __builtin_constant_p (__nfds)) +- return __ppoll_chk (__fds, __nfds, __timeout, __ss, __bos (__fds)); +- else if (__bos (__fds) / sizeof (*__fds) < __nfds) +- return __ppoll_chk_warn (__fds, __nfds, __timeout, __ss, +- __bos (__fds)); +- } +- ++ if (__FORTIFY_CALL_CHK && __bos (__fds) != (__SIZE_TYPE__) -1) ++ return __ppoll_chk (__fds, __nfds, __timeout, __ss, __bos (__fds)); + return __ppoll_alias (__fds, __nfds, __timeout, __ss); + } ++__FORTIFY_FUNCTION_END + #endif + + __END_DECLS +--- a/io/fcntl.h ++++ b/io/fcntl.h +@@ -325,7 +325,7 @@ extern int posix_fallocate64 (int __fd, + + /* Define some inlines helping to catch common problems. */ + #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function \ +- && defined __va_arg_pack_len ++ && (defined __va_arg_pack_len || defined __use_clang_fortify) + # include <bits/fcntl2.h> + #endif + +--- a/libio/bits/stdio2.h ++++ b/libio/bits/stdio2.h +@@ -29,12 +29,23 @@ extern int __vsprintf_chk (char *__restr + const char *__restrict __format, + __gnuc_va_list __ap) __THROW; + +-#ifdef __va_arg_pack +-__fortify_function int +-__NTH (sprintf (char *__restrict __s, const char *__restrict __fmt, ...)) +-{ +- return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1, +- __bos (__s), __fmt, __va_arg_pack ()); ++#define __mul_may_overflow(size, n) \ ++ ((size | n) >= (((size_t)1) << (8 * sizeof (size_t) / 2))) ++ ++#ifdef __FORTIFY_ARG_PACK_OK ++/* clang doesn't have __va_arg_pack, so we need to defer to the va_arg versions ++ of these functions. */ ++__fortify_potential_overload int ++__NTH (sprintf (char *__restrict const __clang_pass_object_size __s, ++ const char *__restrict __fmt, ...)) ++{ ++ __FORTIFY_INIT_ARG_PACK(__fmt); ++ int __result = __FORTIFY_CALL_VA_BUILTIN (sprintf, __s, ++ __USE_FORTIFY_LEVEL - 1, ++ __bos (__s), __fmt, ++ __FORTIFY_ARG_PACK); ++ __FORTIFY_FREE_ARG_PACK(); ++ return __result; + } + #elif !defined __cplusplus + # define sprintf(str, ...) \ +@@ -42,9 +53,9 @@ __NTH (sprintf (char *__restrict __s, co + __VA_ARGS__) + #endif + +-__fortify_function int +-__NTH (vsprintf (char *__restrict __s, const char *__restrict __fmt, +- __gnuc_va_list __ap)) ++__fortify_potential_overload int ++__NTH (vsprintf (char *__restrict const __clang_pass_object_size __s, ++ const char *__restrict __fmt, __gnuc_va_list __ap)) + { + return __builtin___vsprintf_chk (__s, __USE_FORTIFY_LEVEL - 1, + __bos (__s), __fmt, __ap); +@@ -59,13 +70,21 @@ extern int __vsnprintf_chk (char *__rest + size_t __slen, const char *__restrict __format, + __gnuc_va_list __ap) __THROW; + +-# ifdef __va_arg_pack +-__fortify_function int +-__NTH (snprintf (char *__restrict __s, size_t __n, +- const char *__restrict __fmt, ...)) +-{ +- return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, +- __bos (__s), __fmt, __va_arg_pack ()); ++# ifdef __FORTIFY_ARG_PACK_OK ++__fortify_potential_overload __attribute__ ((__format__ (__printf__, 3, 4))) int ++__NTH (snprintf (char *__restrict const __clang_pass_object_size __s, ++ size_t __n, const char *__restrict __fmt, ...)) ++ /* GCC's builtin will catch this, so we just need to cover clang here. */ ++ __clang_warning_if (__bos_static_lt (__n, __s), ++ "call to snprintf may overflow the destination buffer") ++{ ++ __FORTIFY_INIT_ARG_PACK(__fmt); ++ int __result = __FORTIFY_CALL_VA_BUILTIN (snprintf, __s, __n, ++ __USE_FORTIFY_LEVEL - 1, ++ __bos (__s), __fmt, ++ __FORTIFY_ARG_PACK); ++ __FORTIFY_FREE_ARG_PACK(); ++ return __result; + } + # elif !defined __cplusplus + # define snprintf(str, len, ...) \ +@@ -73,9 +92,12 @@ __NTH (snprintf (char *__restrict __s, s + __VA_ARGS__) + # endif + +-__fortify_function int +-__NTH (vsnprintf (char *__restrict __s, size_t __n, +- const char *__restrict __fmt, __gnuc_va_list __ap)) ++__fortify_potential_overload __attribute__ ((__format__ (__printf__, 3, 0))) int ++__NTH (vsnprintf (char *__restrict const __clang_pass_object_size __s, ++ size_t __n, const char *__restrict __fmt, __gnuc_va_list __ap)) ++ __clang_warning_if (__bos_static_lt (__n, __s), ++ "call to vsnprintf may overflow the destination " ++ "buffer") + { + return __builtin___vsnprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, + __bos (__s), __fmt, __ap); +@@ -93,18 +115,27 @@ extern int __vfprintf_chk (FILE *__restr + extern int __vprintf_chk (int __flag, const char *__restrict __format, + __gnuc_va_list __ap); + +-# ifdef __va_arg_pack +-__fortify_function int +-fprintf (FILE *__restrict __stream, const char *__restrict __fmt, ...) +-{ +- return __fprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt, +- __va_arg_pack ()); +-} +- +-__fortify_function int +-printf (const char *__restrict __fmt, ...) +-{ +- return __printf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ()); ++# ifdef __FORTIFY_ARG_PACK_OK ++__fortify_potential_overload __attribute__ ((__format__ (__printf__, 2, 3))) int ++fprintf (FILE *__restrict const __clang_pass_object_size __stream, ++ const char *__restrict __fmt, ...) ++{ ++ __FORTIFY_INIT_ARG_PACK(__fmt); ++ int __result = __FORTIFY_CALL_VA_CHK (fprintf, __stream, ++ __USE_FORTIFY_LEVEL - 1, __fmt, ++ __FORTIFY_ARG_PACK); ++ __FORTIFY_FREE_ARG_PACK(); ++ return __result; ++} ++ ++__fortify_potential_overload __attribute__ ((__format__ (__printf__, 1, 2))) int ++printf (const char *__restrict const __clang_pass_object_size __fmt, ...) ++{ ++ __FORTIFY_INIT_ARG_PACK(__fmt); ++ int __result = __FORTIFY_CALL_VA_CHK (printf, __USE_FORTIFY_LEVEL - 1, __fmt, ++ __FORTIFY_ARG_PACK); ++ __FORTIFY_FREE_ARG_PACK(); ++ return __result; + } + # elif !defined __cplusplus + # define printf(...) \ +@@ -113,8 +144,9 @@ printf (const char *__restrict __fmt, .. + __fprintf_chk (stream, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__) + # endif + +-__fortify_function int +-vprintf (const char *__restrict __fmt, __gnuc_va_list __ap) ++__fortify_potential_overload __attribute__ ((__format__ (__printf__, 1, 0))) int ++vprintf (const char *__restrict const __clang_pass_object_size __fmt, ++ __gnuc_va_list __ap) + { + #ifdef __USE_EXTERN_INLINES + return __vfprintf_chk (stdout, __USE_FORTIFY_LEVEL - 1, __fmt, __ap); +@@ -122,9 +154,8 @@ vprintf (const char *__restrict __fmt, _ + return __vprintf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __ap); + #endif + } +- +-__fortify_function int +-vfprintf (FILE *__restrict __stream, ++__fortify_potential_overload __attribute__ ((__format__ (__printf__, 2, 0))) int ++vfprintf (FILE *__restrict const __clang_pass_object_size __stream, + const char *__restrict __fmt, __gnuc_va_list __ap) + { + return __vfprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt, __ap); +@@ -137,20 +168,26 @@ extern int __vdprintf_chk (int __fd, int + const char *__restrict __fmt, __gnuc_va_list __arg) + __attribute__ ((__format__ (__printf__, 3, 0))); + +-# ifdef __va_arg_pack +-__fortify_function int +-dprintf (int __fd, const char *__restrict __fmt, ...) +-{ +- return __dprintf_chk (__fd, __USE_FORTIFY_LEVEL - 1, __fmt, +- __va_arg_pack ()); ++# ifdef __FORTIFY_ARG_PACK_OK ++__fortify_potential_overload __attribute__ ((__format__ (__printf__, 2, 3))) int ++dprintf (int __fd, const char *__restrict const __clang_pass_object_size __fmt, ++ ...) ++{ ++ __FORTIFY_INIT_ARG_PACK(__fmt); ++ int __result = __FORTIFY_CALL_VA_CHK (dprintf, __fd, __USE_FORTIFY_LEVEL - 1, ++ __fmt, __FORTIFY_ARG_PACK); ++ __FORTIFY_FREE_ARG_PACK(); ++ return __result; + } + # elif !defined __cplusplus + # define dprintf(fd, ...) \ + __dprintf_chk (fd, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__) + # endif + +-__fortify_function int +-vdprintf (int __fd, const char *__restrict __fmt, __gnuc_va_list __ap) ++__fortify_potential_overload __attribute__ ((__format__ (__printf__, 2, 0))) int ++vdprintf (int __fd, ++ const char *__restrict const __clang_pass_object_size __fmt, ++ __gnuc_va_list __ap) + { + return __vdprintf_chk (__fd, __USE_FORTIFY_LEVEL - 1, __fmt, __ap); + } +@@ -174,28 +211,49 @@ extern int __obstack_vprintf_chk (struct + __gnuc_va_list __args) + __THROW __attribute__ ((__format__ (__printf__, 3, 0))); + +-# ifdef __va_arg_pack +-__fortify_function int +-__NTH (asprintf (char **__restrict __ptr, const char *__restrict __fmt, ...)) +-{ +- return __asprintf_chk (__ptr, __USE_FORTIFY_LEVEL - 1, __fmt, +- __va_arg_pack ()); +-} +- +-__fortify_function int +-__NTH (__asprintf (char **__restrict __ptr, const char *__restrict __fmt, +- ...)) ++# ifdef __FORTIFY_ARG_PACK_OK ++__fortify_potential_overload __attribute__ ((__format__ (__printf__, 2, 3))) ++__wur int ++__NTH (asprintf (char **__restrict const __clang_pass_object_size __ptr, ++ const char *__restrict __fmt, ...)) + { +- return __asprintf_chk (__ptr, __USE_FORTIFY_LEVEL - 1, __fmt, +- __va_arg_pack ()); +-} +- +-__fortify_function int +-__NTH (obstack_printf (struct obstack *__restrict __obstack, ++ __FORTIFY_INIT_ARG_PACK(__fmt); ++ int __result = __FORTIFY_CALL_VA_CHK (asprintf, __ptr, ++ __USE_FORTIFY_LEVEL - 1, __fmt, ++ __FORTIFY_ARG_PACK); ++ __FORTIFY_FREE_ARG_PACK(); ++ return __result; ++} ++ ++__fortify_potential_overload __attribute__ ((__format__ (__printf__, 2, 3))) ++__wur int ++__NTH (__asprintf (char **__restrict const __clang_pass_object_size __ptr, ++ const char *__restrict __fmt, ...)) ++{ ++ __FORTIFY_INIT_ARG_PACK(__fmt); ++ int __result = __FORTIFY_CALL_VA_CHK (asprintf, __ptr, ++ __USE_FORTIFY_LEVEL - 1, __fmt, ++ __FORTIFY_ARG_PACK); ++ __FORTIFY_FREE_ARG_PACK(); ++ return __result; ++} ++ ++__fortify_potential_overload __attribute__ ((__format__ (__printf__, 2, 3))) int ++__NTH (obstack_printf (struct obstack * ++ __restrict const __clang_pass_object_size __obstack, + const char *__restrict __fmt, ...)) + { +- return __obstack_printf_chk (__obstack, __USE_FORTIFY_LEVEL - 1, __fmt, +- __va_arg_pack ()); ++ __FORTIFY_INIT_ARG_PACK(__fmt); ++ int __result = ++# ifdef __use_clang_fortify ++ __obstack_vprintf_chk ++# else ++ __obstack_printf_chk ++# endif ++ (__obstack, __USE_FORTIFY_LEVEL - 1, __fmt, ++ __FORTIFY_ARG_PACK); ++ __FORTIFY_FREE_ARG_PACK(); ++ return __result; + } + # elif !defined __cplusplus + # define asprintf(ptr, ...) \ +@@ -206,15 +264,17 @@ __NTH (obstack_printf (struct obstack *_ + __obstack_printf_chk (obstack, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__) + # endif + +-__fortify_function int +-__NTH (vasprintf (char **__restrict __ptr, const char *__restrict __fmt, +- __gnuc_va_list __ap)) ++__fortify_potential_overload __attribute__ ((__format__ (__printf__, 2, 0))) ++__wur int ++__NTH (vasprintf (char **__restrict const __clang_pass_object_size __ptr, ++ const char *__restrict __fmt, __gnuc_va_list __ap)) + { + return __vasprintf_chk (__ptr, __USE_FORTIFY_LEVEL - 1, __fmt, __ap); + } + +-__fortify_function int +-__NTH (obstack_vprintf (struct obstack *__restrict __obstack, ++__fortify_potential_overload __attribute__ ((__format__ (__printf__, 2, 0))) int ++__NTH (obstack_vprintf (struct obstack * ++ __restrict const __clang_pass_object_size __obstack, + const char *__restrict __fmt, __gnuc_va_list __ap)) + { + return __obstack_vprintf_chk (__obstack, __USE_FORTIFY_LEVEL - 1, __fmt, +@@ -227,17 +287,20 @@ __NTH (obstack_vprintf (struct obstack * + + #if __GLIBC_USE (DEPRECATED_GETS) + extern char *__gets_chk (char *__str, size_t) __wur; +-extern char *__REDIRECT (__gets_warn, (char *__str), gets) +- __wur __warnattr ("please use fgets or getline instead, gets can't " +- "specify buffer size"); ++extern char *__REDIRECT_NTH (__gets_alias, (char *__buf), gets) __wur; + +-__fortify_function __wur char * +-gets (char *__str) ++__fortify_potential_overload __wur char * ++gets (char *const __clang_pass_object_size __str) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_IF (__gets_warn, __bos (__str) == (size_t) -1, ++ "please use fgets or getline instead, gets can't " ++ "specify buffer size") + { + if (__bos (__str) != (size_t) -1) + return __gets_chk (__str, __bos (__str)); +- return __gets_warn (__str); ++ return __gets_alias (__str); + } ++__FORTIFY_FUNCTION_END + #endif + + extern char *__fgets_chk (char *__restrict __s, size_t __size, int __n, +@@ -245,25 +308,20 @@ extern char *__fgets_chk (char *__restri + extern char *__REDIRECT (__fgets_alias, + (char *__restrict __s, int __n, + FILE *__restrict __stream), fgets) __wur; +-extern char *__REDIRECT (__fgets_chk_warn, +- (char *__restrict __s, size_t __size, int __n, +- FILE *__restrict __stream), __fgets_chk) +- __wur __warnattr ("fgets called with bigger size than length " +- "of destination buffer"); + +-__fortify_function __wur char * +-fgets (char *__restrict __s, int __n, FILE *__restrict __stream) ++__fortify_potential_overload __wur char * ++fgets (char *__restrict const __clang_pass_object_size __s, int __n, ++ FILE *__restrict __stream) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_IF (__fgets_warn, __bos_static_lt (__n, __s) && __n > 0, ++ "fgets called with bigger size than length of " ++ "destination buffer") + { + if (__bos (__s) != (size_t) -1) +- { +- if (!__builtin_constant_p (__n) || __n <= 0) +- return __fgets_chk (__s, __bos (__s), __n, __stream); +- +- if ((size_t) __n > __bos (__s)) +- return __fgets_chk_warn (__s, __bos (__s), __n, __stream); +- } ++ return __fgets_chk (__s, __bos (__s), __n, __stream); + return __fgets_alias (__s, __n, __stream); + } ++__FORTIFY_FUNCTION_END + + extern size_t __fread_chk (void *__restrict __ptr, size_t __ptrlen, + size_t __size, size_t __n, +@@ -272,30 +330,21 @@ extern size_t __REDIRECT (__fread_alias, + (void *__restrict __ptr, size_t __size, + size_t __n, FILE *__restrict __stream), + fread) __wur; +-extern size_t __REDIRECT (__fread_chk_warn, +- (void *__restrict __ptr, size_t __ptrlen, +- size_t __size, size_t __n, +- FILE *__restrict __stream), +- __fread_chk) +- __wur __warnattr ("fread called with bigger size * nmemb than length " +- "of destination buffer"); + +-__fortify_function __wur size_t +-fread (void *__restrict __ptr, size_t __size, size_t __n, +- FILE *__restrict __stream) ++__fortify_potential_overload __wur size_t ++fread (void *__restrict const __clang_pass_object_size0 __ptr, size_t __size, ++ size_t __n, FILE *__restrict __stream) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_IF (__fread_warn, __bos0_static_lt (__size * __n, __ptr) ++ && !__mul_may_overflow (__size, __n), ++ "fread called with bigger size * nmemb than length " ++ "of destination buffer") + { + if (__bos0 (__ptr) != (size_t) -1) +- { +- if (!__builtin_constant_p (__size) +- || !__builtin_constant_p (__n) +- || (__size | __n) >= (((size_t) 1) << (8 * sizeof (size_t) / 2))) +- return __fread_chk (__ptr, __bos0 (__ptr), __size, __n, __stream); +- +- if (__size * __n > __bos0 (__ptr)) +- return __fread_chk_warn (__ptr, __bos0 (__ptr), __size, __n, __stream); +- } ++ return __fread_chk (__ptr, __bos0 (__ptr), __size, __n, __stream); + return __fread_alias (__ptr, __size, __n, __stream); + } ++__FORTIFY_FUNCTION_END + + #ifdef __USE_GNU + extern char *__fgets_unlocked_chk (char *__restrict __s, size_t __size, +@@ -303,25 +352,21 @@ extern char *__fgets_unlocked_chk (char + extern char *__REDIRECT (__fgets_unlocked_alias, + (char *__restrict __s, int __n, + FILE *__restrict __stream), fgets_unlocked) __wur; +-extern char *__REDIRECT (__fgets_unlocked_chk_warn, +- (char *__restrict __s, size_t __size, int __n, +- FILE *__restrict __stream), __fgets_unlocked_chk) +- __wur __warnattr ("fgets_unlocked called with bigger size than length " +- "of destination buffer"); + +-__fortify_function __wur char * +-fgets_unlocked (char *__restrict __s, int __n, FILE *__restrict __stream) ++__fortify_potential_overload __wur char * ++fgets_unlocked (char *__restrict const __clang_pass_object_size __s, int __n, ++ FILE *__restrict __stream) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_IF (__fgets_unlocked_warn, ++ __bos_static_lt (__n, __s) && __n > 0, ++ "fgets_unlocked called with bigger size than length " ++ "of destination buffer") + { + if (__bos (__s) != (size_t) -1) +- { +- if (!__builtin_constant_p (__n) || __n <= 0) +- return __fgets_unlocked_chk (__s, __bos (__s), __n, __stream); +- +- if ((size_t) __n > __bos (__s)) +- return __fgets_unlocked_chk_warn (__s, __bos (__s), __n, __stream); +- } ++ return __fgets_unlocked_chk (__s, __bos (__s), __n, __stream); + return __fgets_unlocked_alias (__s, __n, __stream); + } ++__FORTIFY_FUNCTION_END + #endif + + #ifdef __USE_MISC +@@ -333,30 +378,19 @@ extern size_t __REDIRECT (__fread_unlock + (void *__restrict __ptr, size_t __size, + size_t __n, FILE *__restrict __stream), + fread_unlocked) __wur; +-extern size_t __REDIRECT (__fread_unlocked_chk_warn, +- (void *__restrict __ptr, size_t __ptrlen, +- size_t __size, size_t __n, +- FILE *__restrict __stream), +- __fread_unlocked_chk) +- __wur __warnattr ("fread_unlocked called with bigger size * nmemb than " +- "length of destination buffer"); + +-__fortify_function __wur size_t +-fread_unlocked (void *__restrict __ptr, size_t __size, size_t __n, +- FILE *__restrict __stream) ++__fortify_potential_overload __wur size_t ++fread_unlocked (void *__restrict const __clang_pass_object_size0 __ptr, ++ size_t __size, size_t __n, FILE *__restrict __stream) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_IF (__fread_unlocked_warn, ++ __bos0_static_lt (__size * __n, __ptr) ++ && !__mul_may_overflow(__size, __n), ++ "fread_unlocked called with bigger size * n than " ++ "length of destination buffer") + { + if (__bos0 (__ptr) != (size_t) -1) +- { +- if (!__builtin_constant_p (__size) +- || !__builtin_constant_p (__n) +- || (__size | __n) >= (((size_t) 1) << (8 * sizeof (size_t) / 2))) +- return __fread_unlocked_chk (__ptr, __bos0 (__ptr), __size, __n, +- __stream); +- +- if (__size * __n > __bos0 (__ptr)) +- return __fread_unlocked_chk_warn (__ptr, __bos0 (__ptr), __size, __n, +- __stream); +- } ++ return __fread_unlocked_chk (__ptr, __bos0 (__ptr), __size, __n, __stream); + + # ifdef __USE_EXTERN_INLINES + if (__builtin_constant_p (__size) +@@ -381,6 +415,7 @@ fread_unlocked (void *__restrict __ptr, + # endif + return __fread_unlocked_alias (__ptr, __size, __n, __stream); + } ++__FORTIFY_FUNCTION_END + #endif +- ++#undef __mul_may_overflow + #endif /* bits/stdio2.h. */ +--- a/misc/bits/syslog.h ++++ b/misc/bits/syslog.h +@@ -20,11 +20,34 @@ + # error "Never include <bits/syslog.h> directly; use <sys/syslog.h> instead." + #endif + ++#ifdef __USE_MISC ++extern void __vsyslog_chk (int __pri, int __flag, const char *__fmt, ++ __gnuc_va_list __ap) ++ __attribute__ ((__format__ (__printf__, 3, 0))); ++ ++__fortify_potential_overload __attribute__ ((__format__ (__printf__, 2, 0))) void ++vsyslog (int __pri, const char *const __clang_pass_object_size __fmt, ++ __gnuc_va_list __ap) ++{ ++ __vsyslog_chk (__pri, __USE_FORTIFY_LEVEL - 1, __fmt, __ap); ++} ++#endif + + extern void __syslog_chk (int __pri, int __flag, const char *__fmt, ...) + __attribute__ ((__format__ (__printf__, 3, 4))); + +-#ifdef __va_arg_pack ++#if defined __use_clang_fortify && __USE_MISC ++/* clang doesn't support __va_arg_pack, so this is only possible if we have ++ vsyslog. */ ++__fortify_overload __attribute__ ((__format__ (__printf__, 2, 3))) void ++syslog (int __pri, const char *const __clang_pass_object_size __fmt, ...) ++{ ++ __gnuc_va_list __ap; ++ va_start (__ap, __fmt); ++ __vsyslog_chk (__pri, __USE_FORTIFY_LEVEL - 1, __fmt, __ap); ++ va_end (__ap); ++} ++#elif defined __va_arg_pack + __fortify_function void + syslog (int __pri, const char *__fmt, ...) + { +@@ -34,16 +57,3 @@ syslog (int __pri, const char *__fmt, .. + # define syslog(pri, ...) \ + __syslog_chk (pri, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__) + #endif +- +- +-#ifdef __USE_MISC +-extern void __vsyslog_chk (int __pri, int __flag, const char *__fmt, +- __gnuc_va_list __ap) +- __attribute__ ((__format__ (__printf__, 3, 0))); +- +-__fortify_function void +-vsyslog (int __pri, const char *__fmt, __gnuc_va_list __ap) +-{ +- __vsyslog_chk (__pri, __USE_FORTIFY_LEVEL - 1, __fmt, __ap); +-} +-#endif +--- a/misc/sys/cdefs.h ++++ b/misc/sys/cdefs.h +@@ -118,11 +118,150 @@ + # define __END_DECLS + #endif + ++#if defined __clang__ && defined __has_extension ++# define __clang_has_extension(x) __has_extension (x) ++#else ++# define __clang_has_extension(x) 0 ++#endif + + /* Fortify support. */ +-#define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1) ++#define __fortify_function __extern_always_inline __attribute_artificial__ ++#if defined __clang__ && __USE_FORTIFY_LEVEL > 0 \ ++ && !defined _CLANG_FORTIFY_DISABLE \ ++ && __clang_has_extension(overloadable_unmarked) ++# define __use_clang_fortify 1 ++/* Clang-style FORTIFY creates a different symbol for each FORTIFY'ed function, ++ whereas GCC-style doesn't. Thus, GCC can assume that the FORTIFY'ed ++ function is always available externally, but clang can't. */ ++# define __attribute_overloadable__ __attribute__ ((__overloadable__)) ++# define __attribute_transparent_overload__ \ ++ __attribute__ ((__overloadable__("transparent"))) ++# define __fortify_overload static __always_inline __attribute_overloadable__ ++/* For FORTIFY functions that exist only as decls. */ ++# define __fortify_error_function static __attribute_overloadable__ ++# define __clang_pass_object_size_n(n) __attribute__ ((pass_object_size (n))) ++# define __clang_warning(what) __attribute__ ((deprecated(what))) ++# define __clang_prefer_this_overload __attribute__ ((enable_if (1, ""))) ++# define __clang_warning_if(c, m) \ ++ __attribute__ ((__diagnose_if__ ((c), (m), "warning"))) ++# define __clang_error(what) __attribute__ ((unavailable(what))) ++# define __clang_error_if(c, m) \ ++ __attribute__ ((__diagnose_if__ ((c), (m), "error"))) ++# define __fortify_potential_overload __fortify_overload ++#else ++# define __fortify_potential_overload __fortify_function ++/* Some functions/decls can be shared between clang and non-clang FORTIFY. ++ Turning these into nops makes that possible. */ ++# define __clang_pass_object_size_n(n) ++# define __attribute_overloadable__ ++# define __bos_n(ptr, n) __builtin_object_size (ptr, n) ++# define __clang_warning_if(c, m) ++# define __clang_error_if(c, m) ++#endif ++ ++#define __bos_level (__USE_FORTIFY_LEVEL > 1) ++#define __bos(ptr) __builtin_object_size (ptr, __bos_level) + #define __bos0(ptr) __builtin_object_size (ptr, 0) + ++#define __clang_pass_object_size0 __clang_pass_object_size_n (0) ++#define __clang_pass_object_size __clang_pass_object_size_n (__bos_level) ++ ++/* Some of these macros are awkwardly written, and more repetitive than they'd ++ ideally need to be. This is because both clang and gcc will emit 'note's ++ about where these warnings originate from. For every macro that's expanded, ++ the user sees a note that ultimately doesn't matter to them... */ ++#ifdef __use_clang_fortify ++# define __FORTIFY_PRECONDITIONS ++# define __FORTIFY_FUNCTION_END ++# define __FORTIFY_WARNING_IF(_, c, msg) __clang_warning_if(c, msg) ++/* __builtin_constant_p isn't needed: this is only used in constructs that ++ must be fully evaluated at compile-time. */ ++# define __bos_static_lt_impl(bos_val, n, s) \ ++ ((bos_val) != -1ULL && (n) > (bos_val) / (s)) ++# define __FORTIFY_CALL_CHK 1 ++ ++# define __FORTIFY_BOSN_ARGS(bos_fn, n, buf, div, complaint) \ ++ (__bos_static_lt_impl (bos_fn (buf), n, div)), (complaint), "warning" ++ ++#define __FORTIFY_WARNING_ONLY_IF_BOS0_LT2(fn_name, n, buf, div, complaint) \ ++ __attribute__ ((__diagnose_if__ \ ++ (__FORTIFY_BOSN_ARGS (__bos0, n, buf, div, complaint)))) ++#define __FORTIFY_WARNING_ONLY_IF_BOS0_LT(fn_name, n, buf, complaint) \ ++ __attribute__ ((__diagnose_if__ \ ++ (__FORTIFY_BOSN_ARGS (__bos0, n, buf, 1, complaint)))) ++#define __FORTIFY_WARNING_ONLY_IF_BOS_LT2(fn_name, n, buf, div, complaint) \ ++ __attribute__ ((__diagnose_if__ \ ++ (__FORTIFY_BOSN_ARGS (__bos, n, buf, div, complaint)))) ++#define __FORTIFY_WARNING_ONLY_IF_BOS_LT(fn_name, n, buf, complaint) \ ++ __attribute__ ((__diagnose_if__ \ ++ (__FORTIFY_BOSN_ARGS (__bos, n, buf, 1, complaint)))) ++#else ++# define __FORTIFY_PRECONDITIONS { ++# define __FORTIFY_FUNCTION_END } ++/* __chk_fail was chosen arbitrarily. The function should never be called ++ anyway; it just exists to be reachable after optimizations. */ ++# define __FORTIFY_DECLARE_WARNING_FUNCTION(name, msg) \ ++ __attribute ((__warning__(msg))) \ ++ extern void __REDIRECT_NTH (name, (void), __chk_fail) ++ ++# define __FORTIFY_WARNING_IF_BEGIN(fn_name, cond, complaint, if_cond_true) \ ++ { \ ++ if (cond) { \ ++ if_cond_true; \ ++ __FORTIFY_DECLARE_WARNING_FUNCTION (fn_name, complaint); \ ++ volatile char __t = 0; \ ++ if (__glibc_unlikely (__t)) \ ++ { ++ ++# define __FORTIFY_WARNING_IF_END \ ++ } \ ++ } \ ++ } ++ ++# define __FORTIFY_WARNING_IF(err_fn, cond, complaint) \ ++ __FORTIFY_WARNING_IF_BEGIN (err_fn, cond, complaint, (void)0) \ ++ err_fn (); \ ++ __FORTIFY_WARNING_IF_END ++ ++# define __bos_static_lt_impl(bos_val, n, s) \ ++ (__builtin_constant_p (n) && (bos_val) != -1ULL && (n) > (bos_val) / (s)) ++ ++#define __FORTIFY_BOS_WARNING_BEGIN(fn_name, bos_fn, n, buf, div, complaint) \ ++ char __need_dynamic_check = !__builtin_constant_p (n); \ ++ __FORTIFY_WARNING_IF_BEGIN (fn_name, \ ++ __bos_static_lt_impl (bos_fn (buf), n, div), \ ++ complaint, (__need_dynamic_check = 1)) ++ ++/* Duplicate this so that the fn_name call happens with the smallest possible ++ macro "call stack". This minimizes diagnostics about expanding macros. */ ++#define __FORTIFY_WARNING_ONLY_IF_BOS0_LT2(err_fn, n, buf, div, complaint) \ ++ __FORTIFY_BOS_WARNING_BEGIN (err_fn, __bos0, n, buf, div, complaint) \ ++ err_fn (); \ ++ __FORTIFY_WARNING_IF_END ++ ++#define __FORTIFY_WARNING_ONLY_IF_BOS0_LT(err_fn, n, buf, complaint) \ ++ __FORTIFY_BOS_WARNING_BEGIN (err_fn, __bos0, n, buf, 1, complaint) \ ++ err_fn (); \ ++ __FORTIFY_WARNING_IF_END ++ ++#define __FORTIFY_WARNING_ONLY_IF_BOS_LT2(err_fn, n, buf, div, complaint) \ ++ __FORTIFY_BOS_WARNING_BEGIN (err_fn, __bos, n, buf, div, complaint) \ ++ err_fn (); \ ++ __FORTIFY_WARNING_IF_END ++ ++#define __FORTIFY_WARNING_ONLY_IF_BOS_LT(err_fn, n, buf, complaint) \ ++ __FORTIFY_BOS_WARNING_BEGIN (err_fn, __bos, n, buf, 1, complaint) \ ++ err_fn (); \ ++ __FORTIFY_WARNING_IF_END ++ ++# define __FORTIFY_CALL_CHK (__need_dynamic_check) ++#endif ++ ++#define __bos_static_lt2(n, e, s) __bos_static_lt_impl (__bos (e), n, s) ++#define __bos_static_lt(n, e) __bos_static_lt2 (n, e, 1) ++#define __bos0_static_lt2(n, e, s) __bos_static_lt_impl (__bos0 (e), n, s) ++#define __bos0_static_lt(n, e) __bos0_static_lt2 (n, e, 1) ++ + #if __GNUC_PREREQ (4,3) + # define __warndecl(name, msg) \ + extern void name (void) __attribute__((__warning__ (msg))) +@@ -363,6 +502,29 @@ + # define __va_arg_pack_len() __builtin_va_arg_pack_len () + #endif + ++#if defined(__use_clang_fortify) ++/* clang doesn't support __va_arg_pack, so we need to call the v* version of ++ FORTIFY'ed functions. */ ++#define __FORTIFY_ARG_PACK __fortify_ap ++#define __FORTIFY_INIT_ARG_PACK(va_arg) \ ++ __gnuc_va_list __FORTIFY_ARG_PACK; \ ++ va_start (__FORTIFY_ARG_PACK, va_arg) ++#define __FORTIFY_CALL_VA_ALIAS(fn, ...) __v##fn##_alias (__VA_ARGS__) ++#define __FORTIFY_CALL_VA_CHK(fn, ...) __v##fn##_chk (__VA_ARGS__) ++#define __FORTIFY_CALL_VA_BUILTIN(fn, ...) \ ++ __builtin___v##fn##_chk (__VA_ARGS__) ++#define __FORTIFY_FREE_ARG_PACK() va_end (__FORTIFY_ARG_PACK) ++#define __FORTIFY_ARG_PACK_OK 1 ++#elif defined(__va_arg_pack) ++#define __FORTIFY_ARG_PACK __va_arg_pack () ++#define __FORTIFY_INIT_ARG_PACK(va_arg) ++#define __FORTIFY_CALL_VA_ALIAS(fn, ...) __##fn##_alias (__VA_ARGS__) ++#define __FORTIFY_CALL_VA_CHK(fn, ...) __##fn##_chk (__VA_ARGS__) ++#define __FORTIFY_CALL_VA_BUILTIN(fn, ...) __builtin___##fn##_chk (__VA_ARGS__) ++#define __FORTIFY_FREE_ARG_PACK() ++#define __FORTIFY_ARG_PACK_OK 1 ++#endif ++ + /* It is possible to compile containing GCC extensions even if GCC is + run in pedantic mode if the uses are carefully marked using the + `__extension__' keyword. But this is not generally available before +--- a/posix/bits/unistd.h ++++ b/posix/bits/unistd.h +@@ -24,25 +24,19 @@ extern ssize_t __read_chk (int __fd, voi + size_t __buflen) __wur; + extern ssize_t __REDIRECT (__read_alias, (int __fd, void *__buf, + size_t __nbytes), read) __wur; +-extern ssize_t __REDIRECT (__read_chk_warn, +- (int __fd, void *__buf, size_t __nbytes, +- size_t __buflen), __read_chk) +- __wur __warnattr ("read called with bigger length than size of " +- "the destination buffer"); +- +-__fortify_function __wur ssize_t +-read (int __fd, void *__buf, size_t __nbytes) +-{ +- if (__bos0 (__buf) != (size_t) -1) +- { +- if (!__builtin_constant_p (__nbytes)) +- return __read_chk (__fd, __buf, __nbytes, __bos0 (__buf)); +- +- if (__nbytes > __bos0 (__buf)) +- return __read_chk_warn (__fd, __buf, __nbytes, __bos0 (__buf)); +- } ++ ++__fortify_potential_overload __wur ssize_t ++read (int __fd, void *const __clang_pass_object_size0 __buf, size_t __nbytes) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_ONLY_IF_BOS0_LT (__read_warn, __nbytes, __buf, ++ "read called with bigger length than " ++ "size of the destination buffer") ++{ ++ if (__FORTIFY_CALL_CHK && __bos0 (__buf) != (size_t) -1) ++ return __read_chk (__fd, __buf, __nbytes, __bos0 (__buf)); + return __read_alias (__fd, __buf, __nbytes); + } ++__FORTIFY_FUNCTION_END + + #ifdef __USE_UNIX98 + extern ssize_t __pread_chk (int __fd, void *__buf, size_t __nbytes, +@@ -55,67 +49,49 @@ extern ssize_t __REDIRECT (__pread_alias + extern ssize_t __REDIRECT (__pread64_alias, + (int __fd, void *__buf, size_t __nbytes, + __off64_t __offset), pread64) __wur; +-extern ssize_t __REDIRECT (__pread_chk_warn, +- (int __fd, void *__buf, size_t __nbytes, +- __off_t __offset, size_t __bufsize), __pread_chk) +- __wur __warnattr ("pread called with bigger length than size of " +- "the destination buffer"); +-extern ssize_t __REDIRECT (__pread64_chk_warn, +- (int __fd, void *__buf, size_t __nbytes, +- __off64_t __offset, size_t __bufsize), +- __pread64_chk) +- __wur __warnattr ("pread64 called with bigger length than size of " +- "the destination buffer"); + + # ifndef __USE_FILE_OFFSET64 +-__fortify_function __wur ssize_t +-pread (int __fd, void *__buf, size_t __nbytes, __off_t __offset) +-{ +- if (__bos0 (__buf) != (size_t) -1) +- { +- if (!__builtin_constant_p (__nbytes)) +- return __pread_chk (__fd, __buf, __nbytes, __offset, __bos0 (__buf)); +- +- if ( __nbytes > __bos0 (__buf)) +- return __pread_chk_warn (__fd, __buf, __nbytes, __offset, +- __bos0 (__buf)); +- } +- return __pread_alias (__fd, __buf, __nbytes, __offset); +-} ++# define __fo_pread_chk __pread_chk ++# define __fo_pread_alias __pread_alias ++# define __fo_off_t __off_t + # else +-__fortify_function __wur ssize_t +-pread (int __fd, void *__buf, size_t __nbytes, __off64_t __offset) +-{ +- if (__bos0 (__buf) != (size_t) -1) +- { +- if (!__builtin_constant_p (__nbytes)) +- return __pread64_chk (__fd, __buf, __nbytes, __offset, __bos0 (__buf)); +- +- if ( __nbytes > __bos0 (__buf)) +- return __pread64_chk_warn (__fd, __buf, __nbytes, __offset, +- __bos0 (__buf)); +- } +- +- return __pread64_alias (__fd, __buf, __nbytes, __offset); +-} ++# define __fo_pread_chk __pread64_chk ++# define __fo_pread_alias __pread64_alias ++# define __fo_off_t __off64_t + # endif + ++__fortify_potential_overload __wur ssize_t ++pread (int __fd, void *const __clang_pass_object_size0 __buf, size_t __nbytes, ++ __fo_off_t __offset) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_ONLY_IF_BOS0_LT (__pread_chk_warn, __nbytes, __buf, ++ "pread called with bigger length than " ++ "size of the destination buffer") ++{ ++ if (__FORTIFY_CALL_CHK && __bos0 (__buf) != (size_t) -1) ++ return __fo_pread_chk (__fd, __buf, __nbytes, __offset, __bos0 (__buf)); ++ return __fo_pread_alias (__fd, __buf, __nbytes, __offset); ++} ++__FORTIFY_FUNCTION_END ++ ++#undef __fo_pread_chk ++#undef __fo_pread_alias ++#undef __fo_off_t ++ + # ifdef __USE_LARGEFILE64 +-__fortify_function __wur ssize_t +-pread64 (int __fd, void *__buf, size_t __nbytes, __off64_t __offset) ++__fortify_potential_overload __wur ssize_t ++pread64 (int __fd, void *const __clang_pass_object_size0 __buf, ++ size_t __nbytes, __off64_t __offset) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_ONLY_IF_BOS0_LT (__pread64_warn, __nbytes, __buf, ++ "pread64 called with bigger length " ++ "than size of the destination buffer") + { +- if (__bos0 (__buf) != (size_t) -1) +- { +- if (!__builtin_constant_p (__nbytes)) +- return __pread64_chk (__fd, __buf, __nbytes, __offset, __bos0 (__buf)); +- +- if ( __nbytes > __bos0 (__buf)) +- return __pread64_chk_warn (__fd, __buf, __nbytes, __offset, +- __bos0 (__buf)); +- } +- ++ if (__FORTIFY_CALL_CHK && __bos0 (__buf) != (size_t) -1) ++ return __pread64_chk (__fd, __buf, __nbytes, __offset, __bos0 (__buf)); + return __pread64_alias (__fd, __buf, __nbytes, __offset); + } ++__FORTIFY_FUNCTION_END + # endif + #endif + +@@ -128,27 +104,21 @@ extern ssize_t __REDIRECT_NTH (__readlin + (const char *__restrict __path, + char *__restrict __buf, size_t __len), readlink) + __nonnull ((1, 2)) __wur; +-extern ssize_t __REDIRECT_NTH (__readlink_chk_warn, +- (const char *__restrict __path, +- char *__restrict __buf, size_t __len, +- size_t __buflen), __readlink_chk) +- __nonnull ((1, 2)) __wur __warnattr ("readlink called with bigger length " +- "than size of destination buffer"); + +-__fortify_function __nonnull ((1, 2)) __wur ssize_t +-__NTH (readlink (const char *__restrict __path, char *__restrict __buf, ++__fortify_potential_overload __nonnull ((1, 2)) __wur ssize_t ++__NTH (readlink (const char *__restrict __path, ++ char *__restrict const __clang_pass_object_size __buf, + size_t __len)) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_ONLY_IF_BOS_LT (__readlink_warn, __len, __buf, ++ "readlink called with bigger length " ++ "than size of destination buffer") + { +- if (__bos (__buf) != (size_t) -1) +- { +- if (!__builtin_constant_p (__len)) +- return __readlink_chk (__path, __buf, __len, __bos (__buf)); +- +- if ( __len > __bos (__buf)) +- return __readlink_chk_warn (__path, __buf, __len, __bos (__buf)); +- } ++ if (__FORTIFY_CALL_CHK && __bos (__buf) != (size_t) -1) ++ return __readlink_chk (__path, __buf, __len, __bos (__buf)); + return __readlink_alias (__path, __buf, __len); + } ++__FORTIFY_FUNCTION_END + #endif + + #ifdef __USE_ATFILE +@@ -161,119 +131,104 @@ extern ssize_t __REDIRECT_NTH (__readlin + char *__restrict __buf, size_t __len), + readlinkat) + __nonnull ((2, 3)) __wur; +-extern ssize_t __REDIRECT_NTH (__readlinkat_chk_warn, +- (int __fd, const char *__restrict __path, +- char *__restrict __buf, size_t __len, +- size_t __buflen), __readlinkat_chk) +- __nonnull ((2, 3)) __wur __warnattr ("readlinkat called with bigger " +- "length than size of destination " +- "buffer"); +- +-__fortify_function __nonnull ((2, 3)) __wur ssize_t +-__NTH (readlinkat (int __fd, const char *__restrict __path, +- char *__restrict __buf, size_t __len)) ++ ++__fortify_potential_overload __nonnull ((2, 3)) __wur ssize_t ++__NTH (readlinkat (int __fd, ++ const char *__restrict __path, ++ char *__restrict const __clang_pass_object_size __buf, ++ size_t __len)) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_ONLY_IF_BOS_LT (__readlinkat_warn, __len, __buf, ++ "readlinkat called with bigger length " ++ "than size of destination buffer") + { +- if (__bos (__buf) != (size_t) -1) +- { +- if (!__builtin_constant_p (__len)) +- return __readlinkat_chk (__fd, __path, __buf, __len, __bos (__buf)); +- +- if (__len > __bos (__buf)) +- return __readlinkat_chk_warn (__fd, __path, __buf, __len, +- __bos (__buf)); +- } ++ if (__FORTIFY_CALL_CHK && __bos (__buf) != (size_t) -1) ++ return __readlinkat_chk (__fd, __path, __buf, __len, __bos (__buf)); + return __readlinkat_alias (__fd, __path, __buf, __len); + } ++__FORTIFY_FUNCTION_END + #endif + + extern char *__getcwd_chk (char *__buf, size_t __size, size_t __buflen) + __THROW __wur; + extern char *__REDIRECT_NTH (__getcwd_alias, + (char *__buf, size_t __size), getcwd) __wur; +-extern char *__REDIRECT_NTH (__getcwd_chk_warn, +- (char *__buf, size_t __size, size_t __buflen), +- __getcwd_chk) +- __wur __warnattr ("getcwd caller with bigger length than size of " +- "destination buffer"); + +-__fortify_function __wur char * +-__NTH (getcwd (char *__buf, size_t __size)) ++__fortify_potential_overload __wur char * ++__NTH (getcwd (char *const __clang_pass_object_size __buf, size_t __size)) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_ONLY_IF_BOS_LT (__getcwd_warn, __size, __buf, ++ "getcwd called with bigger length than " ++ "size of destination buffer") + { +- if (__bos (__buf) != (size_t) -1) +- { +- if (!__builtin_constant_p (__size)) +- return __getcwd_chk (__buf, __size, __bos (__buf)); +- +- if (__size > __bos (__buf)) +- return __getcwd_chk_warn (__buf, __size, __bos (__buf)); +- } ++ if (__FORTIFY_CALL_CHK && __bos (__buf) != (size_t) -1) ++ return __getcwd_chk (__buf, __size, __bos (__buf)); + return __getcwd_alias (__buf, __size); + } ++__FORTIFY_FUNCTION_END + + #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED ++# define __warn_getwd_use_something_else \ ++ "please use getcwd instead, as getwd doesn't specify buffer size" ++ + extern char *__getwd_chk (char *__buf, size_t buflen) + __THROW __nonnull ((1)) __wur; + extern char *__REDIRECT_NTH (__getwd_warn, (char *__buf), getwd) +- __nonnull ((1)) __wur __warnattr ("please use getcwd instead, as getwd " +- "doesn't specify buffer size"); ++ __nonnull ((1)) __wur __warnattr (__warn_getwd_use_something_else); ++ ++extern char *__REDIRECT (__getwd_alias, (char *__str), getwd) __wur; + +-__fortify_function __nonnull ((1)) __attribute_deprecated__ __wur char * +-__NTH (getwd (char *__buf)) ++__fortify_potential_overload __nonnull ((1)) __attribute_deprecated__ __wur ++char * ++__NTH (getwd (char *const __clang_pass_object_size __buf)) ++ __clang_warning_if (__bos (__buf) == (size_t) -1, ++ __warn_getwd_use_something_else) + { + if (__bos (__buf) != (size_t) -1) + return __getwd_chk (__buf, __bos (__buf)); + return __getwd_warn (__buf); + } ++# undef __warn_getwd_use_something_else + #endif + + extern size_t __confstr_chk (int __name, char *__buf, size_t __len, + size_t __buflen) __THROW; + extern size_t __REDIRECT_NTH (__confstr_alias, (int __name, char *__buf, + size_t __len), confstr); +-extern size_t __REDIRECT_NTH (__confstr_chk_warn, +- (int __name, char *__buf, size_t __len, +- size_t __buflen), __confstr_chk) +- __warnattr ("confstr called with bigger length than size of destination " +- "buffer"); + +-__fortify_function size_t +-__NTH (confstr (int __name, char *__buf, size_t __len)) ++__fortify_potential_overload size_t ++__NTH (confstr (int __name, char *const __clang_pass_object_size __buf, ++ size_t __len)) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_ONLY_IF_BOS_LT (__confstr_warn, __len, __buf, ++ "confstr called with bigger length than " ++ "size of destination buffer") + { +- if (__bos (__buf) != (size_t) -1) +- { +- if (!__builtin_constant_p (__len)) +- return __confstr_chk (__name, __buf, __len, __bos (__buf)); +- +- if (__bos (__buf) < __len) +- return __confstr_chk_warn (__name, __buf, __len, __bos (__buf)); +- } ++ if (__FORTIFY_CALL_CHK && __bos (__buf) != (size_t) -1) ++ return __confstr_chk (__name, __buf, __len, __bos (__buf)); + return __confstr_alias (__name, __buf, __len); + } +- ++__FORTIFY_FUNCTION_END + + extern int __getgroups_chk (int __size, __gid_t __list[], size_t __listlen) + __THROW __wur; + extern int __REDIRECT_NTH (__getgroups_alias, (int __size, __gid_t __list[]), + getgroups) __wur; +-extern int __REDIRECT_NTH (__getgroups_chk_warn, +- (int __size, __gid_t __list[], size_t __listlen), +- __getgroups_chk) +- __wur __warnattr ("getgroups called with bigger group count than what " +- "can fit into destination buffer"); +- +-__fortify_function int +-__NTH (getgroups (int __size, __gid_t __list[])) +-{ +- if (__bos (__list) != (size_t) -1) +- { +- if (!__builtin_constant_p (__size) || __size < 0) +- return __getgroups_chk (__size, __list, __bos (__list)); +- +- if (__size * sizeof (__gid_t) > __bos (__list)) +- return __getgroups_chk_warn (__size, __list, __bos (__list)); +- } ++ ++__fortify_potential_overload int ++__NTH (getgroups (int __size, __gid_t *const __clang_pass_object_size __list)) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_ONLY_IF_BOS_LT (__getgroups_warn, ++ __size * sizeof (__gid_t), __list, ++ "getgroups called with bigger group " ++ "count than what can fit into " ++ "destination buffer") ++{ ++ if (__FORTIFY_CALL_CHK && __bos (__list) != (size_t) -1) ++ return __getgroups_chk (__size, __list, __bos (__list)); + return __getgroups_alias (__size, __list); + } ++__FORTIFY_FUNCTION_END + + + extern int __ttyname_r_chk (int __fd, char *__buf, size_t __buflen, +@@ -287,19 +242,19 @@ extern int __REDIRECT_NTH (__ttyname_r_c + __nonnull ((2)) __warnattr ("ttyname_r called with bigger buflen than " + "size of destination buffer"); + +-__fortify_function int +-__NTH (ttyname_r (int __fd, char *__buf, size_t __buflen)) +-{ +- if (__bos (__buf) != (size_t) -1) +- { +- if (!__builtin_constant_p (__buflen)) +- return __ttyname_r_chk (__fd, __buf, __buflen, __bos (__buf)); +- +- if (__buflen > __bos (__buf)) +- return __ttyname_r_chk_warn (__fd, __buf, __buflen, __bos (__buf)); +- } +- return __ttyname_r_alias (__fd, __buf, __buflen); +-} ++__fortify_potential_overload int ++__NTH (ttyname_r (int __fd, char *const __clang_pass_object_size __buf, ++ size_t __buflen)) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_ONLY_IF_BOS_LT (__ttyname_r_warn, __buflen, __buf, ++ "ttyname_r called with bigger buflen " ++ "than size of destination buffer") ++{ ++ if (__FORTIFY_CALL_CHK && __bos (__buf) != (size_t) -1) ++ return __ttyname_r_chk (__fd, __buf, __buflen, __bos (__buf)); ++ return __ttyname_r_alias (__fd, __buf, __buflen); ++ } ++__FORTIFY_FUNCTION_END + + + #ifdef __USE_POSIX199506 +@@ -307,25 +262,19 @@ extern int __getlogin_r_chk (char *__buf + __nonnull ((1)); + extern int __REDIRECT (__getlogin_r_alias, (char *__buf, size_t __buflen), + getlogin_r) __nonnull ((1)); +-extern int __REDIRECT (__getlogin_r_chk_warn, +- (char *__buf, size_t __buflen, size_t __nreal), +- __getlogin_r_chk) +- __nonnull ((1)) __warnattr ("getlogin_r called with bigger buflen than " +- "size of destination buffer"); + +-__fortify_function int +-getlogin_r (char *__buf, size_t __buflen) ++__fortify_potential_overload int ++getlogin_r (char *const __clang_pass_object_size __buf, size_t __buflen) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_ONLY_IF_BOS_LT (__getlogin_r_warn, __buflen, __buf, ++ "getlogin_r called with bigger buflen " ++ "than size of destination buffer") + { +- if (__bos (__buf) != (size_t) -1) +- { +- if (!__builtin_constant_p (__buflen)) +- return __getlogin_r_chk (__buf, __buflen, __bos (__buf)); +- +- if (__buflen > __bos (__buf)) +- return __getlogin_r_chk_warn (__buf, __buflen, __bos (__buf)); +- } ++ if (__FORTIFY_CALL_CHK && __bos (__buf) != (size_t) -1) ++ return __getlogin_r_chk (__buf, __buflen, __bos (__buf)); + return __getlogin_r_alias (__buf, __buflen); + } ++__FORTIFY_FUNCTION_END + #endif + + +@@ -334,25 +283,20 @@ extern int __gethostname_chk (char *__bu + __THROW __nonnull ((1)); + extern int __REDIRECT_NTH (__gethostname_alias, (char *__buf, size_t __buflen), + gethostname) __nonnull ((1)); +-extern int __REDIRECT_NTH (__gethostname_chk_warn, +- (char *__buf, size_t __buflen, size_t __nreal), +- __gethostname_chk) +- __nonnull ((1)) __warnattr ("gethostname called with bigger buflen than " +- "size of destination buffer"); + +-__fortify_function int +-__NTH (gethostname (char *__buf, size_t __buflen)) ++__fortify_potential_overload int ++__NTH (gethostname (char *const __clang_pass_object_size __buf, ++ size_t __buflen)) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_ONLY_IF_BOS_LT (__gethostname_warn, __buflen, __buf, ++ "gethostname called with bigger buflen " ++ "than size of destination buffer") + { +- if (__bos (__buf) != (size_t) -1) +- { +- if (!__builtin_constant_p (__buflen)) +- return __gethostname_chk (__buf, __buflen, __bos (__buf)); +- +- if (__buflen > __bos (__buf)) +- return __gethostname_chk_warn (__buf, __buflen, __bos (__buf)); +- } ++ if (__FORTIFY_CALL_CHK && __bos (__buf) != (size_t) -1) ++ return __gethostname_chk (__buf, __buflen, __bos (__buf)); + return __gethostname_alias (__buf, __buflen); + } ++__FORTIFY_FUNCTION_END + #endif + + +@@ -362,24 +306,18 @@ extern int __getdomainname_chk (char *__ + extern int __REDIRECT_NTH (__getdomainname_alias, (char *__buf, + size_t __buflen), + getdomainname) __nonnull ((1)) __wur; +-extern int __REDIRECT_NTH (__getdomainname_chk_warn, +- (char *__buf, size_t __buflen, size_t __nreal), +- __getdomainname_chk) +- __nonnull ((1)) __wur __warnattr ("getdomainname called with bigger " +- "buflen than size of destination " +- "buffer"); + +-__fortify_function int +-__NTH (getdomainname (char *__buf, size_t __buflen)) ++__fortify_potential_overload int ++__NTH (getdomainname (char *const __clang_pass_object_size __buf, ++ size_t __buflen)) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_ONLY_IF_BOS_LT (__getdomainname_warn, __buflen, __buf, ++ "getdomainname called with bigger " ++ "buflen than size of destination buffer") + { +- if (__bos (__buf) != (size_t) -1) +- { +- if (!__builtin_constant_p (__buflen)) +- return __getdomainname_chk (__buf, __buflen, __bos (__buf)); +- +- if (__buflen > __bos (__buf)) +- return __getdomainname_chk_warn (__buf, __buflen, __bos (__buf)); +- } ++ if (__FORTIFY_CALL_CHK && __bos (__buf) != (size_t) -1) ++ return __getdomainname_chk (__buf, __buflen, __bos (__buf)); + return __getdomainname_alias (__buf, __buflen); + } ++__FORTIFY_FUNCTION_END + #endif +--- a/rt/bits/mqueue2.h ++++ b/rt/bits/mqueue2.h +@@ -29,10 +29,47 @@ extern mqd_t __mq_open_2 (const char *__ + extern mqd_t __REDIRECT_NTH (__mq_open_alias, (const char *__name, + int __oflag, ...), mq_open) + __nonnull ((1)); ++ ++#define __warn_mq_open_wrong_number_of_args "mq_open can be called either " \ ++ "with 2 or 4 arguments" ++#define __warn_mq_open_missing_mode_and_attr "mq_open with O_CREAT in " \ ++ "second argument needs 4 arguments" ++#ifdef __use_clang_fortify ++__fortify_overload __clang_error (__warn_mq_open_wrong_number_of_args) mqd_t ++__NTH (mq_open (const char *const __clang_pass_object_size __name, int __oflag, ++ int __mode)) ++{ ++ return __mq_open_alias (__name, __oflag, __mode); ++} ++ ++__fortify_overload __clang_error (__warn_mq_open_wrong_number_of_args) ++mqd_t ++__NTH (mq_open (const char *const __clang_pass_object_size __name, int __oflag, ++ int __mode, struct mq_attr *__attr, ...)) ++{ ++ return __mq_open_alias (__name, __oflag, __mode, __attr); ++} ++ ++__fortify_overload __clang_prefer_this_overload mqd_t ++__NTH (mq_open (const char *const __clang_pass_object_size __name, ++ int __oflag)) ++ __clang_error_if ((__oflag & O_CREAT), ++ __warn_mq_open_missing_mode_and_attr) ++{ ++ return __mq_open_alias (__name, __oflag); ++} ++ ++__fortify_overload __clang_prefer_this_overload mqd_t ++__NTH (mq_open (const char *const __clang_pass_object_size __name, int __oflag, ++ int __mode, struct mq_attr *__attr)) ++{ ++ return __mq_open_alias (__name, __oflag, __mode, __attr); ++} ++#else + __errordecl (__mq_open_wrong_number_of_args, +- "mq_open can be called either with 2 or 4 arguments"); ++ __warn_mq_open_wrong_number_of_args); + __errordecl (__mq_open_missing_mode_and_attr, +- "mq_open with O_CREAT in second argument needs 4 arguments"); ++ __warn_mq_open_missing_mode_and_attr); + + __fortify_function mqd_t + __NTH (mq_open (const char *__name, int __oflag, ...)) +@@ -55,3 +92,6 @@ __NTH (mq_open (const char *__name, int + + return __mq_open_alias (__name, __oflag, __va_arg_pack ()); + } ++#endif ++#undef __warn_mq_open_wrong_number_of_args ++#undef __warn_mq_open_missing_mode_and_attr +--- a/rt/mqueue.h ++++ b/rt/mqueue.h +@@ -89,7 +89,7 @@ extern int mq_timedsend (mqd_t __mqdes, + + /* Define some inlines helping to catch common problems. */ + #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function \ +- && defined __va_arg_pack_len ++ && (defined __va_arg_pack_len || defined __use_clang_fortify) + # include <bits/mqueue2.h> + #endif + +--- a/socket/bits/socket2.h ++++ b/socket/bits/socket2.h +@@ -24,25 +24,20 @@ extern ssize_t __recv_chk (int __fd, voi + int __flags); + extern ssize_t __REDIRECT (__recv_alias, (int __fd, void *__buf, size_t __n, + int __flags), recv); +-extern ssize_t __REDIRECT (__recv_chk_warn, +- (int __fd, void *__buf, size_t __n, size_t __buflen, +- int __flags), __recv_chk) +- __warnattr ("recv called with bigger length than size of destination " +- "buffer"); + +-__fortify_function ssize_t +-recv (int __fd, void *__buf, size_t __n, int __flags) ++__fortify_potential_overload ssize_t ++recv (int __fd, void *const __clang_pass_object_size0 __buf, size_t __n, ++ int __flags) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_ONLY_IF_BOS0_LT (__recv_warn, __n, __buf, ++ "recv called with bigger length than " ++ "size of destination buffer") + { +- if (__bos0 (__buf) != (size_t) -1) +- { +- if (!__builtin_constant_p (__n)) +- return __recv_chk (__fd, __buf, __n, __bos0 (__buf), __flags); +- +- if (__n > __bos0 (__buf)) +- return __recv_chk_warn (__fd, __buf, __n, __bos0 (__buf), __flags); +- } ++ if (__FORTIFY_CALL_CHK && __bos0 (__buf) != (size_t) -1) ++ return __recv_chk (__fd, __buf, __n, __bos0 (__buf), __flags); + return __recv_alias (__fd, __buf, __n, __flags); + } ++__FORTIFY_FUNCTION_END + + extern ssize_t __recvfrom_chk (int __fd, void *__restrict __buf, size_t __n, + size_t __buflen, int __flags, +@@ -52,26 +47,19 @@ extern ssize_t __REDIRECT (__recvfrom_al + (int __fd, void *__restrict __buf, size_t __n, + int __flags, __SOCKADDR_ARG __addr, + socklen_t *__restrict __addr_len), recvfrom); +-extern ssize_t __REDIRECT (__recvfrom_chk_warn, +- (int __fd, void *__restrict __buf, size_t __n, +- size_t __buflen, int __flags, +- __SOCKADDR_ARG __addr, +- socklen_t *__restrict __addr_len), __recvfrom_chk) +- __warnattr ("recvfrom called with bigger length than size of " +- "destination buffer"); + +-__fortify_function ssize_t +-recvfrom (int __fd, void *__restrict __buf, size_t __n, int __flags, +- __SOCKADDR_ARG __addr, socklen_t *__restrict __addr_len) ++__fortify_potential_overload ssize_t ++recvfrom (int __fd, void *__restrict const __clang_pass_object_size0 __buf, ++ size_t __n, int __flags, __SOCKADDR_ARG __addr, ++ socklen_t *__restrict __addr_len) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_ONLY_IF_BOS0_LT (__recvfrom_warn, __n, __buf, ++ "recvfrom called with bigger length " ++ "than size of destination buffer") + { +- if (__bos0 (__buf) != (size_t) -1) +- { +- if (!__builtin_constant_p (__n)) +- return __recvfrom_chk (__fd, __buf, __n, __bos0 (__buf), __flags, +- __addr, __addr_len); +- if (__n > __bos0 (__buf)) +- return __recvfrom_chk_warn (__fd, __buf, __n, __bos0 (__buf), __flags, +- __addr, __addr_len); +- } ++ if (__FORTIFY_CALL_CHK && __bos0 (__buf) != (size_t) -1) ++ return __recvfrom_chk (__fd, __buf, __n, __bos0 (__buf), __flags, __addr, ++ __addr_len); + return __recvfrom_alias (__fd, __buf, __n, __flags, __addr, __addr_len); + } ++__FORTIFY_FUNCTION_END +--- a/stdlib/bits/stdlib.h ++++ b/stdlib/bits/stdlib.h +@@ -26,27 +26,27 @@ extern char *__realpath_chk (const char + extern char *__REDIRECT_NTH (__realpath_alias, + (const char *__restrict __name, + char *__restrict __resolved), realpath) __wur; +-extern char *__REDIRECT_NTH (__realpath_chk_warn, +- (const char *__restrict __name, +- char *__restrict __resolved, +- size_t __resolvedlen), __realpath_chk) __wur +- __warnattr ("second argument of realpath must be either NULL or at " +- "least PATH_MAX bytes long buffer"); + +-__fortify_function __wur char * +-__NTH (realpath (const char *__restrict __name, char *__restrict __resolved)) ++__fortify_potential_overload __wur char * ++__NTH (realpath (const char *__restrict __name, ++ char *__restrict const __clang_pass_object_size __resolved)) ++__FORTIFY_PRECONDITIONS ++#if defined _LIBC_LIMITS_H_ && defined PATH_MAX ++ __FORTIFY_WARNING_ONLY_IF_BOS_LT (__realpath_warn, PATH_MAX, __resolved, ++ "second argument of realpath must be " ++ "either NULL or at least PATH_MAX " ++ "bytes long buffer") ++#endif + { +- if (__bos (__resolved) != (size_t) -1) +- { ++ if ( + #if defined _LIBC_LIMITS_H_ && defined PATH_MAX +- if (__bos (__resolved) < PATH_MAX) +- return __realpath_chk_warn (__name, __resolved, __bos (__resolved)); ++ __FORTIFY_CALL_CHK && + #endif +- return __realpath_chk (__name, __resolved, __bos (__resolved)); +- } +- ++ __bos (__resolved) != (size_t) -1) ++ return __realpath_chk (__name, __resolved, __bos (__resolved)); + return __realpath_alias (__name, __resolved); + } ++__FORTIFY_FUNCTION_END + + + extern int __ptsname_r_chk (int __fd, char *__buf, size_t __buflen, +@@ -54,33 +54,28 @@ extern int __ptsname_r_chk (int __fd, ch + extern int __REDIRECT_NTH (__ptsname_r_alias, (int __fd, char *__buf, + size_t __buflen), ptsname_r) + __nonnull ((2)); +-extern int __REDIRECT_NTH (__ptsname_r_chk_warn, +- (int __fd, char *__buf, size_t __buflen, +- size_t __nreal), __ptsname_r_chk) +- __nonnull ((2)) __warnattr ("ptsname_r called with buflen bigger than " +- "size of buf"); + +-__fortify_function int +-__NTH (ptsname_r (int __fd, char *__buf, size_t __buflen)) ++__fortify_potential_overload int ++__NTH (ptsname_r (int __fd, char *const __clang_pass_object_size __buf, ++ size_t __buflen)) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_ONLY_IF_BOS_LT (__ptsname_r_warn, __buflen, __buf, ++ "ptsname_r called with buflen " ++ "bigger than size of buf") + { +- if (__bos (__buf) != (size_t) -1) +- { +- if (!__builtin_constant_p (__buflen)) +- return __ptsname_r_chk (__fd, __buf, __buflen, __bos (__buf)); +- if (__buflen > __bos (__buf)) +- return __ptsname_r_chk_warn (__fd, __buf, __buflen, __bos (__buf)); +- } ++ if (__FORTIFY_CALL_CHK && __bos (__buf) != (size_t) -1) ++ return __ptsname_r_chk (__fd, __buf, __buflen, __bos (__buf)); + return __ptsname_r_alias (__fd, __buf, __buflen); + } +- ++__FORTIFY_FUNCTION_END + + extern int __wctomb_chk (char *__s, wchar_t __wchar, size_t __buflen) + __THROW __wur; + extern int __REDIRECT_NTH (__wctomb_alias, (char *__s, wchar_t __wchar), + wctomb) __wur; + +-__fortify_function __wur int +-__NTH (wctomb (char *__s, wchar_t __wchar)) ++__fortify_potential_overload __wur int ++__NTH (wctomb (char *const __clang_pass_object_size __s, wchar_t __wchar)) + { + /* We would have to include <limits.h> to get a definition of MB_LEN_MAX. + But this would only disturb the namespace. So we define our own +@@ -102,29 +97,22 @@ extern size_t __REDIRECT_NTH (__mbstowcs + (wchar_t *__restrict __dst, + const char *__restrict __src, + size_t __len), mbstowcs); +-extern size_t __REDIRECT_NTH (__mbstowcs_chk_warn, +- (wchar_t *__restrict __dst, +- const char *__restrict __src, +- size_t __len, size_t __dstlen), __mbstowcs_chk) +- __warnattr ("mbstowcs called with dst buffer smaller than len " +- "* sizeof (wchar_t)"); +- +-__fortify_function size_t +-__NTH (mbstowcs (wchar_t *__restrict __dst, const char *__restrict __src, +- size_t __len)) ++ ++__fortify_potential_overload size_t ++__NTH (mbstowcs (wchar_t *__restrict const __clang_pass_object_size __dst, ++ const char *__restrict __src, size_t __len)) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_ONLY_IF_BOS_LT2 (__mbstowcs_warn, __len, __dst, ++ sizeof (wchar_t), ++ "mbstowcs called with dst buffer " ++ "smaller than len * sizeof (wchar_t)") + { +- if (__bos (__dst) != (size_t) -1) +- { +- if (!__builtin_constant_p (__len)) +- return __mbstowcs_chk (__dst, __src, __len, +- __bos (__dst) / sizeof (wchar_t)); +- +- if (__len > __bos (__dst) / sizeof (wchar_t)) +- return __mbstowcs_chk_warn (__dst, __src, __len, +- __bos (__dst) / sizeof (wchar_t)); +- } ++ if (__FORTIFY_CALL_CHK && __bos (__dst) != (size_t) -1) ++ return __mbstowcs_chk (__dst, __src, __len, ++ __bos (__dst) / sizeof (wchar_t)); + return __mbstowcs_alias (__dst, __src, __len); + } ++__FORTIFY_FUNCTION_END + + + extern size_t __wcstombs_chk (char *__restrict __dst, +@@ -134,22 +122,17 @@ extern size_t __REDIRECT_NTH (__wcstombs + (char *__restrict __dst, + const wchar_t *__restrict __src, + size_t __len), wcstombs); +-extern size_t __REDIRECT_NTH (__wcstombs_chk_warn, +- (char *__restrict __dst, +- const wchar_t *__restrict __src, +- size_t __len, size_t __dstlen), __wcstombs_chk) +- __warnattr ("wcstombs called with dst buffer smaller than len"); + +-__fortify_function size_t +-__NTH (wcstombs (char *__restrict __dst, const wchar_t *__restrict __src, +- size_t __len)) ++__fortify_potential_overload size_t ++__NTH (wcstombs (char *__restrict const __clang_pass_object_size __dst, ++ const wchar_t *__restrict __src, size_t __len)) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_ONLY_IF_BOS_LT (__wcstombs_warn, __len, __dst, ++ "wcstombs called with dst buffer " ++ "smaller than len") + { +- if (__bos (__dst) != (size_t) -1) +- { +- if (!__builtin_constant_p (__len)) +- return __wcstombs_chk (__dst, __src, __len, __bos (__dst)); +- if (__len > __bos (__dst)) +- return __wcstombs_chk_warn (__dst, __src, __len, __bos (__dst)); +- } ++ if (__FORTIFY_CALL_CHK && __bos (__dst) != (size_t) -1) ++ return __wcstombs_chk (__dst, __src, __len, __bos (__dst)); + return __wcstombs_alias (__dst, __src, __len); + } ++__FORTIFY_FUNCTION_END +--- a/string/bits/string_fortified.h ++++ b/string/bits/string_fortified.h +@@ -22,45 +22,82 @@ + # error "Never use <bits/string_fortified.h> directly; include <string.h> instead." + #endif + +-#if !__GNUC_PREREQ (5,0) +-__warndecl (__warn_memset_zero_len, +- "memset used with constant zero length parameter; this could be due to transposed parameters"); +-#endif +- +-__fortify_function void * +-__NTH (memcpy (void *__restrict __dest, const void *__restrict __src, +- size_t __len)) +-{ +- return __builtin___memcpy_chk (__dest, __src, __len, __bos0 (__dest)); +-} +- +-__fortify_function void * +-__NTH (memmove (void *__dest, const void *__src, size_t __len)) +-{ +- return __builtin___memmove_chk (__dest, __src, __len, __bos0 (__dest)); ++#define __warn_len_too_large \ ++ "function called with bigger length than the destination buffer" ++/* Repeat bodies here to reduce 'note's if we detect a problem. */ ++#define __size_too_small(bos, dest, len) \ ++ (bos (dest) != (size_t) -1 && bos (dest) < len) ++#define __warn_if_dest_too_small(dest, len) \ ++ __clang_warning_if (__size_too_small (__bos, dest, len), \ ++ __warn_len_too_large) ++#define __warn_if_dest_too_small0(dest, len) \ ++ __clang_warning_if (__size_too_small (__bos0, dest, len), \ ++ __warn_len_too_large) ++ ++#define __warn_input_str_too_large \ ++ "destination buffer will always be overflown by source" ++#define __warn_if_src_too_large(dest, src) \ ++ __clang_warning_if (__size_too_small (__bos, dest, __builtin_strlen (src) + 1), \ ++ __warn_input_str_too_large) ++ ++__fortify_potential_overload void * ++__NTH (memcpy (void *__restrict const __clang_pass_object_size0 __dest, ++ const void *__restrict __src, size_t __len)) ++ __warn_if_dest_too_small0 (__dest, __len) ++{ ++ size_t __bos_dst = __bos0 (__dest); ++ if (__bos_dst == (size_t) -1 || (__builtin_constant_p (__len) ++ && __bos_dst >= __len)) ++ return __builtin_memcpy (__dest, __src, __len); ++ return __builtin___memcpy_chk (__dest, __src, __len, __bos_dst); ++} ++ ++__fortify_potential_overload void * ++__NTH (memmove (void *const __clang_pass_object_size0 __dest, ++ const void *__src, size_t __len)) ++ __warn_if_dest_too_small0 (__dest, __len) ++{ ++ size_t __bos_dst = __bos0 (__dest); ++ if (__bos_dst == (size_t) -1 || (__builtin_constant_p (__len) ++ && __bos_dst >= __len)) ++ return __builtin_memmove (__dest, __src, __len); ++ return __builtin___memmove_chk (__dest, __src, __len, __bos_dst); + } + + #ifdef __USE_GNU +-__fortify_function void * +-__NTH (mempcpy (void *__restrict __dest, const void *__restrict __src, +- size_t __len)) +-{ +- return __builtin___mempcpy_chk (__dest, __src, __len, __bos0 (__dest)); ++__fortify_potential_overload void * ++__NTH (mempcpy (void *__restrict const __clang_pass_object_size0 __dest, ++ const void *__restrict __src, size_t __len)) ++ __warn_if_dest_too_small0 (__dest, __len) ++{ ++ size_t __bos_dst = __bos0 (__dest); ++ if (__bos_dst == (size_t) -1 || (__builtin_constant_p (__len) ++ && __bos_dst >= __len)) ++ return __builtin_mempcpy (__dest, __src, __len); ++ return __builtin___mempcpy_chk (__dest, __src, __len, __bos_dst); + } + #endif + +- + /* The first two tests here help to catch a somewhat common problem + where the second and third parameter are transposed. This is + especially problematic if the intended fill value is zero. In this + case no work is done at all. We detect these problems by referring + non-existing functions. */ +-__fortify_function void * +-__NTH (memset (void *__dest, int __ch, size_t __len)) ++#define __warn_memset_zero_len_msg \ ++ "memset used with constant zero length parameter; this could be due to " \ ++ "transposed parameters" ++#if !__GNUC_PREREQ (5,0) ++__warndecl (__warn_memset_zero_len, __warn_memset_zero_len_msg); ++#endif ++__fortify_potential_overload void * ++__NTH (memset (void *const __clang_pass_object_size0 __dest, int __ch, ++ size_t __len)) ++ __warn_if_dest_too_small0 (__dest, __len) ++ __clang_warning_if (__len == 0 && __ch != 0, __warn_memset_zero_len_msg) + { + /* GCC-5.0 and newer implements these checks in the compiler, so we don't + need them here. */ +-#if !__GNUC_PREREQ (5,0) ++#if !__GNUC_PREREQ (5,0) && !defined __use_clang_fortify + if (__builtin_constant_p (__len) && __len == 0 + && (!__builtin_constant_p (__ch) || __ch != 0)) + { +@@ -68,8 +105,13 @@ __NTH (memset (void *__dest, int __ch, s + return __dest; + } + #endif +- return __builtin___memset_chk (__dest, __ch, __len, __bos0 (__dest)); ++ size_t __bos_dst = __bos0 (__dest); ++ if (__bos_dst == (size_t) -1 || (__builtin_constant_p (__len) ++ && __bos_dst >= __len)) ++ return __builtin_memset (__dest, __ch, __len); ++ return __builtin___memset_chk (__dest, __ch, __len, __bos_dst); + } ++#undef __warn_memset_zero_len_msg + + #ifdef __USE_MISC + # include <bits/strings_fortified.h> +@@ -84,24 +126,30 @@ __NTH (explicit_bzero (void *__dest, siz + } + #endif + +-__fortify_function char * +-__NTH (strcpy (char *__restrict __dest, const char *__restrict __src)) ++__fortify_potential_overload char * ++__NTH (strcpy (char *__restrict const __clang_pass_object_size __dest, ++ const char *__restrict __src)) ++ __warn_if_src_too_large (__dest, __src) + { + return __builtin___strcpy_chk (__dest, __src, __bos (__dest)); + } + + #ifdef __USE_GNU +-__fortify_function char * +-__NTH (stpcpy (char *__restrict __dest, const char *__restrict __src)) ++__fortify_potential_overload char * ++__NTH (stpcpy (char *__restrict const __clang_pass_object_size __dest, ++ const char *__restrict __src)) ++ __warn_if_src_too_large (__dest, __src) + { + return __builtin___stpcpy_chk (__dest, __src, __bos (__dest)); + } + #endif + +- +-__fortify_function char * +-__NTH (strncpy (char *__restrict __dest, const char *__restrict __src, +- size_t __len)) ++__fortify_potential_overload char * ++__NTH (strncpy (char *__restrict const __clang_pass_object_size __dest, ++ const char *__restrict __src, size_t __len)) ++/* clang: Don't warn when __builtin_strlen (__src) < __bos (__dest), ++ but __len > __bos (__dest). The user should fix their code instead. */ ++ __warn_if_dest_too_small (__dest, __len) + { + return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest)); + } +@@ -112,28 +160,36 @@ extern char *__stpncpy_chk (char *__dest + extern char *__REDIRECT_NTH (__stpncpy_alias, (char *__dest, const char *__src, + size_t __n), stpncpy); + +-__fortify_function char * +-__NTH (stpncpy (char *__dest, const char *__src, size_t __n)) ++__fortify_potential_overload char * ++__NTH (stpncpy (char *const __clang_pass_object_size __dest, const char *__src, ++ size_t __n)) ++ __warn_if_dest_too_small (__dest, __n) + { +- if (__bos (__dest) != (size_t) -1 +- && (!__builtin_constant_p (__n) || __n > __bos (__dest))) ++ if (__bos (__dest) != (size_t) -1) + return __stpncpy_chk (__dest, __src, __n, __bos (__dest)); + return __stpncpy_alias (__dest, __src, __n); + } + +- +-__fortify_function char * +-__NTH (strcat (char *__restrict __dest, const char *__restrict __src)) ++__fortify_potential_overload char * ++__NTH (strcat (char *__restrict const __clang_pass_object_size __dest, ++ const char *__restrict __src)) ++ __warn_if_src_too_large (__dest, __src) + { + return __builtin___strcat_chk (__dest, __src, __bos (__dest)); + } + +- +-__fortify_function char * +-__NTH (strncat (char *__restrict __dest, const char *__restrict __src, +- size_t __len)) ++__fortify_potential_overload char * ++__NTH (strncat (char *__restrict const __clang_pass_object_size __dest, ++ const char *__restrict __src, size_t __len)) ++ __warn_if_src_too_large (__dest, __src) + { + return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest)); + } + ++#undef __warn_len_too_large ++#undef __size_too_small ++#undef __warn_if_dest_too_small ++#undef __warn_if_dest_too_small0 ++#undef __warn_input_str_too_large ++#undef __warn_if_src_too_large + #endif /* bits/string_fortified.h */ +--- a/string/bits/strings_fortified.h ++++ b/string/bits/strings_fortified.h +@@ -19,16 +19,40 @@ + #ifndef __STRINGS_FORTIFIED + # define __STRINGS_FORTIFIED 1 + +-__fortify_function void +-__NTH (bcopy (const void *__src, void *__dest, size_t __len)) ++#define __strings_warn_len_too_large \ ++ "function called with bigger length than the destination buffer" ++ ++#define __strings_size_too_small(dest, len) \ ++ (__bos0 (dest) != (size_t) -1 && __bos0 (dest) < len) ++ ++__fortify_potential_overload void ++__NTH (bcopy (const void *__src, void *const __clang_pass_object_size0 __dest, ++ size_t __len)) ++ __clang_warning_if (__strings_size_too_small (__dest, __len), ++ __strings_warn_len_too_large) + { +- (void) __builtin___memmove_chk (__dest, __src, __len, __bos0 (__dest)); ++ size_t __bos_dst = __bos0 (__dest); ++ if (__bos_dst == (size_t) -1 || (__builtin_constant_p (__len) ++ && __bos_dst >= __len)) ++ (void) __builtin_memmove (__dest, __src, __len); ++ else ++ (void) __builtin___memmove_chk (__dest, __src, __len, __bos_dst); + } + +-__fortify_function void +-__NTH (bzero (void *__dest, size_t __len)) ++__fortify_potential_overload void ++__NTH (bzero (void *const __clang_pass_object_size0 __dest, size_t __len)) ++ __clang_warning_if (__strings_size_too_small (__dest, __len), ++ __strings_warn_len_too_large) + { +- (void) __builtin___memset_chk (__dest, '\0', __len, __bos0 (__dest)); ++ size_t __bos_dst = __bos0 (__dest); ++ if (__bos_dst == (size_t) -1 || (__builtin_constant_p (__len) ++ && __bos_dst >= __len)) ++ (void) __builtin_memset (__dest, '\0', __len); ++ else ++ (void) __builtin___memset_chk (__dest, '\0', __len, __bos_dst); + } + ++ ++#undef __strings_size_too_small ++#undef __strings_warn_len_too_large + #endif +--- a/wcsmbs/bits/wchar2.h ++++ b/wcsmbs/bits/wchar2.h +@@ -20,7 +20,6 @@ + # error "Never include <bits/wchar2.h> directly; use <wchar.h> instead." + #endif + +- + extern wchar_t *__wmemcpy_chk (wchar_t *__restrict __s1, + const wchar_t *__restrict __s2, size_t __n, + size_t __ns1) __THROW; +@@ -28,57 +27,42 @@ extern wchar_t *__REDIRECT_NTH (__wmemcp + (wchar_t *__restrict __s1, + const wchar_t *__restrict __s2, size_t __n), + wmemcpy); +-extern wchar_t *__REDIRECT_NTH (__wmemcpy_chk_warn, +- (wchar_t *__restrict __s1, +- const wchar_t *__restrict __s2, size_t __n, +- size_t __ns1), __wmemcpy_chk) +- __warnattr ("wmemcpy called with length bigger than size of destination " +- "buffer"); + +-__fortify_function wchar_t * +-__NTH (wmemcpy (wchar_t *__restrict __s1, const wchar_t *__restrict __s2, +- size_t __n)) +-{ +- if (__bos0 (__s1) != (size_t) -1) +- { +- if (!__builtin_constant_p (__n)) +- return __wmemcpy_chk (__s1, __s2, __n, +- __bos0 (__s1) / sizeof (wchar_t)); +- +- if (__n > __bos0 (__s1) / sizeof (wchar_t)) +- return __wmemcpy_chk_warn (__s1, __s2, __n, +- __bos0 (__s1) / sizeof (wchar_t)); +- } +- return __wmemcpy_alias (__s1, __s2, __n); ++__fortify_potential_overload wchar_t * ++__NTH (wmemcpy (wchar_t *__restrict const __clang_pass_object_size0 __s1, ++ const wchar_t *__restrict __s2, size_t __n)) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_ONLY_IF_BOS0_LT2 (__wmemcpy_warn, __n, __s1, ++ sizeof (wchar_t), ++ "wmemcpy called with length bigger " ++ "than size of destination buffer") ++{ ++ if (__FORTIFY_CALL_CHK && __bos0 (__s1) != (size_t)-1) ++ return __wmemcpy_chk(__s1, __s2, __n, __bos0(__s1) / sizeof (wchar_t)); ++ return __wmemcpy_alias(__s1, __s2, __n); + } +- ++__FORTIFY_FUNCTION_END + + extern wchar_t *__wmemmove_chk (wchar_t *__s1, const wchar_t *__s2, + size_t __n, size_t __ns1) __THROW; + extern wchar_t *__REDIRECT_NTH (__wmemmove_alias, (wchar_t *__s1, + const wchar_t *__s2, + size_t __n), wmemmove); +-extern wchar_t *__REDIRECT_NTH (__wmemmove_chk_warn, +- (wchar_t *__s1, const wchar_t *__s2, +- size_t __n, size_t __ns1), __wmemmove_chk) +- __warnattr ("wmemmove called with length bigger than size of destination " +- "buffer"); +- +-__fortify_function wchar_t * +-__NTH (wmemmove (wchar_t *__s1, const wchar_t *__s2, size_t __n)) +-{ +- if (__bos0 (__s1) != (size_t) -1) +- { +- if (!__builtin_constant_p (__n)) +- return __wmemmove_chk (__s1, __s2, __n, +- __bos0 (__s1) / sizeof (wchar_t)); +- +- if (__n > __bos0 (__s1) / sizeof (wchar_t)) +- return __wmemmove_chk_warn (__s1, __s2, __n, +- __bos0 (__s1) / sizeof (wchar_t)); +- } ++ ++__fortify_potential_overload wchar_t * ++__NTH (wmemmove (wchar_t *const __clang_pass_object_size0 __s1, ++ const wchar_t *__s2, size_t __n)) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_ONLY_IF_BOS0_LT2 (__wmemmove_warn, __n, __s1, ++ sizeof (wchar_t), ++ "wmemmove called with length bigger " ++ "than size of destination buffer") ++{ ++ if (__FORTIFY_CALL_CHK && __bos0 (__s1) != (size_t) -1) ++ return __wmemmove_chk (__s1, __s2, __n, __bos0 (__s1) / sizeof (wchar_t)); + return __wmemmove_alias (__s1, __s2, __n); + } ++__FORTIFY_FUNCTION_END + + + #ifdef __USE_GNU +@@ -89,29 +73,21 @@ extern wchar_t *__REDIRECT_NTH (__wmempc + (wchar_t *__restrict __s1, + const wchar_t *__restrict __s2, + size_t __n), wmempcpy); +-extern wchar_t *__REDIRECT_NTH (__wmempcpy_chk_warn, +- (wchar_t *__restrict __s1, +- const wchar_t *__restrict __s2, size_t __n, +- size_t __ns1), __wmempcpy_chk) +- __warnattr ("wmempcpy called with length bigger than size of destination " +- "buffer"); +- +-__fortify_function wchar_t * +-__NTH (wmempcpy (wchar_t *__restrict __s1, const wchar_t *__restrict __s2, +- size_t __n)) +-{ +- if (__bos0 (__s1) != (size_t) -1) +- { +- if (!__builtin_constant_p (__n)) +- return __wmempcpy_chk (__s1, __s2, __n, +- __bos0 (__s1) / sizeof (wchar_t)); +- +- if (__n > __bos0 (__s1) / sizeof (wchar_t)) +- return __wmempcpy_chk_warn (__s1, __s2, __n, +- __bos0 (__s1) / sizeof (wchar_t)); +- } +- return __wmempcpy_alias (__s1, __s2, __n); ++ ++__fortify_potential_overload wchar_t * ++__NTH(wmempcpy(wchar_t *__restrict const __clang_pass_object_size0 __s1, ++ const wchar_t *__restrict __s2, size_t __n)) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_ONLY_IF_BOS0_LT2 (__wmempcpy_warn, __n, __s1, ++ sizeof (wchar_t), ++ "wmempcpy called with length bigger " ++ "than size of destination buffer") ++{ ++ if (__FORTIFY_CALL_CHK && __bos0 (__s1) != (size_t)-1) ++ return __wmempcpy_chk(__s1, __s2, __n, __bos0(__s1) / sizeof (wchar_t)); ++ return __wmempcpy_alias(__s1, __s2, __n); + } ++__FORTIFY_FUNCTION_END + #endif + + +@@ -119,26 +95,21 @@ extern wchar_t *__wmemset_chk (wchar_t * + size_t __ns) __THROW; + extern wchar_t *__REDIRECT_NTH (__wmemset_alias, (wchar_t *__s, wchar_t __c, + size_t __n), wmemset); +-extern wchar_t *__REDIRECT_NTH (__wmemset_chk_warn, +- (wchar_t *__s, wchar_t __c, size_t __n, +- size_t __ns), __wmemset_chk) +- __warnattr ("wmemset called with length bigger than size of destination " +- "buffer"); +- +-__fortify_function wchar_t * +-__NTH (wmemset (wchar_t *__s, wchar_t __c, size_t __n)) +-{ +- if (__bos0 (__s) != (size_t) -1) +- { +- if (!__builtin_constant_p (__n)) +- return __wmemset_chk (__s, __c, __n, __bos0 (__s) / sizeof (wchar_t)); +- +- if (__n > __bos0 (__s) / sizeof (wchar_t)) +- return __wmemset_chk_warn (__s, __c, __n, +- __bos0 (__s) / sizeof (wchar_t)); +- } ++ ++__fortify_potential_overload wchar_t * ++__NTH (wmemset (wchar_t *const __clang_pass_object_size0 __s, wchar_t __c, ++ size_t __n)) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_ONLY_IF_BOS0_LT2 (__wmemset_warn, __n, __s, ++ sizeof (wchar_t), ++ "wmemset called with length bigger " ++ "than size of destination buffer") ++{ ++ if (__FORTIFY_CALL_CHK && __bos0 (__s) != (size_t) -1) ++ return __wmemset_chk (__s, __c, __n, __bos0 (__s) / sizeof (wchar_t)); + return __wmemset_alias (__s, __c, __n); + } ++__FORTIFY_FUNCTION_END + + + extern wchar_t *__wcscpy_chk (wchar_t *__restrict __dest, +@@ -148,8 +119,9 @@ extern wchar_t *__REDIRECT_NTH (__wcscpy + (wchar_t *__restrict __dest, + const wchar_t *__restrict __src), wcscpy); + +-__fortify_function wchar_t * +-__NTH (wcscpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src)) ++__fortify_potential_overload wchar_t * ++__NTH (wcscpy (wchar_t *__restrict const __clang_pass_object_size __dest, ++ const wchar_t *__restrict __src)) + { + if (__bos (__dest) != (size_t) -1) + return __wcscpy_chk (__dest, __src, __bos (__dest) / sizeof (wchar_t)); +@@ -164,8 +136,9 @@ extern wchar_t *__REDIRECT_NTH (__wcpcpy + (wchar_t *__restrict __dest, + const wchar_t *__restrict __src), wcpcpy); + +-__fortify_function wchar_t * +-__NTH (wcpcpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src)) ++__fortify_potential_overload wchar_t * ++__NTH (wcpcpy (wchar_t *__restrict const __clang_pass_object_size __dest, ++ const wchar_t *__restrict __src)) + { + if (__bos (__dest) != (size_t) -1) + return __wcpcpy_chk (__dest, __src, __bos (__dest) / sizeof (wchar_t)); +@@ -180,28 +153,22 @@ extern wchar_t *__REDIRECT_NTH (__wcsncp + (wchar_t *__restrict __dest, + const wchar_t *__restrict __src, + size_t __n), wcsncpy); +-extern wchar_t *__REDIRECT_NTH (__wcsncpy_chk_warn, +- (wchar_t *__restrict __dest, +- const wchar_t *__restrict __src, +- size_t __n, size_t __destlen), __wcsncpy_chk) +- __warnattr ("wcsncpy called with length bigger than size of destination " +- "buffer"); + +-__fortify_function wchar_t * +-__NTH (wcsncpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src, +- size_t __n)) ++__fortify_potential_overload wchar_t * ++__NTH (wcsncpy (wchar_t *__restrict const __clang_pass_object_size __dest, ++ const wchar_t *__restrict __src, size_t __n)) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_ONLY_IF_BOS_LT2 (__wcsncpy_warn, __n, __dest, ++ sizeof (wchar_t), ++ "wcsncpy called with length bigger " ++ "than size of destination buffer") + { +- if (__bos (__dest) != (size_t) -1) +- { +- if (!__builtin_constant_p (__n)) +- return __wcsncpy_chk (__dest, __src, __n, +- __bos (__dest) / sizeof (wchar_t)); +- if (__n > __bos (__dest) / sizeof (wchar_t)) +- return __wcsncpy_chk_warn (__dest, __src, __n, +- __bos (__dest) / sizeof (wchar_t)); +- } ++ if (__FORTIFY_CALL_CHK && __bos (__dest) != (size_t) -1) ++ return __wcsncpy_chk (__dest, __src, __n, ++ __bos (__dest) / sizeof (wchar_t)); + return __wcsncpy_alias (__dest, __src, __n); + } ++__FORTIFY_FUNCTION_END + + + extern wchar_t *__wcpncpy_chk (wchar_t *__restrict __dest, +@@ -211,29 +178,22 @@ extern wchar_t *__REDIRECT_NTH (__wcpncp + (wchar_t *__restrict __dest, + const wchar_t *__restrict __src, + size_t __n), wcpncpy); +-extern wchar_t *__REDIRECT_NTH (__wcpncpy_chk_warn, +- (wchar_t *__restrict __dest, +- const wchar_t *__restrict __src, +- size_t __n, size_t __destlen), __wcpncpy_chk) +- __warnattr ("wcpncpy called with length bigger than size of destination " +- "buffer"); + +-__fortify_function wchar_t * +-__NTH (wcpncpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src, +- size_t __n)) ++__fortify_potential_overload wchar_t * ++__NTH (wcpncpy (wchar_t *__restrict const __clang_pass_object_size __dest, ++ const wchar_t *__restrict __src, size_t __n)) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_ONLY_IF_BOS_LT2 (__wcpncpy_warn, __n, __dest, ++ sizeof (wchar_t), ++ "wcpncpy called with length bigger " ++ "than size of destination buffer") + { +- if (__bos (__dest) != (size_t) -1) +- { +- if (!__builtin_constant_p (__n)) +- return __wcpncpy_chk (__dest, __src, __n, +- __bos (__dest) / sizeof (wchar_t)); +- if (__n > __bos (__dest) / sizeof (wchar_t)) +- return __wcpncpy_chk_warn (__dest, __src, __n, +- __bos (__dest) / sizeof (wchar_t)); +- } ++ if (__FORTIFY_CALL_CHK && __bos (__dest) != (size_t) -1) ++ return __wcpncpy_chk (__dest, __src, __n, ++ __bos (__dest) / sizeof (wchar_t)); + return __wcpncpy_alias (__dest, __src, __n); + } +- ++__FORTIFY_FUNCTION_END + + extern wchar_t *__wcscat_chk (wchar_t *__restrict __dest, + const wchar_t *__restrict __src, +@@ -242,8 +202,9 @@ extern wchar_t *__REDIRECT_NTH (__wcscat + (wchar_t *__restrict __dest, + const wchar_t *__restrict __src), wcscat); + +-__fortify_function wchar_t * +-__NTH (wcscat (wchar_t *__restrict __dest, const wchar_t *__restrict __src)) ++__fortify_potential_overload wchar_t * ++__NTH (wcscat (wchar_t *__restrict const __clang_pass_object_size __dest, ++ const wchar_t *__restrict __src)) + { + if (__bos (__dest) != (size_t) -1) + return __wcscat_chk (__dest, __src, __bos (__dest) / sizeof (wchar_t)); +@@ -259,9 +220,9 @@ extern wchar_t *__REDIRECT_NTH (__wcsnca + const wchar_t *__restrict __src, + size_t __n), wcsncat); + +-__fortify_function wchar_t * +-__NTH (wcsncat (wchar_t *__restrict __dest, const wchar_t *__restrict __src, +- size_t __n)) ++__fortify_potential_overload wchar_t * ++__NTH (wcsncat (wchar_t *__restrict const __clang_pass_object_size __dest, ++ const wchar_t *__restrict __src, size_t __n)) + { + if (__bos (__dest) != (size_t) -1) + return __wcsncat_chk (__dest, __src, __n, +@@ -280,16 +241,34 @@ extern int __REDIRECT_NTH_LDBL (__swprin + const wchar_t *__restrict __fmt, ...), + swprintf); + +-#ifdef __va_arg_pack +-__fortify_function int +-__NTH (swprintf (wchar_t *__restrict __s, size_t __n, +- const wchar_t *__restrict __fmt, ...)) ++extern int __vswprintf_chk (wchar_t *__restrict __s, size_t __n, ++ int __flag, size_t __s_len, ++ const wchar_t *__restrict __format, ++ __gnuc_va_list __arg) ++ __THROW /* __attribute__ ((__format__ (__wprintf__, 5, 0))) */; ++ ++extern int __REDIRECT_NTH_LDBL (__vswprintf_alias, ++ (wchar_t *__restrict __s, size_t __n, ++ const wchar_t *__restrict __fmt, ++ __gnuc_va_list __ap), vswprintf); ++ ++#ifdef __FORTIFY_ARG_PACK_OK ++__fortify_potential_overload int ++__NTH (swprintf (wchar_t *__restrict const __clang_pass_object_size __s, ++ size_t __n, const wchar_t *__restrict __fmt, ...)) + { ++ __FORTIFY_INIT_ARG_PACK(__fmt); ++ int __result; + if (__bos (__s) != (size_t) -1 || __USE_FORTIFY_LEVEL > 1) +- return __swprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, +- __bos (__s) / sizeof (wchar_t), +- __fmt, __va_arg_pack ()); +- return __swprintf_alias (__s, __n, __fmt, __va_arg_pack ()); ++ __result = __FORTIFY_CALL_VA_CHK(swprintf, __s, __n, ++ __USE_FORTIFY_LEVEL - 1, ++ __bos (__s) / sizeof (wchar_t), __fmt, ++ __FORTIFY_ARG_PACK); ++ else ++ __result = __FORTIFY_CALL_VA_ALIAS(swprintf, __s, __n, __fmt, ++ __FORTIFY_ARG_PACK); ++ __FORTIFY_FREE_ARG_PACK(); ++ return __result; + } + #elif !defined __cplusplus + /* XXX We might want to have support in gcc for swprintf. */ +@@ -300,20 +279,10 @@ __NTH (swprintf (wchar_t *__restrict __s + : swprintf (s, n, __VA_ARGS__)) + #endif + +-extern int __vswprintf_chk (wchar_t *__restrict __s, size_t __n, +- int __flag, size_t __s_len, +- const wchar_t *__restrict __format, +- __gnuc_va_list __arg) +- __THROW /* __attribute__ ((__format__ (__wprintf__, 5, 0))) */; +- +-extern int __REDIRECT_NTH_LDBL (__vswprintf_alias, +- (wchar_t *__restrict __s, size_t __n, +- const wchar_t *__restrict __fmt, +- __gnuc_va_list __ap), vswprintf); +- +-__fortify_function int +-__NTH (vswprintf (wchar_t *__restrict __s, size_t __n, +- const wchar_t *__restrict __fmt, __gnuc_va_list __ap)) ++__fortify_potential_overload int ++__NTH (vswprintf (wchar_t *__restrict const __clang_pass_object_size __s, ++ size_t __n, const wchar_t *__restrict __fmt, ++ __gnuc_va_list __ap)) + { + if (__bos (__s) != (size_t) -1 || __USE_FORTIFY_LEVEL > 1) + return __vswprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, +@@ -334,18 +303,27 @@ extern int __vfwprintf_chk (__FILE *__re + extern int __vwprintf_chk (int __flag, const wchar_t *__restrict __format, + __gnuc_va_list __ap); + +-# ifdef __va_arg_pack +-__fortify_function int +-wprintf (const wchar_t *__restrict __fmt, ...) +-{ +- return __wprintf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ()); +-} + +-__fortify_function int +-fwprintf (__FILE *__restrict __stream, const wchar_t *__restrict __fmt, ...) +-{ +- return __fwprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt, +- __va_arg_pack ()); ++#ifdef __FORTIFY_ARG_PACK_OK ++__fortify_potential_overload int ++wprintf (const wchar_t *__restrict const __clang_pass_object_size __fmt, ...) ++{ ++ __FORTIFY_INIT_ARG_PACK(__fmt); ++ int __r = __FORTIFY_CALL_VA_CHK (wprintf, __USE_FORTIFY_LEVEL - 1, __fmt, ++ __FORTIFY_ARG_PACK); ++ __FORTIFY_FREE_ARG_PACK(); ++ return __r; ++} ++ ++__fortify_potential_overload int ++fwprintf (__FILE *__restrict const __clang_pass_object_size __stream, ++ const wchar_t *__restrict __fmt, ...) ++{ ++ __FORTIFY_INIT_ARG_PACK(__fmt); ++ int __r = __FORTIFY_CALL_VA_CHK (fwprintf, __stream, __USE_FORTIFY_LEVEL - 1, ++ __fmt, __FORTIFY_ARG_PACK); ++ __FORTIFY_FREE_ARG_PACK(); ++ return __r; + } + # elif !defined __cplusplus + # define wprintf(...) \ +@@ -354,14 +332,15 @@ fwprintf (__FILE *__restrict __stream, c + __fwprintf_chk (stream, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__) + # endif + +-__fortify_function int +-vwprintf (const wchar_t *__restrict __fmt, __gnuc_va_list __ap) ++__fortify_potential_overload int ++vwprintf (const wchar_t *__restrict const __clang_pass_object_size __fmt, ++ __gnuc_va_list __ap) + { + return __vwprintf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __ap); + } + +-__fortify_function int +-vfwprintf (__FILE *__restrict __stream, ++__fortify_potential_overload int ++vfwprintf (__FILE *__restrict const __clang_pass_object_size __stream, + const wchar_t *__restrict __fmt, __gnuc_va_list __ap) + { + return __vfwprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt, __ap); +@@ -374,27 +353,21 @@ extern wchar_t *__fgetws_chk (wchar_t *_ + extern wchar_t *__REDIRECT (__fgetws_alias, + (wchar_t *__restrict __s, int __n, + __FILE *__restrict __stream), fgetws) __wur; +-extern wchar_t *__REDIRECT (__fgetws_chk_warn, +- (wchar_t *__restrict __s, size_t __size, int __n, +- __FILE *__restrict __stream), __fgetws_chk) +- __wur __warnattr ("fgetws called with bigger size than length " +- "of destination buffer"); + +-__fortify_function __wur wchar_t * +-fgetws (wchar_t *__restrict __s, int __n, __FILE *__restrict __stream) ++__fortify_potential_overload __wur wchar_t * ++fgetws (wchar_t *__restrict const __clang_pass_object_size __s, int __n, ++ __FILE *__restrict __stream) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_ONLY_IF_BOS_LT2 (__fgetws_warn, __n, __s, ++ sizeof (wchar_t), ++ "fgetws called with length bigger " ++ "than size of destination buffer") + { +- if (__bos (__s) != (size_t) -1) +- { +- if (!__builtin_constant_p (__n) || __n <= 0) +- return __fgetws_chk (__s, __bos (__s) / sizeof (wchar_t), +- __n, __stream); +- +- if ((size_t) __n > __bos (__s) / sizeof (wchar_t)) +- return __fgetws_chk_warn (__s, __bos (__s) / sizeof (wchar_t), +- __n, __stream); +- } ++ if (__FORTIFY_CALL_CHK && __bos (__s) != (size_t) -1) ++ return __fgetws_chk (__s, __bos (__s) / sizeof (wchar_t), __n, __stream); + return __fgetws_alias (__s, __n, __stream); + } ++__FORTIFY_FUNCTION_END + + #ifdef __USE_GNU + extern wchar_t *__fgetws_unlocked_chk (wchar_t *__restrict __s, size_t __size, +@@ -404,28 +377,23 @@ extern wchar_t *__REDIRECT (__fgetws_unl + (wchar_t *__restrict __s, int __n, + __FILE *__restrict __stream), fgetws_unlocked) + __wur; +-extern wchar_t *__REDIRECT (__fgetws_unlocked_chk_warn, +- (wchar_t *__restrict __s, size_t __size, int __n, +- __FILE *__restrict __stream), +- __fgetws_unlocked_chk) +- __wur __warnattr ("fgetws_unlocked called with bigger size than length " +- "of destination buffer"); + +-__fortify_function __wur wchar_t * +-fgetws_unlocked (wchar_t *__restrict __s, int __n, __FILE *__restrict __stream) ++__fortify_potential_overload __wur wchar_t * ++fgetws_unlocked (wchar_t *__restrict const __clang_pass_object_size __s, ++ int __n, __FILE *__restrict __stream) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_IF (__fgetws_unlocked_warn, ++ __n > 0 ++ && __bos_static_lt2 (__n, __s, sizeof (wchar_t)), ++ "fgetws_unlocked called with bigger size than " ++ "length of destination buffer") + { + if (__bos (__s) != (size_t) -1) +- { +- if (!__builtin_constant_p (__n) || __n <= 0) +- return __fgetws_unlocked_chk (__s, __bos (__s) / sizeof (wchar_t), +- __n, __stream); +- +- if ((size_t) __n > __bos (__s) / sizeof (wchar_t)) +- return __fgetws_unlocked_chk_warn (__s, __bos (__s) / sizeof (wchar_t), +- __n, __stream); +- } ++ return __fgetws_unlocked_chk (__s, __bos (__s) / sizeof (wchar_t), ++ __n, __stream); + return __fgetws_unlocked_alias (__s, __n, __stream); + } ++__FORTIFY_FUNCTION_END + #endif + + +@@ -436,9 +404,9 @@ extern size_t __REDIRECT_NTH (__wcrtomb_ + (char *__restrict __s, wchar_t __wchar, + mbstate_t *__restrict __ps), wcrtomb) __wur; + +-__fortify_function __wur size_t +-__NTH (wcrtomb (char *__restrict __s, wchar_t __wchar, +- mbstate_t *__restrict __ps)) ++__fortify_potential_overload __wur size_t ++__NTH (wcrtomb (char *__restrict const __clang_pass_object_size __s, ++ wchar_t __wchar, mbstate_t *__restrict __ps)) + { + /* We would have to include <limits.h> to get a definition of MB_LEN_MAX. + But this would only disturb the namespace. So we define our own +@@ -462,30 +430,23 @@ extern size_t __REDIRECT_NTH (__mbsrtowc + const char **__restrict __src, + size_t __len, mbstate_t *__restrict __ps), + mbsrtowcs); +-extern size_t __REDIRECT_NTH (__mbsrtowcs_chk_warn, +- (wchar_t *__restrict __dst, +- const char **__restrict __src, +- size_t __len, mbstate_t *__restrict __ps, +- size_t __dstlen), __mbsrtowcs_chk) +- __warnattr ("mbsrtowcs called with dst buffer smaller than len " +- "* sizeof (wchar_t)"); +- +-__fortify_function size_t +-__NTH (mbsrtowcs (wchar_t *__restrict __dst, const char **__restrict __src, +- size_t __len, mbstate_t *__restrict __ps)) +-{ +- if (__bos (__dst) != (size_t) -1) +- { +- if (!__builtin_constant_p (__len)) +- return __mbsrtowcs_chk (__dst, __src, __len, __ps, +- __bos (__dst) / sizeof (wchar_t)); +- +- if (__len > __bos (__dst) / sizeof (wchar_t)) +- return __mbsrtowcs_chk_warn (__dst, __src, __len, __ps, +- __bos (__dst) / sizeof (wchar_t)); +- } ++ ++__fortify_potential_overload size_t ++__NTH (mbsrtowcs (wchar_t *__restrict const __clang_pass_object_size __dst, ++ const char **__restrict __src, size_t __len, ++ mbstate_t *__restrict __ps)) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_ONLY_IF_BOS_LT2 (__mbsrtowcs_warn, __len, __dst, ++ sizeof (wchar_t), ++ "mbsrtowcs called with dst buffer " ++ "smaller than len * sizeof (wchar_t)") ++{ ++ if (__FORTIFY_CALL_CHK && __bos (__dst) != (size_t) -1) ++ return __mbsrtowcs_chk (__dst, __src, __len, __ps, ++ __bos (__dst) / sizeof (wchar_t)); + return __mbsrtowcs_alias (__dst, __src, __len, __ps); + } ++__FORTIFY_FUNCTION_END + + + extern size_t __wcsrtombs_chk (char *__restrict __dst, +@@ -497,27 +458,21 @@ extern size_t __REDIRECT_NTH (__wcsrtomb + const wchar_t **__restrict __src, + size_t __len, mbstate_t *__restrict __ps), + wcsrtombs); +-extern size_t __REDIRECT_NTH (__wcsrtombs_chk_warn, +- (char *__restrict __dst, +- const wchar_t **__restrict __src, +- size_t __len, mbstate_t *__restrict __ps, +- size_t __dstlen), __wcsrtombs_chk) +- __warnattr ("wcsrtombs called with dst buffer smaller than len"); + +-__fortify_function size_t +-__NTH (wcsrtombs (char *__restrict __dst, const wchar_t **__restrict __src, +- size_t __len, mbstate_t *__restrict __ps)) +-{ +- if (__bos (__dst) != (size_t) -1) +- { +- if (!__builtin_constant_p (__len)) +- return __wcsrtombs_chk (__dst, __src, __len, __ps, __bos (__dst)); +- +- if (__len > __bos (__dst)) +- return __wcsrtombs_chk_warn (__dst, __src, __len, __ps, __bos (__dst)); +- } ++__fortify_potential_overload size_t ++__NTH (wcsrtombs (char *__restrict const __clang_pass_object_size __dst, ++ const wchar_t **__restrict __src, size_t __len, ++ mbstate_t *__restrict __ps)) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_ONLY_IF_BOS_LT (__wcsrtombs_warn, __len, __dst, ++ "wcsrtombs called with dst buffer " ++ "smaller than len") ++{ ++ if (__FORTIFY_CALL_CHK && __bos (__dst) != (size_t) -1) ++ return __wcsrtombs_chk (__dst, __src, __len, __ps, __bos (__dst)); + return __wcsrtombs_alias (__dst, __src, __len, __ps); + } ++__FORTIFY_FUNCTION_END + + + #ifdef __USE_GNU +@@ -530,30 +485,23 @@ extern size_t __REDIRECT_NTH (__mbsnrtow + const char **__restrict __src, size_t __nmc, + size_t __len, mbstate_t *__restrict __ps), + mbsnrtowcs); +-extern size_t __REDIRECT_NTH (__mbsnrtowcs_chk_warn, +- (wchar_t *__restrict __dst, +- const char **__restrict __src, size_t __nmc, +- size_t __len, mbstate_t *__restrict __ps, +- size_t __dstlen), __mbsnrtowcs_chk) +- __warnattr ("mbsnrtowcs called with dst buffer smaller than len " +- "* sizeof (wchar_t)"); +- +-__fortify_function size_t +-__NTH (mbsnrtowcs (wchar_t *__restrict __dst, const char **__restrict __src, +- size_t __nmc, size_t __len, mbstate_t *__restrict __ps)) +-{ +- if (__bos (__dst) != (size_t) -1) +- { +- if (!__builtin_constant_p (__len)) +- return __mbsnrtowcs_chk (__dst, __src, __nmc, __len, __ps, +- __bos (__dst) / sizeof (wchar_t)); +- +- if (__len > __bos (__dst) / sizeof (wchar_t)) +- return __mbsnrtowcs_chk_warn (__dst, __src, __nmc, __len, __ps, +- __bos (__dst) / sizeof (wchar_t)); +- } ++ ++__fortify_potential_overload size_t ++__NTH (mbsnrtowcs (wchar_t *__restrict const __clang_pass_object_size __dst, ++ const char **__restrict __src, size_t __nmc, size_t __len, ++ mbstate_t *__restrict __ps)) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_ONLY_IF_BOS_LT (__mbsnrtowcs_warn, ++ sizeof (wchar_t) * __len, __dst, ++ "mbsnrtowcs called with dst buffer " ++ "smaller than len * sizeof (wchar_t)") ++{ ++ if (__FORTIFY_CALL_CHK && __bos (__dst) != (size_t) -1) ++ return __mbsnrtowcs_chk (__dst, __src, __nmc, __len, __ps, ++ __bos (__dst) / sizeof (wchar_t)); + return __mbsnrtowcs_alias (__dst, __src, __nmc, __len, __ps); + } ++__FORTIFY_FUNCTION_END + + + extern size_t __wcsnrtombs_chk (char *__restrict __dst, +@@ -566,28 +514,19 @@ extern size_t __REDIRECT_NTH (__wcsnrtom + const wchar_t **__restrict __src, + size_t __nwc, size_t __len, + mbstate_t *__restrict __ps), wcsnrtombs); +-extern size_t __REDIRECT_NTH (__wcsnrtombs_chk_warn, +- (char *__restrict __dst, +- const wchar_t **__restrict __src, +- size_t __nwc, size_t __len, +- mbstate_t *__restrict __ps, +- size_t __dstlen), __wcsnrtombs_chk) +- __warnattr ("wcsnrtombs called with dst buffer smaller than len"); +- +-__fortify_function size_t +-__NTH (wcsnrtombs (char *__restrict __dst, const wchar_t **__restrict __src, +- size_t __nwc, size_t __len, mbstate_t *__restrict __ps)) +-{ +- if (__bos (__dst) != (size_t) -1) +- { +- if (!__builtin_constant_p (__len)) +- return __wcsnrtombs_chk (__dst, __src, __nwc, __len, __ps, +- __bos (__dst)); +- +- if (__len > __bos (__dst)) +- return __wcsnrtombs_chk_warn (__dst, __src, __nwc, __len, __ps, +- __bos (__dst)); +- } ++ ++__fortify_potential_overload size_t ++__NTH (wcsnrtombs (char *__restrict const __clang_pass_object_size __dst, ++ const wchar_t **__restrict __src, size_t __nwc, size_t __len, ++ mbstate_t *__restrict __ps)) ++__FORTIFY_PRECONDITIONS ++ __FORTIFY_WARNING_ONLY_IF_BOS_LT (__wcsnrtombs_warn, __len, __dst, ++ "wcsnrtombs called with dst buffer " ++ "smaller than len") ++{ ++ if (__FORTIFY_CALL_CHK && __bos (__dst) != (size_t) -1) ++ return __wcsnrtombs_chk (__dst, __src, __nwc, __len, __ps, __bos (__dst)); + return __wcsnrtombs_alias (__dst, __src, __nwc, __len, __ps); + } ++__FORTIFY_FUNCTION_END + #endif diff --git a/meta/recipes-core/glibc/glibc/CVE-2019-19126.patch b/meta/recipes-core/glibc/glibc/CVE-2019-19126.patch deleted file mode 100644 index aead04c485c..00000000000 --- a/meta/recipes-core/glibc/glibc/CVE-2019-19126.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 37c90e117310728a4ad1eb998c0bbe7d79c4a398 Mon Sep 17 00:00:00 2001 -From: =?utf8?q?Marcin=20Ko=C5=9Bcielnicki?= <mwk@0x04.net> -Date: Thu, 21 Nov 2019 00:20:15 +0100 -Subject: [PATCH] rtld: Check __libc_enable_secure before honoring - LD_PREFER_MAP_32BIT_EXEC (CVE-2019-19126) [BZ #25204] - -The problem was introduced in glibc 2.23, in commit -b9eb92ab05204df772eb4929eccd018637c9f3e9 -("Add Prefer_MAP_32BIT_EXEC to map executable pages with MAP_32BIT"). - -(cherry picked from commit d5dfad4326fc683c813df1e37bbf5cf920591c8e) - -Upstream-Status: Backport [https://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commit;h=37c90e117310728a4ad1eb998c0bbe7d79c4a398] -CVE: CVE-2019-19126 -Signed-off-by: Anuj Mittal <anuj.mittal@intel.com> ---- -diff --git a/sysdeps/unix/sysv/linux/x86_64/64/dl-librecon.h b/sysdeps/unix/sysv/linux/x86_64/64/dl-librecon.h -index 975cbe2..df2cdfd 100644 ---- a/sysdeps/unix/sysv/linux/x86_64/64/dl-librecon.h -+++ b/sysdeps/unix/sysv/linux/x86_64/64/dl-librecon.h -@@ -31,7 +31,8 @@ - environment variable, LD_PREFER_MAP_32BIT_EXEC. */ - #define EXTRA_LD_ENVVARS \ - case 21: \ -- if (memcmp (envline, "PREFER_MAP_32BIT_EXEC", 21) == 0) \ -+ if (!__libc_enable_secure \ -+ && memcmp (envline, "PREFER_MAP_32BIT_EXEC", 21) == 0) \ - GLRO(dl_x86_cpu_features).feature[index_arch_Prefer_MAP_32BIT_EXEC] \ - |= bit_arch_Prefer_MAP_32BIT_EXEC; \ - break; --- -2.9.3 diff --git a/meta/recipes-core/glibc/glibc_2.30.bb b/meta/recipes-core/glibc/glibc_2.31.bb index 7913bc28125..b8c570db523 100644 --- a/meta/recipes-core/glibc/glibc_2.30.bb +++ b/meta/recipes-core/glibc/glibc_2.31.bb @@ -5,11 +5,11 @@ DEPENDS += "gperf-native bison-native make-native" NATIVESDKFIXES ?= "" NATIVESDKFIXES_class-nativesdk = "\ - file://0001-nativesdk-glibc-Look-for-host-system-ld.so.cache-as-.patch \ - file://0002-nativesdk-glibc-Fix-buffer-overrun-with-a-relocated-.patch \ - file://0003-nativesdk-glibc-Raise-the-size-of-arrays-containing-.patch \ - file://0004-nativesdk-glibc-Allow-64-bit-atomics-for-x86.patch \ - file://0005-nativesdk-glibc-Make-relocatable-install-for-locales.patch \ + file://0003-nativesdk-glibc-Look-for-host-system-ld.so.cache-as-.patch \ + file://0004-nativesdk-glibc-Fix-buffer-overrun-with-a-relocated-.patch \ + file://0005-nativesdk-glibc-Raise-the-size-of-arrays-containing-.patch \ + file://0006-nativesdk-glibc-Allow-64-bit-atomics-for-x86.patch \ + file://0007-nativesdk-glibc-Make-relocatable-install-for-locales.patch \ " SRC_URI = "${GLIBC_GIT_URI};branch=${SRCBRANCH};name=glibc \ @@ -18,30 +18,30 @@ SRC_URI = "${GLIBC_GIT_URI};branch=${SRCBRANCH};name=glibc \ file://makedbs.sh \ \ ${NATIVESDKFIXES} \ - file://0006-fsl-e500-e5500-e6500-603e-fsqrt-implementation.patch \ - file://0007-readlib-Add-OECORE_KNOWN_INTERPRETER_NAMES-to-known-.patch \ - file://0008-ppc-sqrt-Fix-undefined-reference-to-__sqrt_finite.patch \ - file://0009-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch \ - file://0010-Quote-from-bug-1443-which-explains-what-the-patch-do.patch \ - file://0011-eglibc-run-libm-err-tab.pl-with-specific-dirs-in-S.patch \ - file://0012-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch \ - file://0013-sysdeps-gnu-configure.ac-handle-correctly-libc_cv_ro.patch \ - file://0014-Add-unused-attribute.patch \ - file://0015-yes-within-the-path-sets-wrong-config-variables.patch \ - file://0016-timezone-re-written-tzselect-as-posix-sh.patch \ - file://0017-Remove-bash-dependency-for-nscd-init-script.patch \ - file://0018-eglibc-Cross-building-and-testing-instructions.patch \ - file://0019-eglibc-Help-bootstrap-cross-toolchain.patch \ - file://0020-eglibc-Clear-cache-lines-on-ppc8xx.patch \ - file://0021-eglibc-Resolve-__fpscr_values-on-SH4.patch \ - file://0022-eglibc-Forward-port-cross-locale-generation-support.patch \ - file://0023-Define-DUMMY_LOCALE_T-if-not-defined.patch \ - file://0024-localedef-add-to-archive-uses-a-hard-coded-locale-pa.patch \ - file://0025-elf-dl-deps.c-Make-_dl_build_local_scope-breadth-fir.patch \ - file://0026-intl-Emit-no-lines-in-bison-generated-files.patch \ - file://0027-inject-file-assembly-directives.patch \ - file://0028-locale-prevent-maybe-uninitialized-errors-with-Os-BZ.patch \ - file://CVE-2019-19126.patch \ + file://0008-fsl-e500-e5500-e6500-603e-fsqrt-implementation.patch \ + file://0009-readlib-Add-OECORE_KNOWN_INTERPRETER_NAMES-to-known-.patch \ + file://0010-ppc-sqrt-Fix-undefined-reference-to-__sqrt_finite.patch \ + file://0011-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch \ + file://0012-Quote-from-bug-1443-which-explains-what-the-patch-do.patch \ + file://0013-eglibc-run-libm-err-tab.pl-with-specific-dirs-in-S.patch \ + file://0014-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch \ + file://0015-sysdeps-gnu-configure.ac-handle-correctly-libc_cv_ro.patch \ + file://0016-Add-unused-attribute.patch \ + file://0017-yes-within-the-path-sets-wrong-config-variables.patch \ + file://0018-timezone-re-written-tzselect-as-posix-sh.patch \ + file://0019-Remove-bash-dependency-for-nscd-init-script.patch \ + file://0020-eglibc-Cross-building-and-testing-instructions.patch \ + file://0021-eglibc-Help-bootstrap-cross-toolchain.patch \ + file://0022-eglibc-Clear-cache-lines-on-ppc8xx.patch \ + file://0023-eglibc-Resolve-__fpscr_values-on-SH4.patch \ + file://0024-eglibc-Forward-port-cross-locale-generation-support.patch \ + file://0025-Define-DUMMY_LOCALE_T-if-not-defined.patch \ + file://0026-localedef-add-to-archive-uses-a-hard-coded-locale-pa.patch \ + file://0027-elf-dl-deps.c-Make-_dl_build_local_scope-breadth-fir.patch \ + file://0028-intl-Emit-no-lines-in-bison-generated-files.patch \ + file://0029-inject-file-assembly-directives.patch \ + file://0030-locale-prevent-maybe-uninitialized-errors-with-Os-BZ.patch \ + file://0031-Refactor-FORTIFY-in-glibc.patch \ " S = "${WORKDIR}/git" B = "${WORKDIR}/build-${TARGET_SYS}" |