From b22626d996e153d6094e1f76ed33ee1bb3eea751 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Fri, 20 Dec 2019 15:40:20 -0800 Subject: 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 Signed-off-by: Richard Purdie --- .../glibc/cross-localedef-native_2.30.bb | 50 - .../glibc/cross-localedef-native_2.31.bb | 53 + meta/recipes-core/glibc/glibc-common.inc | 4 +- meta/recipes-core/glibc/glibc-locale_2.30.bb | 1 - meta/recipes-core/glibc/glibc-locale_2.31.bb | 1 + meta/recipes-core/glibc/glibc-mtrace_2.30.bb | 1 - meta/recipes-core/glibc/glibc-mtrace_2.31.bb | 1 + meta/recipes-core/glibc/glibc-scripts_2.30.bb | 1 - meta/recipes-core/glibc/glibc-scripts_2.31.bb | 1 + meta/recipes-core/glibc/glibc-testsuite_2.30.bb | 60 - meta/recipes-core/glibc/glibc-testsuite_2.31.bb | 60 + meta/recipes-core/glibc/glibc-version.inc | 6 +- ...def-Add-hardlink-resolver-from-util-linux.patch | 1130 ++++++++ ...-localedef-Add-hardlink-resolver-to-build.patch | 52 + ...libc-Look-for-host-system-ld.so.cache-as-.patch | 69 - ...ledef-fix-ups-hardlink-to-make-it-compile.patch | 238 ++ ...libc-Fix-buffer-overrun-with-a-relocated-.patch | 50 - ...libc-Look-for-host-system-ld.so.cache-as-.patch | 65 + ...libc-Raise-the-size-of-arrays-containing-.patch | 141 - ...ivesdk-glibc-Allow-64-bit-atomics-for-x86.patch | 42 - ...libc-Fix-buffer-overrun-with-a-relocated-.patch | 46 + ...libc-Make-relocatable-install-for-locales.patch | 70 - ...libc-Raise-the-size-of-arrays-containing-.patch | 137 + ...500-e5500-e6500-603e-fsqrt-implementation.patch | 1584 ----------- ...ivesdk-glibc-Allow-64-bit-atomics-for-x86.patch | 39 + ...libc-Make-relocatable-install-for-locales.patch | 67 + ...-OECORE_KNOWN_INTERPRETER_NAMES-to-known-.patch | 33 - ...500-e5500-e6500-603e-fsqrt-implementation.patch | 1581 +++++++++++ ...-Fix-undefined-reference-to-__sqrt_finite.patch | 208 -- ...qrt-f-are-now-inline-functions-and-call-o.patch | 387 --- ...-OECORE_KNOWN_INTERPRETER_NAMES-to-known-.patch | 29 + ...bug-1443-which-explains-what-the-patch-do.patch | 62 - ...-Fix-undefined-reference-to-__sqrt_finite.patch | 205 ++ ...qrt-f-are-now-inline-functions-and-call-o.patch | 384 +++ ...n-libm-err-tab.pl-with-specific-dirs-in-S.patch | 36 - ...bug-1443-which-explains-what-the-patch-do.patch | 58 + ...qrt-f-are-now-inline-functions-and-call-o.patch | 61 - ...n-libm-err-tab.pl-with-specific-dirs-in-S.patch | 33 + ...-configure.ac-handle-correctly-libc_cv_ro.patch | 42 - .../glibc/glibc/0014-Add-unused-attribute.patch | 34 - ...qrt-f-are-now-inline-functions-and-call-o.patch | 58 + ...-configure.ac-handle-correctly-libc_cv_ro.patch | 39 + ...thin-the-path-sets-wrong-config-variables.patch | 263 -- .../glibc/glibc/0016-Add-unused-attribute.patch | 31 + ...-timezone-re-written-tzselect-as-posix-sh.patch | 45 - ...move-bash-dependency-for-nscd-init-script.patch | 75 - ...thin-the-path-sets-wrong-config-variables.patch | 260 ++ ...c-Cross-building-and-testing-instructions.patch | 619 ----- ...-timezone-re-written-tzselect-as-posix-sh.patch | 42 + ...move-bash-dependency-for-nscd-init-script.patch | 72 + ...019-eglibc-Help-bootstrap-cross-toolchain.patch | 100 - .../0020-eglibc-Clear-cache-lines-on-ppc8xx.patch | 83 - ...c-Cross-building-and-testing-instructions.patch | 616 +++++ ...021-eglibc-Help-bootstrap-cross-toolchain.patch | 97 + ...0021-eglibc-Resolve-__fpscr_values-on-SH4.patch | 56 - .../0022-eglibc-Clear-cache-lines-on-ppc8xx.patch | 80 + ...ward-port-cross-locale-generation-support.patch | 566 ---- ...0023-Define-DUMMY_LOCALE_T-if-not-defined.patch | 32 - ...0023-eglibc-Resolve-__fpscr_values-on-SH4.patch | 53 + ...ward-port-cross-locale-generation-support.patch | 560 ++++ ...dd-to-archive-uses-a-hard-coded-locale-pa.patch | 84 - ...0025-Define-DUMMY_LOCALE_T-if-not-defined.patch | 29 + ....c-Make-_dl_build_local_scope-breadth-fir.patch | 56 - ...tl-Emit-no-lines-in-bison-generated-files.patch | 34 - ...dd-to-archive-uses-a-hard-coded-locale-pa.patch | 80 + ....c-Make-_dl_build_local_scope-breadth-fir.patch | 53 + .../0027-inject-file-assembly-directives.patch | 304 --- ...tl-Emit-no-lines-in-bison-generated-files.patch | 31 + ...ent-maybe-uninitialized-errors-with-Os-BZ.patch | 56 - ...029-Add-hardlink-resolver-from-util-linux.patch | 1130 -------- .../0029-inject-file-assembly-directives.patch | 301 +++ .../0030-hardlink-fix-ups-to-make-it-compile.patch | 238 -- ...ent-maybe-uninitialized-errors-with-Os-BZ.patch | 53 + .../0031-Add-hardlink-resolver-to-build.patch | 55 - .../glibc/0031-Refactor-FORTIFY-in-glibc.patch | 2780 ++++++++++++++++++++ meta/recipes-core/glibc/glibc/CVE-2019-19126.patch | 32 - meta/recipes-core/glibc/glibc_2.30.bb | 113 - meta/recipes-core/glibc/glibc_2.31.bb | 113 + 78 files changed, 9533 insertions(+), 6878 deletions(-) delete mode 100644 meta/recipes-core/glibc/cross-localedef-native_2.30.bb create mode 100644 meta/recipes-core/glibc/cross-localedef-native_2.31.bb delete mode 100644 meta/recipes-core/glibc/glibc-locale_2.30.bb create mode 100644 meta/recipes-core/glibc/glibc-locale_2.31.bb delete mode 100644 meta/recipes-core/glibc/glibc-mtrace_2.30.bb create mode 100644 meta/recipes-core/glibc/glibc-mtrace_2.31.bb delete mode 100644 meta/recipes-core/glibc/glibc-scripts_2.30.bb create mode 100644 meta/recipes-core/glibc/glibc-scripts_2.31.bb delete mode 100644 meta/recipes-core/glibc/glibc-testsuite_2.30.bb create mode 100644 meta/recipes-core/glibc/glibc-testsuite_2.31.bb create mode 100644 meta/recipes-core/glibc/glibc/0001-localedef-Add-hardlink-resolver-from-util-linux.patch create mode 100644 meta/recipes-core/glibc/glibc/0001-localedef-Add-hardlink-resolver-to-build.patch delete mode 100644 meta/recipes-core/glibc/glibc/0001-nativesdk-glibc-Look-for-host-system-ld.so.cache-as-.patch create mode 100644 meta/recipes-core/glibc/glibc/0002-localedef-fix-ups-hardlink-to-make-it-compile.patch delete mode 100644 meta/recipes-core/glibc/glibc/0002-nativesdk-glibc-Fix-buffer-overrun-with-a-relocated-.patch create mode 100644 meta/recipes-core/glibc/glibc/0003-nativesdk-glibc-Look-for-host-system-ld.so.cache-as-.patch delete mode 100644 meta/recipes-core/glibc/glibc/0003-nativesdk-glibc-Raise-the-size-of-arrays-containing-.patch delete mode 100644 meta/recipes-core/glibc/glibc/0004-nativesdk-glibc-Allow-64-bit-atomics-for-x86.patch create mode 100644 meta/recipes-core/glibc/glibc/0004-nativesdk-glibc-Fix-buffer-overrun-with-a-relocated-.patch delete mode 100644 meta/recipes-core/glibc/glibc/0005-nativesdk-glibc-Make-relocatable-install-for-locales.patch create mode 100644 meta/recipes-core/glibc/glibc/0005-nativesdk-glibc-Raise-the-size-of-arrays-containing-.patch delete mode 100644 meta/recipes-core/glibc/glibc/0006-fsl-e500-e5500-e6500-603e-fsqrt-implementation.patch create mode 100644 meta/recipes-core/glibc/glibc/0006-nativesdk-glibc-Allow-64-bit-atomics-for-x86.patch create mode 100644 meta/recipes-core/glibc/glibc/0007-nativesdk-glibc-Make-relocatable-install-for-locales.patch delete mode 100644 meta/recipes-core/glibc/glibc/0007-readlib-Add-OECORE_KNOWN_INTERPRETER_NAMES-to-known-.patch create mode 100644 meta/recipes-core/glibc/glibc/0008-fsl-e500-e5500-e6500-603e-fsqrt-implementation.patch delete mode 100644 meta/recipes-core/glibc/glibc/0008-ppc-sqrt-Fix-undefined-reference-to-__sqrt_finite.patch delete mode 100644 meta/recipes-core/glibc/glibc/0009-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch create mode 100644 meta/recipes-core/glibc/glibc/0009-readlib-Add-OECORE_KNOWN_INTERPRETER_NAMES-to-known-.patch delete mode 100644 meta/recipes-core/glibc/glibc/0010-Quote-from-bug-1443-which-explains-what-the-patch-do.patch create mode 100644 meta/recipes-core/glibc/glibc/0010-ppc-sqrt-Fix-undefined-reference-to-__sqrt_finite.patch create mode 100644 meta/recipes-core/glibc/glibc/0011-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch delete mode 100644 meta/recipes-core/glibc/glibc/0011-eglibc-run-libm-err-tab.pl-with-specific-dirs-in-S.patch create mode 100644 meta/recipes-core/glibc/glibc/0012-Quote-from-bug-1443-which-explains-what-the-patch-do.patch delete mode 100644 meta/recipes-core/glibc/glibc/0012-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch create mode 100644 meta/recipes-core/glibc/glibc/0013-eglibc-run-libm-err-tab.pl-with-specific-dirs-in-S.patch delete mode 100644 meta/recipes-core/glibc/glibc/0013-sysdeps-gnu-configure.ac-handle-correctly-libc_cv_ro.patch delete mode 100644 meta/recipes-core/glibc/glibc/0014-Add-unused-attribute.patch create mode 100644 meta/recipes-core/glibc/glibc/0014-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch create mode 100644 meta/recipes-core/glibc/glibc/0015-sysdeps-gnu-configure.ac-handle-correctly-libc_cv_ro.patch delete mode 100644 meta/recipes-core/glibc/glibc/0015-yes-within-the-path-sets-wrong-config-variables.patch create mode 100644 meta/recipes-core/glibc/glibc/0016-Add-unused-attribute.patch delete mode 100644 meta/recipes-core/glibc/glibc/0016-timezone-re-written-tzselect-as-posix-sh.patch delete mode 100644 meta/recipes-core/glibc/glibc/0017-Remove-bash-dependency-for-nscd-init-script.patch create mode 100644 meta/recipes-core/glibc/glibc/0017-yes-within-the-path-sets-wrong-config-variables.patch delete mode 100644 meta/recipes-core/glibc/glibc/0018-eglibc-Cross-building-and-testing-instructions.patch create mode 100644 meta/recipes-core/glibc/glibc/0018-timezone-re-written-tzselect-as-posix-sh.patch create mode 100644 meta/recipes-core/glibc/glibc/0019-Remove-bash-dependency-for-nscd-init-script.patch delete mode 100644 meta/recipes-core/glibc/glibc/0019-eglibc-Help-bootstrap-cross-toolchain.patch delete mode 100644 meta/recipes-core/glibc/glibc/0020-eglibc-Clear-cache-lines-on-ppc8xx.patch create mode 100644 meta/recipes-core/glibc/glibc/0020-eglibc-Cross-building-and-testing-instructions.patch create mode 100644 meta/recipes-core/glibc/glibc/0021-eglibc-Help-bootstrap-cross-toolchain.patch delete mode 100644 meta/recipes-core/glibc/glibc/0021-eglibc-Resolve-__fpscr_values-on-SH4.patch create mode 100644 meta/recipes-core/glibc/glibc/0022-eglibc-Clear-cache-lines-on-ppc8xx.patch delete mode 100644 meta/recipes-core/glibc/glibc/0022-eglibc-Forward-port-cross-locale-generation-support.patch delete mode 100644 meta/recipes-core/glibc/glibc/0023-Define-DUMMY_LOCALE_T-if-not-defined.patch create mode 100644 meta/recipes-core/glibc/glibc/0023-eglibc-Resolve-__fpscr_values-on-SH4.patch create mode 100644 meta/recipes-core/glibc/glibc/0024-eglibc-Forward-port-cross-locale-generation-support.patch delete mode 100644 meta/recipes-core/glibc/glibc/0024-localedef-add-to-archive-uses-a-hard-coded-locale-pa.patch create mode 100644 meta/recipes-core/glibc/glibc/0025-Define-DUMMY_LOCALE_T-if-not-defined.patch delete mode 100644 meta/recipes-core/glibc/glibc/0025-elf-dl-deps.c-Make-_dl_build_local_scope-breadth-fir.patch delete mode 100644 meta/recipes-core/glibc/glibc/0026-intl-Emit-no-lines-in-bison-generated-files.patch create mode 100644 meta/recipes-core/glibc/glibc/0026-localedef-add-to-archive-uses-a-hard-coded-locale-pa.patch create mode 100644 meta/recipes-core/glibc/glibc/0027-elf-dl-deps.c-Make-_dl_build_local_scope-breadth-fir.patch delete mode 100644 meta/recipes-core/glibc/glibc/0027-inject-file-assembly-directives.patch create mode 100644 meta/recipes-core/glibc/glibc/0028-intl-Emit-no-lines-in-bison-generated-files.patch delete mode 100644 meta/recipes-core/glibc/glibc/0028-locale-prevent-maybe-uninitialized-errors-with-Os-BZ.patch delete mode 100644 meta/recipes-core/glibc/glibc/0029-Add-hardlink-resolver-from-util-linux.patch create mode 100644 meta/recipes-core/glibc/glibc/0029-inject-file-assembly-directives.patch delete mode 100644 meta/recipes-core/glibc/glibc/0030-hardlink-fix-ups-to-make-it-compile.patch create mode 100644 meta/recipes-core/glibc/glibc/0030-locale-prevent-maybe-uninitialized-errors-with-Os-BZ.patch delete mode 100644 meta/recipes-core/glibc/glibc/0031-Add-hardlink-resolver-to-build.patch create mode 100644 meta/recipes-core/glibc/glibc/0031-Refactor-FORTIFY-in-glibc.patch delete mode 100644 meta/recipes-core/glibc/glibc/CVE-2019-19126.patch delete mode 100644 meta/recipes-core/glibc/glibc_2.30.bb create mode 100644 meta/recipes-core/glibc/glibc_2.31.bb (limited to 'meta/recipes-core') diff --git a/meta/recipes-core/glibc/cross-localedef-native_2.30.bb b/meta/recipes-core/glibc/cross-localedef-native_2.30.bb deleted file mode 100644 index 99c3d30397..0000000000 --- a/meta/recipes-core/glibc/cross-localedef-native_2.30.bb +++ /dev/null @@ -1,50 +0,0 @@ -SUMMARY = "Cross locale generation tool for glibc" -HOMEPAGE = "http://www.gnu.org/software/libc/libc.html" -SECTION = "libs" -LICENSE = "LGPL-2.1" - -LIC_FILES_CHKSUM = "file://LICENSES;md5=cfc0ed77a9f62fa62eded042ebe31d72 \ - file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \ - file://posix/rxspencer/COPYRIGHT;md5=dc5485bb394a13b2332ec1c785f5d83a \ - file://COPYING.LIB;md5=4fbd65380cdd255951079008b364516c" - -require glibc-version.inc - -# Tell autotools that we're working in the localedef directory -# -AUTOTOOLS_SCRIPT_PATH = "${S}/localedef" - -inherit native -inherit autotools - -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 \ -" -# Makes for a rather long rev (22 characters), but... -# -SRCREV_FORMAT = "glibc_localedef" - -S = "${WORKDIR}/git" - -EXTRA_OECONF = "--with-glibc=${S}" -CFLAGS += "-fgnu89-inline -std=gnu99 -DIS_IN\(x\)='0'" - -do_install() { - install -d ${D}${bindir} - install -m 0755 ${B}/localedef ${D}${bindir}/cross-localedef - install -m 0755 ${B}/cross-localedef-hardlink ${D}${bindir}/cross-localedef-hardlink -} diff --git a/meta/recipes-core/glibc/cross-localedef-native_2.31.bb b/meta/recipes-core/glibc/cross-localedef-native_2.31.bb new file mode 100644 index 0000000000..a267a591d4 --- /dev/null +++ b/meta/recipes-core/glibc/cross-localedef-native_2.31.bb @@ -0,0 +1,53 @@ +SUMMARY = "Cross locale generation tool for glibc" +HOMEPAGE = "http://www.gnu.org/software/libc/libc.html" +SECTION = "libs" +LICENSE = "LGPL-2.1" + +LIC_FILES_CHKSUM = "file://LICENSES;md5=1541fd8f5e8f1579512bf05f533371ba \ + file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \ + file://posix/rxspencer/COPYRIGHT;md5=dc5485bb394a13b2332ec1c785f5d83a \ + file://COPYING.LIB;md5=4fbd65380cdd255951079008b364516c" + +require glibc-version.inc + +# Tell autotools that we're working in the localedef directory +# +AUTOTOOLS_SCRIPT_PATH = "${S}/localedef" + +inherit native +inherit autotools + +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://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... +# +SRCREV_FORMAT = "glibc_localedef" + +S = "${WORKDIR}/git" + +EXTRA_OECONF = "--with-glibc=${S}" +CFLAGS += "-fgnu89-inline -std=gnu99 -DIS_IN\(x\)='0'" + +do_install() { + install -d ${D}${bindir} + install -m 0755 ${B}/localedef ${D}${bindir}/cross-localedef + install -m 0755 ${B}/cross-localedef-hardlink ${D}${bindir}/cross-localedef-hardlink +} diff --git a/meta/recipes-core/glibc/glibc-common.inc b/meta/recipes-core/glibc/glibc-common.inc index fa46fd89f1..27534d999f 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.30.bb deleted file mode 100644 index f7702e0358..0000000000 --- a/meta/recipes-core/glibc/glibc-locale_2.30.bb +++ /dev/null @@ -1 +0,0 @@ -require glibc-locale.inc diff --git a/meta/recipes-core/glibc/glibc-locale_2.31.bb b/meta/recipes-core/glibc/glibc-locale_2.31.bb new file mode 100644 index 0000000000..f7702e0358 --- /dev/null +++ b/meta/recipes-core/glibc/glibc-locale_2.31.bb @@ -0,0 +1 @@ +require glibc-locale.inc diff --git a/meta/recipes-core/glibc/glibc-mtrace_2.30.bb b/meta/recipes-core/glibc/glibc-mtrace_2.30.bb deleted file mode 100644 index 0b69bad46a..0000000000 --- a/meta/recipes-core/glibc/glibc-mtrace_2.30.bb +++ /dev/null @@ -1 +0,0 @@ -require glibc-mtrace.inc diff --git a/meta/recipes-core/glibc/glibc-mtrace_2.31.bb b/meta/recipes-core/glibc/glibc-mtrace_2.31.bb new file mode 100644 index 0000000000..0b69bad46a --- /dev/null +++ b/meta/recipes-core/glibc/glibc-mtrace_2.31.bb @@ -0,0 +1 @@ +require glibc-mtrace.inc diff --git a/meta/recipes-core/glibc/glibc-scripts_2.30.bb b/meta/recipes-core/glibc/glibc-scripts_2.30.bb deleted file mode 100644 index 5a89bd8022..0000000000 --- a/meta/recipes-core/glibc/glibc-scripts_2.30.bb +++ /dev/null @@ -1 +0,0 @@ -require glibc-scripts.inc diff --git a/meta/recipes-core/glibc/glibc-scripts_2.31.bb b/meta/recipes-core/glibc/glibc-scripts_2.31.bb new file mode 100644 index 0000000000..5a89bd8022 --- /dev/null +++ b/meta/recipes-core/glibc/glibc-scripts_2.31.bb @@ -0,0 +1 @@ +require glibc-scripts.inc diff --git a/meta/recipes-core/glibc/glibc-testsuite_2.30.bb b/meta/recipes-core/glibc/glibc-testsuite_2.30.bb deleted file mode 100644 index 657fd4dbc1..0000000000 --- a/meta/recipes-core/glibc/glibc-testsuite_2.30.bb +++ /dev/null @@ -1,60 +0,0 @@ -require glibc_${PV}.bb - -# handle PN differences -FILESEXTRAPATHS_prepend := "${THISDIR}/glibc:" - -# strip provides -PROVIDES = "" -# setup depends -INHIBIT_DEFAULT_DEPS = "" - -python () { - libc = d.getVar("PREFERRED_PROVIDER_virtual/libc") - libclocale = d.getVar("PREFERRED_PROVIDER_virtual/libc-locale") - if libc != "glibc" or libclocale != "glibc-locale": - raise bb.parse.SkipRecipe("glibc-testsuite requires that virtual/libc is glibc") -} - -DEPENDS += "glibc-locale libgcc gcc-runtime" - -# remove the initial depends -DEPENDS_remove = "libgcc-initial" - -inherit qemu - -SRC_URI += "file://check-test-wrapper" - -DEPENDS += "${@'qemu-native' if d.getVar('TOOLCHAIN_TEST_TARGET') == 'user' else ''}" - -TOOLCHAIN_TEST_TARGET ??= "user" -TOOLCHAIN_TEST_HOST ??= "localhost" -TOOLCHAIN_TEST_HOST_USER ??= "root" -TOOLCHAIN_TEST_HOST_PORT ??= "2222" - -do_check[dirs] += "${B}" -do_check[nostamp] = "1" -do_check () { - chmod 0755 ${WORKDIR}/check-test-wrapper - - # clean out previous test results - oe_runmake tests-clean - # makefiles don't clean entirely (and also sometimes fails due to too many args) - find ${B} -type f -name "*.out" -delete - find ${B} -type f -name "*.test-result" -delete - find ${B}/catgets -name "*.cat" -delete - find ${B}/conform -name "symlist-*" -delete - [ ! -e ${B}/timezone/testdata ] || rm -rf ${B}/timezone/testdata - - oe_runmake -i \ - QEMU_SYSROOT="${RECIPE_SYSROOT}" \ - QEMU_OPTIONS="${@qemu_target_binary(d)} ${QEMU_OPTIONS}" \ - SSH_HOST="${TOOLCHAIN_TEST_HOST}" \ - SSH_HOST_USER="${TOOLCHAIN_TEST_HOST_USER}" \ - SSH_HOST_PORT="${TOOLCHAIN_TEST_HOST_PORT}" \ - test-wrapper="${WORKDIR}/check-test-wrapper ${TOOLCHAIN_TEST_TARGET}" \ - check -} -addtask do_check after do_compile - -inherit nopackages -deltask do_stash_locale diff --git a/meta/recipes-core/glibc/glibc-testsuite_2.31.bb b/meta/recipes-core/glibc/glibc-testsuite_2.31.bb new file mode 100644 index 0000000000..657fd4dbc1 --- /dev/null +++ b/meta/recipes-core/glibc/glibc-testsuite_2.31.bb @@ -0,0 +1,60 @@ +require glibc_${PV}.bb + +# handle PN differences +FILESEXTRAPATHS_prepend := "${THISDIR}/glibc:" + +# strip provides +PROVIDES = "" +# setup depends +INHIBIT_DEFAULT_DEPS = "" + +python () { + libc = d.getVar("PREFERRED_PROVIDER_virtual/libc") + libclocale = d.getVar("PREFERRED_PROVIDER_virtual/libc-locale") + if libc != "glibc" or libclocale != "glibc-locale": + raise bb.parse.SkipRecipe("glibc-testsuite requires that virtual/libc is glibc") +} + +DEPENDS += "glibc-locale libgcc gcc-runtime" + +# remove the initial depends +DEPENDS_remove = "libgcc-initial" + +inherit qemu + +SRC_URI += "file://check-test-wrapper" + +DEPENDS += "${@'qemu-native' if d.getVar('TOOLCHAIN_TEST_TARGET') == 'user' else ''}" + +TOOLCHAIN_TEST_TARGET ??= "user" +TOOLCHAIN_TEST_HOST ??= "localhost" +TOOLCHAIN_TEST_HOST_USER ??= "root" +TOOLCHAIN_TEST_HOST_PORT ??= "2222" + +do_check[dirs] += "${B}" +do_check[nostamp] = "1" +do_check () { + chmod 0755 ${WORKDIR}/check-test-wrapper + + # clean out previous test results + oe_runmake tests-clean + # makefiles don't clean entirely (and also sometimes fails due to too many args) + find ${B} -type f -name "*.out" -delete + find ${B} -type f -name "*.test-result" -delete + find ${B}/catgets -name "*.cat" -delete + find ${B}/conform -name "symlist-*" -delete + [ ! -e ${B}/timezone/testdata ] || rm -rf ${B}/timezone/testdata + + oe_runmake -i \ + QEMU_SYSROOT="${RECIPE_SYSROOT}" \ + QEMU_OPTIONS="${@qemu_target_binary(d)} ${QEMU_OPTIONS}" \ + SSH_HOST="${TOOLCHAIN_TEST_HOST}" \ + SSH_HOST_USER="${TOOLCHAIN_TEST_HOST_USER}" \ + SSH_HOST_PORT="${TOOLCHAIN_TEST_HOST_PORT}" \ + test-wrapper="${WORKDIR}/check-test-wrapper ${TOOLCHAIN_TEST_TARGET}" \ + check +} +addtask do_check after do_compile + +inherit nopackages +deltask do_stash_locale diff --git a/meta/recipes-core/glibc/glibc-version.inc b/meta/recipes-core/glibc/glibc-version.inc index c18c583399..dca1916e80 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/0001-localedef-Add-hardlink-resolver-from-util-linux.patch b/meta/recipes-core/glibc/glibc/0001-localedef-Add-hardlink-resolver-from-util-linux.patch new file mode 100644 index 0000000000..9b75f2a62f --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0001-localedef-Add-hardlink-resolver-from-util-linux.patch @@ -0,0 +1,1130 @@ +From 169720859cf8f9133882a13f588b15f44b7b8ae6 Mon Sep 17 00:00:00 2001 +From: Jason Wessel +Date: Sat, 7 Dec 2019 09:59:22 -0800 +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 +in parallel) and perform a creation of a .tmp file and remove the +original and move the .tmp file in. The problem is that if a probe +occurs a hard link can be requested to the file that is being removed. +This will lead to a stray copy or potentially, on a loaded system +cause race condition which pseudo cannot deal with, where it is left +with a hard link request to a file that no longer exists. In this +situation psuedo will inherit the permissions of what ever the target +inode had to offer. + +In short, there are two problems: + +1) You will be left with stray copies when using the hard link +resolution that is built in while running in parallel with +localedef. + +2) When running under pseudo the possibility exists for uid/gid +leakage when the source file is removed before the hard link can +be completed. + +The solution is to call localedef with --no-hard-links and separately +process the hardlinks at a later point. To do this requires the +inclusion of the hardlink utility found in modern versions of +util-linux. Most host systems do not have this, so it will be +included with the cross-localedef binary. + +[YOCTO #11299] +[YOCTO #12434] + +Upstream-Status: Pending + +Signed-off-by: Jason Wessel +Signed-off-by: Khem Raj +--- + locale/programs/c.h | 407 ++++++++++++++++ + locale/programs/cross-localedef-hardlink.c | 528 +++++++++++++++++++++ + locale/programs/xalloc.h | 129 +++++ + 3 files changed, 1064 insertions(+) + create mode 100644 locale/programs/c.h + create mode 100644 locale/programs/cross-localedef-hardlink.c + create mode 100644 locale/programs/xalloc.h + +diff --git a/locale/programs/c.h b/locale/programs/c.h +new file mode 100644 +index 0000000000..d0a402e90e +--- /dev/null ++++ b/locale/programs/c.h +@@ -0,0 +1,407 @@ ++/* ++ * Fundamental C definitions. ++ */ ++ ++#ifndef UTIL_LINUX_C_H ++#define UTIL_LINUX_C_H ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include ++ ++#ifdef HAVE_ERR_H ++# include ++#endif ++ ++#ifdef HAVE_SYS_SYSMACROS_H ++# include /* for major, minor */ ++#endif ++ ++#ifndef LOGIN_NAME_MAX ++# define LOGIN_NAME_MAX 256 ++#endif ++ ++#ifndef NAME_MAX ++# define NAME_MAX PATH_MAX ++#endif ++ ++/* ++ * __GNUC_PREREQ is deprecated in favour of __has_attribute() and ++ * __has_feature(). The __has macros are supported by clang and gcc>=5. ++ */ ++#ifndef __GNUC_PREREQ ++# if defined __GNUC__ && defined __GNUC_MINOR__ ++# define __GNUC_PREREQ(maj, min) \ ++ ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) ++# else ++# define __GNUC_PREREQ(maj, min) 0 ++# endif ++#endif ++ ++#ifdef __GNUC__ ++ ++/* &a[0] degrades to a pointer: a different type from an array */ ++# define __must_be_array(a) \ ++ UL_BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(__typeof__(a), __typeof__(&a[0]))) ++ ++# define ignore_result(x) __extension__ ({ \ ++ __typeof__(x) __dummy __attribute__((__unused__)) = (x); (void) __dummy; \ ++}) ++ ++#else /* !__GNUC__ */ ++# define __must_be_array(a) 0 ++# define __attribute__(_arg_) ++# define ignore_result(x) ((void) (x)) ++#endif /* !__GNUC__ */ ++ ++/* ++ * It evaluates to 1 if the attribute/feature is supported by the current ++ * compilation targed. Fallback for old compilers. ++ */ ++#ifndef __has_attribute ++ #define __has_attribute(x) 0 ++#endif ++ ++#ifndef __has_feature ++ #define __has_feature(x) 0 ++#endif ++ ++/* ++ * Function attributes ++ */ ++#ifndef __ul_alloc_size ++# if (__has_attribute(alloc_size) && __has_attribute(warn_unused_result)) || __GNUC_PREREQ (4, 3) ++# define __ul_alloc_size(s) __attribute__((alloc_size(s), warn_unused_result)) ++# else ++# define __ul_alloc_size(s) ++# endif ++#endif ++ ++#ifndef __ul_calloc_size ++# if (__has_attribute(alloc_size) && __has_attribute(warn_unused_result)) || __GNUC_PREREQ (4, 3) ++# define __ul_calloc_size(n, s) __attribute__((alloc_size(n, s), warn_unused_result)) ++# else ++# define __ul_calloc_size(n, s) ++# endif ++#endif ++ ++#if __has_attribute(returns_nonnull) || __GNUC_PREREQ (4, 9) ++# define __ul_returns_nonnull __attribute__((returns_nonnull)) ++#else ++# define __ul_returns_nonnull ++#endif ++ ++/* ++ * Force a compilation error if condition is true, but also produce a ++ * result (of value 0 and type size_t), so the expression can be used ++ * e.g. in a structure initializer (or wherever else comma expressions ++ * aren't permitted). ++ */ ++#define UL_BUILD_BUG_ON_ZERO(e) __extension__ (sizeof(struct { int:-!!(e); })) ++#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); })) ++ ++#ifndef ARRAY_SIZE ++# define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) ++#endif ++ ++#ifndef PATH_MAX ++# define PATH_MAX 4096 ++#endif ++ ++#ifndef TRUE ++# define TRUE 1 ++#endif ++ ++#ifndef FALSE ++# define FALSE 0 ++#endif ++ ++#ifndef min ++# define min(x, y) __extension__ ({ \ ++ __typeof__(x) _min1 = (x); \ ++ __typeof__(y) _min2 = (y); \ ++ (void) (&_min1 == &_min2); \ ++ _min1 < _min2 ? _min1 : _min2; }) ++#endif ++ ++#ifndef max ++# define max(x, y) __extension__ ({ \ ++ __typeof__(x) _max1 = (x); \ ++ __typeof__(y) _max2 = (y); \ ++ (void) (&_max1 == &_max2); \ ++ _max1 > _max2 ? _max1 : _max2; }) ++#endif ++ ++#ifndef cmp_numbers ++# define cmp_numbers(x, y) __extension__ ({ \ ++ __typeof__(x) _a = (x); \ ++ __typeof__(y) _b = (y); \ ++ (void) (&_a == &_b); \ ++ _a == _b ? 0 : _a > _b ? 1 : -1; }) ++#endif ++ ++#ifndef offsetof ++#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) ++#endif ++ ++/* ++ * container_of - cast a member of a structure out to the containing structure ++ * @ptr: the pointer to the member. ++ * @type: the type of the container struct this is embedded in. ++ * @member: the name of the member within the struct. ++ */ ++#ifndef container_of ++#define container_of(ptr, type, member) __extension__ ({ \ ++ const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \ ++ (type *)( (char *)__mptr - offsetof(type,member) );}) ++#endif ++ ++#ifndef HAVE_PROGRAM_INVOCATION_SHORT_NAME ++# ifdef HAVE___PROGNAME ++extern char *__progname; ++# define program_invocation_short_name __progname ++# else ++# ifdef HAVE_GETEXECNAME ++# define program_invocation_short_name \ ++ prog_inv_sh_nm_from_file(getexecname(), 0) ++# else ++# define program_invocation_short_name \ ++ prog_inv_sh_nm_from_file(__FILE__, 1) ++# endif ++static char prog_inv_sh_nm_buf[256]; ++static inline char * ++prog_inv_sh_nm_from_file(char *f, char stripext) ++{ ++ char *t; ++ ++ if ((t = strrchr(f, '/')) != NULL) ++ t++; ++ else ++ t = f; ++ ++ strncpy(prog_inv_sh_nm_buf, t, sizeof(prog_inv_sh_nm_buf) - 1); ++ prog_inv_sh_nm_buf[sizeof(prog_inv_sh_nm_buf) - 1] = '\0'; ++ ++ if (stripext && (t = strrchr(prog_inv_sh_nm_buf, '.')) != NULL) ++ *t = '\0'; ++ ++ return prog_inv_sh_nm_buf; ++} ++# endif ++#endif ++ ++ ++#ifndef HAVE_ERR_H ++static inline void ++errmsg(char doexit, int excode, char adderr, const char *fmt, ...) ++{ ++ fprintf(stderr, "%s: ", program_invocation_short_name); ++ if (fmt != NULL) { ++ va_list argp; ++ va_start(argp, fmt); ++ vfprintf(stderr, fmt, argp); ++ va_end(argp); ++ if (adderr) ++ fprintf(stderr, ": "); ++ } ++ if (adderr) ++ fprintf(stderr, "%m"); ++ fprintf(stderr, "\n"); ++ if (doexit) ++ exit(excode); ++} ++ ++#ifndef HAVE_ERR ++# define err(E, FMT...) errmsg(1, E, 1, FMT) ++#endif ++ ++#ifndef HAVE_ERRX ++# define errx(E, FMT...) errmsg(1, E, 0, FMT) ++#endif ++ ++#ifndef HAVE_WARN ++# define warn(FMT...) errmsg(0, 0, 1, FMT) ++#endif ++ ++#ifndef HAVE_WARNX ++# define warnx(FMT...) errmsg(0, 0, 0, FMT) ++#endif ++#endif /* !HAVE_ERR_H */ ++ ++ ++/* Don't use inline function to avoid '#include "nls.h"' in c.h ++ */ ++#define errtryhelp(eval) __extension__ ({ \ ++ fprintf(stderr, _("Try '%s --help' for more information.\n"), \ ++ program_invocation_short_name); \ ++ exit(eval); \ ++}) ++ ++/* After failed execvp() */ ++#define EX_EXEC_FAILED 126 /* Program located, but not usable. */ ++#define EX_EXEC_ENOENT 127 /* Could not find program to exec. */ ++#define errexec(name) err(errno == ENOENT ? EX_EXEC_ENOENT : EX_EXEC_FAILED, \ ++ _("failed to execute %s"), name) ++ ++ ++static inline __attribute__((const)) int is_power_of_2(unsigned long num) ++{ ++ return (num != 0 && ((num & (num - 1)) == 0)); ++} ++ ++#ifndef HAVE_LOFF_T ++typedef int64_t loff_t; ++#endif ++ ++#if !defined(HAVE_DIRFD) && (!defined(HAVE_DECL_DIRFD) || HAVE_DECL_DIRFD == 0) && defined(HAVE_DIR_DD_FD) ++#include ++#include ++static inline int dirfd(DIR *d) ++{ ++ return d->dd_fd; ++} ++#endif ++ ++/* ++ * Fallback defines for old versions of glibc ++ */ ++#include ++ ++#ifdef O_CLOEXEC ++#define UL_CLOEXECSTR "e" ++#else ++#define UL_CLOEXECSTR "" ++#endif ++ ++#ifndef O_CLOEXEC ++#define O_CLOEXEC 0 ++#endif ++ ++#ifdef __FreeBSD_kernel__ ++#ifndef F_DUPFD_CLOEXEC ++#define F_DUPFD_CLOEXEC 17 /* Like F_DUPFD, but FD_CLOEXEC is set */ ++#endif ++#endif ++ ++ ++#ifndef AI_ADDRCONFIG ++#define AI_ADDRCONFIG 0x0020 ++#endif ++ ++#ifndef IUTF8 ++#define IUTF8 0040000 ++#endif ++ ++/* ++ * MAXHOSTNAMELEN replacement ++ */ ++static inline size_t get_hostname_max(void) ++{ ++ long len = sysconf(_SC_HOST_NAME_MAX); ++ ++ if (0 < len) ++ return len; ++ ++#ifdef MAXHOSTNAMELEN ++ return MAXHOSTNAMELEN; ++#elif HOST_NAME_MAX ++ return HOST_NAME_MAX; ++#endif ++ return 64; ++} ++ ++ ++/* ++ * Constant strings for usage() functions. For more info see ++ * Documentation/{howto-usage-function.txt,boilerplate.c} ++ */ ++#define USAGE_HEADER ("\nUsage:\n") ++#define USAGE_OPTIONS ("\nOptions:\n") ++#define USAGE_FUNCTIONS ("\nFunctions:\n") ++#define USAGE_COMMANDS ("\nCommands:\n") ++#define USAGE_COLUMNS ("\nAvailable output columns:\n") ++#define USAGE_SEPARATOR "\n" ++ ++#define USAGE_OPTSTR_HELP ("display this help") ++#define USAGE_OPTSTR_VERSION ("display version") ++ ++#define USAGE_HELP_OPTIONS(marg_dsc) \ ++ "%-" #marg_dsc "s%s\n" \ ++ "%-" #marg_dsc "s%s\n" \ ++ , " -h, --help", USAGE_OPTSTR_HELP \ ++ , " -V, --version", USAGE_OPTSTR_VERSION ++ ++#define USAGE_MAN_TAIL(_man) ("\nFor more details see %s.\n"), _man ++ ++#define UTIL_LINUX_VERSION ("%s from %s\n"), program_invocation_short_name, PACKAGE_STRING ++ ++#define print_version(eval) __extension__ ({ \ ++ printf(UTIL_LINUX_VERSION); \ ++ exit(eval); \ ++}) ++ ++/* ++ * scanf modifiers for "strings allocation" ++ */ ++#ifdef HAVE_SCANF_MS_MODIFIER ++#define UL_SCNsA "%ms" ++#elif defined(HAVE_SCANF_AS_MODIFIER) ++#define UL_SCNsA "%as" ++#endif ++ ++/* ++ * seek stuff ++ */ ++#ifndef SEEK_DATA ++# define SEEK_DATA 3 ++#endif ++#ifndef SEEK_HOLE ++# define SEEK_HOLE 4 ++#endif ++ ++ ++/* ++ * Macros to convert #define'itions to strings, for example ++ * #define XYXXY 42 ++ * printf ("%s=%s\n", stringify(XYXXY), stringify_value(XYXXY)); ++ */ ++#define stringify_value(s) stringify(s) ++#define stringify(s) #s ++ ++/* ++ * UL_ASAN_BLACKLIST is a macro to tell AddressSanitizer (a compile-time ++ * instrumentation shipped with Clang and GCC) to not instrument the ++ * annotated function. Furthermore, it will prevent the compiler from ++ * inlining the function because inlining currently breaks the blacklisting ++ * mechanism of AddressSanitizer. ++ */ ++#if __has_feature(address_sanitizer) && __has_attribute(no_sanitize_memory) && __has_attribute(no_sanitize_address) ++# define UL_ASAN_BLACKLIST __attribute__((noinline)) __attribute__((no_sanitize_memory)) __attribute__((no_sanitize_address)) ++#else ++# define UL_ASAN_BLACKLIST /* nothing */ ++#endif ++ ++/* ++ * Note that sysconf(_SC_GETPW_R_SIZE_MAX) returns *initial* suggested size for ++ * pwd buffer and in some cases it is not large enough. See POSIX and ++ * getpwnam_r man page for more details. ++ */ ++#define UL_GETPW_BUFSIZ (16 * 1024) ++ ++/* ++ * Darwin or other BSDs may only have MAP_ANON. To get it on Darwin we must ++ * define _DARWIN_C_SOURCE before including sys/mman.h. We do this in config.h. ++ */ ++#if !defined MAP_ANONYMOUS && defined MAP_ANON ++# define MAP_ANONYMOUS (MAP_ANON) ++#endif ++ ++#endif /* UTIL_LINUX_C_H */ +diff --git a/locale/programs/cross-localedef-hardlink.c b/locale/programs/cross-localedef-hardlink.c +new file mode 100644 +index 0000000000..63615896b0 +--- /dev/null ++++ b/locale/programs/cross-localedef-hardlink.c +@@ -0,0 +1,528 @@ ++/* ++ * hardlink - consolidate duplicate files via hardlinks ++ * ++ * Copyright (C) 2018 Red Hat, Inc. All rights reserved. ++ * Written by Jakub Jelinek ++ * ++ * Copyright (C) 2019 Karel Zak ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it would be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License along ++ * with this program; if not, write to the Free Software Foundation, Inc., ++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ++ */ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#ifdef HAVE_PCRE ++# define PCRE2_CODE_UNIT_WIDTH 8 ++# include ++#endif ++ ++#include "c.h" ++#include "xalloc.h" ++#include "nls.h" ++#include "closestream.h" ++ ++#define NHASH (1<<17) /* Must be a power of 2! */ ++#define NBUF 64 ++ ++struct hardlink_file; ++ ++struct hardlink_hash { ++ struct hardlink_hash *next; ++ struct hardlink_file *chain; ++ off_t size; ++ time_t mtime; ++}; ++ ++struct hardlink_dir { ++ struct hardlink_dir *next; ++ char name[]; ++}; ++ ++struct hardlink_file { ++ struct hardlink_file *next; ++ ino_t ino; ++ dev_t dev; ++ unsigned int cksum; ++ char name[]; ++}; ++ ++struct hardlink_dynstr { ++ char *buf; ++ size_t alloc; ++}; ++ ++struct hardlink_ctl { ++ struct hardlink_dir *dirs; ++ struct hardlink_hash *hps[NHASH]; ++ char iobuf1[BUFSIZ]; ++ char iobuf2[BUFSIZ]; ++ /* summary counters */ ++ unsigned long long ndirs; ++ unsigned long long nobjects; ++ unsigned long long nregfiles; ++ unsigned long long ncomp; ++ unsigned long long nlinks; ++ unsigned long long nsaved; ++ /* current device */ ++ dev_t dev; ++ /* flags */ ++ unsigned int verbose; ++ unsigned int ++ no_link:1, ++ content_only:1, ++ force:1; ++}; ++/* ctl is in global scope due use in atexit() */ ++struct hardlink_ctl global_ctl; ++ ++__attribute__ ((always_inline)) ++static inline unsigned int hash(off_t size, time_t mtime) ++{ ++ return (size ^ mtime) & (NHASH - 1); ++} ++ ++__attribute__ ((always_inline)) ++static inline int stcmp(struct stat *st1, struct stat *st2, int content_scope) ++{ ++ if (content_scope) ++ return st1->st_size != st2->st_size; ++ ++ return st1->st_mode != st2->st_mode ++ || st1->st_uid != st2->st_uid ++ || st1->st_gid != st2->st_gid ++ || st1->st_size != st2->st_size ++ || st1->st_mtime != st2->st_mtime; ++} ++ ++static void print_summary(void) ++{ ++ struct hardlink_ctl const *const ctl = &global_ctl; ++ ++ if (!ctl->verbose) ++ return; ++ ++ if (ctl->verbose > 1 && ctl->nlinks) ++ fputc('\n', stdout); ++ ++ printf(_("Directories: %9lld\n"), ctl->ndirs); ++ printf(_("Objects: %9lld\n"), ctl->nobjects); ++ printf(_("Regular files: %9lld\n"), ctl->nregfiles); ++ printf(_("Comparisons: %9lld\n"), ctl->ncomp); ++ printf( "%s%9lld\n", (ctl->no_link ? ++ _("Would link: ") : ++ _("Linked: ")), ctl->nlinks); ++ printf( "%s %9lld\n", (ctl->no_link ? ++ _("Would save: ") : ++ _("Saved: ")), ctl->nsaved); ++} ++ ++static void __attribute__((__noreturn__)) usage(void) ++{ ++ fputs(USAGE_HEADER, stdout); ++ printf(_(" %s [options] directory...\n"), program_invocation_short_name); ++ ++ fputs(USAGE_SEPARATOR, stdout); ++ puts(_("Consolidate duplicate files using hardlinks.")); ++ ++ fputs(USAGE_OPTIONS, stdout); ++ puts(_(" -c, --content compare only contents, ignore permission, etc.")); ++ puts(_(" -n, --dry-run don't actually link anything")); ++ puts(_(" -v, --verbose print summary after hardlinking")); ++ puts(_(" -vv print every hardlinked file and summary")); ++ puts(_(" -f, --force force hardlinking across filesystems")); ++ puts(_(" -x, --exclude exclude files matching pattern")); ++ ++ fputs(USAGE_SEPARATOR, stdout); ++ printf(USAGE_HELP_OPTIONS(16)); /* char offset to align option descriptions */ ++ printf(USAGE_MAN_TAIL("hardlink(1)")); ++ exit(EXIT_SUCCESS); ++} ++ ++__attribute__ ((always_inline)) ++static inline size_t add2(size_t a, size_t b) ++{ ++ size_t sum = a + b; ++ ++ if (sum < a) ++ errx(EXIT_FAILURE, _("integer overflow")); ++ return sum; ++} ++ ++__attribute__ ((always_inline)) ++static inline size_t add3(size_t a, size_t b, size_t c) ++{ ++ return add2(add2(a, b), c); ++} ++ ++static void growstr(struct hardlink_dynstr *str, size_t newlen) ++{ ++ if (newlen < str->alloc) ++ return; ++ str->buf = xrealloc(str->buf, str->alloc = add2(newlen, 1)); ++} ++ ++static void process_path(struct hardlink_ctl *ctl, const char *name) ++{ ++ struct stat st, st2, st3; ++ const size_t namelen = strlen(name); ++ ++ ctl->nobjects++; ++ if (lstat(name, &st)) ++ return; ++ ++ if (st.st_dev != ctl->dev && !ctl->force) { ++ if (ctl->dev) ++ errx(EXIT_FAILURE, ++ _("%s is on different filesystem than the rest " ++ "(use -f option to override)."), name); ++ ctl->dev = st.st_dev; ++ } ++ if (S_ISDIR(st.st_mode)) { ++ struct hardlink_dir *dp = xmalloc(add3(sizeof(*dp), namelen, 1)); ++ memcpy(dp->name, name, namelen + 1); ++ dp->next = ctl->dirs; ++ ctl->dirs = dp; ++ ++ } else if (S_ISREG(st.st_mode)) { ++ int fd, i; ++ struct hardlink_file *fp, *fp2; ++ struct hardlink_hash *hp; ++ const char *n1, *n2; ++ unsigned int buf[NBUF]; ++ int cksumsize = sizeof(buf); ++ unsigned int cksum; ++ time_t mtime = ctl->content_only ? 0 : st.st_mtime; ++ unsigned int hsh = hash(st.st_size, mtime); ++ off_t fsize; ++ ++ ctl->nregfiles++; ++ if (ctl->verbose > 1) ++ printf("%s\n", name); ++ ++ fd = open(name, O_RDONLY); ++ if (fd < 0) ++ return; ++ ++ if ((size_t)st.st_size < sizeof(buf)) { ++ cksumsize = st.st_size; ++ memset(((char *)buf) + cksumsize, 0, ++ (sizeof(buf) - cksumsize) % sizeof(buf[0])); ++ } ++ if (read(fd, buf, cksumsize) != cksumsize) { ++ close(fd); ++ return; ++ } ++ cksumsize = (cksumsize + sizeof(buf[0]) - 1) / sizeof(buf[0]); ++ for (i = 0, cksum = 0; i < cksumsize; i++) { ++ if (cksum + buf[i] < cksum) ++ cksum += buf[i] + 1; ++ else ++ cksum += buf[i]; ++ } ++ for (hp = ctl->hps[hsh]; hp; hp = hp->next) { ++ if (hp->size == st.st_size && hp->mtime == mtime) ++ break; ++ } ++ if (!hp) { ++ hp = xmalloc(sizeof(*hp)); ++ hp->size = st.st_size; ++ hp->mtime = mtime; ++ hp->chain = NULL; ++ hp->next = ctl->hps[hsh]; ++ ctl->hps[hsh] = hp; ++ } ++ for (fp = hp->chain; fp; fp = fp->next) { ++ if (fp->cksum == cksum) ++ break; ++ } ++ for (fp2 = fp; fp2 && fp2->cksum == cksum; fp2 = fp2->next) { ++ if (fp2->ino == st.st_ino && fp2->dev == st.st_dev) { ++ close(fd); ++ return; ++ } ++ } ++ for (fp2 = fp; fp2 && fp2->cksum == cksum; fp2 = fp2->next) { ++ ++ if (!lstat(fp2->name, &st2) && S_ISREG(st2.st_mode) && ++ !stcmp(&st, &st2, ctl->content_only) && ++ st2.st_ino != st.st_ino && ++ st2.st_dev == st.st_dev) { ++ ++ int fd2 = open(fp2->name, O_RDONLY); ++ if (fd2 < 0) ++ continue; ++ ++ if (fstat(fd2, &st2) || !S_ISREG(st2.st_mode) ++ || st2.st_size == 0) { ++ close(fd2); ++ continue; ++ } ++ ctl->ncomp++; ++ lseek(fd, 0, SEEK_SET); ++ ++ for (fsize = st.st_size; fsize > 0; ++ fsize -= (off_t)sizeof(ctl->iobuf1)) { ++ ssize_t xsz; ++ ssize_t rsize = fsize > (ssize_t) sizeof(ctl->iobuf1) ? ++ (ssize_t) sizeof(ctl->iobuf1) : fsize; ++ ++ if ((xsz = read(fd, ctl->iobuf1, rsize)) != rsize) ++ warn(_("cannot read %s"), name); ++ else if ((xsz = read(fd2, ctl->iobuf2, rsize)) != rsize) ++ warn(_("cannot read %s"), fp2->name); ++ ++ if (xsz != rsize) { ++ close(fd); ++ close(fd2); ++ return; ++ } ++ if (memcmp(ctl->iobuf1, ctl->iobuf2, rsize)) ++ break; ++ } ++ close(fd2); ++ if (fsize > 0) ++ continue; ++ if (lstat(name, &st3)) { ++ warn(_("cannot stat %s"), name); ++ close(fd); ++ return; ++ } ++ st3.st_atime = st.st_atime; ++ if (stcmp(&st, &st3, 0)) { ++ warnx(_("file %s changed underneath us"), name); ++ close(fd); ++ return; ++ } ++ n1 = fp2->name; ++ n2 = name; ++ ++ if (!ctl->no_link) { ++ const char *suffix = ++ ".$$$___cleanit___$$$"; ++ const size_t suffixlen = strlen(suffix); ++ size_t n2len = strlen(n2); ++ struct hardlink_dynstr nam2 = { NULL, 0 }; ++ ++ growstr(&nam2, add2(n2len, suffixlen)); ++ memcpy(nam2.buf, n2, n2len); ++ memcpy(&nam2.buf[n2len], suffix, ++ suffixlen + 1); ++ /* First create a temporary link to n1 under a new name */ ++ if (link(n1, nam2.buf)) { ++ warn(_("failed to hardlink %s to %s (create temporary link as %s failed)"), ++ n1, n2, nam2.buf); ++ free(nam2.buf); ++ continue; ++ } ++ /* Then rename into place over the existing n2 */ ++ if (rename(nam2.buf, n2)) { ++ warn(_("failed to hardlink %s to %s (rename temporary link to %s failed)"), ++ n1, n2, n2); ++ /* Something went wrong, try to remove the now redundant temporary link */ ++ if (unlink(nam2.buf)) ++ warn(_("failed to remove temporary link %s"), nam2.buf); ++ free(nam2.buf); ++ continue; ++ } ++ free(nam2.buf); ++ } ++ ctl->nlinks++; ++ if (st3.st_nlink > 1) { ++ /* We actually did not save anything this time, since the link second argument ++ had some other links as well. */ ++ if (ctl->verbose > 1) ++ printf(_(" %s %s to %s\n"), ++ (ctl->no_link ? _("Would link") : _("Linked")), ++ n1, n2); ++ } else { ++ ctl->nsaved += ((st.st_size + 4095) / 4096) * 4096; ++ if (ctl->verbose > 1) ++ printf(_(" %s %s to %s, %s %jd\n"), ++ (ctl->no_link ? _("Would link") : _("Linked")), ++ n1, n2, ++ (ctl->no_link ? _("would save") : _("saved")), ++ (intmax_t)st.st_size); ++ } ++ close(fd); ++ return; ++ } ++ } ++ fp2 = xmalloc(add3(sizeof(*fp2), namelen, 1)); ++ close(fd); ++ fp2->ino = st.st_ino; ++ fp2->dev = st.st_dev; ++ fp2->cksum = cksum; ++ memcpy(fp2->name, name, namelen + 1); ++ ++ if (fp) { ++ fp2->next = fp->next; ++ fp->next = fp2; ++ } else { ++ fp2->next = hp->chain; ++ hp->chain = fp2; ++ } ++ return; ++ } ++} ++ ++int main(int argc, char **argv) ++{ ++ int ch; ++ int i; ++#ifdef HAVE_PCRE ++ int errornumber; ++ PCRE2_SIZE erroroffset; ++ pcre2_code *re = NULL; ++ PCRE2_SPTR exclude_pattern = NULL; ++ pcre2_match_data *match_data = NULL; ++#endif ++ struct hardlink_dynstr nam1 = { NULL, 0 }; ++ struct hardlink_ctl *ctl = &global_ctl; ++ ++ static const struct option longopts[] = { ++ { "content", no_argument, NULL, 'c' }, ++ { "dry-run", no_argument, NULL, 'n' }, ++ { "exclude", required_argument, NULL, 'x' }, ++ { "force", no_argument, NULL, 'f' }, ++ { "help", no_argument, NULL, 'h' }, ++ { "verbose", no_argument, NULL, 'v' }, ++ { "version", no_argument, NULL, 'V' }, ++ { NULL, 0, NULL, 0 }, ++ }; ++ ++ setlocale(LC_ALL, ""); ++ bindtextdomain(PACKAGE, LOCALEDIR); ++ textdomain(PACKAGE); ++ close_stdout_atexit(); ++ ++ while ((ch = getopt_long(argc, argv, "cnvfx:Vh", longopts, NULL)) != -1) { ++ switch (ch) { ++ case 'n': ++ ctl->no_link = 1; ++ break; ++ case 'v': ++ ctl->verbose++; ++ break; ++ case 'c': ++ ctl->content_only = 1; ++ break; ++ case 'f': ++ ctl->force = 1; ++ break; ++ case 'x': ++#ifdef HAVE_PCRE ++ exclude_pattern = (PCRE2_SPTR) optarg; ++#else ++ errx(EXIT_FAILURE, ++ _("option --exclude not supported (built without pcre2)")); ++#endif ++ break; ++ case 'V': ++ print_version(EXIT_SUCCESS); ++ case 'h': ++ usage(); ++ default: ++ errtryhelp(EXIT_FAILURE); ++ } ++ } ++ ++ if (optind == argc) { ++ warnx(_("no directory specified")); ++ errtryhelp(EXIT_FAILURE); ++ } ++ ++#ifdef HAVE_PCRE ++ if (exclude_pattern) { ++ re = pcre2_compile(exclude_pattern, /* the pattern */ ++ PCRE2_ZERO_TERMINATED, /* indicates pattern is zero-terminate */ ++ 0, /* default options */ ++ &errornumber, &erroroffset, NULL); /* use default compile context */ ++ if (!re) { ++ PCRE2_UCHAR buffer[256]; ++ pcre2_get_error_message(errornumber, buffer, ++ sizeof(buffer)); ++ errx(EXIT_FAILURE, _("pattern error at offset %d: %s"), ++ (int)erroroffset, buffer); ++ } ++ match_data = pcre2_match_data_create_from_pattern(re, NULL); ++ } ++#endif ++ atexit(print_summary); ++ ++ for (i = optind; i < argc; i++) ++ process_path(ctl, argv[i]); ++ ++ while (ctl->dirs) { ++ DIR *dh; ++ struct dirent *di; ++ struct hardlink_dir *dp = ctl->dirs; ++ size_t nam1baselen = strlen(dp->name); ++ ++ ctl->dirs = dp->next; ++ growstr(&nam1, add2(nam1baselen, 1)); ++ memcpy(nam1.buf, dp->name, nam1baselen); ++ free(dp); ++ nam1.buf[nam1baselen++] = '/'; ++ nam1.buf[nam1baselen] = 0; ++ dh = opendir(nam1.buf); ++ ++ if (dh == NULL) ++ continue; ++ ctl->ndirs++; ++ ++ while ((di = readdir(dh)) != NULL) { ++ if (!di->d_name[0]) ++ continue; ++ if (di->d_name[0] == '.') { ++ if (!di->d_name[1] || !strcmp(di->d_name, "..")) ++ continue; ++ } ++#ifdef HAVE_PCRE ++ if (re && pcre2_match(re, /* compiled regex */ ++ (PCRE2_SPTR) di->d_name, strlen(di->d_name), 0, /* start at offset 0 */ ++ 0, /* default options */ ++ match_data, /* block for storing the result */ ++ NULL) /* use default match context */ ++ >=0) { ++ if (ctl->verbose) { ++ nam1.buf[nam1baselen] = 0; ++ printf(_("Skipping %s%s\n"), nam1.buf, di->d_name); ++ } ++ continue; ++ } ++#endif ++ { ++ size_t subdirlen; ++ growstr(&nam1, ++ add2(nam1baselen, subdirlen = ++ strlen(di->d_name))); ++ memcpy(&nam1.buf[nam1baselen], di->d_name, ++ add2(subdirlen, 1)); ++ } ++ process_path(ctl, nam1.buf); ++ } ++ closedir(dh); ++ } ++ ++ return 0; ++} +diff --git a/locale/programs/xalloc.h b/locale/programs/xalloc.h +new file mode 100644 +index 0000000000..0129a85e2e +--- /dev/null ++++ b/locale/programs/xalloc.h +@@ -0,0 +1,129 @@ ++/* ++ * Copyright (C) 2010 Davidlohr Bueso ++ * ++ * This file may be redistributed under the terms of the ++ * GNU Lesser General Public License. ++ * ++ * General memory allocation wrappers for malloc, realloc, calloc and strdup ++ */ ++ ++#ifndef UTIL_LINUX_XALLOC_H ++#define UTIL_LINUX_XALLOC_H ++ ++#include ++#include ++ ++#include "c.h" ++ ++#ifndef XALLOC_EXIT_CODE ++# define XALLOC_EXIT_CODE EXIT_FAILURE ++#endif ++ ++static inline void __attribute__((__noreturn__)) ++__err_oom(const char *file, unsigned int line) ++{ ++ err(XALLOC_EXIT_CODE, "%s: %u: cannot allocate memory", file, line); ++} ++ ++#define err_oom() __err_oom(__FILE__, __LINE__) ++ ++static inline __ul_alloc_size(1) __ul_returns_nonnull ++void *xmalloc(const size_t size) ++{ ++ void *ret = malloc(size); ++ ++ if (!ret && size) ++ err(XALLOC_EXIT_CODE, "cannot allocate %zu bytes", size); ++ return ret; ++} ++ ++static inline __ul_alloc_size(2) __ul_returns_nonnull ++void *xrealloc(void *ptr, const size_t size) ++{ ++ void *ret = realloc(ptr, size); ++ ++ if (!ret && size) ++ err(XALLOC_EXIT_CODE, "cannot allocate %zu bytes", size); ++ return ret; ++} ++ ++static inline __ul_calloc_size(1, 2) __ul_returns_nonnull ++void *xcalloc(const size_t nelems, const size_t size) ++{ ++ void *ret = calloc(nelems, size); ++ ++ if (!ret && size && nelems) ++ err(XALLOC_EXIT_CODE, "cannot allocate %zu bytes", size); ++ return ret; ++} ++ ++static inline char __attribute__((warn_unused_result)) __ul_returns_nonnull ++*xstrdup(const char *str) ++{ ++ char *ret; ++ ++ if (!str) ++ return NULL; ++ ++ ret = strdup(str); ++ ++ if (!ret) ++ err(XALLOC_EXIT_CODE, "cannot duplicate string"); ++ return ret; ++} ++ ++static inline char * __attribute__((warn_unused_result)) __ul_returns_nonnull ++xstrndup(const char *str, size_t size) ++{ ++ char *ret; ++ ++ if (!str) ++ return NULL; ++ ++ ret = strndup(str, size); ++ ++ if (!ret) ++ err(XALLOC_EXIT_CODE, "cannot duplicate string"); ++ return ret; ++} ++ ++ ++static inline int __attribute__ ((__format__(printf, 2, 3))) ++ xasprintf(char **strp, const char *fmt, ...) ++{ ++ int ret; ++ va_list args; ++ va_start(args, fmt); ++ ret = vasprintf(&(*strp), fmt, args); ++ va_end(args); ++ if (ret < 0) ++ err(XALLOC_EXIT_CODE, "cannot allocate string"); ++ return ret; ++} ++ ++static inline int __attribute__ ((__format__(printf, 2, 0))) ++xvasprintf(char **strp, const char *fmt, va_list ap) ++{ ++ int ret = vasprintf(&(*strp), fmt, ap); ++ if (ret < 0) ++ err(XALLOC_EXIT_CODE, "cannot allocate string"); ++ return ret; ++} ++ ++ ++static inline char * __attribute__((warn_unused_result)) xgethostname(void) ++{ ++ char *name; ++ size_t sz = get_hostname_max() + 1; ++ ++ name = xmalloc(sizeof(char) * sz); ++ ++ if (gethostname(name, sz) != 0) { ++ free(name); ++ return NULL; ++ } ++ name[sz - 1] = '\0'; ++ return name; ++} ++ ++#endif diff --git a/meta/recipes-core/glibc/glibc/0001-localedef-Add-hardlink-resolver-to-build.patch b/meta/recipes-core/glibc/glibc/0001-localedef-Add-hardlink-resolver-to-build.patch new file mode 100644 index 0000000000..d6652981a8 --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0001-localedef-Add-hardlink-resolver-to-build.patch @@ -0,0 +1,52 @@ +From 56ae260ac24ade94e2e0e77c81751312372d253f Mon Sep 17 00:00:00 2001 +From: Jason Wessel +Date: Sat, 7 Dec 2019 09:56:23 -0800 +Subject: [PATCH] localedef: Add hardlink resolver to build + +The sourcecode for this is imported from util-linux and is kept with +glibc sources + +Upstream-Status: Pending +Signed-off-by: Jason Wessel +Signed-off-by: Khem Raj +--- + Makefile.in | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/Makefile.in b/Makefile.in +index 77fbded..a87e5b2 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -40,6 +40,8 @@ WARNFLAGS = -Wall -Wno-format + FULLCC = $(CC) $(CPPFLAGS) $(CFLAGS) \ + $(DEFINES) $(INCLUDES) $(WARNFLAGS) + ++CROSS_LOCALEDEF_HARDLINK_OBJS = cross-localedef-hardlink.o ++ + LOCALEDEF_OBJS = charmap.o charmap-dir.o ld-address.o ld-collate.o \ + ld-ctype.o ld-identification.o ld-measurement.o \ + ld-messages.o ld-monetary.o ld-name.o ld-numeric.o \ +@@ -54,11 +56,14 @@ LOCALEDEF_OBJS = charmap.o charmap-dir.o ld-address.o ld-collate.o \ + asprintf.o getdelim.o localedef_extra.o \ + obstack_printf.o vasprintf.o + +-all: localedef$(EXEEXT) ++all: localedef$(EXEEXT) cross-localedef-hardlink$(EXEEXT) + + localedef$(EXEEXT): $(LOCALEDEF_OBJS) + $(CC) -o $@ $(LOCALEDEF_OBJS) $(LIBS) + ++cross-localedef-hardlink$(EXEEXT): $(CROSS_LOCALEDEF_HARDLINK_OBJS) ++ $(CC) -o $@ $(CROSS_LOCALEDEF_HARDLINK_OBJS) $(LIBS) ++ + clean: + rm -f locale$(EXEEXT) $(LOCALEDEF_OBJS) + +@@ -77,6 +82,7 @@ clean: + %.o: $(srcdir)/%.c + $(FULLCC) -c -o $@ $< + ++cross-localedef-hardlink.o: glibc/locale/programs/cross-localedef-hardlink.c + 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 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/0001-nativesdk-glibc-Look-for-host-system-ld.so.cache-as-.patch deleted file mode 100644 index d86d1d8dc7..0000000000 --- a/meta/recipes-core/glibc/glibc/0001-nativesdk-glibc-Look-for-host-system-ld.so.cache-as-.patch +++ /dev/null @@ -1,69 +0,0 @@ -From f6984c923b41155979764bfa3f44609572be5414 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Wed, 18 Mar 2015 01:48:24 +0000 -Subject: [PATCH 01/28] nativesdk-glibc: Look for host system ld.so.cache as - well - -Upstream-Status: Inappropriate [embedded specific] - -The default lib search path order is: - - 1) LD_LIBRARY_PATH - 2) RPATH from the binary - 3) ld.so.cache - 4) default search paths embedded in the linker - -For nativesdk binaries which are being used alongside binaries on a host system, we -need the search paths to firstly search the shipped nativesdk libs but then also -cover the host system. For example we want the host system's libGL and this may be -in a non-standard location like /usr/lib/mesa. The only place the location is know -about is in the ld.so.cache of the host system. - -Since nativesdk has a simple structure and doesn't need to use a cache itself, we -repurpose the cache for use as a last resort in finding host system binaries. This -means we need to switch the order of 3 and 4 above to make this work effectively. - -RP 14/10/2010 - -Signed-off-by: Khem Raj ---- - elf/dl-load.c | 16 ++++++++-------- - 1 file changed, 8 insertions(+), 8 deletions(-) - -diff --git a/elf/dl-load.c b/elf/dl-load.c -index 5abeb867f1..981bd5b4af 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, - } - } - -+ /* try the default path. */ -+ if (fd == -1 -+ && ((l = loader ?: GL(dl_ns)[nsid]._ns_loaded) == NULL -+ || __builtin_expect (!(l->l_flags_1 & DF_1_NODEFLIB), 1)) -+ && rtld_search_dirs.dirs != (void *) -1) -+ fd = open_path (name, namelen, mode & __RTLD_SECURE, &rtld_search_dirs, -+ &realname, &fb, l, LA_SER_DEFAULT, &found_other_class); -+ /* Finally try ld.so.cache */ - #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, - } - #endif - -- /* Finally, try the default path. */ -- if (fd == -1 -- && ((l = loader ?: GL(dl_ns)[nsid]._ns_loaded) == NULL -- || __glibc_likely (!(l->l_flags_1 & DF_1_NODEFLIB))) -- && rtld_search_dirs.dirs != (void *) -1) -- fd = open_path (name, namelen, mode, &rtld_search_dirs, -- &realname, &fb, l, LA_SER_DEFAULT, &found_other_class); -- - /* 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-localedef-fix-ups-hardlink-to-make-it-compile.patch b/meta/recipes-core/glibc/glibc/0002-localedef-fix-ups-hardlink-to-make-it-compile.patch new file mode 100644 index 0000000000..029292fe36 --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0002-localedef-fix-ups-hardlink-to-make-it-compile.patch @@ -0,0 +1,238 @@ +From 9b966b758d0c96ef6654251689318614ef10becc Mon Sep 17 00:00:00 2001 +From: Jason Wessel +Date: Sat, 7 Dec 2019 10:01:37 -0800 +Subject: [PATCH] localedef: fix-ups hardlink to make it compile + +Upstream-Status: Pending +Signed-off-by: Jason Wessel +Signed-off-by: Khem Raj +--- + locale/programs/c.h | 2 +- + locale/programs/cross-localedef-hardlink.c | 79 +++++++++++----------- + 2 files changed, 39 insertions(+), 42 deletions(-) + +diff --git a/locale/programs/c.h b/locale/programs/c.h +index d0a402e90e..1804d31c73 100644 +--- a/locale/programs/c.h ++++ b/locale/programs/c.h +@@ -240,7 +240,7 @@ errmsg(char doexit, int excode, char adderr, const char *fmt, ...) + /* Don't use inline function to avoid '#include "nls.h"' in c.h + */ + #define errtryhelp(eval) __extension__ ({ \ +- fprintf(stderr, _("Try '%s --help' for more information.\n"), \ ++ fprintf(stderr, ("Try '%s --help' for more information.\n"), \ + program_invocation_short_name); \ + exit(eval); \ + }) +diff --git a/locale/programs/cross-localedef-hardlink.c b/locale/programs/cross-localedef-hardlink.c +index 63615896b0..726e6dd948 100644 +--- a/locale/programs/cross-localedef-hardlink.c ++++ b/locale/programs/cross-localedef-hardlink.c +@@ -20,6 +20,8 @@ + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ ++ ++#undef HAVE_PCRE + #include + #include + #include +@@ -38,8 +40,8 @@ + + #include "c.h" + #include "xalloc.h" +-#include "nls.h" +-#include "closestream.h" ++//#include "nls.h" ++//#include "closestream.h" + + #define NHASH (1<<17) /* Must be a power of 2! */ + #define NBUF 64 +@@ -124,33 +126,33 @@ static void print_summary(void) + if (ctl->verbose > 1 && ctl->nlinks) + fputc('\n', stdout); + +- printf(_("Directories: %9lld\n"), ctl->ndirs); +- printf(_("Objects: %9lld\n"), ctl->nobjects); +- printf(_("Regular files: %9lld\n"), ctl->nregfiles); +- printf(_("Comparisons: %9lld\n"), ctl->ncomp); ++ printf(("Directories: %9lld\n"), ctl->ndirs); ++ printf(("Objects: %9lld\n"), ctl->nobjects); ++ printf(("Regular files: %9lld\n"), ctl->nregfiles); ++ printf(("Comparisons: %9lld\n"), ctl->ncomp); + printf( "%s%9lld\n", (ctl->no_link ? +- _("Would link: ") : +- _("Linked: ")), ctl->nlinks); ++ ("Would link: ") : ++ ("Linked: ")), ctl->nlinks); + printf( "%s %9lld\n", (ctl->no_link ? +- _("Would save: ") : +- _("Saved: ")), ctl->nsaved); ++ ("Would save: ") : ++ ("Saved: ")), ctl->nsaved); + } + + static void __attribute__((__noreturn__)) usage(void) + { + fputs(USAGE_HEADER, stdout); +- printf(_(" %s [options] directory...\n"), program_invocation_short_name); ++ printf((" %s [options] directory...\n"), program_invocation_short_name); + + fputs(USAGE_SEPARATOR, stdout); +- puts(_("Consolidate duplicate files using hardlinks.")); ++ puts(("Consolidate duplicate files using hardlinks.")); + + fputs(USAGE_OPTIONS, stdout); +- puts(_(" -c, --content compare only contents, ignore permission, etc.")); +- puts(_(" -n, --dry-run don't actually link anything")); +- puts(_(" -v, --verbose print summary after hardlinking")); +- puts(_(" -vv print every hardlinked file and summary")); +- puts(_(" -f, --force force hardlinking across filesystems")); +- puts(_(" -x, --exclude exclude files matching pattern")); ++ puts((" -c, --content compare only contents, ignore permission, etc.")); ++ puts((" -n, --dry-run don't actually link anything")); ++ puts((" -v, --verbose print summary after hardlinking")); ++ puts((" -vv print every hardlinked file and summary")); ++ puts((" -f, --force force hardlinking across filesystems")); ++ puts((" -x, --exclude exclude files matching pattern")); + + fputs(USAGE_SEPARATOR, stdout); + printf(USAGE_HELP_OPTIONS(16)); /* char offset to align option descriptions */ +@@ -164,7 +166,7 @@ static inline size_t add2(size_t a, size_t b) + size_t sum = a + b; + + if (sum < a) +- errx(EXIT_FAILURE, _("integer overflow")); ++ errx(EXIT_FAILURE, ("integer overflow")); + return sum; + } + +@@ -193,7 +195,7 @@ static void process_path(struct hardlink_ctl *ctl, const char *name) + if (st.st_dev != ctl->dev && !ctl->force) { + if (ctl->dev) + errx(EXIT_FAILURE, +- _("%s is on different filesystem than the rest " ++ ("%s is on different filesystem than the rest " + "(use -f option to override)."), name); + ctl->dev = st.st_dev; + } +@@ -287,9 +289,9 @@ static void process_path(struct hardlink_ctl *ctl, const char *name) + (ssize_t) sizeof(ctl->iobuf1) : fsize; + + if ((xsz = read(fd, ctl->iobuf1, rsize)) != rsize) +- warn(_("cannot read %s"), name); ++ warn(("cannot read %s"), name); + else if ((xsz = read(fd2, ctl->iobuf2, rsize)) != rsize) +- warn(_("cannot read %s"), fp2->name); ++ warn(("cannot read %s"), fp2->name); + + if (xsz != rsize) { + close(fd); +@@ -303,13 +305,13 @@ static void process_path(struct hardlink_ctl *ctl, const char *name) + if (fsize > 0) + continue; + if (lstat(name, &st3)) { +- warn(_("cannot stat %s"), name); ++ warn(("cannot stat %s"), name); + close(fd); + return; + } + st3.st_atime = st.st_atime; + if (stcmp(&st, &st3, 0)) { +- warnx(_("file %s changed underneath us"), name); ++ warnx(("file %s changed underneath us"), name); + close(fd); + return; + } +@@ -329,18 +331,18 @@ static void process_path(struct hardlink_ctl *ctl, const char *name) + suffixlen + 1); + /* First create a temporary link to n1 under a new name */ + if (link(n1, nam2.buf)) { +- warn(_("failed to hardlink %s to %s (create temporary link as %s failed)"), ++ warn(("failed to hardlink %s to %s (create temporary link as %s failed)"), + n1, n2, nam2.buf); + free(nam2.buf); + continue; + } + /* Then rename into place over the existing n2 */ + if (rename(nam2.buf, n2)) { +- warn(_("failed to hardlink %s to %s (rename temporary link to %s failed)"), ++ warn(("failed to hardlink %s to %s (rename temporary link to %s failed)"), + n1, n2, n2); + /* Something went wrong, try to remove the now redundant temporary link */ + if (unlink(nam2.buf)) +- warn(_("failed to remove temporary link %s"), nam2.buf); ++ warn(("failed to remove temporary link %s"), nam2.buf); + free(nam2.buf); + continue; + } +@@ -351,16 +353,16 @@ static void process_path(struct hardlink_ctl *ctl, const char *name) + /* We actually did not save anything this time, since the link second argument + had some other links as well. */ + if (ctl->verbose > 1) +- printf(_(" %s %s to %s\n"), +- (ctl->no_link ? _("Would link") : _("Linked")), ++ printf((" %s %s to %s\n"), ++ (ctl->no_link ? ("Would link") : ("Linked")), + n1, n2); + } else { + ctl->nsaved += ((st.st_size + 4095) / 4096) * 4096; + if (ctl->verbose > 1) +- printf(_(" %s %s to %s, %s %jd\n"), +- (ctl->no_link ? _("Would link") : _("Linked")), ++ printf((" %s %s to %s, %s %jd\n"), ++ (ctl->no_link ? ("Would link") : ("Linked")), + n1, n2, +- (ctl->no_link ? _("would save") : _("saved")), ++ (ctl->no_link ? ("would save") : ("saved")), + (intmax_t)st.st_size); + } + close(fd); +@@ -410,11 +412,6 @@ int main(int argc, char **argv) + { NULL, 0, NULL, 0 }, + }; + +- setlocale(LC_ALL, ""); +- bindtextdomain(PACKAGE, LOCALEDIR); +- textdomain(PACKAGE); +- close_stdout_atexit(); +- + while ((ch = getopt_long(argc, argv, "cnvfx:Vh", longopts, NULL)) != -1) { + switch (ch) { + case 'n': +@@ -434,7 +431,7 @@ int main(int argc, char **argv) + exclude_pattern = (PCRE2_SPTR) optarg; + #else + errx(EXIT_FAILURE, +- _("option --exclude not supported (built without pcre2)")); ++ ("option --exclude not supported (built without pcre2)")); + #endif + break; + case 'V': +@@ -447,7 +444,7 @@ int main(int argc, char **argv) + } + + if (optind == argc) { +- warnx(_("no directory specified")); ++ warnx(("no directory specified")); + errtryhelp(EXIT_FAILURE); + } + +@@ -461,7 +458,7 @@ int main(int argc, char **argv) + PCRE2_UCHAR buffer[256]; + pcre2_get_error_message(errornumber, buffer, + sizeof(buffer)); +- errx(EXIT_FAILURE, _("pattern error at offset %d: %s"), ++ errx(EXIT_FAILURE, ("pattern error at offset %d: %s"), + (int)erroroffset, buffer); + } + match_data = pcre2_match_data_create_from_pattern(re, NULL); +@@ -506,7 +503,7 @@ int main(int argc, char **argv) + >=0) { + if (ctl->verbose) { + nam1.buf[nam1baselen] = 0; +- printf(_("Skipping %s%s\n"), nam1.buf, di->d_name); ++ printf(("Skipping %s%s\n"), nam1.buf, di->d_name); + } + continue; + } diff --git a/meta/recipes-core/glibc/glibc/0002-nativesdk-glibc-Fix-buffer-overrun-with-a-relocated-.patch b/meta/recipes-core/glibc/glibc/0002-nativesdk-glibc-Fix-buffer-overrun-with-a-relocated-.patch deleted file mode 100644 index 63531082a4..0000000000 --- a/meta/recipes-core/glibc/glibc/0002-nativesdk-glibc-Fix-buffer-overrun-with-a-relocated-.patch +++ /dev/null @@ -1,50 +0,0 @@ -From b91c323d809039bf9b8c445418579a8b5fe61aea Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Wed, 18 Mar 2015 01:50:00 +0000 -Subject: [PATCH 02/28] 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 -because it implicitly assumes that max_dirnamelen is a fixed size that -never changes. - -The allocated buffer will not be large enough to contain the directory -path string which is larger than the fixed location provided at build -time. - -Upstream-Status: Inappropriate [OE SDK specific] - -Signed-off-by: Jason Wessel -Signed-off-by: Khem Raj ---- - elf/dl-load.c | 12 ++++++++++++ - 1 file changed, 12 insertions(+) - -diff --git a/elf/dl-load.c b/elf/dl-load.c -index 981bd5b4af..c7a0fa58cb 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, - given on the command line when rtld is run directly. */ - return -1; - -+ do -+ { -+ struct r_search_path_elem *this_dir = *dirs; -+ if (this_dir->dirnamelen > max_dirnamelen) -+ { -+ max_dirnamelen = this_dir->dirnamelen; -+ } -+ } -+ while (*++dirs != NULL); -+ - buf = alloca (max_dirnamelen + max_capstrlen + namelen); -+ -+ dirs = sps->dirs; - do - { - struct r_search_path_elem *this_dir = *dirs; --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0003-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 new file mode 100644 index 0000000000..e1c3512e4e --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0003-nativesdk-glibc-Look-for-host-system-ld.so.cache-as-.patch @@ -0,0 +1,65 @@ +From 14ddf13b7fc2e39a1ae657ceb3963e35731e95d0 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 18 Mar 2015 01:48:24 +0000 +Subject: [PATCH] nativesdk-glibc: Look for host system ld.so.cache as well + +Upstream-Status: Inappropriate [embedded specific] + +The default lib search path order is: + + 1) LD_LIBRARY_PATH + 2) RPATH from the binary + 3) ld.so.cache + 4) default search paths embedded in the linker + +For nativesdk binaries which are being used alongside binaries on a host system, we +need the search paths to firstly search the shipped nativesdk libs but then also +cover the host system. For example we want the host system's libGL and this may be +in a non-standard location like /usr/lib/mesa. The only place the location is know +about is in the ld.so.cache of the host system. + +Since nativesdk has a simple structure and doesn't need to use a cache itself, we +repurpose the cache for use as a last resort in finding host system binaries. This +means we need to switch the order of 3 and 4 above to make this work effectively. + +RP 14/10/2010 + +Signed-off-by: Khem Raj +--- + elf/dl-load.c | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +diff --git a/elf/dl-load.c b/elf/dl-load.c +index a6b80f9395..3226f2e531 100644 +--- a/elf/dl-load.c ++++ b/elf/dl-load.c +@@ -2073,6 +2073,14 @@ _dl_map_object (struct link_map *loader, const char *name, + } + } + ++ /* try the default path. */ ++ if (fd == -1 ++ && ((l = loader ?: GL(dl_ns)[nsid]._ns_loaded) == NULL ++ || __builtin_expect (!(l->l_flags_1 & DF_1_NODEFLIB), 1)) ++ && rtld_search_dirs.dirs != (void *) -1) ++ fd = open_path (name, namelen, mode & __RTLD_SECURE, &rtld_search_dirs, ++ &realname, &fb, l, LA_SER_DEFAULT, &found_other_class); ++ /* Finally try ld.so.cache */ + #ifdef USE_LDCONFIG + if (fd == -1 + && (__glibc_likely ((mode & __RTLD_SECURE) == 0) +@@ -2131,14 +2139,6 @@ _dl_map_object (struct link_map *loader, const char *name, + } + #endif + +- /* Finally, try the default path. */ +- if (fd == -1 +- && ((l = loader ?: GL(dl_ns)[nsid]._ns_loaded) == NULL +- || __glibc_likely (!(l->l_flags_1 & DF_1_NODEFLIB))) +- && rtld_search_dirs.dirs != (void *) -1) +- fd = open_path (name, namelen, mode, &rtld_search_dirs, +- &realname, &fb, l, LA_SER_DEFAULT, &found_other_class); +- + /* Add another newline when we are tracing the library loading. */ + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_LIBS)) + _dl_debug_printf ("\n"); diff --git a/meta/recipes-core/glibc/glibc/0003-nativesdk-glibc-Raise-the-size-of-arrays-containing-.patch b/meta/recipes-core/glibc/glibc/0003-nativesdk-glibc-Raise-the-size-of-arrays-containing-.patch deleted file mode 100644 index 48f5a78716..0000000000 --- a/meta/recipes-core/glibc/glibc/0003-nativesdk-glibc-Raise-the-size-of-arrays-containing-.patch +++ /dev/null @@ -1,141 +0,0 @@ -From 3aceb84e2bc0f796204fe059beede91179b1bc6e Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Wed, 18 Mar 2015 01:51:38 +0000 -Subject: [PATCH 03/28] 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 -sections in memory. The sections that contain paths have been allocated a 4096 -byte section, which is the maximum path length in linux. This will allow the -relocating script to parse the ELF binary, detect the section and easily replace -the strings in a certain path. - -Upstream-Status: Inappropriate [SDK specific] - -Signed-off-by: Laurentiu Palcu -Signed-off-by: Khem Raj ---- - elf/dl-cache.c | 4 ++++ - elf/dl-load.c | 4 ++-- - elf/interp.c | 2 +- - elf/ldconfig.c | 3 +++ - elf/rtld.c | 5 +++-- - iconv/gconv_conf.c | 2 +- - sysdeps/generic/dl-cache.h | 4 ---- - 7 files changed, 14 insertions(+), 10 deletions(-) - -diff --git a/elf/dl-cache.c b/elf/dl-cache.c -index d8d1e2344e..d2247bfc4f 100644 ---- a/elf/dl-cache.c -+++ b/elf/dl-cache.c -@@ -133,6 +133,10 @@ do \ - while (0) - - -+const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache"))) = -+ SYSCONFDIR "/ld.so.cache"; -+ -+ - int - _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 ---- a/elf/dl-load.c -+++ b/elf/dl-load.c -@@ -110,8 +110,8 @@ static size_t max_capstrlen attribute_relro; - gen-trusted-dirs.awk. */ - #include "trusted-dirs.h" - --static const char system_dirs[] = SYSTEM_DIRS; --static const size_t system_dirs_len[] = -+static const char system_dirs[4096] __attribute__ ((section (".sysdirs"))) = SYSTEM_DIRS; -+volatile static const size_t system_dirs_len[] __attribute__ ((section (".sysdirslen"))) = - { - SYSTEM_DIRS_LEN - }; -diff --git a/elf/interp.c b/elf/interp.c -index 243829f5f7..0e74241703 100644 ---- a/elf/interp.c -+++ b/elf/interp.c -@@ -18,5 +18,5 @@ - - #include - --const char __invoke_dynamic_linker__[] __attribute__ ((section (".interp"))) -+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 ---- a/elf/ldconfig.c -+++ b/elf/ldconfig.c -@@ -168,6 +168,9 @@ static struct argp argp = - options, parse_opt, NULL, doc, NULL, more_help, NULL - }; - -+ -+extern const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache"))); -+ - /* Check if string corresponds to an important hardware capability or - a platform. */ - static int -diff --git a/elf/rtld.c b/elf/rtld.c -index c9490ff694..3962373ebb 100644 ---- a/elf/rtld.c -+++ b/elf/rtld.c -@@ -173,6 +173,7 @@ dso_name_valid_for_suid (const char *p) - } - return *p != '\0'; - } -+extern const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache"))); - - /* 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\ - --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\ -- --inhibit-cache Do not use " LD_SO_CACHE "\n\ -+ --inhibit-cache Do not use %s\n\ - --library-path PATH use given PATH instead of content of the environment\n\ - variable LD_LIBRARY_PATH\n\ - --inhibit-rpath LIST ignore RUNPATH and RPATH information in object names\n\ - in LIST\n\ - --audit LIST use objects named in LIST as auditors\n\ -- --preload LIST preload objects named in LIST\n"); -+ --preload LIST preload objects named in LIST\n", LD_SO_CACHE); - - ++_dl_skip_args; - --_dl_argc; -diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c -index ae8937cba0..f321ee419e 100644 ---- a/iconv/gconv_conf.c -+++ b/iconv/gconv_conf.c -@@ -36,7 +36,7 @@ - - - /* This is the default path where we look for module lists. */ --static const char default_gconv_path[] = GCONV_PATH; -+static char default_gconv_path[4096] __attribute__ ((section (".gccrelocprefix"))) = GCONV_PATH; - - /* 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 ---- a/sysdeps/generic/dl-cache.h -+++ b/sysdeps/generic/dl-cache.h -@@ -27,10 +27,6 @@ - ((flags) == 1 || (flags) == _DL_CACHE_DEFAULT_ID) - #endif - --#ifndef LD_SO_CACHE --# define LD_SO_CACHE SYSCONFDIR "/ld.so.cache" --#endif -- - #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/0004-nativesdk-glibc-Allow-64-bit-atomics-for-x86.patch deleted file mode 100644 index a43f294345..0000000000 --- a/meta/recipes-core/glibc/glibc/0004-nativesdk-glibc-Allow-64-bit-atomics-for-x86.patch +++ /dev/null @@ -1,42 +0,0 @@ -From e41e042149eac349e09fa629fcac4c64e574322c Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Thu, 31 Dec 2015 14:35:35 -0800 -Subject: [PATCH 04/28] 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. -It also makes the synchronization more efficient. - -Upstream-Status: Inappropriate [OE-Specific] - -Signed-off-by: Juro Bystricky -Signed-off-by: Richard Purdie -Signed-off-by: Khem Raj ---- - sysdeps/x86/atomic-machine.h | 3 +-- - 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 ---- a/sysdeps/x86/atomic-machine.h -+++ b/sysdeps/x86/atomic-machine.h -@@ -58,15 +58,14 @@ typedef uintmax_t uatomic_max_t; - #endif - - #define USE_ATOMIC_COMPILER_BUILTINS 1 -+# define __HAVE_64B_ATOMICS 1 - - #ifdef __x86_64__ --# define __HAVE_64B_ATOMICS 1 - # define SP_REG "rsp" - # define SEG_REG "fs" - # define BR_CONSTRAINT "q" - # define IBR_CONSTRAINT "iq" - #else --# define __HAVE_64B_ATOMICS 0 - # define SP_REG "esp" - # define SEG_REG "gs" - # define BR_CONSTRAINT "r" --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0004-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 new file mode 100644 index 0000000000..523b6da897 --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0004-nativesdk-glibc-Fix-buffer-overrun-with-a-relocated-.patch @@ -0,0 +1,46 @@ +From 3ac58bf1028841cc0a8fa7f258cbf21466740360 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 18 Mar 2015 01:50:00 +0000 +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 +because it implicitly assumes that max_dirnamelen is a fixed size that +never changes. + +The allocated buffer will not be large enough to contain the directory +path string which is larger than the fixed location provided at build +time. + +Upstream-Status: Inappropriate [OE SDK specific] + +Signed-off-by: Jason Wessel +Signed-off-by: Khem Raj +--- + elf/dl-load.c | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +diff --git a/elf/dl-load.c b/elf/dl-load.c +index 3226f2e531..7cb8a86fab 100644 +--- a/elf/dl-load.c ++++ b/elf/dl-load.c +@@ -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; + ++ do ++ { ++ struct r_search_path_elem *this_dir = *dirs; ++ if (this_dir->dirnamelen > max_dirnamelen) ++ { ++ max_dirnamelen = this_dir->dirnamelen; ++ } ++ } ++ while (*++dirs != NULL); ++ + buf = alloca (max_dirnamelen + max_capstrlen + namelen); ++ ++ dirs = sps->dirs; + do + { + struct r_search_path_elem *this_dir = *dirs; diff --git a/meta/recipes-core/glibc/glibc/0005-nativesdk-glibc-Make-relocatable-install-for-locales.patch b/meta/recipes-core/glibc/glibc/0005-nativesdk-glibc-Make-relocatable-install-for-locales.patch deleted file mode 100644 index 3aad603ada..0000000000 --- a/meta/recipes-core/glibc/glibc/0005-nativesdk-glibc-Make-relocatable-install-for-locales.patch +++ /dev/null @@ -1,70 +0,0 @@ -From 50ab0b0c116f4ae3d975ec1b15ed4595fd9147f6 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 3 Aug 2018 09:55:12 -0700 -Subject: [PATCH 05/28] 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 -magic segment that we can relocate at install time. - -Upstream-Status: Inappropriate (OE-specific) - -Signed-off-by: Ross Burton -Signed-off-by: Khem Raj ---- - locale/findlocale.c | 4 ++-- - locale/loadarchive.c | 2 +- - locale/localeinfo.h | 2 +- - 3 files changed, 4 insertions(+), 4 deletions(-) - -diff --git a/locale/findlocale.c b/locale/findlocale.c -index 9af605bd64..b2b0a3f93b 100644 ---- a/locale/findlocale.c -+++ b/locale/findlocale.c -@@ -56,7 +56,7 @@ struct __locale_data *const _nl_C[] attribute_hidden = - which are somehow addressed. */ - struct loaded_l10nfile *_nl_locale_file_list[__LC_LAST]; - --const char _nl_default_locale_path[] attribute_hidden = COMPLOCALEDIR; -+char _nl_default_locale_path[4096] attribute_hidden __attribute__ ((section (".gccrelocprefix"))) = COMPLOCALEDIR; - - /* 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, - - /* Nothing in the archive. Set the default path to search below. */ - locale_path = _nl_default_locale_path; -- locale_path_len = sizeof _nl_default_locale_path; -+ locale_path_len = strlen(locale_path) + 1; - } - 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 ---- a/locale/loadarchive.c -+++ b/locale/loadarchive.c -@@ -42,7 +42,7 @@ - - - /* Name of the locale archive file. */ --static const char archfname[] = COMPLOCALEDIR "/locale-archive"; -+static const char archfname[4096] __attribute__ ((section (".gccrelocprefix"))) = COMPLOCALEDIR "/locale-archive"; - - /* 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 ---- a/locale/localeinfo.h -+++ b/locale/localeinfo.h -@@ -325,7 +325,7 @@ _nl_lookup_word (locale_t l, int category, int item) - } - - /* Default search path if no LOCPATH environment variable. */ --extern const char _nl_default_locale_path[] attribute_hidden; -+extern char _nl_default_locale_path[4096] attribute_hidden; - - /* 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/0005-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 new file mode 100644 index 0000000000..4d88d9b413 --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0005-nativesdk-glibc-Raise-the-size-of-arrays-containing-.patch @@ -0,0 +1,137 @@ +From 702d68cbdf405e086f72e2a062127cbea43045ec Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 18 Mar 2015 01:51:38 +0000 +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 +sections in memory. The sections that contain paths have been allocated a 4096 +byte section, which is the maximum path length in linux. This will allow the +relocating script to parse the ELF binary, detect the section and easily replace +the strings in a certain path. + +Upstream-Status: Inappropriate [SDK specific] + +Signed-off-by: Laurentiu Palcu +Signed-off-by: Khem Raj +--- + elf/dl-cache.c | 4 ++++ + elf/dl-load.c | 4 ++-- + elf/interp.c | 2 +- + elf/ldconfig.c | 3 +++ + elf/rtld.c | 5 +++-- + iconv/gconv_conf.c | 2 +- + sysdeps/generic/dl-cache.h | 4 ---- + 7 files changed, 14 insertions(+), 10 deletions(-) + +diff --git a/elf/dl-cache.c b/elf/dl-cache.c +index 3eedd9afcf..efdfe5cae7 100644 +--- a/elf/dl-cache.c ++++ b/elf/dl-cache.c +@@ -133,6 +133,10 @@ do \ + while (0) + + ++const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache"))) = ++ SYSCONFDIR "/ld.so.cache"; ++ ++ + int + _dl_cache_libcmp (const char *p1, const char *p2) + { +diff --git a/elf/dl-load.c b/elf/dl-load.c +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; + gen-trusted-dirs.awk. */ + #include "trusted-dirs.h" + +-static const char system_dirs[] = SYSTEM_DIRS; +-static const size_t system_dirs_len[] = ++static const char system_dirs[4096] __attribute__ ((section (".sysdirs"))) = SYSTEM_DIRS; ++volatile static const size_t system_dirs_len[] __attribute__ ((section (".sysdirslen"))) = + { + SYSTEM_DIRS_LEN + }; +diff --git a/elf/interp.c b/elf/interp.c +index 331cc1df48..885b2d9476 100644 +--- a/elf/interp.c ++++ b/elf/interp.c +@@ -18,5 +18,5 @@ + + #include + +-const char __invoke_dynamic_linker__[] __attribute__ ((section (".interp"))) ++const char __invoke_dynamic_linker__[4096] __attribute__ ((section (".interp"))) + = RUNTIME_LINKER; +diff --git a/elf/ldconfig.c b/elf/ldconfig.c +index 681ed78496..8833ed0a6b 100644 +--- a/elf/ldconfig.c ++++ b/elf/ldconfig.c +@@ -168,6 +168,9 @@ static struct argp argp = + options, parse_opt, NULL, doc, NULL, more_help, NULL + }; + ++ ++extern const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache"))); ++ + /* Check if string corresponds to an important hardware capability or + a platform. */ + static int +diff --git a/elf/rtld.c b/elf/rtld.c +index 553cfbd1b7..39347c2c03 100644 +--- a/elf/rtld.c ++++ b/elf/rtld.c +@@ -175,6 +175,7 @@ dso_name_valid_for_suid (const char *p) + } + return *p != '\0'; + } ++extern const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache"))); + + /* LD_AUDIT variable contents. Must be processed before the + audit_list below. */ +@@ -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\ +- --inhibit-cache Do not use " LD_SO_CACHE "\n\ ++ --inhibit-cache Do not use %s\n\ + --library-path PATH use given PATH instead of content of the environment\n\ + variable LD_LIBRARY_PATH\n\ + --inhibit-rpath LIST ignore RUNPATH and RPATH information in object names\n\ + in LIST\n\ + --audit LIST use objects named in LIST as auditors\n\ +- --preload LIST preload objects named in LIST\n"); ++ --preload LIST preload objects named in LIST\n", LD_SO_CACHE); + + ++_dl_skip_args; + --_dl_argc; +diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c +index 735bd1f2d5..25100ba666 100644 +--- a/iconv/gconv_conf.c ++++ b/iconv/gconv_conf.c +@@ -36,7 +36,7 @@ + + + /* This is the default path where we look for module lists. */ +-static const char default_gconv_path[] = GCONV_PATH; ++static char default_gconv_path[4096] __attribute__ ((section (".gccrelocprefix"))) = GCONV_PATH; + + /* Type to represent search path. */ + struct path_elem +diff --git a/sysdeps/generic/dl-cache.h b/sysdeps/generic/dl-cache.h +index 6b310e9e15..3877311df4 100644 +--- a/sysdeps/generic/dl-cache.h ++++ b/sysdeps/generic/dl-cache.h +@@ -27,10 +27,6 @@ + ((flags) == 1 || (flags) == _DL_CACHE_DEFAULT_ID) + #endif + +-#ifndef LD_SO_CACHE +-# define LD_SO_CACHE SYSCONFDIR "/ld.so.cache" +-#endif +- + #ifndef add_system_dir + # define add_system_dir(dir) add_dir (dir) + #endif diff --git a/meta/recipes-core/glibc/glibc/0006-fsl-e500-e5500-e6500-603e-fsqrt-implementation.patch b/meta/recipes-core/glibc/glibc/0006-fsl-e500-e5500-e6500-603e-fsqrt-implementation.patch deleted file mode 100644 index 5e1c591432..0000000000 --- a/meta/recipes-core/glibc/glibc/0006-fsl-e500-e5500-e6500-603e-fsqrt-implementation.patch +++ /dev/null @@ -1,1584 +0,0 @@ -From 7cccf5cec09f2a42cc3fe5d82ce21b7309330b33 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Wed, 18 Mar 2015 00:01:50 +0000 -Subject: [PATCH 06/28] fsl e500/e5500/e6500/603e fsqrt implementation - -Upstream-Status: Pending -Signed-off-by: Edmar Wienskoski -Signed-off-by: Khem Raj ---- - sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c | 134 ++++++++++++++++++ - sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c | 101 +++++++++++++ - sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c | 134 ++++++++++++++++++ - .../powerpc/powerpc32/e500mc/fpu/e_sqrtf.c | 101 +++++++++++++ - sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c | 134 ++++++++++++++++++ - sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c | 101 +++++++++++++ - sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c | 134 ++++++++++++++++++ - sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c | 101 +++++++++++++ - sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c | 134 ++++++++++++++++++ - sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c | 101 +++++++++++++ - sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c | 134 ++++++++++++++++++ - sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c | 101 +++++++++++++ - .../linux/powerpc/powerpc32/603e/fpu/Implies | 1 + - .../powerpc/powerpc32/e300c3/fpu/Implies | 2 + - .../powerpc/powerpc32/e500mc/fpu/Implies | 1 + - .../linux/powerpc/powerpc32/e5500/fpu/Implies | 1 + - .../linux/powerpc/powerpc32/e6500/fpu/Implies | 1 + - .../linux/powerpc/powerpc64/e5500/fpu/Implies | 1 + - .../linux/powerpc/powerpc64/e6500/fpu/Implies | 1 + - 19 files changed, 1418 insertions(+) - create mode 100644 sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c - create mode 100644 sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c - create mode 100644 sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c - create mode 100644 sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c - create mode 100644 sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c - create mode 100644 sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c - create mode 100644 sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c - create mode 100644 sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c - create mode 100644 sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c - create mode 100644 sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c - create mode 100644 sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c - create mode 100644 sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c - create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/603e/fpu/Implies - create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/e300c3/fpu/Implies - create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/e500mc/fpu/Implies - create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/e5500/fpu/Implies - create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/e6500/fpu/Implies - create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/e5500/fpu/Implies - create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/e6500/fpu/Implies - -diff --git a/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c -new file mode 100644 -index 0000000000..71e516d1c8 ---- /dev/null -+++ b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c -@@ -0,0 +1,134 @@ -+/* Double-precision floating point square root. -+ Copyright (C) 2010 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, write to the Free -+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -+ 02111-1307 USA. */ -+ -+#include -+#include -+#include -+#include -+ -+#include -+#include -+ -+static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; -+static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; -+static const float two108 = 3.245185536584267269e+32; -+static const float twom54 = 5.551115123125782702e-17; -+static const float half = 0.5; -+ -+/* The method is based on the descriptions in: -+ -+ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; -+ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 -+ -+ We find the actual square root and half of its reciprocal -+ simultaneously. */ -+ -+#ifdef __STDC__ -+double -+__ieee754_sqrt (double b) -+#else -+double -+__ieee754_sqrt (b) -+ double b; -+#endif -+{ -+ if (__builtin_expect (b > 0, 1)) -+ { -+ double y, g, h, d, r; -+ ieee_double_shape_type u; -+ -+ if (__builtin_expect (b != a_inf.value, 1)) -+ { -+ fenv_t fe; -+ -+ fe = fegetenv_register (); -+ -+ u.value = b; -+ -+ relax_fenv_state (); -+ -+ __asm__ ("frsqrte %[estimate], %[x]\n" -+ : [estimate] "=f" (y) : [x] "f" (b)); -+ -+ /* Following Muller et al, page 168, equation 5.20. -+ -+ h goes to 1/(2*sqrt(b)) -+ g goes to sqrt(b). -+ -+ We need three iterations to get within 1ulp. */ -+ -+ /* Indicate that these can be performed prior to the branch. GCC -+ insists on sinking them below the branch, however; it seems like -+ they'd be better before the branch so that we can cover any latency -+ from storing the argument and loading its high word. Oh well. */ -+ -+ g = b * y; -+ h = 0.5 * y; -+ -+ /* Handle small numbers by scaling. */ -+ if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) -+ return __ieee754_sqrt (b * two108) * twom54; -+ -+#define FMADD(a_, c_, b_) \ -+ ({ double __r; \ -+ __asm__ ("fmadd %[r], %[a], %[c], %[b]\n" \ -+ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ -+ __r;}) -+#define FNMSUB(a_, c_, b_) \ -+ ({ double __r; \ -+ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ -+ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ -+ __r;}) -+ -+ r = FNMSUB (g, h, half); -+ g = FMADD (g, r, g); -+ h = FMADD (h, r, h); -+ -+ r = FNMSUB (g, h, half); -+ g = FMADD (g, r, g); -+ h = FMADD (h, r, h); -+ -+ r = FNMSUB (g, h, half); -+ g = FMADD (g, r, g); -+ h = FMADD (h, r, h); -+ -+ /* g is now +/- 1ulp, or exactly equal to, the square root of b. */ -+ -+ /* Final refinement. */ -+ d = FNMSUB (g, g, b); -+ -+ fesetenv_register (fe); -+ return FMADD (d, h, g); -+ } -+ } -+ else if (b < 0) -+ { -+ /* For some reason, some PowerPC32 processors don't implement -+ FE_INVALID_SQRT. */ -+#ifdef FE_INVALID_SQRT -+ feraiseexcept (FE_INVALID_SQRT); -+ -+ fenv_union_t u = { .fenv = fegetenv_register () }; -+ if ((u.l & FE_INVALID) == 0) -+#endif -+ feraiseexcept (FE_INVALID); -+ b = a_nan.value; -+ } -+ return f_wash (b); -+} -diff --git a/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c -new file mode 100644 -index 0000000000..26fa067abf ---- /dev/null -+++ b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c -@@ -0,0 +1,101 @@ -+/* Single-precision floating point square root. -+ Copyright (C) 2010 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, write to the Free -+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -+ 02111-1307 USA. */ -+ -+#include -+#include -+#include -+#include -+ -+#include -+#include -+ -+static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; -+static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; -+static const float threehalf = 1.5; -+ -+/* The method is based on the descriptions in: -+ -+ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; -+ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 -+ -+ We find the reciprocal square root and use that to compute the actual -+ square root. */ -+ -+#ifdef __STDC__ -+float -+__ieee754_sqrtf (float b) -+#else -+float -+__ieee754_sqrtf (b) -+ float b; -+#endif -+{ -+ if (__builtin_expect (b > 0, 1)) -+ { -+#define FMSUB(a_, c_, b_) \ -+ ({ double __r; \ -+ __asm__ ("fmsub %[r], %[a], %[c], %[b]\n" \ -+ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ -+ __r;}) -+#define FNMSUB(a_, c_, b_) \ -+ ({ double __r; \ -+ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ -+ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ -+ __r;}) -+ -+ if (__builtin_expect (b != a_inf.value, 1)) -+ { -+ double y, x; -+ fenv_t fe; -+ -+ fe = fegetenv_register (); -+ -+ relax_fenv_state (); -+ -+ /* Compute y = 1.5 * b - b. Uses fewer constants than y = 0.5 * b. */ -+ y = FMSUB (threehalf, b, b); -+ -+ /* Initial estimate. */ -+ __asm__ ("frsqrte %[x], %[b]\n" : [x] "=f" (x) : [b] "f" (b)); -+ -+ /* Iterate. x_{n+1} = x_n * (1.5 - y * (x_n * x_n)). */ -+ x = x * FNMSUB (y, x * x, threehalf); -+ x = x * FNMSUB (y, x * x, threehalf); -+ x = x * FNMSUB (y, x * x, threehalf); -+ -+ /* All done. */ -+ fesetenv_register (fe); -+ return x * b; -+ } -+ } -+ else if (b < 0) -+ { -+ /* For some reason, some PowerPC32 processors don't implement -+ FE_INVALID_SQRT. */ -+#ifdef FE_INVALID_SQRT -+ feraiseexcept (FE_INVALID_SQRT); -+ -+ fenv_union_t u = { .fenv = fegetenv_register () }; -+ if ((u.l & FE_INVALID) == 0) -+#endif -+ feraiseexcept (FE_INVALID); -+ b = a_nan.value; -+ } -+ return f_washf (b); -+} -diff --git a/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c -new file mode 100644 -index 0000000000..71e516d1c8 ---- /dev/null -+++ b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c -@@ -0,0 +1,134 @@ -+/* Double-precision floating point square root. -+ Copyright (C) 2010 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, write to the Free -+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -+ 02111-1307 USA. */ -+ -+#include -+#include -+#include -+#include -+ -+#include -+#include -+ -+static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; -+static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; -+static const float two108 = 3.245185536584267269e+32; -+static const float twom54 = 5.551115123125782702e-17; -+static const float half = 0.5; -+ -+/* The method is based on the descriptions in: -+ -+ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; -+ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 -+ -+ We find the actual square root and half of its reciprocal -+ simultaneously. */ -+ -+#ifdef __STDC__ -+double -+__ieee754_sqrt (double b) -+#else -+double -+__ieee754_sqrt (b) -+ double b; -+#endif -+{ -+ if (__builtin_expect (b > 0, 1)) -+ { -+ double y, g, h, d, r; -+ ieee_double_shape_type u; -+ -+ if (__builtin_expect (b != a_inf.value, 1)) -+ { -+ fenv_t fe; -+ -+ fe = fegetenv_register (); -+ -+ u.value = b; -+ -+ relax_fenv_state (); -+ -+ __asm__ ("frsqrte %[estimate], %[x]\n" -+ : [estimate] "=f" (y) : [x] "f" (b)); -+ -+ /* Following Muller et al, page 168, equation 5.20. -+ -+ h goes to 1/(2*sqrt(b)) -+ g goes to sqrt(b). -+ -+ We need three iterations to get within 1ulp. */ -+ -+ /* Indicate that these can be performed prior to the branch. GCC -+ insists on sinking them below the branch, however; it seems like -+ they'd be better before the branch so that we can cover any latency -+ from storing the argument and loading its high word. Oh well. */ -+ -+ g = b * y; -+ h = 0.5 * y; -+ -+ /* Handle small numbers by scaling. */ -+ if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) -+ return __ieee754_sqrt (b * two108) * twom54; -+ -+#define FMADD(a_, c_, b_) \ -+ ({ double __r; \ -+ __asm__ ("fmadd %[r], %[a], %[c], %[b]\n" \ -+ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ -+ __r;}) -+#define FNMSUB(a_, c_, b_) \ -+ ({ double __r; \ -+ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ -+ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ -+ __r;}) -+ -+ r = FNMSUB (g, h, half); -+ g = FMADD (g, r, g); -+ h = FMADD (h, r, h); -+ -+ r = FNMSUB (g, h, half); -+ g = FMADD (g, r, g); -+ h = FMADD (h, r, h); -+ -+ r = FNMSUB (g, h, half); -+ g = FMADD (g, r, g); -+ h = FMADD (h, r, h); -+ -+ /* g is now +/- 1ulp, or exactly equal to, the square root of b. */ -+ -+ /* Final refinement. */ -+ d = FNMSUB (g, g, b); -+ -+ fesetenv_register (fe); -+ return FMADD (d, h, g); -+ } -+ } -+ else if (b < 0) -+ { -+ /* For some reason, some PowerPC32 processors don't implement -+ FE_INVALID_SQRT. */ -+#ifdef FE_INVALID_SQRT -+ feraiseexcept (FE_INVALID_SQRT); -+ -+ fenv_union_t u = { .fenv = fegetenv_register () }; -+ if ((u.l & FE_INVALID) == 0) -+#endif -+ feraiseexcept (FE_INVALID); -+ b = a_nan.value; -+ } -+ return f_wash (b); -+} -diff --git a/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c -new file mode 100644 -index 0000000000..26fa067abf ---- /dev/null -+++ b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c -@@ -0,0 +1,101 @@ -+/* Single-precision floating point square root. -+ Copyright (C) 2010 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, write to the Free -+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -+ 02111-1307 USA. */ -+ -+#include -+#include -+#include -+#include -+ -+#include -+#include -+ -+static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; -+static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; -+static const float threehalf = 1.5; -+ -+/* The method is based on the descriptions in: -+ -+ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; -+ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 -+ -+ We find the reciprocal square root and use that to compute the actual -+ square root. */ -+ -+#ifdef __STDC__ -+float -+__ieee754_sqrtf (float b) -+#else -+float -+__ieee754_sqrtf (b) -+ float b; -+#endif -+{ -+ if (__builtin_expect (b > 0, 1)) -+ { -+#define FMSUB(a_, c_, b_) \ -+ ({ double __r; \ -+ __asm__ ("fmsub %[r], %[a], %[c], %[b]\n" \ -+ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ -+ __r;}) -+#define FNMSUB(a_, c_, b_) \ -+ ({ double __r; \ -+ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ -+ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ -+ __r;}) -+ -+ if (__builtin_expect (b != a_inf.value, 1)) -+ { -+ double y, x; -+ fenv_t fe; -+ -+ fe = fegetenv_register (); -+ -+ relax_fenv_state (); -+ -+ /* Compute y = 1.5 * b - b. Uses fewer constants than y = 0.5 * b. */ -+ y = FMSUB (threehalf, b, b); -+ -+ /* Initial estimate. */ -+ __asm__ ("frsqrte %[x], %[b]\n" : [x] "=f" (x) : [b] "f" (b)); -+ -+ /* Iterate. x_{n+1} = x_n * (1.5 - y * (x_n * x_n)). */ -+ x = x * FNMSUB (y, x * x, threehalf); -+ x = x * FNMSUB (y, x * x, threehalf); -+ x = x * FNMSUB (y, x * x, threehalf); -+ -+ /* All done. */ -+ fesetenv_register (fe); -+ return x * b; -+ } -+ } -+ else if (b < 0) -+ { -+ /* For some reason, some PowerPC32 processors don't implement -+ FE_INVALID_SQRT. */ -+#ifdef FE_INVALID_SQRT -+ feraiseexcept (FE_INVALID_SQRT); -+ -+ fenv_union_t u = { .fenv = fegetenv_register () }; -+ if ((u.l & FE_INVALID) == 0) -+#endif -+ feraiseexcept (FE_INVALID); -+ b = a_nan.value; -+ } -+ return f_washf (b); -+} -diff --git a/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c -new file mode 100644 -index 0000000000..71e516d1c8 ---- /dev/null -+++ b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c -@@ -0,0 +1,134 @@ -+/* Double-precision floating point square root. -+ Copyright (C) 2010 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, write to the Free -+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -+ 02111-1307 USA. */ -+ -+#include -+#include -+#include -+#include -+ -+#include -+#include -+ -+static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; -+static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; -+static const float two108 = 3.245185536584267269e+32; -+static const float twom54 = 5.551115123125782702e-17; -+static const float half = 0.5; -+ -+/* The method is based on the descriptions in: -+ -+ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; -+ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 -+ -+ We find the actual square root and half of its reciprocal -+ simultaneously. */ -+ -+#ifdef __STDC__ -+double -+__ieee754_sqrt (double b) -+#else -+double -+__ieee754_sqrt (b) -+ double b; -+#endif -+{ -+ if (__builtin_expect (b > 0, 1)) -+ { -+ double y, g, h, d, r; -+ ieee_double_shape_type u; -+ -+ if (__builtin_expect (b != a_inf.value, 1)) -+ { -+ fenv_t fe; -+ -+ fe = fegetenv_register (); -+ -+ u.value = b; -+ -+ relax_fenv_state (); -+ -+ __asm__ ("frsqrte %[estimate], %[x]\n" -+ : [estimate] "=f" (y) : [x] "f" (b)); -+ -+ /* Following Muller et al, page 168, equation 5.20. -+ -+ h goes to 1/(2*sqrt(b)) -+ g goes to sqrt(b). -+ -+ We need three iterations to get within 1ulp. */ -+ -+ /* Indicate that these can be performed prior to the branch. GCC -+ insists on sinking them below the branch, however; it seems like -+ they'd be better before the branch so that we can cover any latency -+ from storing the argument and loading its high word. Oh well. */ -+ -+ g = b * y; -+ h = 0.5 * y; -+ -+ /* Handle small numbers by scaling. */ -+ if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) -+ return __ieee754_sqrt (b * two108) * twom54; -+ -+#define FMADD(a_, c_, b_) \ -+ ({ double __r; \ -+ __asm__ ("fmadd %[r], %[a], %[c], %[b]\n" \ -+ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ -+ __r;}) -+#define FNMSUB(a_, c_, b_) \ -+ ({ double __r; \ -+ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ -+ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ -+ __r;}) -+ -+ r = FNMSUB (g, h, half); -+ g = FMADD (g, r, g); -+ h = FMADD (h, r, h); -+ -+ r = FNMSUB (g, h, half); -+ g = FMADD (g, r, g); -+ h = FMADD (h, r, h); -+ -+ r = FNMSUB (g, h, half); -+ g = FMADD (g, r, g); -+ h = FMADD (h, r, h); -+ -+ /* g is now +/- 1ulp, or exactly equal to, the square root of b. */ -+ -+ /* Final refinement. */ -+ d = FNMSUB (g, g, b); -+ -+ fesetenv_register (fe); -+ return FMADD (d, h, g); -+ } -+ } -+ else if (b < 0) -+ { -+ /* For some reason, some PowerPC32 processors don't implement -+ FE_INVALID_SQRT. */ -+#ifdef FE_INVALID_SQRT -+ feraiseexcept (FE_INVALID_SQRT); -+ -+ fenv_union_t u = { .fenv = fegetenv_register () }; -+ if ((u.l & FE_INVALID) == 0) -+#endif -+ feraiseexcept (FE_INVALID); -+ b = a_nan.value; -+ } -+ return f_wash (b); -+} -diff --git a/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c -new file mode 100644 -index 0000000000..26fa067abf ---- /dev/null -+++ b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c -@@ -0,0 +1,101 @@ -+/* Single-precision floating point square root. -+ Copyright (C) 2010 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, write to the Free -+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -+ 02111-1307 USA. */ -+ -+#include -+#include -+#include -+#include -+ -+#include -+#include -+ -+static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; -+static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; -+static const float threehalf = 1.5; -+ -+/* The method is based on the descriptions in: -+ -+ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; -+ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 -+ -+ We find the reciprocal square root and use that to compute the actual -+ square root. */ -+ -+#ifdef __STDC__ -+float -+__ieee754_sqrtf (float b) -+#else -+float -+__ieee754_sqrtf (b) -+ float b; -+#endif -+{ -+ if (__builtin_expect (b > 0, 1)) -+ { -+#define FMSUB(a_, c_, b_) \ -+ ({ double __r; \ -+ __asm__ ("fmsub %[r], %[a], %[c], %[b]\n" \ -+ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ -+ __r;}) -+#define FNMSUB(a_, c_, b_) \ -+ ({ double __r; \ -+ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ -+ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ -+ __r;}) -+ -+ if (__builtin_expect (b != a_inf.value, 1)) -+ { -+ double y, x; -+ fenv_t fe; -+ -+ fe = fegetenv_register (); -+ -+ relax_fenv_state (); -+ -+ /* Compute y = 1.5 * b - b. Uses fewer constants than y = 0.5 * b. */ -+ y = FMSUB (threehalf, b, b); -+ -+ /* Initial estimate. */ -+ __asm__ ("frsqrte %[x], %[b]\n" : [x] "=f" (x) : [b] "f" (b)); -+ -+ /* Iterate. x_{n+1} = x_n * (1.5 - y * (x_n * x_n)). */ -+ x = x * FNMSUB (y, x * x, threehalf); -+ x = x * FNMSUB (y, x * x, threehalf); -+ x = x * FNMSUB (y, x * x, threehalf); -+ -+ /* All done. */ -+ fesetenv_register (fe); -+ return x * b; -+ } -+ } -+ else if (b < 0) -+ { -+ /* For some reason, some PowerPC32 processors don't implement -+ FE_INVALID_SQRT. */ -+#ifdef FE_INVALID_SQRT -+ feraiseexcept (FE_INVALID_SQRT); -+ -+ fenv_union_t u = { .fenv = fegetenv_register () }; -+ if ((u.l & FE_INVALID) == 0) -+#endif -+ feraiseexcept (FE_INVALID); -+ b = a_nan.value; -+ } -+ return f_washf (b); -+} -diff --git a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c -new file mode 100644 -index 0000000000..71e516d1c8 ---- /dev/null -+++ b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c -@@ -0,0 +1,134 @@ -+/* Double-precision floating point square root. -+ Copyright (C) 2010 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, write to the Free -+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -+ 02111-1307 USA. */ -+ -+#include -+#include -+#include -+#include -+ -+#include -+#include -+ -+static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; -+static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; -+static const float two108 = 3.245185536584267269e+32; -+static const float twom54 = 5.551115123125782702e-17; -+static const float half = 0.5; -+ -+/* The method is based on the descriptions in: -+ -+ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; -+ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 -+ -+ We find the actual square root and half of its reciprocal -+ simultaneously. */ -+ -+#ifdef __STDC__ -+double -+__ieee754_sqrt (double b) -+#else -+double -+__ieee754_sqrt (b) -+ double b; -+#endif -+{ -+ if (__builtin_expect (b > 0, 1)) -+ { -+ double y, g, h, d, r; -+ ieee_double_shape_type u; -+ -+ if (__builtin_expect (b != a_inf.value, 1)) -+ { -+ fenv_t fe; -+ -+ fe = fegetenv_register (); -+ -+ u.value = b; -+ -+ relax_fenv_state (); -+ -+ __asm__ ("frsqrte %[estimate], %[x]\n" -+ : [estimate] "=f" (y) : [x] "f" (b)); -+ -+ /* Following Muller et al, page 168, equation 5.20. -+ -+ h goes to 1/(2*sqrt(b)) -+ g goes to sqrt(b). -+ -+ We need three iterations to get within 1ulp. */ -+ -+ /* Indicate that these can be performed prior to the branch. GCC -+ insists on sinking them below the branch, however; it seems like -+ they'd be better before the branch so that we can cover any latency -+ from storing the argument and loading its high word. Oh well. */ -+ -+ g = b * y; -+ h = 0.5 * y; -+ -+ /* Handle small numbers by scaling. */ -+ if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) -+ return __ieee754_sqrt (b * two108) * twom54; -+ -+#define FMADD(a_, c_, b_) \ -+ ({ double __r; \ -+ __asm__ ("fmadd %[r], %[a], %[c], %[b]\n" \ -+ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ -+ __r;}) -+#define FNMSUB(a_, c_, b_) \ -+ ({ double __r; \ -+ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ -+ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ -+ __r;}) -+ -+ r = FNMSUB (g, h, half); -+ g = FMADD (g, r, g); -+ h = FMADD (h, r, h); -+ -+ r = FNMSUB (g, h, half); -+ g = FMADD (g, r, g); -+ h = FMADD (h, r, h); -+ -+ r = FNMSUB (g, h, half); -+ g = FMADD (g, r, g); -+ h = FMADD (h, r, h); -+ -+ /* g is now +/- 1ulp, or exactly equal to, the square root of b. */ -+ -+ /* Final refinement. */ -+ d = FNMSUB (g, g, b); -+ -+ fesetenv_register (fe); -+ return FMADD (d, h, g); -+ } -+ } -+ else if (b < 0) -+ { -+ /* For some reason, some PowerPC32 processors don't implement -+ FE_INVALID_SQRT. */ -+#ifdef FE_INVALID_SQRT -+ feraiseexcept (FE_INVALID_SQRT); -+ -+ fenv_union_t u = { .fenv = fegetenv_register () }; -+ if ((u.l & FE_INVALID) == 0) -+#endif -+ feraiseexcept (FE_INVALID); -+ b = a_nan.value; -+ } -+ return f_wash (b); -+} -diff --git a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c -new file mode 100644 -index 0000000000..26fa067abf ---- /dev/null -+++ b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c -@@ -0,0 +1,101 @@ -+/* Single-precision floating point square root. -+ Copyright (C) 2010 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, write to the Free -+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -+ 02111-1307 USA. */ -+ -+#include -+#include -+#include -+#include -+ -+#include -+#include -+ -+static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; -+static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; -+static const float threehalf = 1.5; -+ -+/* The method is based on the descriptions in: -+ -+ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; -+ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 -+ -+ We find the reciprocal square root and use that to compute the actual -+ square root. */ -+ -+#ifdef __STDC__ -+float -+__ieee754_sqrtf (float b) -+#else -+float -+__ieee754_sqrtf (b) -+ float b; -+#endif -+{ -+ if (__builtin_expect (b > 0, 1)) -+ { -+#define FMSUB(a_, c_, b_) \ -+ ({ double __r; \ -+ __asm__ ("fmsub %[r], %[a], %[c], %[b]\n" \ -+ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ -+ __r;}) -+#define FNMSUB(a_, c_, b_) \ -+ ({ double __r; \ -+ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ -+ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ -+ __r;}) -+ -+ if (__builtin_expect (b != a_inf.value, 1)) -+ { -+ double y, x; -+ fenv_t fe; -+ -+ fe = fegetenv_register (); -+ -+ relax_fenv_state (); -+ -+ /* Compute y = 1.5 * b - b. Uses fewer constants than y = 0.5 * b. */ -+ y = FMSUB (threehalf, b, b); -+ -+ /* Initial estimate. */ -+ __asm__ ("frsqrte %[x], %[b]\n" : [x] "=f" (x) : [b] "f" (b)); -+ -+ /* Iterate. x_{n+1} = x_n * (1.5 - y * (x_n * x_n)). */ -+ x = x * FNMSUB (y, x * x, threehalf); -+ x = x * FNMSUB (y, x * x, threehalf); -+ x = x * FNMSUB (y, x * x, threehalf); -+ -+ /* All done. */ -+ fesetenv_register (fe); -+ return x * b; -+ } -+ } -+ else if (b < 0) -+ { -+ /* For some reason, some PowerPC32 processors don't implement -+ FE_INVALID_SQRT. */ -+#ifdef FE_INVALID_SQRT -+ feraiseexcept (FE_INVALID_SQRT); -+ -+ fenv_union_t u = { .fenv = fegetenv_register () }; -+ if ((u.l & FE_INVALID) == 0) -+#endif -+ feraiseexcept (FE_INVALID); -+ b = a_nan.value; -+ } -+ return f_washf (b); -+} -diff --git a/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c -new file mode 100644 -index 0000000000..71e516d1c8 ---- /dev/null -+++ b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c -@@ -0,0 +1,134 @@ -+/* Double-precision floating point square root. -+ Copyright (C) 2010 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, write to the Free -+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -+ 02111-1307 USA. */ -+ -+#include -+#include -+#include -+#include -+ -+#include -+#include -+ -+static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; -+static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; -+static const float two108 = 3.245185536584267269e+32; -+static const float twom54 = 5.551115123125782702e-17; -+static const float half = 0.5; -+ -+/* The method is based on the descriptions in: -+ -+ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; -+ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 -+ -+ We find the actual square root and half of its reciprocal -+ simultaneously. */ -+ -+#ifdef __STDC__ -+double -+__ieee754_sqrt (double b) -+#else -+double -+__ieee754_sqrt (b) -+ double b; -+#endif -+{ -+ if (__builtin_expect (b > 0, 1)) -+ { -+ double y, g, h, d, r; -+ ieee_double_shape_type u; -+ -+ if (__builtin_expect (b != a_inf.value, 1)) -+ { -+ fenv_t fe; -+ -+ fe = fegetenv_register (); -+ -+ u.value = b; -+ -+ relax_fenv_state (); -+ -+ __asm__ ("frsqrte %[estimate], %[x]\n" -+ : [estimate] "=f" (y) : [x] "f" (b)); -+ -+ /* Following Muller et al, page 168, equation 5.20. -+ -+ h goes to 1/(2*sqrt(b)) -+ g goes to sqrt(b). -+ -+ We need three iterations to get within 1ulp. */ -+ -+ /* Indicate that these can be performed prior to the branch. GCC -+ insists on sinking them below the branch, however; it seems like -+ they'd be better before the branch so that we can cover any latency -+ from storing the argument and loading its high word. Oh well. */ -+ -+ g = b * y; -+ h = 0.5 * y; -+ -+ /* Handle small numbers by scaling. */ -+ if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) -+ return __ieee754_sqrt (b * two108) * twom54; -+ -+#define FMADD(a_, c_, b_) \ -+ ({ double __r; \ -+ __asm__ ("fmadd %[r], %[a], %[c], %[b]\n" \ -+ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ -+ __r;}) -+#define FNMSUB(a_, c_, b_) \ -+ ({ double __r; \ -+ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ -+ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ -+ __r;}) -+ -+ r = FNMSUB (g, h, half); -+ g = FMADD (g, r, g); -+ h = FMADD (h, r, h); -+ -+ r = FNMSUB (g, h, half); -+ g = FMADD (g, r, g); -+ h = FMADD (h, r, h); -+ -+ r = FNMSUB (g, h, half); -+ g = FMADD (g, r, g); -+ h = FMADD (h, r, h); -+ -+ /* g is now +/- 1ulp, or exactly equal to, the square root of b. */ -+ -+ /* Final refinement. */ -+ d = FNMSUB (g, g, b); -+ -+ fesetenv_register (fe); -+ return FMADD (d, h, g); -+ } -+ } -+ else if (b < 0) -+ { -+ /* For some reason, some PowerPC32 processors don't implement -+ FE_INVALID_SQRT. */ -+#ifdef FE_INVALID_SQRT -+ feraiseexcept (FE_INVALID_SQRT); -+ -+ fenv_union_t u = { .fenv = fegetenv_register () }; -+ if ((u.l & FE_INVALID) == 0) -+#endif -+ feraiseexcept (FE_INVALID); -+ b = a_nan.value; -+ } -+ return f_wash (b); -+} -diff --git a/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c -new file mode 100644 -index 0000000000..26fa067abf ---- /dev/null -+++ b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c -@@ -0,0 +1,101 @@ -+/* Single-precision floating point square root. -+ Copyright (C) 2010 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, write to the Free -+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -+ 02111-1307 USA. */ -+ -+#include -+#include -+#include -+#include -+ -+#include -+#include -+ -+static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; -+static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; -+static const float threehalf = 1.5; -+ -+/* The method is based on the descriptions in: -+ -+ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; -+ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 -+ -+ We find the reciprocal square root and use that to compute the actual -+ square root. */ -+ -+#ifdef __STDC__ -+float -+__ieee754_sqrtf (float b) -+#else -+float -+__ieee754_sqrtf (b) -+ float b; -+#endif -+{ -+ if (__builtin_expect (b > 0, 1)) -+ { -+#define FMSUB(a_, c_, b_) \ -+ ({ double __r; \ -+ __asm__ ("fmsub %[r], %[a], %[c], %[b]\n" \ -+ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ -+ __r;}) -+#define FNMSUB(a_, c_, b_) \ -+ ({ double __r; \ -+ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ -+ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ -+ __r;}) -+ -+ if (__builtin_expect (b != a_inf.value, 1)) -+ { -+ double y, x; -+ fenv_t fe; -+ -+ fe = fegetenv_register (); -+ -+ relax_fenv_state (); -+ -+ /* Compute y = 1.5 * b - b. Uses fewer constants than y = 0.5 * b. */ -+ y = FMSUB (threehalf, b, b); -+ -+ /* Initial estimate. */ -+ __asm__ ("frsqrte %[x], %[b]\n" : [x] "=f" (x) : [b] "f" (b)); -+ -+ /* Iterate. x_{n+1} = x_n * (1.5 - y * (x_n * x_n)). */ -+ x = x * FNMSUB (y, x * x, threehalf); -+ x = x * FNMSUB (y, x * x, threehalf); -+ x = x * FNMSUB (y, x * x, threehalf); -+ -+ /* All done. */ -+ fesetenv_register (fe); -+ return x * b; -+ } -+ } -+ else if (b < 0) -+ { -+ /* For some reason, some PowerPC32 processors don't implement -+ FE_INVALID_SQRT. */ -+#ifdef FE_INVALID_SQRT -+ feraiseexcept (FE_INVALID_SQRT); -+ -+ fenv_union_t u = { .fenv = fegetenv_register () }; -+ if ((u.l & FE_INVALID) == 0) -+#endif -+ feraiseexcept (FE_INVALID); -+ b = a_nan.value; -+ } -+ return f_washf (b); -+} -diff --git a/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c -new file mode 100644 -index 0000000000..71e516d1c8 ---- /dev/null -+++ b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c -@@ -0,0 +1,134 @@ -+/* Double-precision floating point square root. -+ Copyright (C) 2010 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, write to the Free -+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -+ 02111-1307 USA. */ -+ -+#include -+#include -+#include -+#include -+ -+#include -+#include -+ -+static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; -+static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; -+static const float two108 = 3.245185536584267269e+32; -+static const float twom54 = 5.551115123125782702e-17; -+static const float half = 0.5; -+ -+/* The method is based on the descriptions in: -+ -+ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; -+ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 -+ -+ We find the actual square root and half of its reciprocal -+ simultaneously. */ -+ -+#ifdef __STDC__ -+double -+__ieee754_sqrt (double b) -+#else -+double -+__ieee754_sqrt (b) -+ double b; -+#endif -+{ -+ if (__builtin_expect (b > 0, 1)) -+ { -+ double y, g, h, d, r; -+ ieee_double_shape_type u; -+ -+ if (__builtin_expect (b != a_inf.value, 1)) -+ { -+ fenv_t fe; -+ -+ fe = fegetenv_register (); -+ -+ u.value = b; -+ -+ relax_fenv_state (); -+ -+ __asm__ ("frsqrte %[estimate], %[x]\n" -+ : [estimate] "=f" (y) : [x] "f" (b)); -+ -+ /* Following Muller et al, page 168, equation 5.20. -+ -+ h goes to 1/(2*sqrt(b)) -+ g goes to sqrt(b). -+ -+ We need three iterations to get within 1ulp. */ -+ -+ /* Indicate that these can be performed prior to the branch. GCC -+ insists on sinking them below the branch, however; it seems like -+ they'd be better before the branch so that we can cover any latency -+ from storing the argument and loading its high word. Oh well. */ -+ -+ g = b * y; -+ h = 0.5 * y; -+ -+ /* Handle small numbers by scaling. */ -+ if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) -+ return __ieee754_sqrt (b * two108) * twom54; -+ -+#define FMADD(a_, c_, b_) \ -+ ({ double __r; \ -+ __asm__ ("fmadd %[r], %[a], %[c], %[b]\n" \ -+ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ -+ __r;}) -+#define FNMSUB(a_, c_, b_) \ -+ ({ double __r; \ -+ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ -+ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ -+ __r;}) -+ -+ r = FNMSUB (g, h, half); -+ g = FMADD (g, r, g); -+ h = FMADD (h, r, h); -+ -+ r = FNMSUB (g, h, half); -+ g = FMADD (g, r, g); -+ h = FMADD (h, r, h); -+ -+ r = FNMSUB (g, h, half); -+ g = FMADD (g, r, g); -+ h = FMADD (h, r, h); -+ -+ /* g is now +/- 1ulp, or exactly equal to, the square root of b. */ -+ -+ /* Final refinement. */ -+ d = FNMSUB (g, g, b); -+ -+ fesetenv_register (fe); -+ return FMADD (d, h, g); -+ } -+ } -+ else if (b < 0) -+ { -+ /* For some reason, some PowerPC32 processors don't implement -+ FE_INVALID_SQRT. */ -+#ifdef FE_INVALID_SQRT -+ feraiseexcept (FE_INVALID_SQRT); -+ -+ fenv_union_t u = { .fenv = fegetenv_register () }; -+ if ((u.l & FE_INVALID) == 0) -+#endif -+ feraiseexcept (FE_INVALID); -+ b = a_nan.value; -+ } -+ return f_wash (b); -+} -diff --git a/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c -new file mode 100644 -index 0000000000..26fa067abf ---- /dev/null -+++ b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c -@@ -0,0 +1,101 @@ -+/* Single-precision floating point square root. -+ Copyright (C) 2010 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, write to the Free -+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -+ 02111-1307 USA. */ -+ -+#include -+#include -+#include -+#include -+ -+#include -+#include -+ -+static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; -+static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; -+static const float threehalf = 1.5; -+ -+/* The method is based on the descriptions in: -+ -+ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; -+ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 -+ -+ We find the reciprocal square root and use that to compute the actual -+ square root. */ -+ -+#ifdef __STDC__ -+float -+__ieee754_sqrtf (float b) -+#else -+float -+__ieee754_sqrtf (b) -+ float b; -+#endif -+{ -+ if (__builtin_expect (b > 0, 1)) -+ { -+#define FMSUB(a_, c_, b_) \ -+ ({ double __r; \ -+ __asm__ ("fmsub %[r], %[a], %[c], %[b]\n" \ -+ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ -+ __r;}) -+#define FNMSUB(a_, c_, b_) \ -+ ({ double __r; \ -+ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ -+ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ -+ __r;}) -+ -+ if (__builtin_expect (b != a_inf.value, 1)) -+ { -+ double y, x; -+ fenv_t fe; -+ -+ fe = fegetenv_register (); -+ -+ relax_fenv_state (); -+ -+ /* Compute y = 1.5 * b - b. Uses fewer constants than y = 0.5 * b. */ -+ y = FMSUB (threehalf, b, b); -+ -+ /* Initial estimate. */ -+ __asm__ ("frsqrte %[x], %[b]\n" : [x] "=f" (x) : [b] "f" (b)); -+ -+ /* Iterate. x_{n+1} = x_n * (1.5 - y * (x_n * x_n)). */ -+ x = x * FNMSUB (y, x * x, threehalf); -+ x = x * FNMSUB (y, x * x, threehalf); -+ x = x * FNMSUB (y, x * x, threehalf); -+ -+ /* All done. */ -+ fesetenv_register (fe); -+ return x * b; -+ } -+ } -+ else if (b < 0) -+ { -+ /* For some reason, some PowerPC32 processors don't implement -+ FE_INVALID_SQRT. */ -+#ifdef FE_INVALID_SQRT -+ feraiseexcept (FE_INVALID_SQRT); -+ -+ fenv_union_t u = { .fenv = fegetenv_register () }; -+ if ((u.l & FE_INVALID) == 0) -+#endif -+ feraiseexcept (FE_INVALID); -+ b = a_nan.value; -+ } -+ return f_washf (b); -+} -diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/603e/fpu/Implies b/sysdeps/unix/sysv/linux/powerpc/powerpc32/603e/fpu/Implies -new file mode 100644 -index 0000000000..b103b4dea5 ---- /dev/null -+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/603e/fpu/Implies -@@ -0,0 +1 @@ -+powerpc/powerpc32/603e/fpu -diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/e300c3/fpu/Implies b/sysdeps/unix/sysv/linux/powerpc/powerpc32/e300c3/fpu/Implies -new file mode 100644 -index 0000000000..64db17fada ---- /dev/null -+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/e300c3/fpu/Implies -@@ -0,0 +1,2 @@ -+# e300c3 is a variant of 603e so use the same optimizations for sqrt -+powerpc/powerpc32/603e/fpu -diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/e500mc/fpu/Implies b/sysdeps/unix/sysv/linux/powerpc/powerpc32/e500mc/fpu/Implies -new file mode 100644 -index 0000000000..7eac5fcf02 ---- /dev/null -+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/e500mc/fpu/Implies -@@ -0,0 +1 @@ -+powerpc/powerpc32/e500mc/fpu -diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/e5500/fpu/Implies b/sysdeps/unix/sysv/linux/powerpc/powerpc32/e5500/fpu/Implies -new file mode 100644 -index 0000000000..264b2a7700 ---- /dev/null -+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/e5500/fpu/Implies -@@ -0,0 +1 @@ -+powerpc/powerpc32/e5500/fpu -diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/e6500/fpu/Implies b/sysdeps/unix/sysv/linux/powerpc/powerpc32/e6500/fpu/Implies -new file mode 100644 -index 0000000000..a25934467b ---- /dev/null -+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/e6500/fpu/Implies -@@ -0,0 +1 @@ -+powerpc/powerpc32/e6500/fpu -diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/e5500/fpu/Implies b/sysdeps/unix/sysv/linux/powerpc/powerpc64/e5500/fpu/Implies -new file mode 100644 -index 0000000000..a7bc854be8 ---- /dev/null -+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/e5500/fpu/Implies -@@ -0,0 +1 @@ -+powerpc/powerpc64/e5500/fpu -diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/e6500/fpu/Implies b/sysdeps/unix/sysv/linux/powerpc/powerpc64/e6500/fpu/Implies -new file mode 100644 -index 0000000000..04ff8cc181 ---- /dev/null -+++ 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/0006-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 new file mode 100644 index 0000000000..0d070a93b9 --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0006-nativesdk-glibc-Allow-64-bit-atomics-for-x86.patch @@ -0,0 +1,39 @@ +From f9993e652bd4a0f03402d0c527cf24b83d0ff7ea Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Thu, 31 Dec 2015 14:35:35 -0800 +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. +It also makes the synchronization more efficient. + +Upstream-Status: Inappropriate [OE-Specific] + +Signed-off-by: Juro Bystricky +Signed-off-by: Richard Purdie +Signed-off-by: Khem Raj +--- + sysdeps/x86/atomic-machine.h | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/sysdeps/x86/atomic-machine.h b/sysdeps/x86/atomic-machine.h +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; + #endif + + #define USE_ATOMIC_COMPILER_BUILTINS 1 ++# define __HAVE_64B_ATOMICS 1 + + #ifdef __x86_64__ +-# define __HAVE_64B_ATOMICS 1 + # define SP_REG "rsp" + # define SEG_REG "fs" + # define BR_CONSTRAINT "q" + # define IBR_CONSTRAINT "iq" + #else +-# define __HAVE_64B_ATOMICS 0 + # define SP_REG "esp" + # define SEG_REG "gs" + # define BR_CONSTRAINT "r" diff --git a/meta/recipes-core/glibc/glibc/0007-nativesdk-glibc-Make-relocatable-install-for-locales.patch b/meta/recipes-core/glibc/glibc/0007-nativesdk-glibc-Make-relocatable-install-for-locales.patch new file mode 100644 index 0000000000..66abcce3ce --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0007-nativesdk-glibc-Make-relocatable-install-for-locales.patch @@ -0,0 +1,67 @@ +From ee9d5e423e4a709ae5a62abfb476863b3b57378f Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Fri, 3 Aug 2018 09:55:12 -0700 +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 +magic segment that we can relocate at install time. + +Upstream-Status: Inappropriate (OE-specific) + +Signed-off-by: Ross Burton +Signed-off-by: Khem Raj +--- + locale/findlocale.c | 4 ++-- + locale/loadarchive.c | 2 +- + locale/localeinfo.h | 2 +- + 3 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/locale/findlocale.c b/locale/findlocale.c +index 9cd3b71a6d..84272310e0 100644 +--- a/locale/findlocale.c ++++ b/locale/findlocale.c +@@ -56,7 +56,7 @@ struct __locale_data *const _nl_C[] attribute_hidden = + which are somehow addressed. */ + struct loaded_l10nfile *_nl_locale_file_list[__LC_LAST]; + +-const char _nl_default_locale_path[] attribute_hidden = COMPLOCALEDIR; ++char _nl_default_locale_path[4096] attribute_hidden __attribute__ ((section (".gccrelocprefix"))) = COMPLOCALEDIR; + + /* Checks if the name is actually present, that is, not NULL and not + empty. */ +@@ -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; +- locale_path_len = sizeof _nl_default_locale_path; ++ locale_path_len = strlen(locale_path) + 1; + } + 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 ba0fe45648..9737fd4cda 100644 +--- a/locale/loadarchive.c ++++ b/locale/loadarchive.c +@@ -42,7 +42,7 @@ + + + /* Name of the locale archive file. */ +-static const char archfname[] = COMPLOCALEDIR "/locale-archive"; ++static const char archfname[4096] __attribute__ ((section (".gccrelocprefix"))) = COMPLOCALEDIR "/locale-archive"; + + /* 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 1bfe22aa7f..fdc283c69a 100644 +--- a/locale/localeinfo.h ++++ b/locale/localeinfo.h +@@ -331,7 +331,7 @@ _nl_lookup_word (locale_t l, int category, int item) + } + + /* Default search path if no LOCPATH environment variable. */ +-extern const char _nl_default_locale_path[] attribute_hidden; ++extern char _nl_default_locale_path[4096] attribute_hidden; + + /* Load the locale data for CATEGORY from the file specified by *NAME. + If *NAME is "", use environment variables as specified by POSIX, and diff --git a/meta/recipes-core/glibc/glibc/0007-readlib-Add-OECORE_KNOWN_INTERPRETER_NAMES-to-known-.patch b/meta/recipes-core/glibc/glibc/0007-readlib-Add-OECORE_KNOWN_INTERPRETER_NAMES-to-known-.patch deleted file mode 100644 index ae6fb268a5..0000000000 --- a/meta/recipes-core/glibc/glibc/0007-readlib-Add-OECORE_KNOWN_INTERPRETER_NAMES-to-known-.patch +++ /dev/null @@ -1,33 +0,0 @@ -From dc715f6c70d01e9c3b31c1825fa5bc447967c847 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Wed, 18 Mar 2015 00:11:22 +0000 -Subject: [PATCH 07/28] 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 -other distros - -Upstream-Status: Inappropriate [OE specific] - -Signed-off-by: Lianhao Lu -Signed-off-by: Khem Raj ---- - elf/readlib.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/elf/readlib.c b/elf/readlib.c -index c9743e6692..6307f918fc 100644 ---- a/elf/readlib.c -+++ b/elf/readlib.c -@@ -51,6 +51,7 @@ static struct known_names interpreters[] = - #ifdef SYSDEP_KNOWN_INTERPRETER_NAMES - SYSDEP_KNOWN_INTERPRETER_NAMES - #endif -+ OECORE_KNOWN_INTERPRETER_NAMES - }; - - static struct known_names known_libs[] = --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0008-fsl-e500-e5500-e6500-603e-fsqrt-implementation.patch b/meta/recipes-core/glibc/glibc/0008-fsl-e500-e5500-e6500-603e-fsqrt-implementation.patch new file mode 100644 index 0000000000..4f3ed38065 --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0008-fsl-e500-e5500-e6500-603e-fsqrt-implementation.patch @@ -0,0 +1,1581 @@ +From 2cc7b79157ce17144791dda1a2e3a6dc4902c736 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 18 Mar 2015 00:01:50 +0000 +Subject: [PATCH] fsl e500/e5500/e6500/603e fsqrt implementation + +Upstream-Status: Pending +Signed-off-by: Edmar Wienskoski +Signed-off-by: Khem Raj +--- + sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c | 134 ++++++++++++++++++ + sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c | 101 +++++++++++++ + sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c | 134 ++++++++++++++++++ + .../powerpc/powerpc32/e500mc/fpu/e_sqrtf.c | 101 +++++++++++++ + sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c | 134 ++++++++++++++++++ + sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c | 101 +++++++++++++ + sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c | 134 ++++++++++++++++++ + sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c | 101 +++++++++++++ + sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c | 134 ++++++++++++++++++ + sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c | 101 +++++++++++++ + sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c | 134 ++++++++++++++++++ + sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c | 101 +++++++++++++ + .../linux/powerpc/powerpc32/603e/fpu/Implies | 1 + + .../powerpc/powerpc32/e300c3/fpu/Implies | 2 + + .../powerpc/powerpc32/e500mc/fpu/Implies | 1 + + .../linux/powerpc/powerpc32/e5500/fpu/Implies | 1 + + .../linux/powerpc/powerpc32/e6500/fpu/Implies | 1 + + .../linux/powerpc/powerpc64/e5500/fpu/Implies | 1 + + .../linux/powerpc/powerpc64/e6500/fpu/Implies | 1 + + 19 files changed, 1418 insertions(+) + create mode 100644 sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c + create mode 100644 sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c + create mode 100644 sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c + create mode 100644 sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c + create mode 100644 sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c + create mode 100644 sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c + create mode 100644 sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c + create mode 100644 sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c + create mode 100644 sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c + create mode 100644 sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c + create mode 100644 sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c + create mode 100644 sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c + create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/603e/fpu/Implies + create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/e300c3/fpu/Implies + create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/e500mc/fpu/Implies + create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/e5500/fpu/Implies + create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/e6500/fpu/Implies + create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/e5500/fpu/Implies + create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/e6500/fpu/Implies + +diff --git a/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c +new file mode 100644 +index 0000000000..71e516d1c8 +--- /dev/null ++++ b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c +@@ -0,0 +1,134 @@ ++/* Double-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include ++#include ++#include ++#include ++ ++#include ++#include ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float two108 = 3.245185536584267269e+32; ++static const float twom54 = 5.551115123125782702e-17; ++static const float half = 0.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the actual square root and half of its reciprocal ++ simultaneously. */ ++ ++#ifdef __STDC__ ++double ++__ieee754_sqrt (double b) ++#else ++double ++__ieee754_sqrt (b) ++ double b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++ double y, g, h, d, r; ++ ieee_double_shape_type u; ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ u.value = b; ++ ++ relax_fenv_state (); ++ ++ __asm__ ("frsqrte %[estimate], %[x]\n" ++ : [estimate] "=f" (y) : [x] "f" (b)); ++ ++ /* Following Muller et al, page 168, equation 5.20. ++ ++ h goes to 1/(2*sqrt(b)) ++ g goes to sqrt(b). ++ ++ We need three iterations to get within 1ulp. */ ++ ++ /* Indicate that these can be performed prior to the branch. GCC ++ insists on sinking them below the branch, however; it seems like ++ they'd be better before the branch so that we can cover any latency ++ from storing the argument and loading its high word. Oh well. */ ++ ++ g = b * y; ++ h = 0.5 * y; ++ ++ /* Handle small numbers by scaling. */ ++ if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) ++ return __ieee754_sqrt (b * two108) * twom54; ++ ++#define FMADD(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmadd %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ /* g is now +/- 1ulp, or exactly equal to, the square root of b. */ ++ ++ /* Final refinement. */ ++ d = FNMSUB (g, g, b); ++ ++ fesetenv_register (fe); ++ return FMADD (d, h, g); ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_wash (b); ++} +diff --git a/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c +new file mode 100644 +index 0000000000..26fa067abf +--- /dev/null ++++ b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c +@@ -0,0 +1,101 @@ ++/* Single-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include ++#include ++#include ++#include ++ ++#include ++#include ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float threehalf = 1.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the reciprocal square root and use that to compute the actual ++ square root. */ ++ ++#ifdef __STDC__ ++float ++__ieee754_sqrtf (float b) ++#else ++float ++__ieee754_sqrtf (b) ++ float b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++#define FMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ double y, x; ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ relax_fenv_state (); ++ ++ /* Compute y = 1.5 * b - b. Uses fewer constants than y = 0.5 * b. */ ++ y = FMSUB (threehalf, b, b); ++ ++ /* Initial estimate. */ ++ __asm__ ("frsqrte %[x], %[b]\n" : [x] "=f" (x) : [b] "f" (b)); ++ ++ /* Iterate. x_{n+1} = x_n * (1.5 - y * (x_n * x_n)). */ ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ ++ /* All done. */ ++ fesetenv_register (fe); ++ return x * b; ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_washf (b); ++} +diff --git a/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c +new file mode 100644 +index 0000000000..71e516d1c8 +--- /dev/null ++++ b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c +@@ -0,0 +1,134 @@ ++/* Double-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include ++#include ++#include ++#include ++ ++#include ++#include ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float two108 = 3.245185536584267269e+32; ++static const float twom54 = 5.551115123125782702e-17; ++static const float half = 0.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the actual square root and half of its reciprocal ++ simultaneously. */ ++ ++#ifdef __STDC__ ++double ++__ieee754_sqrt (double b) ++#else ++double ++__ieee754_sqrt (b) ++ double b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++ double y, g, h, d, r; ++ ieee_double_shape_type u; ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ u.value = b; ++ ++ relax_fenv_state (); ++ ++ __asm__ ("frsqrte %[estimate], %[x]\n" ++ : [estimate] "=f" (y) : [x] "f" (b)); ++ ++ /* Following Muller et al, page 168, equation 5.20. ++ ++ h goes to 1/(2*sqrt(b)) ++ g goes to sqrt(b). ++ ++ We need three iterations to get within 1ulp. */ ++ ++ /* Indicate that these can be performed prior to the branch. GCC ++ insists on sinking them below the branch, however; it seems like ++ they'd be better before the branch so that we can cover any latency ++ from storing the argument and loading its high word. Oh well. */ ++ ++ g = b * y; ++ h = 0.5 * y; ++ ++ /* Handle small numbers by scaling. */ ++ if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) ++ return __ieee754_sqrt (b * two108) * twom54; ++ ++#define FMADD(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmadd %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ /* g is now +/- 1ulp, or exactly equal to, the square root of b. */ ++ ++ /* Final refinement. */ ++ d = FNMSUB (g, g, b); ++ ++ fesetenv_register (fe); ++ return FMADD (d, h, g); ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_wash (b); ++} +diff --git a/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c +new file mode 100644 +index 0000000000..26fa067abf +--- /dev/null ++++ b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c +@@ -0,0 +1,101 @@ ++/* Single-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include ++#include ++#include ++#include ++ ++#include ++#include ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float threehalf = 1.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the reciprocal square root and use that to compute the actual ++ square root. */ ++ ++#ifdef __STDC__ ++float ++__ieee754_sqrtf (float b) ++#else ++float ++__ieee754_sqrtf (b) ++ float b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++#define FMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ double y, x; ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ relax_fenv_state (); ++ ++ /* Compute y = 1.5 * b - b. Uses fewer constants than y = 0.5 * b. */ ++ y = FMSUB (threehalf, b, b); ++ ++ /* Initial estimate. */ ++ __asm__ ("frsqrte %[x], %[b]\n" : [x] "=f" (x) : [b] "f" (b)); ++ ++ /* Iterate. x_{n+1} = x_n * (1.5 - y * (x_n * x_n)). */ ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ ++ /* All done. */ ++ fesetenv_register (fe); ++ return x * b; ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_washf (b); ++} +diff --git a/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c +new file mode 100644 +index 0000000000..71e516d1c8 +--- /dev/null ++++ b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c +@@ -0,0 +1,134 @@ ++/* Double-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include ++#include ++#include ++#include ++ ++#include ++#include ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float two108 = 3.245185536584267269e+32; ++static const float twom54 = 5.551115123125782702e-17; ++static const float half = 0.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the actual square root and half of its reciprocal ++ simultaneously. */ ++ ++#ifdef __STDC__ ++double ++__ieee754_sqrt (double b) ++#else ++double ++__ieee754_sqrt (b) ++ double b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++ double y, g, h, d, r; ++ ieee_double_shape_type u; ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ u.value = b; ++ ++ relax_fenv_state (); ++ ++ __asm__ ("frsqrte %[estimate], %[x]\n" ++ : [estimate] "=f" (y) : [x] "f" (b)); ++ ++ /* Following Muller et al, page 168, equation 5.20. ++ ++ h goes to 1/(2*sqrt(b)) ++ g goes to sqrt(b). ++ ++ We need three iterations to get within 1ulp. */ ++ ++ /* Indicate that these can be performed prior to the branch. GCC ++ insists on sinking them below the branch, however; it seems like ++ they'd be better before the branch so that we can cover any latency ++ from storing the argument and loading its high word. Oh well. */ ++ ++ g = b * y; ++ h = 0.5 * y; ++ ++ /* Handle small numbers by scaling. */ ++ if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) ++ return __ieee754_sqrt (b * two108) * twom54; ++ ++#define FMADD(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmadd %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ /* g is now +/- 1ulp, or exactly equal to, the square root of b. */ ++ ++ /* Final refinement. */ ++ d = FNMSUB (g, g, b); ++ ++ fesetenv_register (fe); ++ return FMADD (d, h, g); ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_wash (b); ++} +diff --git a/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c +new file mode 100644 +index 0000000000..26fa067abf +--- /dev/null ++++ b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c +@@ -0,0 +1,101 @@ ++/* Single-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include ++#include ++#include ++#include ++ ++#include ++#include ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float threehalf = 1.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the reciprocal square root and use that to compute the actual ++ square root. */ ++ ++#ifdef __STDC__ ++float ++__ieee754_sqrtf (float b) ++#else ++float ++__ieee754_sqrtf (b) ++ float b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++#define FMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ double y, x; ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ relax_fenv_state (); ++ ++ /* Compute y = 1.5 * b - b. Uses fewer constants than y = 0.5 * b. */ ++ y = FMSUB (threehalf, b, b); ++ ++ /* Initial estimate. */ ++ __asm__ ("frsqrte %[x], %[b]\n" : [x] "=f" (x) : [b] "f" (b)); ++ ++ /* Iterate. x_{n+1} = x_n * (1.5 - y * (x_n * x_n)). */ ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ ++ /* All done. */ ++ fesetenv_register (fe); ++ return x * b; ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_washf (b); ++} +diff --git a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c +new file mode 100644 +index 0000000000..71e516d1c8 +--- /dev/null ++++ b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c +@@ -0,0 +1,134 @@ ++/* Double-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include ++#include ++#include ++#include ++ ++#include ++#include ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float two108 = 3.245185536584267269e+32; ++static const float twom54 = 5.551115123125782702e-17; ++static const float half = 0.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the actual square root and half of its reciprocal ++ simultaneously. */ ++ ++#ifdef __STDC__ ++double ++__ieee754_sqrt (double b) ++#else ++double ++__ieee754_sqrt (b) ++ double b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++ double y, g, h, d, r; ++ ieee_double_shape_type u; ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ u.value = b; ++ ++ relax_fenv_state (); ++ ++ __asm__ ("frsqrte %[estimate], %[x]\n" ++ : [estimate] "=f" (y) : [x] "f" (b)); ++ ++ /* Following Muller et al, page 168, equation 5.20. ++ ++ h goes to 1/(2*sqrt(b)) ++ g goes to sqrt(b). ++ ++ We need three iterations to get within 1ulp. */ ++ ++ /* Indicate that these can be performed prior to the branch. GCC ++ insists on sinking them below the branch, however; it seems like ++ they'd be better before the branch so that we can cover any latency ++ from storing the argument and loading its high word. Oh well. */ ++ ++ g = b * y; ++ h = 0.5 * y; ++ ++ /* Handle small numbers by scaling. */ ++ if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) ++ return __ieee754_sqrt (b * two108) * twom54; ++ ++#define FMADD(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmadd %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ /* g is now +/- 1ulp, or exactly equal to, the square root of b. */ ++ ++ /* Final refinement. */ ++ d = FNMSUB (g, g, b); ++ ++ fesetenv_register (fe); ++ return FMADD (d, h, g); ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_wash (b); ++} +diff --git a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c +new file mode 100644 +index 0000000000..26fa067abf +--- /dev/null ++++ b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c +@@ -0,0 +1,101 @@ ++/* Single-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include ++#include ++#include ++#include ++ ++#include ++#include ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float threehalf = 1.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the reciprocal square root and use that to compute the actual ++ square root. */ ++ ++#ifdef __STDC__ ++float ++__ieee754_sqrtf (float b) ++#else ++float ++__ieee754_sqrtf (b) ++ float b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++#define FMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ double y, x; ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ relax_fenv_state (); ++ ++ /* Compute y = 1.5 * b - b. Uses fewer constants than y = 0.5 * b. */ ++ y = FMSUB (threehalf, b, b); ++ ++ /* Initial estimate. */ ++ __asm__ ("frsqrte %[x], %[b]\n" : [x] "=f" (x) : [b] "f" (b)); ++ ++ /* Iterate. x_{n+1} = x_n * (1.5 - y * (x_n * x_n)). */ ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ ++ /* All done. */ ++ fesetenv_register (fe); ++ return x * b; ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_washf (b); ++} +diff --git a/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c +new file mode 100644 +index 0000000000..71e516d1c8 +--- /dev/null ++++ b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c +@@ -0,0 +1,134 @@ ++/* Double-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include ++#include ++#include ++#include ++ ++#include ++#include ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float two108 = 3.245185536584267269e+32; ++static const float twom54 = 5.551115123125782702e-17; ++static const float half = 0.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the actual square root and half of its reciprocal ++ simultaneously. */ ++ ++#ifdef __STDC__ ++double ++__ieee754_sqrt (double b) ++#else ++double ++__ieee754_sqrt (b) ++ double b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++ double y, g, h, d, r; ++ ieee_double_shape_type u; ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ u.value = b; ++ ++ relax_fenv_state (); ++ ++ __asm__ ("frsqrte %[estimate], %[x]\n" ++ : [estimate] "=f" (y) : [x] "f" (b)); ++ ++ /* Following Muller et al, page 168, equation 5.20. ++ ++ h goes to 1/(2*sqrt(b)) ++ g goes to sqrt(b). ++ ++ We need three iterations to get within 1ulp. */ ++ ++ /* Indicate that these can be performed prior to the branch. GCC ++ insists on sinking them below the branch, however; it seems like ++ they'd be better before the branch so that we can cover any latency ++ from storing the argument and loading its high word. Oh well. */ ++ ++ g = b * y; ++ h = 0.5 * y; ++ ++ /* Handle small numbers by scaling. */ ++ if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) ++ return __ieee754_sqrt (b * two108) * twom54; ++ ++#define FMADD(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmadd %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ /* g is now +/- 1ulp, or exactly equal to, the square root of b. */ ++ ++ /* Final refinement. */ ++ d = FNMSUB (g, g, b); ++ ++ fesetenv_register (fe); ++ return FMADD (d, h, g); ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_wash (b); ++} +diff --git a/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c +new file mode 100644 +index 0000000000..26fa067abf +--- /dev/null ++++ b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c +@@ -0,0 +1,101 @@ ++/* Single-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include ++#include ++#include ++#include ++ ++#include ++#include ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float threehalf = 1.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the reciprocal square root and use that to compute the actual ++ square root. */ ++ ++#ifdef __STDC__ ++float ++__ieee754_sqrtf (float b) ++#else ++float ++__ieee754_sqrtf (b) ++ float b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++#define FMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ double y, x; ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ relax_fenv_state (); ++ ++ /* Compute y = 1.5 * b - b. Uses fewer constants than y = 0.5 * b. */ ++ y = FMSUB (threehalf, b, b); ++ ++ /* Initial estimate. */ ++ __asm__ ("frsqrte %[x], %[b]\n" : [x] "=f" (x) : [b] "f" (b)); ++ ++ /* Iterate. x_{n+1} = x_n * (1.5 - y * (x_n * x_n)). */ ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ ++ /* All done. */ ++ fesetenv_register (fe); ++ return x * b; ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_washf (b); ++} +diff --git a/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c +new file mode 100644 +index 0000000000..71e516d1c8 +--- /dev/null ++++ b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c +@@ -0,0 +1,134 @@ ++/* Double-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include ++#include ++#include ++#include ++ ++#include ++#include ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float two108 = 3.245185536584267269e+32; ++static const float twom54 = 5.551115123125782702e-17; ++static const float half = 0.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the actual square root and half of its reciprocal ++ simultaneously. */ ++ ++#ifdef __STDC__ ++double ++__ieee754_sqrt (double b) ++#else ++double ++__ieee754_sqrt (b) ++ double b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++ double y, g, h, d, r; ++ ieee_double_shape_type u; ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ u.value = b; ++ ++ relax_fenv_state (); ++ ++ __asm__ ("frsqrte %[estimate], %[x]\n" ++ : [estimate] "=f" (y) : [x] "f" (b)); ++ ++ /* Following Muller et al, page 168, equation 5.20. ++ ++ h goes to 1/(2*sqrt(b)) ++ g goes to sqrt(b). ++ ++ We need three iterations to get within 1ulp. */ ++ ++ /* Indicate that these can be performed prior to the branch. GCC ++ insists on sinking them below the branch, however; it seems like ++ they'd be better before the branch so that we can cover any latency ++ from storing the argument and loading its high word. Oh well. */ ++ ++ g = b * y; ++ h = 0.5 * y; ++ ++ /* Handle small numbers by scaling. */ ++ if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) ++ return __ieee754_sqrt (b * two108) * twom54; ++ ++#define FMADD(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmadd %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ r = FNMSUB (g, h, half); ++ g = FMADD (g, r, g); ++ h = FMADD (h, r, h); ++ ++ /* g is now +/- 1ulp, or exactly equal to, the square root of b. */ ++ ++ /* Final refinement. */ ++ d = FNMSUB (g, g, b); ++ ++ fesetenv_register (fe); ++ return FMADD (d, h, g); ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_wash (b); ++} +diff --git a/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c +new file mode 100644 +index 0000000000..26fa067abf +--- /dev/null ++++ b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c +@@ -0,0 +1,101 @@ ++/* Single-precision floating point square root. ++ Copyright (C) 2010 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include ++#include ++#include ++#include ++ ++#include ++#include ++ ++static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 }; ++static const ieee_float_shape_type a_inf = {.word = 0x7f800000 }; ++static const float threehalf = 1.5; ++ ++/* The method is based on the descriptions in: ++ ++ _The Handbook of Floating-Pointer Arithmetic_ by Muller et al., chapter 5; ++ _IA-64 and Elementary Functions: Speed and Precision_ by Markstein, chapter 9 ++ ++ We find the reciprocal square root and use that to compute the actual ++ square root. */ ++ ++#ifdef __STDC__ ++float ++__ieee754_sqrtf (float b) ++#else ++float ++__ieee754_sqrtf (b) ++ float b; ++#endif ++{ ++ if (__builtin_expect (b > 0, 1)) ++ { ++#define FMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++#define FNMSUB(a_, c_, b_) \ ++ ({ double __r; \ ++ __asm__ ("fnmsub %[r], %[a], %[c], %[b]\n" \ ++ : [r] "=f" (__r) : [a] "f" (a_), [c] "f" (c_), [b] "f" (b_)); \ ++ __r;}) ++ ++ if (__builtin_expect (b != a_inf.value, 1)) ++ { ++ double y, x; ++ fenv_t fe; ++ ++ fe = fegetenv_register (); ++ ++ relax_fenv_state (); ++ ++ /* Compute y = 1.5 * b - b. Uses fewer constants than y = 0.5 * b. */ ++ y = FMSUB (threehalf, b, b); ++ ++ /* Initial estimate. */ ++ __asm__ ("frsqrte %[x], %[b]\n" : [x] "=f" (x) : [b] "f" (b)); ++ ++ /* Iterate. x_{n+1} = x_n * (1.5 - y * (x_n * x_n)). */ ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ x = x * FNMSUB (y, x * x, threehalf); ++ ++ /* All done. */ ++ fesetenv_register (fe); ++ return x * b; ++ } ++ } ++ else if (b < 0) ++ { ++ /* For some reason, some PowerPC32 processors don't implement ++ FE_INVALID_SQRT. */ ++#ifdef FE_INVALID_SQRT ++ feraiseexcept (FE_INVALID_SQRT); ++ ++ fenv_union_t u = { .fenv = fegetenv_register () }; ++ if ((u.l & FE_INVALID) == 0) ++#endif ++ feraiseexcept (FE_INVALID); ++ b = a_nan.value; ++ } ++ return f_washf (b); ++} +diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/603e/fpu/Implies b/sysdeps/unix/sysv/linux/powerpc/powerpc32/603e/fpu/Implies +new file mode 100644 +index 0000000000..b103b4dea5 +--- /dev/null ++++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/603e/fpu/Implies +@@ -0,0 +1 @@ ++powerpc/powerpc32/603e/fpu +diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/e300c3/fpu/Implies b/sysdeps/unix/sysv/linux/powerpc/powerpc32/e300c3/fpu/Implies +new file mode 100644 +index 0000000000..64db17fada +--- /dev/null ++++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/e300c3/fpu/Implies +@@ -0,0 +1,2 @@ ++# e300c3 is a variant of 603e so use the same optimizations for sqrt ++powerpc/powerpc32/603e/fpu +diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/e500mc/fpu/Implies b/sysdeps/unix/sysv/linux/powerpc/powerpc32/e500mc/fpu/Implies +new file mode 100644 +index 0000000000..7eac5fcf02 +--- /dev/null ++++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/e500mc/fpu/Implies +@@ -0,0 +1 @@ ++powerpc/powerpc32/e500mc/fpu +diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/e5500/fpu/Implies b/sysdeps/unix/sysv/linux/powerpc/powerpc32/e5500/fpu/Implies +new file mode 100644 +index 0000000000..264b2a7700 +--- /dev/null ++++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/e5500/fpu/Implies +@@ -0,0 +1 @@ ++powerpc/powerpc32/e5500/fpu +diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/e6500/fpu/Implies b/sysdeps/unix/sysv/linux/powerpc/powerpc32/e6500/fpu/Implies +new file mode 100644 +index 0000000000..a25934467b +--- /dev/null ++++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/e6500/fpu/Implies +@@ -0,0 +1 @@ ++powerpc/powerpc32/e6500/fpu +diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/e5500/fpu/Implies b/sysdeps/unix/sysv/linux/powerpc/powerpc64/e5500/fpu/Implies +new file mode 100644 +index 0000000000..a7bc854be8 +--- /dev/null ++++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/e5500/fpu/Implies +@@ -0,0 +1 @@ ++powerpc/powerpc64/e5500/fpu +diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/e6500/fpu/Implies b/sysdeps/unix/sysv/linux/powerpc/powerpc64/e6500/fpu/Implies +new file mode 100644 +index 0000000000..04ff8cc181 +--- /dev/null ++++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/e6500/fpu/Implies +@@ -0,0 +1 @@ ++powerpc/powerpc64/e6500/fpu diff --git a/meta/recipes-core/glibc/glibc/0008-ppc-sqrt-Fix-undefined-reference-to-__sqrt_finite.patch b/meta/recipes-core/glibc/glibc/0008-ppc-sqrt-Fix-undefined-reference-to-__sqrt_finite.patch deleted file mode 100644 index 8bed20306e..0000000000 --- a/meta/recipes-core/glibc/glibc/0008-ppc-sqrt-Fix-undefined-reference-to-__sqrt_finite.patch +++ /dev/null @@ -1,208 +0,0 @@ -From 42a01c55786a9472934e12e0bf0c40983579b607 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Wed, 18 Mar 2015 00:15:07 +0000 -Subject: [PATCH 08/28] 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' -| collect2: ld returned 1 exit status - -Upstream-Status: Pending - -ChangeLog - -2012-01-06 Khem Raj - - * sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c: Add __*_finite alias. - Remove cruft. - * sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c: Ditto. - * sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c: Ditto. - * sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c: Ditto. - -Signed-off-by: Khem Raj ---- - sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c | 7 +------ - sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c | 7 +------ - sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c | 1 + - sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c | 1 + - sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c | 1 + - sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c | 1 + - sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c | 1 + - sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c | 1 + - sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c | 7 +------ - sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c | 7 +------ - sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c | 1 + - sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c | 1 + - 12 files changed, 12 insertions(+), 24 deletions(-) - -diff --git a/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c -index 71e516d1c8..1795fd6c3e 100644 ---- a/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c -+++ b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c -@@ -39,14 +39,8 @@ static const float half = 0.5; - We find the actual square root and half of its reciprocal - simultaneously. */ - --#ifdef __STDC__ - double - __ieee754_sqrt (double b) --#else --double --__ieee754_sqrt (b) -- double b; --#endif - { - if (__builtin_expect (b > 0, 1)) - { -@@ -132,3 +126,4 @@ __ieee754_sqrt (b) - } - return f_wash (b); - } -+strong_alias (__ieee754_sqrt, __sqrt_finite) -diff --git a/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c -index 26fa067abf..a917f313ab 100644 ---- a/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c -+++ b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c -@@ -37,14 +37,8 @@ static const float threehalf = 1.5; - We find the reciprocal square root and use that to compute the actual - square root. */ - --#ifdef __STDC__ - float - __ieee754_sqrtf (float b) --#else --float --__ieee754_sqrtf (b) -- float b; --#endif - { - if (__builtin_expect (b > 0, 1)) - { -@@ -99,3 +93,4 @@ __ieee754_sqrtf (b) - } - return f_washf (b); - } -+strong_alias (__ieee754_sqrtf, __sqrtf_finite) -diff --git a/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c -index 71e516d1c8..fc4a74990e 100644 ---- a/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c -+++ b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c -@@ -132,3 +132,4 @@ __ieee754_sqrt (b) - } - return f_wash (b); - } -+strong_alias (__ieee754_sqrt, __sqrt_finite) -diff --git a/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c -index 26fa067abf..9d175122a8 100644 ---- a/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c -+++ b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c -@@ -99,3 +99,4 @@ __ieee754_sqrtf (b) - } - return f_washf (b); - } -+strong_alias (__ieee754_sqrtf, __sqrtf_finite) -diff --git a/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c -index 71e516d1c8..fc4a74990e 100644 ---- a/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c -+++ b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c -@@ -132,3 +132,4 @@ __ieee754_sqrt (b) - } - return f_wash (b); - } -+strong_alias (__ieee754_sqrt, __sqrt_finite) -diff --git a/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c -index 26fa067abf..9d175122a8 100644 ---- a/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c -+++ b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c -@@ -99,3 +99,4 @@ __ieee754_sqrtf (b) - } - return f_washf (b); - } -+strong_alias (__ieee754_sqrtf, __sqrtf_finite) -diff --git a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c -index 71e516d1c8..fc4a74990e 100644 ---- a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c -+++ b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c -@@ -132,3 +132,4 @@ __ieee754_sqrt (b) - } - return f_wash (b); - } -+strong_alias (__ieee754_sqrt, __sqrt_finite) -diff --git a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c -index 26fa067abf..9d175122a8 100644 ---- a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c -+++ b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c -@@ -99,3 +99,4 @@ __ieee754_sqrtf (b) - } - return f_washf (b); - } -+strong_alias (__ieee754_sqrtf, __sqrtf_finite) -diff --git a/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c -index 71e516d1c8..1795fd6c3e 100644 ---- a/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c -+++ b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c -@@ -39,14 +39,8 @@ static const float half = 0.5; - We find the actual square root and half of its reciprocal - simultaneously. */ - --#ifdef __STDC__ - double - __ieee754_sqrt (double b) --#else --double --__ieee754_sqrt (b) -- double b; --#endif - { - if (__builtin_expect (b > 0, 1)) - { -@@ -132,3 +126,4 @@ __ieee754_sqrt (b) - } - return f_wash (b); - } -+strong_alias (__ieee754_sqrt, __sqrt_finite) -diff --git a/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c -index 26fa067abf..a917f313ab 100644 ---- a/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c -+++ b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c -@@ -37,14 +37,8 @@ static const float threehalf = 1.5; - We find the reciprocal square root and use that to compute the actual - square root. */ - --#ifdef __STDC__ - float - __ieee754_sqrtf (float b) --#else --float --__ieee754_sqrtf (b) -- float b; --#endif - { - if (__builtin_expect (b > 0, 1)) - { -@@ -99,3 +93,4 @@ __ieee754_sqrtf (b) - } - return f_washf (b); - } -+strong_alias (__ieee754_sqrtf, __sqrtf_finite) -diff --git a/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c -index 71e516d1c8..fc4a74990e 100644 ---- a/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c -+++ b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c -@@ -132,3 +132,4 @@ __ieee754_sqrt (b) - } - return f_wash (b); - } -+strong_alias (__ieee754_sqrt, __sqrt_finite) -diff --git a/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c -index 26fa067abf..9d175122a8 100644 ---- a/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c -+++ b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c -@@ -99,3 +99,4 @@ __ieee754_sqrtf (b) - } - 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/0009-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch deleted file mode 100644 index 8a5d6d8b7f..0000000000 --- a/meta/recipes-core/glibc/glibc/0009-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch +++ /dev/null @@ -1,387 +0,0 @@ -From a0fcb9135bc8c2b9d8a161d166b6f9d56d7af245 Mon Sep 17 00:00:00 2001 -From: Khem Raj -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 - -Upstream-Status: Pending - -Signed-off-by: Khem Raj ---- - sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c | 12 ++++++++++-- - sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c | 8 +++++++- - sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c | 14 +++++++++++--- - sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c | 12 ++++++++++-- - sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c | 14 +++++++++++--- - sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c | 12 ++++++++++-- - sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c | 8 ++++++++ - sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c | 8 ++++++++ - sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c | 12 ++++++++++-- - sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c | 9 ++++++++- - sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c | 14 +++++++++++--- - sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c | 12 ++++++++++-- - 12 files changed, 114 insertions(+), 21 deletions(-) - -diff --git a/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c -index 1795fd6c3e..daa83f3fe8 100644 ---- a/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c -+++ b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c -@@ -40,7 +40,7 @@ static const float half = 0.5; - simultaneously. */ - - double --__ieee754_sqrt (double b) -+__slow_ieee754_sqrt (double b) - { - if (__builtin_expect (b > 0, 1)) - { -@@ -77,7 +77,7 @@ __ieee754_sqrt (double b) - - /* Handle small numbers by scaling. */ - if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) -- return __ieee754_sqrt (b * two108) * twom54; -+ return __slow_ieee754_sqrt (b * two108) * twom54; - - #define FMADD(a_, c_, b_) \ - ({ double __r; \ -@@ -126,4 +126,12 @@ __ieee754_sqrt (double b) - } - return f_wash (b); - } -+ -+#undef __ieee754_sqrt -+double -+__ieee754_sqrt (double x) -+{ -+ return __slow_ieee754_sqrt (x); -+} -+ - strong_alias (__ieee754_sqrt, __sqrt_finite) -diff --git a/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c -index a917f313ab..b812cf1705 100644 ---- a/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c -+++ b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c -@@ -38,7 +38,7 @@ static const float threehalf = 1.5; - square root. */ - - float --__ieee754_sqrtf (float b) -+__slow_ieee754_sqrtf (float b) - { - if (__builtin_expect (b > 0, 1)) - { -@@ -93,4 +93,10 @@ __ieee754_sqrtf (float b) - } - return f_washf (b); - } -+#undef __ieee754_sqrtf -+float -+__ieee754_sqrtf (float x) -+{ -+ return __slow_ieee754_sqrtf (x); -+} - strong_alias (__ieee754_sqrtf, __sqrtf_finite) -diff --git a/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c -index fc4a74990e..7038a70b47 100644 ---- a/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c -+++ b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c -@@ -41,10 +41,10 @@ static const float half = 0.5; - - #ifdef __STDC__ - double --__ieee754_sqrt (double b) -+__slow_ieee754_sqrt (double b) - #else - double --__ieee754_sqrt (b) -+__slow_ieee754_sqrt (b) - double b; - #endif - { -@@ -83,7 +83,7 @@ __ieee754_sqrt (b) - - /* Handle small numbers by scaling. */ - if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) -- return __ieee754_sqrt (b * two108) * twom54; -+ return __slow_ieee754_sqrt (b * two108) * twom54; - - #define FMADD(a_, c_, b_) \ - ({ double __r; \ -@@ -132,4 +132,12 @@ __ieee754_sqrt (b) - } - return f_wash (b); - } -+ -+#undef __ieee754_sqrt -+double -+__ieee754_sqrt (double x) -+{ -+ return __slow_ieee754_sqrt (x); -+} -+ - strong_alias (__ieee754_sqrt, __sqrt_finite) -diff --git a/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c -index 9d175122a8..10de1f0cc3 100644 ---- a/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c -+++ b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c -@@ -39,10 +39,10 @@ static const float threehalf = 1.5; - - #ifdef __STDC__ - float --__ieee754_sqrtf (float b) -+__slow_ieee754_sqrtf (float b) - #else - float --__ieee754_sqrtf (b) -+__slow_ieee754_sqrtf (b) - float b; - #endif - { -@@ -99,4 +99,12 @@ __ieee754_sqrtf (b) - } - return f_washf (b); - } -+ -+#undef __ieee754_sqrtf -+float -+__ieee754_sqrtf (float x) -+{ -+ return __slow_ieee754_sqrtf (x); -+} -+ - strong_alias (__ieee754_sqrtf, __sqrtf_finite) -diff --git a/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c -index fc4a74990e..7038a70b47 100644 ---- a/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c -+++ b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c -@@ -41,10 +41,10 @@ static const float half = 0.5; - - #ifdef __STDC__ - double --__ieee754_sqrt (double b) -+__slow_ieee754_sqrt (double b) - #else - double --__ieee754_sqrt (b) -+__slow_ieee754_sqrt (b) - double b; - #endif - { -@@ -83,7 +83,7 @@ __ieee754_sqrt (b) - - /* Handle small numbers by scaling. */ - if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) -- return __ieee754_sqrt (b * two108) * twom54; -+ return __slow_ieee754_sqrt (b * two108) * twom54; - - #define FMADD(a_, c_, b_) \ - ({ double __r; \ -@@ -132,4 +132,12 @@ __ieee754_sqrt (b) - } - return f_wash (b); - } -+ -+#undef __ieee754_sqrt -+double -+__ieee754_sqrt (double x) -+{ -+ return __slow_ieee754_sqrt (x); -+} -+ - strong_alias (__ieee754_sqrt, __sqrt_finite) -diff --git a/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c -index 9d175122a8..10de1f0cc3 100644 ---- a/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c -+++ b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c -@@ -39,10 +39,10 @@ static const float threehalf = 1.5; - - #ifdef __STDC__ - float --__ieee754_sqrtf (float b) -+__slow_ieee754_sqrtf (float b) - #else - float --__ieee754_sqrtf (b) -+__slow_ieee754_sqrtf (b) - float b; - #endif - { -@@ -99,4 +99,12 @@ __ieee754_sqrtf (b) - } - return f_washf (b); - } -+ -+#undef __ieee754_sqrtf -+float -+__ieee754_sqrtf (float x) -+{ -+ return __slow_ieee754_sqrtf (x); -+} -+ - strong_alias (__ieee754_sqrtf, __sqrtf_finite) -diff --git a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c -index fc4a74990e..1c34244bd8 100644 ---- a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c -+++ b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c -@@ -132,4 +132,12 @@ __ieee754_sqrt (b) - } - return f_wash (b); - } -+ -+#undef __ieee754_sqrt -+double -+__ieee754_sqrt (double x) -+{ -+ return __slow_ieee754_sqrt (x); -+} -+ - strong_alias (__ieee754_sqrt, __sqrt_finite) -diff --git a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c -index 9d175122a8..812653558f 100644 ---- a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c -+++ b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c -@@ -99,4 +99,12 @@ __ieee754_sqrtf (b) - } - return f_washf (b); - } -+ -+#undef __ieee754_sqrtf -+float -+__ieee754_sqrtf (float x) -+{ -+ return __slow_ieee754_sqrtf (x); -+} -+ - strong_alias (__ieee754_sqrtf, __sqrtf_finite) -diff --git a/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c -index 1795fd6c3e..13a81973e3 100644 ---- a/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c -+++ b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c -@@ -40,7 +40,7 @@ static const float half = 0.5; - simultaneously. */ - - double --__ieee754_sqrt (double b) -+__slow_ieee754_sqrt (double b) - { - if (__builtin_expect (b > 0, 1)) - { -@@ -77,7 +77,7 @@ __ieee754_sqrt (double b) - - /* Handle small numbers by scaling. */ - if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) -- return __ieee754_sqrt (b * two108) * twom54; -+ return __slow_ieee754_sqrt (b * two108) * twom54; - - #define FMADD(a_, c_, b_) \ - ({ double __r; \ -@@ -126,4 +126,12 @@ __ieee754_sqrt (double b) - } - return f_wash (b); - } -+ -+#undef __ieee754_sqrt -+double -+__ieee754_sqrt (double x) -+{ -+ return __slow_ieee754_sqrt (x); -+} -+ - strong_alias (__ieee754_sqrt, __sqrt_finite) -diff --git a/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c -index a917f313ab..fae2d81210 100644 ---- a/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c -+++ b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c -@@ -38,7 +38,7 @@ static const float threehalf = 1.5; - square root. */ - - float --__ieee754_sqrtf (float b) -+__slow_ieee754_sqrtf (float b) - { - if (__builtin_expect (b > 0, 1)) - { -@@ -93,4 +93,11 @@ __ieee754_sqrtf (float b) - } - return f_washf (b); - } -+#undef __ieee754_sqrtf -+float -+__ieee754_sqrtf (float x) -+{ -+ return __slow_ieee754_sqrtf (x); -+} -+ - strong_alias (__ieee754_sqrtf, __sqrtf_finite) -diff --git a/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c -index fc4a74990e..7038a70b47 100644 ---- a/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c -+++ b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c -@@ -41,10 +41,10 @@ static const float half = 0.5; - - #ifdef __STDC__ - double --__ieee754_sqrt (double b) -+__slow_ieee754_sqrt (double b) - #else - double --__ieee754_sqrt (b) -+__slow_ieee754_sqrt (b) - double b; - #endif - { -@@ -83,7 +83,7 @@ __ieee754_sqrt (b) - - /* Handle small numbers by scaling. */ - if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) -- return __ieee754_sqrt (b * two108) * twom54; -+ return __slow_ieee754_sqrt (b * two108) * twom54; - - #define FMADD(a_, c_, b_) \ - ({ double __r; \ -@@ -132,4 +132,12 @@ __ieee754_sqrt (b) - } - return f_wash (b); - } -+ -+#undef __ieee754_sqrt -+double -+__ieee754_sqrt (double x) -+{ -+ return __slow_ieee754_sqrt (x); -+} -+ - strong_alias (__ieee754_sqrt, __sqrt_finite) -diff --git a/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c -index 9d175122a8..10de1f0cc3 100644 ---- a/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c -+++ b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c -@@ -39,10 +39,10 @@ static const float threehalf = 1.5; - - #ifdef __STDC__ - float --__ieee754_sqrtf (float b) -+__slow_ieee754_sqrtf (float b) - #else - float --__ieee754_sqrtf (b) -+__slow_ieee754_sqrtf (b) - float b; - #endif - { -@@ -99,4 +99,12 @@ __ieee754_sqrtf (b) - } - return f_washf (b); - } -+ -+#undef __ieee754_sqrtf -+float -+__ieee754_sqrtf (float x) -+{ -+ return __slow_ieee754_sqrtf (x); -+} -+ - strong_alias (__ieee754_sqrtf, __sqrtf_finite) --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0009-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 new file mode 100644 index 0000000000..6e4259f4ff --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0009-readlib-Add-OECORE_KNOWN_INTERPRETER_NAMES-to-known-.patch @@ -0,0 +1,29 @@ +From e6ff3960d9e4ed6a9a4be70732313127f0e6d0e0 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 18 Mar 2015 00:11:22 +0000 +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 +other distros + +Upstream-Status: Inappropriate [OE specific] + +Signed-off-by: Lianhao Lu +Signed-off-by: Khem Raj +--- + elf/readlib.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/elf/readlib.c b/elf/readlib.c +index 994a4426a1..baabf099b1 100644 +--- a/elf/readlib.c ++++ b/elf/readlib.c +@@ -51,6 +51,7 @@ static struct known_names interpreters[] = + #ifdef SYSDEP_KNOWN_INTERPRETER_NAMES + SYSDEP_KNOWN_INTERPRETER_NAMES + #endif ++ OECORE_KNOWN_INTERPRETER_NAMES + }; + + static struct known_names known_libs[] = 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/0010-Quote-from-bug-1443-which-explains-what-the-patch-do.patch deleted file mode 100644 index a140a15479..0000000000 --- a/meta/recipes-core/glibc/glibc/0010-Quote-from-bug-1443-which-explains-what-the-patch-do.patch +++ /dev/null @@ -1,62 +0,0 @@ -From 9c1f2229c48c37b38628c485ef16e01f6780160c Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Wed, 18 Mar 2015 00:20:09 +0000 -Subject: [PATCH 10/28] 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(). - - Libust.so depends on liburcu-bp.so from the usermode-rcu package. - Although libust.so is not prelinked, liburcu-bp.so IS prelinked; this - is critical. - - Libust.so uses a TLS / __thread variable that is defined in liburcu- - bp.so. There are special ARM-specific relocation types that allow two - shared libraries to share thread-specific data. This is critical too. - - One more critical issue: although liburcu-bp.so is prelinked, we can't - load it at its prelinked address, because we also link against - librt.so, and librt.so uses that address. - - The dynamic linker is forced to relink liburcu-bp.so at a different - address. In the course of relinking, it processes the special ARM - relocation record mentioned above. The prelinker has already filled - in the information, which is a short offset into a table of thread- - specific data that is allocated per-thread for each library that uses - TLS. Because the normal behavior of a relocation is to add the symbol - value to an addend stored at the address being relocated, we end up - adding the short offset to itself, doubling it. - - Now we have an awkward situation. The libust.so library doesn't know - about the addend, so its TLS data for this element is correct. The - liburcu-bp.so library has a different offset for the element. When we - go to initialize the element for the first time in liburcu-bp.so, we - write the address of the result at the doubled (broken) offset. - Later, when we refer to the address from libust.so, we check the value - at the correct offset, but it's NULL, so we eat hot SIGSEGV. - -Upstream-Status: Pending - -Signed-off-by: Andrei Dinu -Signed-off-by: Khem Raj ---- - sysdeps/arm/dl-machine.h | 2 +- - 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 ---- 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, - - case R_ARM_TLS_DTPOFF32: - if (sym != NULL) -- *reloc_addr += sym->st_value; -+ *reloc_addr = sym->st_value; - break; - - case R_ARM_TLS_TPOFF32: --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0010-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 new file mode 100644 index 0000000000..91da344089 --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0010-ppc-sqrt-Fix-undefined-reference-to-__sqrt_finite.patch @@ -0,0 +1,205 @@ +From ad055d58bd99b80e41face63bf20db3f04afa4e3 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 18 Mar 2015 00:15:07 +0000 +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' +| collect2: ld returned 1 exit status + +Upstream-Status: Pending + +ChangeLog + +2012-01-06 Khem Raj + + * sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c: Add __*_finite alias. + Remove cruft. + * sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c: Ditto. + * sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c: Ditto. + * sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c: Ditto. + +Signed-off-by: Khem Raj +--- + sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c | 7 +------ + sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c | 7 +------ + sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c | 1 + + sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c | 1 + + sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c | 1 + + sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c | 1 + + sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c | 1 + + sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c | 1 + + sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c | 7 +------ + sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c | 7 +------ + sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c | 1 + + sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c | 1 + + 12 files changed, 12 insertions(+), 24 deletions(-) + +diff --git a/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c +index 71e516d1c8..1795fd6c3e 100644 +--- a/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c ++++ b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c +@@ -39,14 +39,8 @@ static const float half = 0.5; + We find the actual square root and half of its reciprocal + simultaneously. */ + +-#ifdef __STDC__ + double + __ieee754_sqrt (double b) +-#else +-double +-__ieee754_sqrt (b) +- double b; +-#endif + { + if (__builtin_expect (b > 0, 1)) + { +@@ -132,3 +126,4 @@ __ieee754_sqrt (b) + } + return f_wash (b); + } ++strong_alias (__ieee754_sqrt, __sqrt_finite) +diff --git a/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c +index 26fa067abf..a917f313ab 100644 +--- a/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c ++++ b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c +@@ -37,14 +37,8 @@ static const float threehalf = 1.5; + We find the reciprocal square root and use that to compute the actual + square root. */ + +-#ifdef __STDC__ + float + __ieee754_sqrtf (float b) +-#else +-float +-__ieee754_sqrtf (b) +- float b; +-#endif + { + if (__builtin_expect (b > 0, 1)) + { +@@ -99,3 +93,4 @@ __ieee754_sqrtf (b) + } + return f_washf (b); + } ++strong_alias (__ieee754_sqrtf, __sqrtf_finite) +diff --git a/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c +index 71e516d1c8..fc4a74990e 100644 +--- a/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c ++++ b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c +@@ -132,3 +132,4 @@ __ieee754_sqrt (b) + } + return f_wash (b); + } ++strong_alias (__ieee754_sqrt, __sqrt_finite) +diff --git a/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c +index 26fa067abf..9d175122a8 100644 +--- a/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c ++++ b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c +@@ -99,3 +99,4 @@ __ieee754_sqrtf (b) + } + return f_washf (b); + } ++strong_alias (__ieee754_sqrtf, __sqrtf_finite) +diff --git a/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c +index 71e516d1c8..fc4a74990e 100644 +--- a/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c ++++ b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c +@@ -132,3 +132,4 @@ __ieee754_sqrt (b) + } + return f_wash (b); + } ++strong_alias (__ieee754_sqrt, __sqrt_finite) +diff --git a/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c +index 26fa067abf..9d175122a8 100644 +--- a/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c ++++ b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c +@@ -99,3 +99,4 @@ __ieee754_sqrtf (b) + } + return f_washf (b); + } ++strong_alias (__ieee754_sqrtf, __sqrtf_finite) +diff --git a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c +index 71e516d1c8..fc4a74990e 100644 +--- a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c ++++ b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c +@@ -132,3 +132,4 @@ __ieee754_sqrt (b) + } + return f_wash (b); + } ++strong_alias (__ieee754_sqrt, __sqrt_finite) +diff --git a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c +index 26fa067abf..9d175122a8 100644 +--- a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c ++++ b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c +@@ -99,3 +99,4 @@ __ieee754_sqrtf (b) + } + return f_washf (b); + } ++strong_alias (__ieee754_sqrtf, __sqrtf_finite) +diff --git a/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c +index 71e516d1c8..1795fd6c3e 100644 +--- a/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c ++++ b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c +@@ -39,14 +39,8 @@ static const float half = 0.5; + We find the actual square root and half of its reciprocal + simultaneously. */ + +-#ifdef __STDC__ + double + __ieee754_sqrt (double b) +-#else +-double +-__ieee754_sqrt (b) +- double b; +-#endif + { + if (__builtin_expect (b > 0, 1)) + { +@@ -132,3 +126,4 @@ __ieee754_sqrt (b) + } + return f_wash (b); + } ++strong_alias (__ieee754_sqrt, __sqrt_finite) +diff --git a/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c +index 26fa067abf..a917f313ab 100644 +--- a/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c ++++ b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c +@@ -37,14 +37,8 @@ static const float threehalf = 1.5; + We find the reciprocal square root and use that to compute the actual + square root. */ + +-#ifdef __STDC__ + float + __ieee754_sqrtf (float b) +-#else +-float +-__ieee754_sqrtf (b) +- float b; +-#endif + { + if (__builtin_expect (b > 0, 1)) + { +@@ -99,3 +93,4 @@ __ieee754_sqrtf (b) + } + return f_washf (b); + } ++strong_alias (__ieee754_sqrtf, __sqrtf_finite) +diff --git a/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c +index 71e516d1c8..fc4a74990e 100644 +--- a/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c ++++ b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c +@@ -132,3 +132,4 @@ __ieee754_sqrt (b) + } + return f_wash (b); + } ++strong_alias (__ieee754_sqrt, __sqrt_finite) +diff --git a/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c +index 26fa067abf..9d175122a8 100644 +--- a/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c ++++ b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c +@@ -99,3 +99,4 @@ __ieee754_sqrtf (b) + } + return f_washf (b); + } ++strong_alias (__ieee754_sqrtf, __sqrtf_finite) diff --git a/meta/recipes-core/glibc/glibc/0011-__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 new file mode 100644 index 0000000000..6a5a44af9d --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0011-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch @@ -0,0 +1,384 @@ +From ac4450bc74dc0754a3724f1bebb2290c4dc29d72 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 18 Mar 2015 00:16:38 +0000 +Subject: [PATCH] __ieee754_sqrt{,f} are now inline functions and call out + __slow versions + +Upstream-Status: Pending + +Signed-off-by: Khem Raj +--- + sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c | 12 ++++++++++-- + sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c | 8 +++++++- + sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c | 14 +++++++++++--- + sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c | 12 ++++++++++-- + sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c | 14 +++++++++++--- + sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c | 12 ++++++++++-- + sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c | 8 ++++++++ + sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c | 8 ++++++++ + sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c | 12 ++++++++++-- + sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c | 9 ++++++++- + sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c | 14 +++++++++++--- + sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c | 12 ++++++++++-- + 12 files changed, 114 insertions(+), 21 deletions(-) + +diff --git a/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c +index 1795fd6c3e..daa83f3fe8 100644 +--- a/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c ++++ b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrt.c +@@ -40,7 +40,7 @@ static const float half = 0.5; + simultaneously. */ + + double +-__ieee754_sqrt (double b) ++__slow_ieee754_sqrt (double b) + { + if (__builtin_expect (b > 0, 1)) + { +@@ -77,7 +77,7 @@ __ieee754_sqrt (double b) + + /* Handle small numbers by scaling. */ + if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) +- return __ieee754_sqrt (b * two108) * twom54; ++ return __slow_ieee754_sqrt (b * two108) * twom54; + + #define FMADD(a_, c_, b_) \ + ({ double __r; \ +@@ -126,4 +126,12 @@ __ieee754_sqrt (double b) + } + return f_wash (b); + } ++ ++#undef __ieee754_sqrt ++double ++__ieee754_sqrt (double x) ++{ ++ return __slow_ieee754_sqrt (x); ++} ++ + strong_alias (__ieee754_sqrt, __sqrt_finite) +diff --git a/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c +index a917f313ab..b812cf1705 100644 +--- a/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c ++++ b/sysdeps/powerpc/powerpc32/603e/fpu/e_sqrtf.c +@@ -38,7 +38,7 @@ static const float threehalf = 1.5; + square root. */ + + float +-__ieee754_sqrtf (float b) ++__slow_ieee754_sqrtf (float b) + { + if (__builtin_expect (b > 0, 1)) + { +@@ -93,4 +93,10 @@ __ieee754_sqrtf (float b) + } + return f_washf (b); + } ++#undef __ieee754_sqrtf ++float ++__ieee754_sqrtf (float x) ++{ ++ return __slow_ieee754_sqrtf (x); ++} + strong_alias (__ieee754_sqrtf, __sqrtf_finite) +diff --git a/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c +index fc4a74990e..7038a70b47 100644 +--- a/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c ++++ b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrt.c +@@ -41,10 +41,10 @@ static const float half = 0.5; + + #ifdef __STDC__ + double +-__ieee754_sqrt (double b) ++__slow_ieee754_sqrt (double b) + #else + double +-__ieee754_sqrt (b) ++__slow_ieee754_sqrt (b) + double b; + #endif + { +@@ -83,7 +83,7 @@ __ieee754_sqrt (b) + + /* Handle small numbers by scaling. */ + if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) +- return __ieee754_sqrt (b * two108) * twom54; ++ return __slow_ieee754_sqrt (b * two108) * twom54; + + #define FMADD(a_, c_, b_) \ + ({ double __r; \ +@@ -132,4 +132,12 @@ __ieee754_sqrt (b) + } + return f_wash (b); + } ++ ++#undef __ieee754_sqrt ++double ++__ieee754_sqrt (double x) ++{ ++ return __slow_ieee754_sqrt (x); ++} ++ + strong_alias (__ieee754_sqrt, __sqrt_finite) +diff --git a/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c +index 9d175122a8..10de1f0cc3 100644 +--- a/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c ++++ b/sysdeps/powerpc/powerpc32/e500mc/fpu/e_sqrtf.c +@@ -39,10 +39,10 @@ static const float threehalf = 1.5; + + #ifdef __STDC__ + float +-__ieee754_sqrtf (float b) ++__slow_ieee754_sqrtf (float b) + #else + float +-__ieee754_sqrtf (b) ++__slow_ieee754_sqrtf (b) + float b; + #endif + { +@@ -99,4 +99,12 @@ __ieee754_sqrtf (b) + } + return f_washf (b); + } ++ ++#undef __ieee754_sqrtf ++float ++__ieee754_sqrtf (float x) ++{ ++ return __slow_ieee754_sqrtf (x); ++} ++ + strong_alias (__ieee754_sqrtf, __sqrtf_finite) +diff --git a/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c +index fc4a74990e..7038a70b47 100644 +--- a/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c ++++ b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrt.c +@@ -41,10 +41,10 @@ static const float half = 0.5; + + #ifdef __STDC__ + double +-__ieee754_sqrt (double b) ++__slow_ieee754_sqrt (double b) + #else + double +-__ieee754_sqrt (b) ++__slow_ieee754_sqrt (b) + double b; + #endif + { +@@ -83,7 +83,7 @@ __ieee754_sqrt (b) + + /* Handle small numbers by scaling. */ + if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) +- return __ieee754_sqrt (b * two108) * twom54; ++ return __slow_ieee754_sqrt (b * two108) * twom54; + + #define FMADD(a_, c_, b_) \ + ({ double __r; \ +@@ -132,4 +132,12 @@ __ieee754_sqrt (b) + } + return f_wash (b); + } ++ ++#undef __ieee754_sqrt ++double ++__ieee754_sqrt (double x) ++{ ++ return __slow_ieee754_sqrt (x); ++} ++ + strong_alias (__ieee754_sqrt, __sqrt_finite) +diff --git a/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c +index 9d175122a8..10de1f0cc3 100644 +--- a/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c ++++ b/sysdeps/powerpc/powerpc32/e5500/fpu/e_sqrtf.c +@@ -39,10 +39,10 @@ static const float threehalf = 1.5; + + #ifdef __STDC__ + float +-__ieee754_sqrtf (float b) ++__slow_ieee754_sqrtf (float b) + #else + float +-__ieee754_sqrtf (b) ++__slow_ieee754_sqrtf (b) + float b; + #endif + { +@@ -99,4 +99,12 @@ __ieee754_sqrtf (b) + } + return f_washf (b); + } ++ ++#undef __ieee754_sqrtf ++float ++__ieee754_sqrtf (float x) ++{ ++ return __slow_ieee754_sqrtf (x); ++} ++ + strong_alias (__ieee754_sqrtf, __sqrtf_finite) +diff --git a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c +index fc4a74990e..1c34244bd8 100644 +--- a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c ++++ b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c +@@ -132,4 +132,12 @@ __ieee754_sqrt (b) + } + return f_wash (b); + } ++ ++#undef __ieee754_sqrt ++double ++__ieee754_sqrt (double x) ++{ ++ return __slow_ieee754_sqrt (x); ++} ++ + strong_alias (__ieee754_sqrt, __sqrt_finite) +diff --git a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c +index 9d175122a8..812653558f 100644 +--- a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c ++++ b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c +@@ -99,4 +99,12 @@ __ieee754_sqrtf (b) + } + return f_washf (b); + } ++ ++#undef __ieee754_sqrtf ++float ++__ieee754_sqrtf (float x) ++{ ++ return __slow_ieee754_sqrtf (x); ++} ++ + strong_alias (__ieee754_sqrtf, __sqrtf_finite) +diff --git a/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c +index 1795fd6c3e..13a81973e3 100644 +--- a/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c ++++ b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrt.c +@@ -40,7 +40,7 @@ static const float half = 0.5; + simultaneously. */ + + double +-__ieee754_sqrt (double b) ++__slow_ieee754_sqrt (double b) + { + if (__builtin_expect (b > 0, 1)) + { +@@ -77,7 +77,7 @@ __ieee754_sqrt (double b) + + /* Handle small numbers by scaling. */ + if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) +- return __ieee754_sqrt (b * two108) * twom54; ++ return __slow_ieee754_sqrt (b * two108) * twom54; + + #define FMADD(a_, c_, b_) \ + ({ double __r; \ +@@ -126,4 +126,12 @@ __ieee754_sqrt (double b) + } + return f_wash (b); + } ++ ++#undef __ieee754_sqrt ++double ++__ieee754_sqrt (double x) ++{ ++ return __slow_ieee754_sqrt (x); ++} ++ + strong_alias (__ieee754_sqrt, __sqrt_finite) +diff --git a/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c +index a917f313ab..fae2d81210 100644 +--- a/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c ++++ b/sysdeps/powerpc/powerpc64/e5500/fpu/e_sqrtf.c +@@ -38,7 +38,7 @@ static const float threehalf = 1.5; + square root. */ + + float +-__ieee754_sqrtf (float b) ++__slow_ieee754_sqrtf (float b) + { + if (__builtin_expect (b > 0, 1)) + { +@@ -93,4 +93,11 @@ __ieee754_sqrtf (float b) + } + return f_washf (b); + } ++#undef __ieee754_sqrtf ++float ++__ieee754_sqrtf (float x) ++{ ++ return __slow_ieee754_sqrtf (x); ++} ++ + strong_alias (__ieee754_sqrtf, __sqrtf_finite) +diff --git a/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c +index fc4a74990e..7038a70b47 100644 +--- a/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c ++++ b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrt.c +@@ -41,10 +41,10 @@ static const float half = 0.5; + + #ifdef __STDC__ + double +-__ieee754_sqrt (double b) ++__slow_ieee754_sqrt (double b) + #else + double +-__ieee754_sqrt (b) ++__slow_ieee754_sqrt (b) + double b; + #endif + { +@@ -83,7 +83,7 @@ __ieee754_sqrt (b) + + /* Handle small numbers by scaling. */ + if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) +- return __ieee754_sqrt (b * two108) * twom54; ++ return __slow_ieee754_sqrt (b * two108) * twom54; + + #define FMADD(a_, c_, b_) \ + ({ double __r; \ +@@ -132,4 +132,12 @@ __ieee754_sqrt (b) + } + return f_wash (b); + } ++ ++#undef __ieee754_sqrt ++double ++__ieee754_sqrt (double x) ++{ ++ return __slow_ieee754_sqrt (x); ++} ++ + strong_alias (__ieee754_sqrt, __sqrt_finite) +diff --git a/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c +index 9d175122a8..10de1f0cc3 100644 +--- a/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c ++++ b/sysdeps/powerpc/powerpc64/e6500/fpu/e_sqrtf.c +@@ -39,10 +39,10 @@ static const float threehalf = 1.5; + + #ifdef __STDC__ + float +-__ieee754_sqrtf (float b) ++__slow_ieee754_sqrtf (float b) + #else + float +-__ieee754_sqrtf (b) ++__slow_ieee754_sqrtf (b) + float b; + #endif + { +@@ -99,4 +99,12 @@ __ieee754_sqrtf (b) + } + return f_washf (b); + } ++ ++#undef __ieee754_sqrtf ++float ++__ieee754_sqrtf (float x) ++{ ++ return __slow_ieee754_sqrtf (x); ++} ++ + strong_alias (__ieee754_sqrtf, __sqrtf_finite) 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/0011-eglibc-run-libm-err-tab.pl-with-specific-dirs-in-S.patch deleted file mode 100644 index cb99092eef..0000000000 --- a/meta/recipes-core/glibc/glibc/0011-eglibc-run-libm-err-tab.pl-with-specific-dirs-in-S.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 171d2afb930917b0cfbe9df770774da1c92dd185 Mon Sep 17 00:00:00 2001 -From: Ting Liu -Date: Wed, 19 Dec 2012 04:39:57 -0600 -Subject: [PATCH 11/28] 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 -${S}/.pc/ (it does exist after eglibc adds aarch64 support, -${S}/.pc/aarch64-0001-glibc-fsf-v1-eaf6f205.patch/ports/sysdeps/ -aarch64/libm-test-ulps), run libm-err-tab.pl with specific dirs -in ${S}. - -Upstream-Status: inappropriate [OE specific] - -Signed-off-by: Ting Liu ---- - manual/Makefile | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/manual/Makefile b/manual/Makefile -index 4f76ee85d2..04b8c8c320 100644 ---- a/manual/Makefile -+++ b/manual/Makefile -@@ -103,7 +103,8 @@ $(objpfx)stamp-libm-err: $(..)math/gen-libm-test.py \ - $(wildcard $(foreach dir,$(sysdirs),\ - $(dir)/libm-test-ulps)) - pwd=`pwd`; \ -- $(PYTHON) $< -s $$pwd/.. -m $(objpfx)libm-err-tmp -+ $(PYTHON) $< -s $$pwd/../ports -m $(objpfx)libm-err-tmp -+ $(PYTHON) $< -s $$pwd/../sysdeps -m $(objpfx)libm-err-tmp - $(move-if-change) $(objpfx)libm-err-tmp $(objpfx)libm-err.texi - touch $@ - --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0012-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 new file mode 100644 index 0000000000..e8eaa4d90b --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0012-Quote-from-bug-1443-which-explains-what-the-patch-do.patch @@ -0,0 +1,58 @@ +From 0c73e17d5ea7c88247c1bfbb03511b0ccb6ba6b4 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 18 Mar 2015 00:20:09 +0000 +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(). + + Libust.so depends on liburcu-bp.so from the usermode-rcu package. + Although libust.so is not prelinked, liburcu-bp.so IS prelinked; this + is critical. + + Libust.so uses a TLS / __thread variable that is defined in liburcu- + bp.so. There are special ARM-specific relocation types that allow two + shared libraries to share thread-specific data. This is critical too. + + One more critical issue: although liburcu-bp.so is prelinked, we can't + load it at its prelinked address, because we also link against + librt.so, and librt.so uses that address. + + The dynamic linker is forced to relink liburcu-bp.so at a different + address. In the course of relinking, it processes the special ARM + relocation record mentioned above. The prelinker has already filled + in the information, which is a short offset into a table of thread- + specific data that is allocated per-thread for each library that uses + TLS. Because the normal behavior of a relocation is to add the symbol + value to an addend stored at the address being relocated, we end up + adding the short offset to itself, doubling it. + + Now we have an awkward situation. The libust.so library doesn't know + about the addend, so its TLS data for this element is correct. The + liburcu-bp.so library has a different offset for the element. When we + go to initialize the element for the first time in liburcu-bp.so, we + write the address of the result at the doubled (broken) offset. + Later, when we refer to the address from libust.so, we check the value + at the correct offset, but it's NULL, so we eat hot SIGSEGV. + +Upstream-Status: Pending + +Signed-off-by: Andrei Dinu +Signed-off-by: Khem Raj +--- + sysdeps/arm/dl-machine.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/sysdeps/arm/dl-machine.h b/sysdeps/arm/dl-machine.h +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, + + case R_ARM_TLS_DTPOFF32: + if (sym != NULL) +- *reloc_addr += sym->st_value; ++ *reloc_addr = sym->st_value; + break; + + case R_ARM_TLS_TPOFF32: 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/0012-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch deleted file mode 100644 index e233fbe542..0000000000 --- a/meta/recipes-core/glibc/glibc/0012-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch +++ /dev/null @@ -1,61 +0,0 @@ -From 376be7b96152ef501c8cf95ed6dc52c0318bd26a Mon Sep 17 00:00:00 2001 -From: Khem Raj -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 - -Upstream-Status: Pending - -Signed-off-by: chunrong guo -Signed-off-by: Khem Raj ---- - sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c | 6 +++--- - sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c | 4 ++-- - 2 files changed, 5 insertions(+), 5 deletions(-) - -diff --git a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c -index 1c34244bd8..7038a70b47 100644 ---- a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c -+++ b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c -@@ -41,10 +41,10 @@ static const float half = 0.5; - - #ifdef __STDC__ - double --__ieee754_sqrt (double b) -+__slow_ieee754_sqrt (double b) - #else - double --__ieee754_sqrt (b) -+__slow_ieee754_sqrt (b) - double b; - #endif - { -@@ -83,7 +83,7 @@ __ieee754_sqrt (b) - - /* Handle small numbers by scaling. */ - if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) -- return __ieee754_sqrt (b * two108) * twom54; -+ return __slow_ieee754_sqrt (b * two108) * twom54; - - #define FMADD(a_, c_, b_) \ - ({ double __r; \ -diff --git a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c -index 812653558f..10de1f0cc3 100644 ---- a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c -+++ b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c -@@ -39,10 +39,10 @@ static const float threehalf = 1.5; - - #ifdef __STDC__ - float --__ieee754_sqrtf (float b) -+__slow_ieee754_sqrtf (float b) - #else - float --__ieee754_sqrtf (b) -+__slow_ieee754_sqrtf (b) - float b; - #endif - { --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0013-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 new file mode 100644 index 0000000000..3b3611f448 --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0013-eglibc-run-libm-err-tab.pl-with-specific-dirs-in-S.patch @@ -0,0 +1,33 @@ +From 6a1ebbab0643fb2169314bcf1a0850b0f06dd27e Mon Sep 17 00:00:00 2001 +From: Ting Liu +Date: Wed, 19 Dec 2012 04:39:57 -0600 +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 +${S}/.pc/ (it does exist after eglibc adds aarch64 support, +${S}/.pc/aarch64-0001-glibc-fsf-v1-eaf6f205.patch/ports/sysdeps/ +aarch64/libm-test-ulps), run libm-err-tab.pl with specific dirs +in ${S}. + +Upstream-Status: inappropriate [OE specific] + +Signed-off-by: Ting Liu +--- + manual/Makefile | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/manual/Makefile b/manual/Makefile +index c61e11dcd7..5d859e6f84 100644 +--- a/manual/Makefile ++++ b/manual/Makefile +@@ -103,7 +103,8 @@ $(objpfx)stamp-libm-err: $(..)math/gen-libm-test.py \ + $(wildcard $(foreach dir,$(sysdirs),\ + $(dir)/libm-test-ulps)) + pwd=`pwd`; \ +- $(PYTHON) $< -s $$pwd/.. -m $(objpfx)libm-err-tmp ++ $(PYTHON) $< -s $$pwd/../ports -m $(objpfx)libm-err-tmp ++ $(PYTHON) $< -s $$pwd/../sysdeps -m $(objpfx)libm-err-tmp + $(move-if-change) $(objpfx)libm-err-tmp $(objpfx)libm-err.texi + touch $@ + 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/0013-sysdeps-gnu-configure.ac-handle-correctly-libc_cv_ro.patch deleted file mode 100644 index 9ba52e6e10..0000000000 --- a/meta/recipes-core/glibc/glibc/0013-sysdeps-gnu-configure.ac-handle-correctly-libc_cv_ro.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 1ba4e9577437632856d719cbd5d63b5a76cbb4c4 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Wed, 18 Mar 2015 00:27:10 +0000 -Subject: [PATCH 13/28] sysdeps/gnu/configure.ac: handle correctly - $libc_cv_rootsbindir - -Upstream-Status:Pending - -Signed-off-by: Matthieu Crapet -Signed-off-by: Khem Raj ---- - sysdeps/gnu/configure | 2 +- - sysdeps/gnu/configure.ac | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/sysdeps/gnu/configure b/sysdeps/gnu/configure -index c15d1087e8..37cc983f2a 100644 ---- a/sysdeps/gnu/configure -+++ b/sysdeps/gnu/configure -@@ -32,6 +32,6 @@ case "$prefix" in - else - libc_cv_localstatedir=$localstatedir - fi -- libc_cv_rootsbindir=/sbin -+ test -n "$libc_cv_rootsbindir" || libc_cv_rootsbindir=/sbin - ;; - esac -diff --git a/sysdeps/gnu/configure.ac b/sysdeps/gnu/configure.ac -index 634fe4de2a..3db1697f4f 100644 ---- a/sysdeps/gnu/configure.ac -+++ b/sysdeps/gnu/configure.ac -@@ -21,6 +21,6 @@ case "$prefix" in - else - libc_cv_localstatedir=$localstatedir - fi -- libc_cv_rootsbindir=/sbin -+ 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/0014-Add-unused-attribute.patch deleted file mode 100644 index 0a602bb38c..0000000000 --- a/meta/recipes-core/glibc/glibc/0014-Add-unused-attribute.patch +++ /dev/null @@ -1,34 +0,0 @@ -From b84999dcf642b07e6c14e6ff507be14743349949 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Wed, 18 Mar 2015 00:28:41 +0000 -Subject: [PATCH 14/28] Add unused attribute - -Helps in avoiding gcc warning when header is is included in -a source file which does not use both functions - - * iconv/gconv_charset.h (strip): - Add unused attribute. - -Signed-off-by: Khem Raj - -Upstream-Status: Pending ---- - iconv/gconv_charset.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/iconv/gconv_charset.h b/iconv/gconv_charset.h -index 91e0ad3141..2e9549fe49 100644 ---- a/iconv/gconv_charset.h -+++ b/iconv/gconv_charset.h -@@ -21,7 +21,7 @@ - #include - - --static void -+static void __attribute__ ((unused)) - strip (char *wp, const char *s) - { - int slash_count = 0; --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0014-__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 new file mode 100644 index 0000000000..b35de40eea --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0014-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch @@ -0,0 +1,58 @@ +From 106aee1de5c95fc9e02f10c05537dcc39f8478f4 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 18 Mar 2015 00:24:46 +0000 +Subject: [PATCH] __ieee754_sqrt{,f} are now inline functions and call out + __slow versions + +Upstream-Status: Pending + +Signed-off-by: chunrong guo +Signed-off-by: Khem Raj +--- + sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c | 6 +++--- + sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c | 4 ++-- + 2 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c +index 1c34244bd8..7038a70b47 100644 +--- a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c ++++ b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrt.c +@@ -41,10 +41,10 @@ static const float half = 0.5; + + #ifdef __STDC__ + double +-__ieee754_sqrt (double b) ++__slow_ieee754_sqrt (double b) + #else + double +-__ieee754_sqrt (b) ++__slow_ieee754_sqrt (b) + double b; + #endif + { +@@ -83,7 +83,7 @@ __ieee754_sqrt (b) + + /* Handle small numbers by scaling. */ + if (__builtin_expect ((u.parts.msw & 0x7ff00000) <= 0x02000000, 0)) +- return __ieee754_sqrt (b * two108) * twom54; ++ return __slow_ieee754_sqrt (b * two108) * twom54; + + #define FMADD(a_, c_, b_) \ + ({ double __r; \ +diff --git a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c +index 812653558f..10de1f0cc3 100644 +--- a/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c ++++ b/sysdeps/powerpc/powerpc32/e6500/fpu/e_sqrtf.c +@@ -39,10 +39,10 @@ static const float threehalf = 1.5; + + #ifdef __STDC__ + float +-__ieee754_sqrtf (float b) ++__slow_ieee754_sqrtf (float b) + #else + float +-__ieee754_sqrtf (b) ++__slow_ieee754_sqrtf (b) + float b; + #endif + { diff --git a/meta/recipes-core/glibc/glibc/0015-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 new file mode 100644 index 0000000000..5669341916 --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0015-sysdeps-gnu-configure.ac-handle-correctly-libc_cv_ro.patch @@ -0,0 +1,39 @@ +From 6c07d094556606ce7c1dc08f4dd3bc6af483364f Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 18 Mar 2015 00:27:10 +0000 +Subject: [PATCH] sysdeps/gnu/configure.ac: handle correctly + $libc_cv_rootsbindir + +Upstream-Status:Pending + +Signed-off-by: Matthieu Crapet +Signed-off-by: Khem Raj +--- + sysdeps/gnu/configure | 2 +- + sysdeps/gnu/configure.ac | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/sysdeps/gnu/configure b/sysdeps/gnu/configure +index c15d1087e8..37cc983f2a 100644 +--- a/sysdeps/gnu/configure ++++ b/sysdeps/gnu/configure +@@ -32,6 +32,6 @@ case "$prefix" in + else + libc_cv_localstatedir=$localstatedir + fi +- libc_cv_rootsbindir=/sbin ++ test -n "$libc_cv_rootsbindir" || libc_cv_rootsbindir=/sbin + ;; + esac +diff --git a/sysdeps/gnu/configure.ac b/sysdeps/gnu/configure.ac +index 634fe4de2a..3db1697f4f 100644 +--- a/sysdeps/gnu/configure.ac ++++ b/sysdeps/gnu/configure.ac +@@ -21,6 +21,6 @@ case "$prefix" in + else + libc_cv_localstatedir=$localstatedir + fi +- libc_cv_rootsbindir=/sbin ++ test -n "$libc_cv_rootsbindir" || libc_cv_rootsbindir=/sbin + ;; + esac diff --git a/meta/recipes-core/glibc/glibc/0015-yes-within-the-path-sets-wrong-config-variables.patch b/meta/recipes-core/glibc/glibc/0015-yes-within-the-path-sets-wrong-config-variables.patch deleted file mode 100644 index dd6562a631..0000000000 --- a/meta/recipes-core/glibc/glibc/0015-yes-within-the-path-sets-wrong-config-variables.patch +++ /dev/null @@ -1,263 +0,0 @@ -From 7c57f84bef4aaffe4204a7a354411ab3ea7e5273 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Wed, 18 Mar 2015 00:31:06 +0000 -Subject: [PATCH 15/28] '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 -false-positive matches with the path it is configured into. - -The change is to use a more elaborated string to grep for. - -Upstream-Status: Submitted [libc-alpha@sourceware.org] - -Signed-off-by: Benjamin Esquivel -Signed-off-by: Khem Raj ---- - sysdeps/aarch64/configure | 4 ++-- - sysdeps/aarch64/configure.ac | 4 ++-- - sysdeps/arm/configure | 4 ++-- - sysdeps/arm/configure.ac | 4 ++-- - sysdeps/mips/configure | 4 ++-- - sysdeps/mips/configure.ac | 4 ++-- - sysdeps/nios2/configure | 4 ++-- - sysdeps/nios2/configure.ac | 4 ++-- - sysdeps/unix/sysv/linux/mips/configure | 4 ++-- - sysdeps/unix/sysv/linux/mips/configure.ac | 4 ++-- - sysdeps/unix/sysv/linux/powerpc/powerpc64/configure | 8 ++++---- - sysdeps/unix/sysv/linux/powerpc/powerpc64/configure.ac | 8 ++++---- - 12 files changed, 28 insertions(+), 28 deletions(-) - -diff --git a/sysdeps/aarch64/configure b/sysdeps/aarch64/configure -index 5bd355a691..3bc5537bc0 100644 ---- a/sysdeps/aarch64/configure -+++ b/sysdeps/aarch64/configure -@@ -148,12 +148,12 @@ else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext - /* end confdefs.h. */ - #ifdef __AARCH64EB__ -- yes -+ is_aarch64_be - #endif - - _ACEOF - if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | -- $EGREP "yes" >/dev/null 2>&1; then : -+ $EGREP "is_aarch64_be" >/dev/null 2>&1; then : - libc_cv_aarch64_be=yes - else - libc_cv_aarch64_be=no -diff --git a/sysdeps/aarch64/configure.ac b/sysdeps/aarch64/configure.ac -index 7851dd4dac..6e9238171f 100644 ---- a/sysdeps/aarch64/configure.ac -+++ b/sysdeps/aarch64/configure.ac -@@ -10,8 +10,8 @@ GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory. - # the dynamic linker via %ifdef. - AC_CACHE_CHECK([for big endian], - [libc_cv_aarch64_be], -- [AC_EGREP_CPP(yes,[#ifdef __AARCH64EB__ -- yes -+ [AC_EGREP_CPP(is_aarch64_be,[#ifdef __AARCH64EB__ -+ is_aarch64_be - #endif - ], libc_cv_aarch64_be=yes, libc_cv_aarch64_be=no)]) - if test $libc_cv_aarch64_be = yes; then -diff --git a/sysdeps/arm/configure b/sysdeps/arm/configure -index 431e843b2b..e152461138 100644 ---- a/sysdeps/arm/configure -+++ b/sysdeps/arm/configure -@@ -151,12 +151,12 @@ else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext - /* end confdefs.h. */ - #ifdef __ARM_PCS_VFP -- yes -+ use_arm_pcs_vfp - #endif - - _ACEOF - if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | -- $EGREP "yes" >/dev/null 2>&1; then : -+ $EGREP "use_arm_pcs_vfp" >/dev/null 2>&1; then : - libc_cv_arm_pcs_vfp=yes - else - libc_cv_arm_pcs_vfp=no -diff --git a/sysdeps/arm/configure.ac b/sysdeps/arm/configure.ac -index 90cdd69c75..05a262ba00 100644 ---- a/sysdeps/arm/configure.ac -+++ b/sysdeps/arm/configure.ac -@@ -15,8 +15,8 @@ AC_DEFINE(PI_STATIC_AND_HIDDEN) - # the dynamic linker via %ifdef. - AC_CACHE_CHECK([whether the compiler is using the ARM hard-float ABI], - [libc_cv_arm_pcs_vfp], -- [AC_EGREP_CPP(yes,[#ifdef __ARM_PCS_VFP -- yes -+ [AC_EGREP_CPP(use_arm_pcs_vfp,[#ifdef __ARM_PCS_VFP -+ use_arm_pcs_vfp - #endif - ], libc_cv_arm_pcs_vfp=yes, libc_cv_arm_pcs_vfp=no)]) - if test $libc_cv_arm_pcs_vfp = yes; then -diff --git a/sysdeps/mips/configure b/sysdeps/mips/configure -index 4e13248c03..f14af952d0 100644 ---- a/sysdeps/mips/configure -+++ b/sysdeps/mips/configure -@@ -143,11 +143,11 @@ else - /* end confdefs.h. */ - dnl - #ifdef __mips_nan2008 --yes -+use_mips_nan2008 - #endif - _ACEOF - if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | -- $EGREP "yes" >/dev/null 2>&1; then : -+ $EGREP "use_mips_nan2008" >/dev/null 2>&1; then : - libc_cv_mips_nan2008=yes - else - libc_cv_mips_nan2008=no -diff --git a/sysdeps/mips/configure.ac b/sysdeps/mips/configure.ac -index bcbdaffd9f..ad3057f4cc 100644 ---- a/sysdeps/mips/configure.ac -+++ b/sysdeps/mips/configure.ac -@@ -6,9 +6,9 @@ dnl position independent way. - dnl AC_DEFINE(PI_STATIC_AND_HIDDEN) - - AC_CACHE_CHECK([whether the compiler is using the 2008 NaN encoding], -- libc_cv_mips_nan2008, [AC_EGREP_CPP(yes, [dnl -+ libc_cv_mips_nan2008, [AC_EGREP_CPP(use_mips_nan2008, [dnl - #ifdef __mips_nan2008 --yes -+use_mips_nan2008 - #endif], libc_cv_mips_nan2008=yes, libc_cv_mips_nan2008=no)]) - if test x$libc_cv_mips_nan2008 = xyes; then - AC_DEFINE(HAVE_MIPS_NAN2008) -diff --git a/sysdeps/nios2/configure b/sysdeps/nios2/configure -index 14c8a3a014..dde3814ef2 100644 ---- a/sysdeps/nios2/configure -+++ b/sysdeps/nios2/configure -@@ -142,12 +142,12 @@ else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext - /* end confdefs.h. */ - #ifdef __nios2_big_endian__ -- yes -+ is_nios2_be - #endif - - _ACEOF - if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | -- $EGREP "yes" >/dev/null 2>&1; then : -+ $EGREP "is_nios2_be" >/dev/null 2>&1; then : - libc_cv_nios2_be=yes - else - libc_cv_nios2_be=no -diff --git a/sysdeps/nios2/configure.ac b/sysdeps/nios2/configure.ac -index f05f43802b..dc8639902d 100644 ---- a/sysdeps/nios2/configure.ac -+++ b/sysdeps/nios2/configure.ac -@@ -4,8 +4,8 @@ GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory. - # Nios II big endian is not yet supported. - AC_CACHE_CHECK([for big endian], - [libc_cv_nios2_be], -- [AC_EGREP_CPP(yes,[#ifdef __nios2_big_endian__ -- yes -+ [AC_EGREP_CPP(is_nios2_be,[#ifdef __nios2_big_endian__ -+ is_nios2_be - #endif - ], 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 ---- a/sysdeps/unix/sysv/linux/mips/configure -+++ b/sysdeps/unix/sysv/linux/mips/configure -@@ -414,11 +414,11 @@ else - /* end confdefs.h. */ - dnl - #ifdef __mips_nan2008 --yes -+use_mips_nan2008 - #endif - _ACEOF - if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | -- $EGREP "yes" >/dev/null 2>&1; then : -+ $EGREP "use_mips_nan2008" >/dev/null 2>&1; then : - libc_cv_mips_nan2008=yes - 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 ---- a/sysdeps/unix/sysv/linux/mips/configure.ac -+++ b/sysdeps/unix/sysv/linux/mips/configure.ac -@@ -105,9 +105,9 @@ AC_COMPILE_IFELSE( - LIBC_CONFIG_VAR([mips-mode-switch],[${libc_mips_mode_switch}]) - - AC_CACHE_CHECK([whether the compiler is using the 2008 NaN encoding], -- libc_cv_mips_nan2008, [AC_EGREP_CPP(yes, [dnl -+ libc_cv_mips_nan2008, [AC_EGREP_CPP(use_mips_nan2008, [dnl - #ifdef __mips_nan2008 --yes -+use_mips_nan2008 - #endif], libc_cv_mips_nan2008=yes, libc_cv_mips_nan2008=no)]) - - libc_mips_nan= -diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure b/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure -index ae7f254da4..874519000b 100644 ---- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure -+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure -@@ -155,12 +155,12 @@ else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext - /* end confdefs.h. */ - #if _CALL_ELF == 2 -- yes -+ use_ppc_elfv2_abi - #endif - - _ACEOF - if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | -- $EGREP "yes" >/dev/null 2>&1; then : -+ $EGREP "use_ppc_elfv2_abi" >/dev/null 2>&1; then : - libc_cv_ppc64_elfv2_abi=yes - else - libc_cv_ppc64_elfv2_abi=no -@@ -188,12 +188,12 @@ else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext - /* end confdefs.h. */ - #ifdef _CALL_ELF -- yes -+ is_def_call_elf - #endif - - _ACEOF - if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | -- $EGREP "yes" >/dev/null 2>&1; then : -+ $EGREP "is_def_call_elf" >/dev/null 2>&1; then : - libc_cv_ppc64_def_call_elf=yes - else - libc_cv_ppc64_def_call_elf=no -diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure.ac b/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure.ac -index f9cba6e15d..b21f72f1e4 100644 ---- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure.ac -+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure.ac -@@ -6,8 +6,8 @@ LIBC_SLIBDIR_RTLDDIR([lib64], [lib64]) - # Define default-abi according to compiler flags. - AC_CACHE_CHECK([whether the compiler is using the PowerPC64 ELFv2 ABI], - [libc_cv_ppc64_elfv2_abi], -- [AC_EGREP_CPP(yes,[#if _CALL_ELF == 2 -- yes -+ [AC_EGREP_CPP(use_ppc_elfv2_abi,[#if _CALL_ELF == 2 -+ use_ppc_elfv2_abi - #endif - ], libc_cv_ppc64_elfv2_abi=yes, libc_cv_ppc64_elfv2_abi=no)]) - if test $libc_cv_ppc64_elfv2_abi = yes; then -@@ -19,8 +19,8 @@ else - # Compiler that do not support ELFv2 ABI does not define _CALL_ELF - AC_CACHE_CHECK([whether the compiler defines _CALL_ELF], - [libc_cv_ppc64_def_call_elf], -- [AC_EGREP_CPP(yes,[#ifdef _CALL_ELF -- yes -+ [AC_EGREP_CPP(is_def_call_elf,[#ifdef _CALL_ELF -+ is_def_call_elf - #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-Add-unused-attribute.patch b/meta/recipes-core/glibc/glibc/0016-Add-unused-attribute.patch new file mode 100644 index 0000000000..3e5bba5a59 --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0016-Add-unused-attribute.patch @@ -0,0 +1,31 @@ +From 8a8c81ba4e652dddb730d3dad2fecab1ee65fd9c Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 18 Mar 2015 00:28:41 +0000 +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 + + * iconv/gconv_charset.h (strip): + Add unused attribute. + +Signed-off-by: Khem Raj + +Upstream-Status: Pending +--- + iconv/gconv_charset.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/iconv/gconv_charset.h b/iconv/gconv_charset.h +index 348acc089b..fa92465d89 100644 +--- a/iconv/gconv_charset.h ++++ b/iconv/gconv_charset.h +@@ -21,7 +21,7 @@ + #include + + +-static void ++static void __attribute__ ((unused)) + strip (char *wp, const char *s) + { + int slash_count = 0; diff --git a/meta/recipes-core/glibc/glibc/0016-timezone-re-written-tzselect-as-posix-sh.patch b/meta/recipes-core/glibc/glibc/0016-timezone-re-written-tzselect-as-posix-sh.patch deleted file mode 100644 index 4d1cf31973..0000000000 --- a/meta/recipes-core/glibc/glibc/0016-timezone-re-written-tzselect-as-posix-sh.patch +++ /dev/null @@ -1,45 +0,0 @@ -From a74f31ea9edf105f1a6dc26497aa2a12ae736660 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Wed, 18 Mar 2015 00:33:03 +0000 -Subject: [PATCH 16/28] timezone: re-written tzselect as posix sh - -To avoid the bash dependency. - -Upstream-Status: Pending - -Signed-off-by: Hongxu Jia -Signed-off-by: Khem Raj ---- - timezone/Makefile | 2 +- - timezone/tzselect.ksh | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/timezone/Makefile b/timezone/Makefile -index 493deca790..36e559e16c 100644 ---- a/timezone/Makefile -+++ b/timezone/Makefile -@@ -122,7 +122,7 @@ $(testdata)/XT%: testdata/XT% - cp $< $@ - - $(objpfx)tzselect: tzselect.ksh $(common-objpfx)config.make -- sed -e 's|/bin/bash|$(BASH)|' \ -+ sed -e 's|/bin/bash|/bin/sh|' \ - -e 's|TZDIR=[^}]*|TZDIR=$(zonedir)|' \ - -e '/TZVERSION=/s|see_Makefile|"$(version)"|' \ - -e '/PKGVERSION=/s|=.*|="$(PKGVERSION)"|' \ -diff --git a/timezone/tzselect.ksh b/timezone/tzselect.ksh -index 18fce27e24..70745f9d36 100755 ---- a/timezone/tzselect.ksh -+++ b/timezone/tzselect.ksh -@@ -34,7 +34,7 @@ REPORT_BUGS_TO=tz@iana.org - - # Specify default values for environment variables if they are unset. - : ${AWK=awk} --: ${TZDIR=`pwd`} -+: ${TZDIR=$(pwd)} - - # 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/0017-Remove-bash-dependency-for-nscd-init-script.patch deleted file mode 100644 index e4f8a135d3..0000000000 --- a/meta/recipes-core/glibc/glibc/0017-Remove-bash-dependency-for-nscd-init-script.patch +++ /dev/null @@ -1,75 +0,0 @@ -From 95882b9864ff20e476d15c6825c83728eb99597f Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Thu, 31 Dec 2015 14:33:02 -0800 -Subject: [PATCH 17/28] 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. - -Upstream-Status: Pending - -Signed-off-by: Ross Burton -Signed-off-by: Khem Raj ---- - nscd/nscd.init | 14 +++++++------- - 1 file changed, 7 insertions(+), 7 deletions(-) - -diff --git a/nscd/nscd.init b/nscd/nscd.init -index a882da7d8b..b02986ec15 100644 ---- a/nscd/nscd.init -+++ b/nscd/nscd.init -@@ -1,4 +1,4 @@ --#!/bin/bash -+#!/bin/sh - # - # nscd: Starts the Name Switch Cache Daemon - # -@@ -49,7 +49,7 @@ prog=nscd - start () { - [ -d /var/run/nscd ] || mkdir /var/run/nscd - [ -d /var/db/nscd ] || mkdir /var/db/nscd -- echo -n $"Starting $prog: " -+ echo -n "Starting $prog: " - daemon /usr/sbin/nscd - RETVAL=$? - echo -@@ -58,7 +58,7 @@ start () { - } - - stop () { -- echo -n $"Stopping $prog: " -+ echo -n "Stopping $prog: " - /usr/sbin/nscd -K - RETVAL=$? - if [ $RETVAL -eq 0 ]; then -@@ -67,9 +67,9 @@ stop () { - # a non-privileged user - rm -f /var/run/nscd/nscd.pid - rm -f /var/run/nscd/socket -- success $"$prog shutdown" -+ success "$prog shutdown" - else -- failure $"$prog shutdown" -+ failure "$prog shutdown" - fi - echo - return $RETVAL -@@ -103,13 +103,13 @@ case "$1" in - RETVAL=$? - ;; - force-reload | reload) -- echo -n $"Reloading $prog: " -+ echo -n "Reloading $prog: " - killproc /usr/sbin/nscd -HUP - RETVAL=$? - echo - ;; - *) -- echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}" -+ echo "Usage: $0 {start|stop|status|restart|reload|condrestart}" - RETVAL=1 - ;; - esac --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0017-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 new file mode 100644 index 0000000000..0b626bdfac --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0017-yes-within-the-path-sets-wrong-config-variables.patch @@ -0,0 +1,260 @@ +From 601b2d11b6ddd974f0e1685f70e0d368e706d976 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 18 Mar 2015 00:31:06 +0000 +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 +false-positive matches with the path it is configured into. + +The change is to use a more elaborated string to grep for. + +Upstream-Status: Submitted [libc-alpha@sourceware.org] + +Signed-off-by: Benjamin Esquivel +Signed-off-by: Khem Raj +--- + sysdeps/aarch64/configure | 4 ++-- + sysdeps/aarch64/configure.ac | 4 ++-- + sysdeps/arm/configure | 4 ++-- + sysdeps/arm/configure.ac | 4 ++-- + sysdeps/mips/configure | 4 ++-- + sysdeps/mips/configure.ac | 4 ++-- + sysdeps/nios2/configure | 4 ++-- + sysdeps/nios2/configure.ac | 4 ++-- + sysdeps/unix/sysv/linux/mips/configure | 4 ++-- + sysdeps/unix/sysv/linux/mips/configure.ac | 4 ++-- + sysdeps/unix/sysv/linux/powerpc/powerpc64/configure | 8 ++++---- + sysdeps/unix/sysv/linux/powerpc/powerpc64/configure.ac | 8 ++++---- + 12 files changed, 28 insertions(+), 28 deletions(-) + +diff --git a/sysdeps/aarch64/configure b/sysdeps/aarch64/configure +index 5bd355a691..3bc5537bc0 100644 +--- a/sysdeps/aarch64/configure ++++ b/sysdeps/aarch64/configure +@@ -148,12 +148,12 @@ else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + #ifdef __AARCH64EB__ +- yes ++ is_aarch64_be + #endif + + _ACEOF + if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | +- $EGREP "yes" >/dev/null 2>&1; then : ++ $EGREP "is_aarch64_be" >/dev/null 2>&1; then : + libc_cv_aarch64_be=yes + else + libc_cv_aarch64_be=no +diff --git a/sysdeps/aarch64/configure.ac b/sysdeps/aarch64/configure.ac +index 7851dd4dac..6e9238171f 100644 +--- a/sysdeps/aarch64/configure.ac ++++ b/sysdeps/aarch64/configure.ac +@@ -10,8 +10,8 @@ GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory. + # the dynamic linker via %ifdef. + AC_CACHE_CHECK([for big endian], + [libc_cv_aarch64_be], +- [AC_EGREP_CPP(yes,[#ifdef __AARCH64EB__ +- yes ++ [AC_EGREP_CPP(is_aarch64_be,[#ifdef __AARCH64EB__ ++ is_aarch64_be + #endif + ], libc_cv_aarch64_be=yes, libc_cv_aarch64_be=no)]) + if test $libc_cv_aarch64_be = yes; then +diff --git a/sysdeps/arm/configure b/sysdeps/arm/configure +index 431e843b2b..e152461138 100644 +--- a/sysdeps/arm/configure ++++ b/sysdeps/arm/configure +@@ -151,12 +151,12 @@ else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + #ifdef __ARM_PCS_VFP +- yes ++ use_arm_pcs_vfp + #endif + + _ACEOF + if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | +- $EGREP "yes" >/dev/null 2>&1; then : ++ $EGREP "use_arm_pcs_vfp" >/dev/null 2>&1; then : + libc_cv_arm_pcs_vfp=yes + else + libc_cv_arm_pcs_vfp=no +diff --git a/sysdeps/arm/configure.ac b/sysdeps/arm/configure.ac +index 90cdd69c75..05a262ba00 100644 +--- a/sysdeps/arm/configure.ac ++++ b/sysdeps/arm/configure.ac +@@ -15,8 +15,8 @@ AC_DEFINE(PI_STATIC_AND_HIDDEN) + # the dynamic linker via %ifdef. + AC_CACHE_CHECK([whether the compiler is using the ARM hard-float ABI], + [libc_cv_arm_pcs_vfp], +- [AC_EGREP_CPP(yes,[#ifdef __ARM_PCS_VFP +- yes ++ [AC_EGREP_CPP(use_arm_pcs_vfp,[#ifdef __ARM_PCS_VFP ++ use_arm_pcs_vfp + #endif + ], libc_cv_arm_pcs_vfp=yes, libc_cv_arm_pcs_vfp=no)]) + if test $libc_cv_arm_pcs_vfp = yes; then +diff --git a/sysdeps/mips/configure b/sysdeps/mips/configure +index 4e13248c03..f14af952d0 100644 +--- a/sysdeps/mips/configure ++++ b/sysdeps/mips/configure +@@ -143,11 +143,11 @@ else + /* end confdefs.h. */ + dnl + #ifdef __mips_nan2008 +-yes ++use_mips_nan2008 + #endif + _ACEOF + if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | +- $EGREP "yes" >/dev/null 2>&1; then : ++ $EGREP "use_mips_nan2008" >/dev/null 2>&1; then : + libc_cv_mips_nan2008=yes + else + libc_cv_mips_nan2008=no +diff --git a/sysdeps/mips/configure.ac b/sysdeps/mips/configure.ac +index bcbdaffd9f..ad3057f4cc 100644 +--- a/sysdeps/mips/configure.ac ++++ b/sysdeps/mips/configure.ac +@@ -6,9 +6,9 @@ dnl position independent way. + dnl AC_DEFINE(PI_STATIC_AND_HIDDEN) + + AC_CACHE_CHECK([whether the compiler is using the 2008 NaN encoding], +- libc_cv_mips_nan2008, [AC_EGREP_CPP(yes, [dnl ++ libc_cv_mips_nan2008, [AC_EGREP_CPP(use_mips_nan2008, [dnl + #ifdef __mips_nan2008 +-yes ++use_mips_nan2008 + #endif], libc_cv_mips_nan2008=yes, libc_cv_mips_nan2008=no)]) + if test x$libc_cv_mips_nan2008 = xyes; then + AC_DEFINE(HAVE_MIPS_NAN2008) +diff --git a/sysdeps/nios2/configure b/sysdeps/nios2/configure +index 14c8a3a014..dde3814ef2 100644 +--- a/sysdeps/nios2/configure ++++ b/sysdeps/nios2/configure +@@ -142,12 +142,12 @@ else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + #ifdef __nios2_big_endian__ +- yes ++ is_nios2_be + #endif + + _ACEOF + if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | +- $EGREP "yes" >/dev/null 2>&1; then : ++ $EGREP "is_nios2_be" >/dev/null 2>&1; then : + libc_cv_nios2_be=yes + else + libc_cv_nios2_be=no +diff --git a/sysdeps/nios2/configure.ac b/sysdeps/nios2/configure.ac +index f05f43802b..dc8639902d 100644 +--- a/sysdeps/nios2/configure.ac ++++ b/sysdeps/nios2/configure.ac +@@ -4,8 +4,8 @@ GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory. + # Nios II big endian is not yet supported. + AC_CACHE_CHECK([for big endian], + [libc_cv_nios2_be], +- [AC_EGREP_CPP(yes,[#ifdef __nios2_big_endian__ +- yes ++ [AC_EGREP_CPP(is_nios2_be,[#ifdef __nios2_big_endian__ ++ is_nios2_be + #endif + ], 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 25f98e0c7b..e95bfae359 100644 +--- a/sysdeps/unix/sysv/linux/mips/configure ++++ b/sysdeps/unix/sysv/linux/mips/configure +@@ -414,11 +414,11 @@ else + /* end confdefs.h. */ + dnl + #ifdef __mips_nan2008 +-yes ++use_mips_nan2008 + #endif + _ACEOF + if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | +- $EGREP "yes" >/dev/null 2>&1; then : ++ $EGREP "use_mips_nan2008" >/dev/null 2>&1; then : + libc_cv_mips_nan2008=yes + 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 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( + LIBC_CONFIG_VAR([mips-mode-switch],[${libc_mips_mode_switch}]) + + AC_CACHE_CHECK([whether the compiler is using the 2008 NaN encoding], +- libc_cv_mips_nan2008, [AC_EGREP_CPP(yes, [dnl ++ libc_cv_mips_nan2008, [AC_EGREP_CPP(use_mips_nan2008, [dnl + #ifdef __mips_nan2008 +-yes ++use_mips_nan2008 + #endif], libc_cv_mips_nan2008=yes, libc_cv_mips_nan2008=no)]) + + libc_mips_nan= +diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure b/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure +index ae7f254da4..874519000b 100644 +--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure ++++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure +@@ -155,12 +155,12 @@ else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + #if _CALL_ELF == 2 +- yes ++ use_ppc_elfv2_abi + #endif + + _ACEOF + if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | +- $EGREP "yes" >/dev/null 2>&1; then : ++ $EGREP "use_ppc_elfv2_abi" >/dev/null 2>&1; then : + libc_cv_ppc64_elfv2_abi=yes + else + libc_cv_ppc64_elfv2_abi=no +@@ -188,12 +188,12 @@ else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + #ifdef _CALL_ELF +- yes ++ is_def_call_elf + #endif + + _ACEOF + if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | +- $EGREP "yes" >/dev/null 2>&1; then : ++ $EGREP "is_def_call_elf" >/dev/null 2>&1; then : + libc_cv_ppc64_def_call_elf=yes + else + libc_cv_ppc64_def_call_elf=no +diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure.ac b/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure.ac +index f9cba6e15d..b21f72f1e4 100644 +--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure.ac ++++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure.ac +@@ -6,8 +6,8 @@ LIBC_SLIBDIR_RTLDDIR([lib64], [lib64]) + # Define default-abi according to compiler flags. + AC_CACHE_CHECK([whether the compiler is using the PowerPC64 ELFv2 ABI], + [libc_cv_ppc64_elfv2_abi], +- [AC_EGREP_CPP(yes,[#if _CALL_ELF == 2 +- yes ++ [AC_EGREP_CPP(use_ppc_elfv2_abi,[#if _CALL_ELF == 2 ++ use_ppc_elfv2_abi + #endif + ], libc_cv_ppc64_elfv2_abi=yes, libc_cv_ppc64_elfv2_abi=no)]) + if test $libc_cv_ppc64_elfv2_abi = yes; then +@@ -19,8 +19,8 @@ else + # Compiler that do not support ELFv2 ABI does not define _CALL_ELF + AC_CACHE_CHECK([whether the compiler defines _CALL_ELF], + [libc_cv_ppc64_def_call_elf], +- [AC_EGREP_CPP(yes,[#ifdef _CALL_ELF +- yes ++ [AC_EGREP_CPP(is_def_call_elf,[#ifdef _CALL_ELF ++ is_def_call_elf + #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 diff --git a/meta/recipes-core/glibc/glibc/0018-eglibc-Cross-building-and-testing-instructions.patch b/meta/recipes-core/glibc/glibc/0018-eglibc-Cross-building-and-testing-instructions.patch deleted file mode 100644 index b5efc43042..0000000000 --- a/meta/recipes-core/glibc/glibc/0018-eglibc-Cross-building-and-testing-instructions.patch +++ /dev/null @@ -1,619 +0,0 @@ -From 6b603d25cc5723ba631dfc60b544774db1147d81 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Wed, 18 Mar 2015 00:42:58 +0000 -Subject: [PATCH 18/28] eglibc: Cross building and testing instructions - -Ported from eglibc -Upstream-Status: Pending - -Signed-off-by: Khem Raj ---- - GLIBC.cross-building | 383 +++++++++++++++++++++++++++++++++++++++++++ - GLIBC.cross-testing | 205 +++++++++++++++++++++++ - 2 files changed, 588 insertions(+) - create mode 100644 GLIBC.cross-building - create mode 100644 GLIBC.cross-testing - -diff --git a/GLIBC.cross-building b/GLIBC.cross-building -new file mode 100644 -index 0000000000..e6e0da1aaf ---- /dev/null -+++ b/GLIBC.cross-building -@@ -0,0 +1,383 @@ -+ -*- mode: text -*- -+ -+ Cross-Compiling GLIBC -+ Jim Blandy -+ -+ -+Introduction -+ -+Most GNU tools have a simple build procedure: you run their -+'configure' script, and then you run 'make'. Unfortunately, the -+process of cross-compiling the GNU C library is quite a bit more -+involved: -+ -+1) Build a cross-compiler, with certain facilities disabled. -+ -+2) Configure the C library using the compiler you built in step 1). -+ Build a few of the C run-time object files, but not the rest of the -+ library. Install the library's header files and the run-time -+ object files, and create a dummy libc.so. -+ -+3) Build a second cross-compiler, using the header files and object -+ files you installed in step 2. -+ -+4) Configure, build, and install a fresh C library, using the compiler -+ built in step 3. -+ -+5) Build a third cross-compiler, based on the C library built in step 4. -+ -+The reason for this complexity is that, although GCC and the GNU C -+library are distributed separately, they are not actually independent -+of each other: GCC requires the C library's headers and some object -+files to compile its own libraries, while the C library depends on -+GCC's libraries. GLIBC includes features and bug fixes to the stock -+GNU C library that simplify this process, but the fundamental -+interdependency stands. -+ -+In this document, we explain how to cross-compile an GLIBC/GCC pair -+from source. Our intended audience is developers who are already -+familiar with the GNU toolchain and comfortable working with -+cross-development tools. While we do present a worked example to -+accompany the explanation, for clarity's sake we do not cover many of -+the options available to cross-toolchain users. -+ -+ -+Preparation -+ -+GLIBC requires recent versions of the GNU binutils, GCC, and the -+Linux kernel. The web page -+documents the current requirements, and lists patches needed for -+certain target architectures. As of this writing, these build -+instructions have been tested with binutils 2.22.51, GCC 4.6.2, -+and Linux 3.1. -+ -+First, let's set some variables, to simplify later commands. We'll -+build GLIBC and GCC for an ARM target, known to the Linux kernel -+as 'arm', and we'll do the build on an Intel x86_64 Linux box: -+ -+ $ build=x86_64-pc-linux-gnu -+ $ host=$build -+ $ target=arm-none-linux-gnueabi -+ $ linux_arch=arm -+ -+We're using the aforementioned versions of Binutils, GCC, and Linux: -+ -+ $ binutilsv=binutils-2.22.51 -+ $ gccv=gcc-4.6.2 -+ $ linuxv=linux-3.1 -+ -+We're carrying out the entire process under '~/cross-build', which -+contains unpacked source trees for binutils, gcc, and linux kernel, -+along with GLIBC svn trunk (which can be checked-out with -+'svn co http://www.eglibc.org/svn/trunk eglibc'): -+ -+ $ top=$HOME/cross-build/$target -+ $ src=$HOME/cross-build/src -+ $ ls $src -+ binutils-2.22.51 glibc gcc-4.6.2 linux-3.1 -+ -+We're going to place our build directories in a subdirectory 'obj', -+we'll install the cross-development toolchain in 'tools', and we'll -+place our sysroot (containing files to be installed on the target -+system) in 'sysroot': -+ -+ $ obj=$top/obj -+ $ tools=$top/tools -+ $ sysroot=$top/sysroot -+ -+ -+Binutils -+ -+Configuring and building binutils for the target is straightforward: -+ -+ $ mkdir -p $obj/binutils -+ $ cd $obj/binutils -+ $ $src/$binutilsv/configure \ -+ > --target=$target \ -+ > --prefix=$tools \ -+ > --with-sysroot=$sysroot -+ $ make -+ $ make install -+ -+ -+The First GCC -+ -+For our work, we need a cross-compiler targeting an ARM Linux -+system. However, that configuration includes the shared library -+'libgcc_s.so', which is compiled against the GLIBC headers (which we -+haven't installed yet) and linked against 'libc.so' (which we haven't -+built yet). -+ -+Fortunately, there are configuration options for GCC which tell it not -+to build 'libgcc_s.so'. The '--without-headers' option is supposed to -+take care of this, but its implementation is incomplete, so you must -+also configure with the '--with-newlib' option. While '--with-newlib' -+appears to mean "Use the Newlib C library", its effect is to tell the -+GCC build machinery, "Don't assume there is a C library available." -+ -+We also need to disable some of the libraries that would normally be -+built along with GCC, and specify that only the compiler for the C -+language is needed. -+ -+So, we create a build directory, configure, make, and install. -+ -+ $ mkdir -p $obj/gcc1 -+ $ cd $obj/gcc1 -+ $ $src/$gccv/configure \ -+ > --target=$target \ -+ > --prefix=$tools \ -+ > --without-headers --with-newlib \ -+ > --disable-shared --disable-threads --disable-libssp \ -+ > --disable-libgomp --disable-libmudflap --disable-libquadmath \ -+ > --disable-decimal-float --disable-libffi \ -+ > --enable-languages=c -+ $ PATH=$tools/bin:$PATH make -+ $ PATH=$tools/bin:$PATH make install -+ -+ -+Linux Kernel Headers -+ -+To configure GLIBC, we also need Linux kernel headers in place. -+Fortunately, the Linux makefiles have a target that installs them for -+us. Since the process does modify the source tree a bit, we make a -+copy first: -+ -+ $ cp -r $src/$linuxv $obj/linux -+ $ cd $obj/linux -+ -+Now we're ready to install the headers into the sysroot: -+ -+ $ PATH=$tools/bin:$PATH \ -+ > make headers_install \ -+ > ARCH=$linux_arch CROSS_COMPILE=$target- \ -+ > INSTALL_HDR_PATH=$sysroot/usr -+ -+ -+GLIBC Headers and Preliminary Objects -+ -+Using the cross-compiler we've just built, we can now configure GLIBC -+well enough to install the headers and build the object files that the -+full cross-compiler will need: -+ -+ $ mkdir -p $obj/glibc-headers -+ $ cd $obj/glibc-headers -+ $ BUILD_CC=gcc \ -+ > CC=$tools/bin/$target-gcc \ -+ > CXX=$tools/bin/$target-g++ \ -+ > AR=$tools/bin/$target-ar \ -+ > RANLIB=$tools/bin/$target-ranlib \ -+ > $src/glibc/libc/configure \ -+ > --prefix=/usr \ -+ > --with-headers=$sysroot/usr/include \ -+ > --build=$build \ -+ > --host=$target \ -+ > --disable-profile --without-gd --without-cvs \ -+ > --enable-add-ons=nptl,libidn,../ports -+ -+The option '--prefix=/usr' may look strange, but you should never -+configure GLIBC with a prefix other than '/usr': in various places, -+GLIBC's build system checks whether the prefix is '/usr', and does -+special handling only if that is the case. Unless you use this -+prefix, you will get a sysroot that does not use the standard Linux -+directory layouts and cannot be used as a basis for the root -+filesystem on your target system compatibly with normal GLIBC -+installations. -+ -+The '--with-headers' option tells GLIBC where the Linux headers have -+been installed. -+ -+The '--enable-add-ons=nptl,libidn,../ports' option tells GLIBC to look -+for the listed glibc add-ons. Most notably the ports add-on (located -+just above the libc sources in the GLIBC svn tree) is required to -+support ARM targets. -+ -+We can now use the 'install-headers' makefile target to install the -+headers: -+ -+ $ make install-headers install_root=$sysroot \ -+ > install-bootstrap-headers=yes -+ -+The 'install_root' variable indicates where the files should actually -+be installed; its value is treated as the parent of the '--prefix' -+directory we passed to the configure script, so the headers will go in -+'$sysroot/usr/include'. The 'install-bootstrap-headers' variable -+requests special handling for certain tricky header files. -+ -+Next, there are a few object files needed to link shared libraries, -+which we build and install by hand: -+ -+ $ mkdir -p $sysroot/usr/lib -+ $ make csu/subdir_lib -+ $ cp csu/crt1.o csu/crti.o csu/crtn.o $sysroot/usr/lib -+ -+Finally, 'libgcc_s.so' requires a 'libc.so' to link against. However, -+since we will never actually execute its code, it doesn't matter what -+it contains. So, treating '/dev/null' as a C source file, we produce -+a dummy 'libc.so' in one step: -+ -+ $ $tools/bin/$target-gcc -nostdlib -nostartfiles -shared -x c /dev/null \ -+ > -o $sysroot/usr/lib/libc.so -+ -+ -+The Second GCC -+ -+With the GLIBC headers and selected object files installed, we can -+now build a GCC that is capable of compiling GLIBC. We configure, -+build, and install the second GCC, again building only the C compiler, -+and avoiding libraries we won't use: -+ -+ $ mkdir -p $obj/gcc2 -+ $ cd $obj/gcc2 -+ $ $src/$gccv/configure \ -+ > --target=$target \ -+ > --prefix=$tools \ -+ > --with-sysroot=$sysroot \ -+ > --disable-libssp --disable-libgomp --disable-libmudflap \ -+ > --disable-libffi --disable-libquadmath \ -+ > --enable-languages=c -+ $ PATH=$tools/bin:$PATH make -+ $ PATH=$tools/bin:$PATH make install -+ -+ -+GLIBC, Complete -+ -+With the second compiler built and installed, we're now ready for the -+full GLIBC build: -+ -+ $ mkdir -p $obj/glibc -+ $ cd $obj/glibc -+ $ BUILD_CC=gcc \ -+ > CC=$tools/bin/$target-gcc \ -+ > CXX=$tools/bin/$target-g++ \ -+ > AR=$tools/bin/$target-ar \ -+ > RANLIB=$tools/bin/$target-ranlib \ -+ > $src/glibc/libc/configure \ -+ > --prefix=/usr \ -+ > --with-headers=$sysroot/usr/include \ -+ > --with-kconfig=$obj/linux/scripts/kconfig \ -+ > --build=$build \ -+ > --host=$target \ -+ > --disable-profile --without-gd --without-cvs \ -+ > --enable-add-ons=nptl,libidn,../ports -+ -+Note the additional '--with-kconfig' option. This tells GLIBC where to -+find the host config tools used by the kernel 'make config' and 'make -+menuconfig'. These tools can be re-used by GLIBC for its own 'make -+*config' support, which will create 'option-groups.config' for you. -+But first make sure those tools have been built by running some -+dummy 'make *config' calls in the kernel directory: -+ -+ $ cd $obj/linux -+ $ PATH=$tools/bin:$PATH make config \ -+ > ARCH=$linux_arch CROSS_COMPILE=$target- \ -+ $ PATH=$tools/bin:$PATH make menuconfig \ -+ > ARCH=$linux_arch CROSS_COMPILE=$target- \ -+ -+Now we can configure and build the full GLIBC: -+ -+ $ cd $obj/glibc -+ $ PATH=$tools/bin:$PATH make defconfig -+ $ PATH=$tools/bin:$PATH make menuconfig -+ $ PATH=$tools/bin:$PATH make -+ $ PATH=$tools/bin:$PATH make install install_root=$sysroot -+ -+At this point, we have a complete GLIBC installation in '$sysroot', -+with header files, library files, and most of the C runtime startup -+files in place. -+ -+ -+The Third GCC -+ -+Finally, we recompile GCC against this full installation, enabling -+whatever languages and libraries we would like to use: -+ -+ $ mkdir -p $obj/gcc3 -+ $ cd $obj/gcc3 -+ $ $src/$gccv/configure \ -+ > --target=$target \ -+ > --prefix=$tools \ -+ > --with-sysroot=$sysroot \ -+ > --enable-__cxa_atexit \ -+ > --disable-libssp --disable-libgomp --disable-libmudflap \ -+ > --enable-languages=c,c++ -+ $ PATH=$tools/bin:$PATH make -+ $ PATH=$tools/bin:$PATH make install -+ -+The '--enable-__cxa_atexit' option tells GCC what sort of C++ -+destructor support to expect from the C library; it's required with -+GLIBC. -+ -+And since GCC's installation process isn't designed to help construct -+sysroot trees, we must manually copy certain libraries into place in -+the sysroot. -+ -+ $ cp -d $tools/$target/lib/libgcc_s.so* $sysroot/lib -+ $ cp -d $tools/$target/lib/libstdc++.so* $sysroot/usr/lib -+ -+ -+Trying Things Out -+ -+At this point, '$tools' contains a cross toolchain ready to use -+the GLIBC installation in '$sysroot': -+ -+ $ cat > hello.c < #include -+ > int -+ > main (int argc, char **argv) -+ > { -+ > puts ("Hello, world!"); -+ > return 0; -+ > } -+ > EOF -+ $ $tools/bin/$target-gcc -Wall hello.c -o hello -+ $ cat > c++-hello.cc < #include -+ > int -+ > main (int argc, char **argv) -+ > { -+ > std::cout << "Hello, C++ world!" << std::endl; -+ > return 0; -+ > } -+ > EOF -+ $ $tools/bin/$target-g++ -Wall c++-hello.cc -o c++-hello -+ -+ -+We can use 'readelf' to verify that these are indeed executables for -+our target, using our dynamic linker: -+ -+ $ $tools/bin/$target-readelf -hl hello -+ ELF Header: -+ ... -+ Type: EXEC (Executable file) -+ Machine: ARM -+ -+ ... -+ Program Headers: -+ Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align -+ PHDR 0x000034 0x10000034 0x10000034 0x00100 0x00100 R E 0x4 -+ INTERP 0x000134 0x00008134 0x00008134 0x00013 0x00013 R 0x1 -+ [Requesting program interpreter: /lib/ld-linux.so.3] -+ LOAD 0x000000 0x00008000 0x00008000 0x0042c 0x0042c R E 0x8000 -+ ... -+ -+Looking at the dynamic section of the installed 'libgcc_s.so', we see -+that the 'NEEDED' entry for the C library does include the '.6' -+suffix, indicating that was linked against our fully build GLIBC, and -+not our dummy 'libc.so': -+ -+ $ $tools/bin/$target-readelf -d $sysroot/lib/libgcc_s.so.1 -+ Dynamic section at offset 0x1083c contains 24 entries: -+ Tag Type Name/Value -+ 0x00000001 (NEEDED) Shared library: [libc.so.6] -+ 0x0000000e (SONAME) Library soname: [libgcc_s.so.1] -+ ... -+ -+ -+And on the target machine, we can run our programs: -+ -+ $ $sysroot/lib/ld.so.1 --library-path $sysroot/lib:$sysroot/usr/lib \ -+ > ./hello -+ Hello, world! -+ $ $sysroot/lib/ld.so.1 --library-path $sysroot/lib:$sysroot/usr/lib \ -+ > ./c++-hello -+ Hello, C++ world! -diff --git a/GLIBC.cross-testing b/GLIBC.cross-testing -new file mode 100644 -index 0000000000..b67b468466 ---- /dev/null -+++ b/GLIBC.cross-testing -@@ -0,0 +1,205 @@ -+ -*- mode: text -*- -+ -+ Cross-Testing With GLIBC -+ Jim Blandy -+ -+ -+Introduction -+ -+Developers writing software for embedded systems often use a desktop -+or other similarly capable computer for development, but need to run -+tests on the embedded system, or perhaps on a simulator. When -+configured for cross-compilation, the stock GNU C library simply -+disables running tests altogether: the command 'make tests' builds -+test programs, but does not run them. GLIBC, however, provides -+facilities for compiling tests and generating data files on the build -+system, but running the test programs themselves on a remote system or -+simulator. -+ -+ -+Test environment requirements -+ -+The test environment must meet certain conditions for GLIBC's -+cross-testing facilities to work: -+ -+- Shared filesystems. The 'build' system, on which you configure and -+ compile GLIBC, and the 'host' system, on which you intend to run -+ GLIBC, must share a filesystem containing the GLIBC build and -+ source trees. Files must appear at the same paths on both systems. -+ -+- Remote-shell like invocation. There must be a way to run a program -+ on the host system from the build system, passing it properly quoted -+ command-line arguments, setting environment variables, and -+ inheriting the caller's standard input and output. -+ -+ -+Usage -+ -+To use GLIBC's cross-testing support, provide values for the -+following Make variables when you invoke 'make': -+ -+- cross-test-wrapper -+ -+ This should be the name of the cross-testing wrapper command, along -+ with any arguments. -+ -+- cross-localedef -+ -+ This should be the name of a cross-capable localedef program, like -+ that included in the GLIBC 'localedef' module, along with any -+ arguments needed. -+ -+These are each explained in detail below. -+ -+ -+The Cross-Testing Wrapper -+ -+To run test programs reliably, the stock GNU C library takes care to -+ensure that test programs use the newly compiled dynamic linker and -+shared libraries, and never the host system's installed libraries. To -+accomplish this, it runs the tests by explicitly invoking the dynamic -+linker from the build tree, passing it a list of build tree -+directories to search for shared libraries, followed by the name of -+the executable to run and its arguments. -+ -+For example, where one might normally run a test program like this: -+ -+ $ ./tst-foo arg1 arg2 -+ -+the GNU C library might run that program like this: -+ -+ $ $objdir/elf/ld-linux.so.3 --library-path $objdir \ -+ ./tst-foo arg1 arg2 -+ -+(where $objdir is the path to the top of the build tree, and the -+trailing backslash indicates a continuation of the command). In other -+words, each test program invocation is 'wrapped up' inside an explicit -+invocation of the dynamic linker, which must itself execute the test -+program, having loaded shared libraries from the appropriate -+directories. -+ -+To support cross-testing, GLIBC allows the developer to optionally -+set the 'cross-test-wrapper' Make variable to another wrapper command, -+to which it passes the entire dynamic linker invocation shown above as -+arguments. For example, if the developer supplies a wrapper of -+'my-wrapper hostname', then GLIBC would run the test above as -+follows: -+ -+ $ my-wrapper hostname \ -+ $objdir/elf/ld-linux.so.3 --library-path $objdir \ -+ ./tst-foo arg1 arg2 -+ -+The 'my-wrapper' command is responsible for executing the command -+given on the host system. -+ -+Since tests are run in varying directories, the wrapper should either -+be in your command search path, or 'cross-test-wrapper' should give an -+absolute path for the wrapper. -+ -+The wrapper must meet several requirements: -+ -+- It must preserve the current directory. As explained above, the -+ build directory tree must be visible on both the build and host -+ systems, at the same path. The test wrapper must ensure that the -+ current directory it inherits is also inherited by the dynamic -+ linker (and thus the test program itself). -+ -+- It must preserve environment variables' values. Many GLIBC tests -+ set environment variables for test runs; in native testing, it -+ invokes programs like this: -+ -+ $ GCONV_PATH=$objdir/iconvdata \ -+ $objdir/elf/ld-linux.so.3 --library-path $objdir \ -+ ./tst-foo arg1 arg2 -+ -+ With the cross-testing wrapper, that invocation becomes: -+ -+ $ GCONV_PATH=$objdir/iconvdata \ -+ my-wrapper hostname \ -+ $objdir/elf/ld-linux.so.3 --library-path $objdir \ -+ ./tst-foo arg1 arg2 -+ -+ Here, 'my-wrapper' must ensure that the value it sees for -+ 'GCONV_PATH' will be seen by the dynamic linker, and thus 'tst-foo' -+ itself. (The wrapper supplied with GLIBC simply preserves the -+ values of *all* enviroment variables, with a fixed set of -+ exceptions.) -+ -+ If your wrapper is a shell script, take care to correctly propagate -+ environment variables whose values contain spaces and shell -+ metacharacters. -+ -+- It must pass the command's arguments, unmodified. The arguments -+ seen by the test program should be exactly those seen by the wrapper -+ (after whatever arguments are given to the wrapper itself). The -+ GLIBC test framework performs all needed shell word splitting and -+ expansion (wildcard expansion, parameter substitution, and so on) -+ before invoking the wrapper; further expansion may break the tests. -+ -+ -+The 'cross-test-ssh.sh' script -+ -+If you want to use 'ssh' (or something sufficiently similar) to run -+test programs on your host system, GLIBC includes a shell script, -+'scripts/cross-test-ssh.sh', which you can use as your wrapper -+command. This script takes care of setting the test command's current -+directory, propagating environment variable values, and carrying -+command-line arguments, all across an 'ssh' connection. You may even -+supply an alternative to 'ssh' on the command line, if needed. -+ -+For more details, pass 'cross-test-ssh.sh' the '--help' option. -+ -+ -+The Cross-Compiling Locale Definition Command -+ -+Some GLIBC tests rely on locales generated especially for the test -+process. In a native configuration, these tests simply run the -+'localedef' command built by the normal GLIBC build process, -+'locale/localedef', to process and install their locales. However, in -+a cross-compiling configuration, this 'localedef' is built for the -+host system, not the build system, and since it requires quite a bit -+of memory to run (we have seen it fail on systems with 64MiB of -+memory), it may not be practical to run it on the host system. -+ -+If set, GLIBC uses the 'cross-localedef' Make variable as the command -+to run on the build system to process and install locales. The -+localedef program built from the GLIBC 'localedef' module is -+suitable. -+ -+The value of 'cross-localedef' may also include command-line arguments -+to be passed to the program; if you are using GLIBC's 'localedef', -+you may include endianness and 'uint32_t' alignment arguments here. -+ -+ -+Example -+ -+In developing GLIBC's cross-testing facility, we invoked 'make' with -+the following script: -+ -+ #!/bin/sh -+ -+ srcdir=... -+ test_hostname=... -+ localedefdir=... -+ cross_gxx=...-g++ -+ -+ wrapper="$srcdir/scripts/cross-test-ssh.sh $test_hostname" -+ localedef="$localedefdir/localedef --little-endian --uint32-align=4" -+ -+ make cross-test-wrapper="$wrapper" \ -+ cross-localedef="$localedef" \ -+ CXX="$cross_gxx" \ -+ "$@" -+ -+ -+Other Cross-Testing Concerns -+ -+Here are notes on some other issues which you may encounter in running -+the GLIBC tests in a cross-compiling environment: -+ -+- Some tests require a C++ cross-compiler; you should set the 'CXX' -+ Make variable to the name of an appropriate cross-compiler. -+ -+- 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/0018-timezone-re-written-tzselect-as-posix-sh.patch b/meta/recipes-core/glibc/glibc/0018-timezone-re-written-tzselect-as-posix-sh.patch new file mode 100644 index 0000000000..f18c7a1107 --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0018-timezone-re-written-tzselect-as-posix-sh.patch @@ -0,0 +1,42 @@ +From 8678c584bca244fe9a3f8926eabb6b6c7e9784f1 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 18 Mar 2015 00:33:03 +0000 +Subject: [PATCH] timezone: re-written tzselect as posix sh + +To avoid the bash dependency. + +Upstream-Status: Pending + +Signed-off-by: Hongxu Jia +Signed-off-by: Khem Raj +--- + timezone/Makefile | 2 +- + timezone/tzselect.ksh | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/timezone/Makefile b/timezone/Makefile +index 75f38df527..74e1ab7ff7 100644 +--- a/timezone/Makefile ++++ b/timezone/Makefile +@@ -122,7 +122,7 @@ $(testdata)/XT%: testdata/XT% + cp $< $@ + + $(objpfx)tzselect: tzselect.ksh $(common-objpfx)config.make +- sed -e 's|/bin/bash|$(BASH)|' \ ++ sed -e 's|/bin/bash|/bin/sh|' \ + -e 's|TZDIR=[^}]*|TZDIR=$(zonedir)|' \ + -e '/TZVERSION=/s|see_Makefile|"$(version)"|' \ + -e '/PKGVERSION=/s|=.*|="$(PKGVERSION)"|' \ +diff --git a/timezone/tzselect.ksh b/timezone/tzselect.ksh +index 18fce27e24..70745f9d36 100755 +--- a/timezone/tzselect.ksh ++++ b/timezone/tzselect.ksh +@@ -34,7 +34,7 @@ REPORT_BUGS_TO=tz@iana.org + + # Specify default values for environment variables if they are unset. + : ${AWK=awk} +-: ${TZDIR=`pwd`} ++: ${TZDIR=$(pwd)} + + # Output one argument as-is to standard output. + # Safer than 'echo', which can mishandle '\' or leading '-'. diff --git a/meta/recipes-core/glibc/glibc/0019-Remove-bash-dependency-for-nscd-init-script.patch b/meta/recipes-core/glibc/glibc/0019-Remove-bash-dependency-for-nscd-init-script.patch new file mode 100644 index 0000000000..82026694de --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0019-Remove-bash-dependency-for-nscd-init-script.patch @@ -0,0 +1,72 @@ +From a78f21f2f9b9246cd12b310833313328e8f646ed Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Thu, 31 Dec 2015 14:33:02 -0800 +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. + +Upstream-Status: Pending + +Signed-off-by: Ross Burton +Signed-off-by: Khem Raj +--- + nscd/nscd.init | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +diff --git a/nscd/nscd.init b/nscd/nscd.init +index a882da7d8b..b02986ec15 100644 +--- a/nscd/nscd.init ++++ b/nscd/nscd.init +@@ -1,4 +1,4 @@ +-#!/bin/bash ++#!/bin/sh + # + # nscd: Starts the Name Switch Cache Daemon + # +@@ -49,7 +49,7 @@ prog=nscd + start () { + [ -d /var/run/nscd ] || mkdir /var/run/nscd + [ -d /var/db/nscd ] || mkdir /var/db/nscd +- echo -n $"Starting $prog: " ++ echo -n "Starting $prog: " + daemon /usr/sbin/nscd + RETVAL=$? + echo +@@ -58,7 +58,7 @@ start () { + } + + stop () { +- echo -n $"Stopping $prog: " ++ echo -n "Stopping $prog: " + /usr/sbin/nscd -K + RETVAL=$? + if [ $RETVAL -eq 0 ]; then +@@ -67,9 +67,9 @@ stop () { + # a non-privileged user + rm -f /var/run/nscd/nscd.pid + rm -f /var/run/nscd/socket +- success $"$prog shutdown" ++ success "$prog shutdown" + else +- failure $"$prog shutdown" ++ failure "$prog shutdown" + fi + echo + return $RETVAL +@@ -103,13 +103,13 @@ case "$1" in + RETVAL=$? + ;; + force-reload | reload) +- echo -n $"Reloading $prog: " ++ echo -n "Reloading $prog: " + killproc /usr/sbin/nscd -HUP + RETVAL=$? + echo + ;; + *) +- echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}" ++ echo "Usage: $0 {start|stop|status|restart|reload|condrestart}" + RETVAL=1 + ;; + esac diff --git a/meta/recipes-core/glibc/glibc/0019-eglibc-Help-bootstrap-cross-toolchain.patch b/meta/recipes-core/glibc/glibc/0019-eglibc-Help-bootstrap-cross-toolchain.patch deleted file mode 100644 index 0333db2814..0000000000 --- a/meta/recipes-core/glibc/glibc/0019-eglibc-Help-bootstrap-cross-toolchain.patch +++ /dev/null @@ -1,100 +0,0 @@ -From 2864aaae984d945445f3f79869c703e0b791df88 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Wed, 18 Mar 2015 00:49:28 +0000 -Subject: [PATCH 19/28] eglibc: Help bootstrap cross toolchain - -Taken from EGLIBC, r1484 + r1525 - - 2007-02-20 Jim Blandy - - * Makefile (install-headers): Preserve old behavior: depend on - $(inst_includedir)/gnu/stubs.h only if install-bootstrap-headers - is set; otherwise, place gnu/stubs.h on the 'install-others' list. - - 2007-02-16 Jim Blandy - - * Makefile: Amend make install-headers to install everything - necessary for building a cross-compiler. Install gnu/stubs.h as - part of 'install-headers', not 'install-others'. - If install-bootstrap-headers is 'yes', install a dummy copy of - gnu/stubs.h, instead of computing the real thing. - * include/stubs-bootstrap.h: New file. - -Upstream-Status: Pending -Signed-off-by: Khem Raj ---- - Makefile | 22 +++++++++++++++++++++- - include/stubs-bootstrap.h | 12 ++++++++++++ - 2 files changed, 33 insertions(+), 1 deletion(-) - create mode 100644 include/stubs-bootstrap.h - -diff --git a/Makefile b/Makefile -index 9fbf705200..64bfd455bc 100644 ---- a/Makefile -+++ b/Makefile -@@ -70,9 +70,18 @@ subdir-dirs = include - vpath %.h $(subdir-dirs) - - # What to install. --install-others = $(inst_includedir)/gnu/stubs.h - install-bin-script = - -+# If we're bootstrapping, install a dummy gnu/stubs.h along with the -+# other headers, so 'make install-headers' produces a useable include -+# tree. Otherwise, install gnu/stubs.h later, after the rest of the -+# build is done. -+ifeq ($(install-bootstrap-headers),yes) -+install-headers: $(inst_includedir)/gnu/stubs.h -+else -+install-others = $(inst_includedir)/gnu/stubs.h -+endif -+ - ifeq (yes,$(build-shared)) - headers += gnu/lib-names.h - endif -@@ -196,6 +205,16 @@ others: $(common-objpfx)testrun.sh - - subdir-stubs := $(foreach dir,$(subdirs),$(common-objpfx)$(dir)/stubs) - -+# gnu/stubs.h depends (via the subdir 'stubs' targets) on all the .o -+# files in EGLIBC. For bootstrapping a GCC/EGLIBC pair, an empty -+# gnu/stubs.h is good enough. -+ifeq ($(install-bootstrap-headers),yes) -+$(inst_includedir)/gnu/stubs.h: include/stubs-bootstrap.h $(+force) -+ $(make-target-directory) -+ $(INSTALL_DATA) $< $@ -+ -+installed-stubs = -+else - ifndef abi-variants - installed-stubs = $(inst_includedir)/gnu/stubs.h - else -@@ -222,6 +241,7 @@ $(inst_includedir)/gnu/stubs.h: $(+force) - - install-others-nosubdir: $(installed-stubs) - endif -+endif - - - # Since stubs.h is never needed when building the library, we simplify the -diff --git a/include/stubs-bootstrap.h b/include/stubs-bootstrap.h -new file mode 100644 -index 0000000000..1d2b669aff ---- /dev/null -+++ b/include/stubs-bootstrap.h -@@ -0,0 +1,12 @@ -+/* Placeholder stubs.h file for bootstrapping. -+ -+ When bootstrapping a GCC/EGLIBC pair, GCC requires that the EGLIBC -+ headers be installed, but we can't fully build EGLIBC without that -+ GCC. So we run the command: -+ -+ make install-headers install-bootstrap-headers=yes -+ -+ to install the headers GCC needs, but avoid building certain -+ difficult headers. The 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/0020-eglibc-Clear-cache-lines-on-ppc8xx.patch deleted file mode 100644 index 965ad6578e..0000000000 --- a/meta/recipes-core/glibc/glibc/0020-eglibc-Clear-cache-lines-on-ppc8xx.patch +++ /dev/null @@ -1,83 +0,0 @@ -From e2667086bf984de4d3f1226b9467761cd5a4c39f Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Thu, 31 Dec 2015 15:15:09 -0800 -Subject: [PATCH 20/28] eglibc: Clear cache lines on ppc8xx - -2007-06-13 Nathan Sidwell - Mark Shinwell - - * sysdeps/unix/sysv/linux/powerpc/libc-start.c - (__libc_start_main): Detect 8xx parts and clear - __cache_line_size if detected. - * sysdeps/unix/sysv/linux/powerpc/dl-sysdep.c - (DL_PLATFORM_AUXV): Likewise. - -Upstream-Status: Pending - -Signed-off-by: Khem Raj ---- - sysdeps/unix/sysv/linux/powerpc/dl-sysdep.c | 14 +++++++++++++- - sysdeps/unix/sysv/linux/powerpc/libc-start.c | 16 +++++++++++++++- - 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 ---- 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; - /* Scan the Aux Vector for the "Data Cache Block Size" entry. If found - verify that the static extern __cache_line_size is defined by checking - for not NULL. If it is defined then assign the cache block size -- value to __cache_line_size. */ -+ value to __cache_line_size. This is used by memset to -+ optimize setting to zero. We have to detect 8xx processors, which -+ have buggy dcbz implementations that cannot report page faults -+ correctly. That requires reading SPR, which is a privileged -+ operation. Fortunately 2.2.18 and later emulates PowerPC mfspr -+ reads from the PVR register. */ - #define DL_PLATFORM_AUXV \ - case AT_DCACHEBSIZE: \ -+ if (__LINUX_KERNEL_VERSION >= 0x020218) \ -+ { \ -+ unsigned pvr = 0; \ -+ asm ("mfspr %0, 287" : "=r" (pvr)); \ -+ if ((pvr & 0xffff0000) == 0x00500000) \ -+ break; \ -+ } \ - __cache_line_size = av->a_un.a_val; \ - 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 ---- 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, - - /* Initialize the __cache_line_size variable from the aux vector. For the - static case, we also need _dl_hwcap, _dl_hwcap2 and _dl_platform, so we -- can call __tcb_parse_hwcap_and_convert_at_platform (). */ -+ can call __tcb_parse_hwcap_and_convert_at_platform (). -+ -+ This is used by memset to optimize setting to zero. We have to -+ detect 8xx processors, which have buggy dcbz implementations that -+ cannot report page faults correctly. That requires reading SPR, -+ which is a privileged operation. Fortunately 2.2.18 and later -+ emulates PowerPC mfspr reads from the PVR register. */ - for (ElfW (auxv_t) * av = auxvec; av->a_type != AT_NULL; ++av) - switch (av->a_type) - { - case AT_DCACHEBSIZE: -+ if (__LINUX_KERNEL_VERSION >= 0x020218) -+ { -+ unsigned pvr = 0; -+ -+ asm ("mfspr %0, 287" : "=r" (pvr) :); -+ if ((pvr & 0xffff0000) == 0x00500000) -+ break; -+ } - __cache_line_size = av->a_un.a_val; - break; - #ifndef SHARED --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0020-eglibc-Cross-building-and-testing-instructions.patch b/meta/recipes-core/glibc/glibc/0020-eglibc-Cross-building-and-testing-instructions.patch new file mode 100644 index 0000000000..f8f3efe582 --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0020-eglibc-Cross-building-and-testing-instructions.patch @@ -0,0 +1,616 @@ +From 7c48f61b0c5ef6274df4b03609991d383adc5df0 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 18 Mar 2015 00:42:58 +0000 +Subject: [PATCH] eglibc: Cross building and testing instructions + +Ported from eglibc +Upstream-Status: Pending + +Signed-off-by: Khem Raj +--- + GLIBC.cross-building | 383 +++++++++++++++++++++++++++++++++++++++++++ + GLIBC.cross-testing | 205 +++++++++++++++++++++++ + 2 files changed, 588 insertions(+) + create mode 100644 GLIBC.cross-building + create mode 100644 GLIBC.cross-testing + +diff --git a/GLIBC.cross-building b/GLIBC.cross-building +new file mode 100644 +index 0000000000..e6e0da1aaf +--- /dev/null ++++ b/GLIBC.cross-building +@@ -0,0 +1,383 @@ ++ -*- mode: text -*- ++ ++ Cross-Compiling GLIBC ++ Jim Blandy ++ ++ ++Introduction ++ ++Most GNU tools have a simple build procedure: you run their ++'configure' script, and then you run 'make'. Unfortunately, the ++process of cross-compiling the GNU C library is quite a bit more ++involved: ++ ++1) Build a cross-compiler, with certain facilities disabled. ++ ++2) Configure the C library using the compiler you built in step 1). ++ Build a few of the C run-time object files, but not the rest of the ++ library. Install the library's header files and the run-time ++ object files, and create a dummy libc.so. ++ ++3) Build a second cross-compiler, using the header files and object ++ files you installed in step 2. ++ ++4) Configure, build, and install a fresh C library, using the compiler ++ built in step 3. ++ ++5) Build a third cross-compiler, based on the C library built in step 4. ++ ++The reason for this complexity is that, although GCC and the GNU C ++library are distributed separately, they are not actually independent ++of each other: GCC requires the C library's headers and some object ++files to compile its own libraries, while the C library depends on ++GCC's libraries. GLIBC includes features and bug fixes to the stock ++GNU C library that simplify this process, but the fundamental ++interdependency stands. ++ ++In this document, we explain how to cross-compile an GLIBC/GCC pair ++from source. Our intended audience is developers who are already ++familiar with the GNU toolchain and comfortable working with ++cross-development tools. While we do present a worked example to ++accompany the explanation, for clarity's sake we do not cover many of ++the options available to cross-toolchain users. ++ ++ ++Preparation ++ ++GLIBC requires recent versions of the GNU binutils, GCC, and the ++Linux kernel. The web page ++documents the current requirements, and lists patches needed for ++certain target architectures. As of this writing, these build ++instructions have been tested with binutils 2.22.51, GCC 4.6.2, ++and Linux 3.1. ++ ++First, let's set some variables, to simplify later commands. We'll ++build GLIBC and GCC for an ARM target, known to the Linux kernel ++as 'arm', and we'll do the build on an Intel x86_64 Linux box: ++ ++ $ build=x86_64-pc-linux-gnu ++ $ host=$build ++ $ target=arm-none-linux-gnueabi ++ $ linux_arch=arm ++ ++We're using the aforementioned versions of Binutils, GCC, and Linux: ++ ++ $ binutilsv=binutils-2.22.51 ++ $ gccv=gcc-4.6.2 ++ $ linuxv=linux-3.1 ++ ++We're carrying out the entire process under '~/cross-build', which ++contains unpacked source trees for binutils, gcc, and linux kernel, ++along with GLIBC svn trunk (which can be checked-out with ++'svn co http://www.eglibc.org/svn/trunk eglibc'): ++ ++ $ top=$HOME/cross-build/$target ++ $ src=$HOME/cross-build/src ++ $ ls $src ++ binutils-2.22.51 glibc gcc-4.6.2 linux-3.1 ++ ++We're going to place our build directories in a subdirectory 'obj', ++we'll install the cross-development toolchain in 'tools', and we'll ++place our sysroot (containing files to be installed on the target ++system) in 'sysroot': ++ ++ $ obj=$top/obj ++ $ tools=$top/tools ++ $ sysroot=$top/sysroot ++ ++ ++Binutils ++ ++Configuring and building binutils for the target is straightforward: ++ ++ $ mkdir -p $obj/binutils ++ $ cd $obj/binutils ++ $ $src/$binutilsv/configure \ ++ > --target=$target \ ++ > --prefix=$tools \ ++ > --with-sysroot=$sysroot ++ $ make ++ $ make install ++ ++ ++The First GCC ++ ++For our work, we need a cross-compiler targeting an ARM Linux ++system. However, that configuration includes the shared library ++'libgcc_s.so', which is compiled against the GLIBC headers (which we ++haven't installed yet) and linked against 'libc.so' (which we haven't ++built yet). ++ ++Fortunately, there are configuration options for GCC which tell it not ++to build 'libgcc_s.so'. The '--without-headers' option is supposed to ++take care of this, but its implementation is incomplete, so you must ++also configure with the '--with-newlib' option. While '--with-newlib' ++appears to mean "Use the Newlib C library", its effect is to tell the ++GCC build machinery, "Don't assume there is a C library available." ++ ++We also need to disable some of the libraries that would normally be ++built along with GCC, and specify that only the compiler for the C ++language is needed. ++ ++So, we create a build directory, configure, make, and install. ++ ++ $ mkdir -p $obj/gcc1 ++ $ cd $obj/gcc1 ++ $ $src/$gccv/configure \ ++ > --target=$target \ ++ > --prefix=$tools \ ++ > --without-headers --with-newlib \ ++ > --disable-shared --disable-threads --disable-libssp \ ++ > --disable-libgomp --disable-libmudflap --disable-libquadmath \ ++ > --disable-decimal-float --disable-libffi \ ++ > --enable-languages=c ++ $ PATH=$tools/bin:$PATH make ++ $ PATH=$tools/bin:$PATH make install ++ ++ ++Linux Kernel Headers ++ ++To configure GLIBC, we also need Linux kernel headers in place. ++Fortunately, the Linux makefiles have a target that installs them for ++us. Since the process does modify the source tree a bit, we make a ++copy first: ++ ++ $ cp -r $src/$linuxv $obj/linux ++ $ cd $obj/linux ++ ++Now we're ready to install the headers into the sysroot: ++ ++ $ PATH=$tools/bin:$PATH \ ++ > make headers_install \ ++ > ARCH=$linux_arch CROSS_COMPILE=$target- \ ++ > INSTALL_HDR_PATH=$sysroot/usr ++ ++ ++GLIBC Headers and Preliminary Objects ++ ++Using the cross-compiler we've just built, we can now configure GLIBC ++well enough to install the headers and build the object files that the ++full cross-compiler will need: ++ ++ $ mkdir -p $obj/glibc-headers ++ $ cd $obj/glibc-headers ++ $ BUILD_CC=gcc \ ++ > CC=$tools/bin/$target-gcc \ ++ > CXX=$tools/bin/$target-g++ \ ++ > AR=$tools/bin/$target-ar \ ++ > RANLIB=$tools/bin/$target-ranlib \ ++ > $src/glibc/libc/configure \ ++ > --prefix=/usr \ ++ > --with-headers=$sysroot/usr/include \ ++ > --build=$build \ ++ > --host=$target \ ++ > --disable-profile --without-gd --without-cvs \ ++ > --enable-add-ons=nptl,libidn,../ports ++ ++The option '--prefix=/usr' may look strange, but you should never ++configure GLIBC with a prefix other than '/usr': in various places, ++GLIBC's build system checks whether the prefix is '/usr', and does ++special handling only if that is the case. Unless you use this ++prefix, you will get a sysroot that does not use the standard Linux ++directory layouts and cannot be used as a basis for the root ++filesystem on your target system compatibly with normal GLIBC ++installations. ++ ++The '--with-headers' option tells GLIBC where the Linux headers have ++been installed. ++ ++The '--enable-add-ons=nptl,libidn,../ports' option tells GLIBC to look ++for the listed glibc add-ons. Most notably the ports add-on (located ++just above the libc sources in the GLIBC svn tree) is required to ++support ARM targets. ++ ++We can now use the 'install-headers' makefile target to install the ++headers: ++ ++ $ make install-headers install_root=$sysroot \ ++ > install-bootstrap-headers=yes ++ ++The 'install_root' variable indicates where the files should actually ++be installed; its value is treated as the parent of the '--prefix' ++directory we passed to the configure script, so the headers will go in ++'$sysroot/usr/include'. The 'install-bootstrap-headers' variable ++requests special handling for certain tricky header files. ++ ++Next, there are a few object files needed to link shared libraries, ++which we build and install by hand: ++ ++ $ mkdir -p $sysroot/usr/lib ++ $ make csu/subdir_lib ++ $ cp csu/crt1.o csu/crti.o csu/crtn.o $sysroot/usr/lib ++ ++Finally, 'libgcc_s.so' requires a 'libc.so' to link against. However, ++since we will never actually execute its code, it doesn't matter what ++it contains. So, treating '/dev/null' as a C source file, we produce ++a dummy 'libc.so' in one step: ++ ++ $ $tools/bin/$target-gcc -nostdlib -nostartfiles -shared -x c /dev/null \ ++ > -o $sysroot/usr/lib/libc.so ++ ++ ++The Second GCC ++ ++With the GLIBC headers and selected object files installed, we can ++now build a GCC that is capable of compiling GLIBC. We configure, ++build, and install the second GCC, again building only the C compiler, ++and avoiding libraries we won't use: ++ ++ $ mkdir -p $obj/gcc2 ++ $ cd $obj/gcc2 ++ $ $src/$gccv/configure \ ++ > --target=$target \ ++ > --prefix=$tools \ ++ > --with-sysroot=$sysroot \ ++ > --disable-libssp --disable-libgomp --disable-libmudflap \ ++ > --disable-libffi --disable-libquadmath \ ++ > --enable-languages=c ++ $ PATH=$tools/bin:$PATH make ++ $ PATH=$tools/bin:$PATH make install ++ ++ ++GLIBC, Complete ++ ++With the second compiler built and installed, we're now ready for the ++full GLIBC build: ++ ++ $ mkdir -p $obj/glibc ++ $ cd $obj/glibc ++ $ BUILD_CC=gcc \ ++ > CC=$tools/bin/$target-gcc \ ++ > CXX=$tools/bin/$target-g++ \ ++ > AR=$tools/bin/$target-ar \ ++ > RANLIB=$tools/bin/$target-ranlib \ ++ > $src/glibc/libc/configure \ ++ > --prefix=/usr \ ++ > --with-headers=$sysroot/usr/include \ ++ > --with-kconfig=$obj/linux/scripts/kconfig \ ++ > --build=$build \ ++ > --host=$target \ ++ > --disable-profile --without-gd --without-cvs \ ++ > --enable-add-ons=nptl,libidn,../ports ++ ++Note the additional '--with-kconfig' option. This tells GLIBC where to ++find the host config tools used by the kernel 'make config' and 'make ++menuconfig'. These tools can be re-used by GLIBC for its own 'make ++*config' support, which will create 'option-groups.config' for you. ++But first make sure those tools have been built by running some ++dummy 'make *config' calls in the kernel directory: ++ ++ $ cd $obj/linux ++ $ PATH=$tools/bin:$PATH make config \ ++ > ARCH=$linux_arch CROSS_COMPILE=$target- \ ++ $ PATH=$tools/bin:$PATH make menuconfig \ ++ > ARCH=$linux_arch CROSS_COMPILE=$target- \ ++ ++Now we can configure and build the full GLIBC: ++ ++ $ cd $obj/glibc ++ $ PATH=$tools/bin:$PATH make defconfig ++ $ PATH=$tools/bin:$PATH make menuconfig ++ $ PATH=$tools/bin:$PATH make ++ $ PATH=$tools/bin:$PATH make install install_root=$sysroot ++ ++At this point, we have a complete GLIBC installation in '$sysroot', ++with header files, library files, and most of the C runtime startup ++files in place. ++ ++ ++The Third GCC ++ ++Finally, we recompile GCC against this full installation, enabling ++whatever languages and libraries we would like to use: ++ ++ $ mkdir -p $obj/gcc3 ++ $ cd $obj/gcc3 ++ $ $src/$gccv/configure \ ++ > --target=$target \ ++ > --prefix=$tools \ ++ > --with-sysroot=$sysroot \ ++ > --enable-__cxa_atexit \ ++ > --disable-libssp --disable-libgomp --disable-libmudflap \ ++ > --enable-languages=c,c++ ++ $ PATH=$tools/bin:$PATH make ++ $ PATH=$tools/bin:$PATH make install ++ ++The '--enable-__cxa_atexit' option tells GCC what sort of C++ ++destructor support to expect from the C library; it's required with ++GLIBC. ++ ++And since GCC's installation process isn't designed to help construct ++sysroot trees, we must manually copy certain libraries into place in ++the sysroot. ++ ++ $ cp -d $tools/$target/lib/libgcc_s.so* $sysroot/lib ++ $ cp -d $tools/$target/lib/libstdc++.so* $sysroot/usr/lib ++ ++ ++Trying Things Out ++ ++At this point, '$tools' contains a cross toolchain ready to use ++the GLIBC installation in '$sysroot': ++ ++ $ cat > hello.c < #include ++ > int ++ > main (int argc, char **argv) ++ > { ++ > puts ("Hello, world!"); ++ > return 0; ++ > } ++ > EOF ++ $ $tools/bin/$target-gcc -Wall hello.c -o hello ++ $ cat > c++-hello.cc < #include ++ > int ++ > main (int argc, char **argv) ++ > { ++ > std::cout << "Hello, C++ world!" << std::endl; ++ > return 0; ++ > } ++ > EOF ++ $ $tools/bin/$target-g++ -Wall c++-hello.cc -o c++-hello ++ ++ ++We can use 'readelf' to verify that these are indeed executables for ++our target, using our dynamic linker: ++ ++ $ $tools/bin/$target-readelf -hl hello ++ ELF Header: ++ ... ++ Type: EXEC (Executable file) ++ Machine: ARM ++ ++ ... ++ Program Headers: ++ Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align ++ PHDR 0x000034 0x10000034 0x10000034 0x00100 0x00100 R E 0x4 ++ INTERP 0x000134 0x00008134 0x00008134 0x00013 0x00013 R 0x1 ++ [Requesting program interpreter: /lib/ld-linux.so.3] ++ LOAD 0x000000 0x00008000 0x00008000 0x0042c 0x0042c R E 0x8000 ++ ... ++ ++Looking at the dynamic section of the installed 'libgcc_s.so', we see ++that the 'NEEDED' entry for the C library does include the '.6' ++suffix, indicating that was linked against our fully build GLIBC, and ++not our dummy 'libc.so': ++ ++ $ $tools/bin/$target-readelf -d $sysroot/lib/libgcc_s.so.1 ++ Dynamic section at offset 0x1083c contains 24 entries: ++ Tag Type Name/Value ++ 0x00000001 (NEEDED) Shared library: [libc.so.6] ++ 0x0000000e (SONAME) Library soname: [libgcc_s.so.1] ++ ... ++ ++ ++And on the target machine, we can run our programs: ++ ++ $ $sysroot/lib/ld.so.1 --library-path $sysroot/lib:$sysroot/usr/lib \ ++ > ./hello ++ Hello, world! ++ $ $sysroot/lib/ld.so.1 --library-path $sysroot/lib:$sysroot/usr/lib \ ++ > ./c++-hello ++ Hello, C++ world! +diff --git a/GLIBC.cross-testing b/GLIBC.cross-testing +new file mode 100644 +index 0000000000..b67b468466 +--- /dev/null ++++ b/GLIBC.cross-testing +@@ -0,0 +1,205 @@ ++ -*- mode: text -*- ++ ++ Cross-Testing With GLIBC ++ Jim Blandy ++ ++ ++Introduction ++ ++Developers writing software for embedded systems often use a desktop ++or other similarly capable computer for development, but need to run ++tests on the embedded system, or perhaps on a simulator. When ++configured for cross-compilation, the stock GNU C library simply ++disables running tests altogether: the command 'make tests' builds ++test programs, but does not run them. GLIBC, however, provides ++facilities for compiling tests and generating data files on the build ++system, but running the test programs themselves on a remote system or ++simulator. ++ ++ ++Test environment requirements ++ ++The test environment must meet certain conditions for GLIBC's ++cross-testing facilities to work: ++ ++- Shared filesystems. The 'build' system, on which you configure and ++ compile GLIBC, and the 'host' system, on which you intend to run ++ GLIBC, must share a filesystem containing the GLIBC build and ++ source trees. Files must appear at the same paths on both systems. ++ ++- Remote-shell like invocation. There must be a way to run a program ++ on the host system from the build system, passing it properly quoted ++ command-line arguments, setting environment variables, and ++ inheriting the caller's standard input and output. ++ ++ ++Usage ++ ++To use GLIBC's cross-testing support, provide values for the ++following Make variables when you invoke 'make': ++ ++- cross-test-wrapper ++ ++ This should be the name of the cross-testing wrapper command, along ++ with any arguments. ++ ++- cross-localedef ++ ++ This should be the name of a cross-capable localedef program, like ++ that included in the GLIBC 'localedef' module, along with any ++ arguments needed. ++ ++These are each explained in detail below. ++ ++ ++The Cross-Testing Wrapper ++ ++To run test programs reliably, the stock GNU C library takes care to ++ensure that test programs use the newly compiled dynamic linker and ++shared libraries, and never the host system's installed libraries. To ++accomplish this, it runs the tests by explicitly invoking the dynamic ++linker from the build tree, passing it a list of build tree ++directories to search for shared libraries, followed by the name of ++the executable to run and its arguments. ++ ++For example, where one might normally run a test program like this: ++ ++ $ ./tst-foo arg1 arg2 ++ ++the GNU C library might run that program like this: ++ ++ $ $objdir/elf/ld-linux.so.3 --library-path $objdir \ ++ ./tst-foo arg1 arg2 ++ ++(where $objdir is the path to the top of the build tree, and the ++trailing backslash indicates a continuation of the command). In other ++words, each test program invocation is 'wrapped up' inside an explicit ++invocation of the dynamic linker, which must itself execute the test ++program, having loaded shared libraries from the appropriate ++directories. ++ ++To support cross-testing, GLIBC allows the developer to optionally ++set the 'cross-test-wrapper' Make variable to another wrapper command, ++to which it passes the entire dynamic linker invocation shown above as ++arguments. For example, if the developer supplies a wrapper of ++'my-wrapper hostname', then GLIBC would run the test above as ++follows: ++ ++ $ my-wrapper hostname \ ++ $objdir/elf/ld-linux.so.3 --library-path $objdir \ ++ ./tst-foo arg1 arg2 ++ ++The 'my-wrapper' command is responsible for executing the command ++given on the host system. ++ ++Since tests are run in varying directories, the wrapper should either ++be in your command search path, or 'cross-test-wrapper' should give an ++absolute path for the wrapper. ++ ++The wrapper must meet several requirements: ++ ++- It must preserve the current directory. As explained above, the ++ build directory tree must be visible on both the build and host ++ systems, at the same path. The test wrapper must ensure that the ++ current directory it inherits is also inherited by the dynamic ++ linker (and thus the test program itself). ++ ++- It must preserve environment variables' values. Many GLIBC tests ++ set environment variables for test runs; in native testing, it ++ invokes programs like this: ++ ++ $ GCONV_PATH=$objdir/iconvdata \ ++ $objdir/elf/ld-linux.so.3 --library-path $objdir \ ++ ./tst-foo arg1 arg2 ++ ++ With the cross-testing wrapper, that invocation becomes: ++ ++ $ GCONV_PATH=$objdir/iconvdata \ ++ my-wrapper hostname \ ++ $objdir/elf/ld-linux.so.3 --library-path $objdir \ ++ ./tst-foo arg1 arg2 ++ ++ Here, 'my-wrapper' must ensure that the value it sees for ++ 'GCONV_PATH' will be seen by the dynamic linker, and thus 'tst-foo' ++ itself. (The wrapper supplied with GLIBC simply preserves the ++ values of *all* enviroment variables, with a fixed set of ++ exceptions.) ++ ++ If your wrapper is a shell script, take care to correctly propagate ++ environment variables whose values contain spaces and shell ++ metacharacters. ++ ++- It must pass the command's arguments, unmodified. The arguments ++ seen by the test program should be exactly those seen by the wrapper ++ (after whatever arguments are given to the wrapper itself). The ++ GLIBC test framework performs all needed shell word splitting and ++ expansion (wildcard expansion, parameter substitution, and so on) ++ before invoking the wrapper; further expansion may break the tests. ++ ++ ++The 'cross-test-ssh.sh' script ++ ++If you want to use 'ssh' (or something sufficiently similar) to run ++test programs on your host system, GLIBC includes a shell script, ++'scripts/cross-test-ssh.sh', which you can use as your wrapper ++command. This script takes care of setting the test command's current ++directory, propagating environment variable values, and carrying ++command-line arguments, all across an 'ssh' connection. You may even ++supply an alternative to 'ssh' on the command line, if needed. ++ ++For more details, pass 'cross-test-ssh.sh' the '--help' option. ++ ++ ++The Cross-Compiling Locale Definition Command ++ ++Some GLIBC tests rely on locales generated especially for the test ++process. In a native configuration, these tests simply run the ++'localedef' command built by the normal GLIBC build process, ++'locale/localedef', to process and install their locales. However, in ++a cross-compiling configuration, this 'localedef' is built for the ++host system, not the build system, and since it requires quite a bit ++of memory to run (we have seen it fail on systems with 64MiB of ++memory), it may not be practical to run it on the host system. ++ ++If set, GLIBC uses the 'cross-localedef' Make variable as the command ++to run on the build system to process and install locales. The ++localedef program built from the GLIBC 'localedef' module is ++suitable. ++ ++The value of 'cross-localedef' may also include command-line arguments ++to be passed to the program; if you are using GLIBC's 'localedef', ++you may include endianness and 'uint32_t' alignment arguments here. ++ ++ ++Example ++ ++In developing GLIBC's cross-testing facility, we invoked 'make' with ++the following script: ++ ++ #!/bin/sh ++ ++ srcdir=... ++ test_hostname=... ++ localedefdir=... ++ cross_gxx=...-g++ ++ ++ wrapper="$srcdir/scripts/cross-test-ssh.sh $test_hostname" ++ localedef="$localedefdir/localedef --little-endian --uint32-align=4" ++ ++ make cross-test-wrapper="$wrapper" \ ++ cross-localedef="$localedef" \ ++ CXX="$cross_gxx" \ ++ "$@" ++ ++ ++Other Cross-Testing Concerns ++ ++Here are notes on some other issues which you may encounter in running ++the GLIBC tests in a cross-compiling environment: ++ ++- Some tests require a C++ cross-compiler; you should set the 'CXX' ++ Make variable to the name of an appropriate cross-compiler. ++ ++- 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. diff --git a/meta/recipes-core/glibc/glibc/0021-eglibc-Help-bootstrap-cross-toolchain.patch b/meta/recipes-core/glibc/glibc/0021-eglibc-Help-bootstrap-cross-toolchain.patch new file mode 100644 index 0000000000..02e5def339 --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0021-eglibc-Help-bootstrap-cross-toolchain.patch @@ -0,0 +1,97 @@ +From 86a6e94e86664976b305c24e5a52093fe962240a Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 18 Mar 2015 00:49:28 +0000 +Subject: [PATCH] eglibc: Help bootstrap cross toolchain + +Taken from EGLIBC, r1484 + r1525 + + 2007-02-20 Jim Blandy + + * Makefile (install-headers): Preserve old behavior: depend on + $(inst_includedir)/gnu/stubs.h only if install-bootstrap-headers + is set; otherwise, place gnu/stubs.h on the 'install-others' list. + + 2007-02-16 Jim Blandy + + * Makefile: Amend make install-headers to install everything + necessary for building a cross-compiler. Install gnu/stubs.h as + part of 'install-headers', not 'install-others'. + If install-bootstrap-headers is 'yes', install a dummy copy of + gnu/stubs.h, instead of computing the real thing. + * include/stubs-bootstrap.h: New file. + +Upstream-Status: Pending +Signed-off-by: Khem Raj +--- + Makefile | 22 +++++++++++++++++++++- + include/stubs-bootstrap.h | 12 ++++++++++++ + 2 files changed, 33 insertions(+), 1 deletion(-) + create mode 100644 include/stubs-bootstrap.h + +diff --git a/Makefile b/Makefile +index 8f0a93aceb..8eba23a868 100644 +--- a/Makefile ++++ b/Makefile +@@ -79,9 +79,18 @@ subdir-dirs = include + vpath %.h $(subdir-dirs) + + # What to install. +-install-others = $(inst_includedir)/gnu/stubs.h + install-bin-script = + ++# If we're bootstrapping, install a dummy gnu/stubs.h along with the ++# other headers, so 'make install-headers' produces a useable include ++# tree. Otherwise, install gnu/stubs.h later, after the rest of the ++# build is done. ++ifeq ($(install-bootstrap-headers),yes) ++install-headers: $(inst_includedir)/gnu/stubs.h ++else ++install-others = $(inst_includedir)/gnu/stubs.h ++endif ++ + ifeq (yes,$(build-shared)) + headers += gnu/lib-names.h + endif +@@ -407,6 +416,16 @@ others: $(common-objpfx)testrun.sh $(common-objpfx)debugglibc.sh + + subdir-stubs := $(foreach dir,$(subdirs),$(common-objpfx)$(dir)/stubs) + ++# gnu/stubs.h depends (via the subdir 'stubs' targets) on all the .o ++# files in EGLIBC. For bootstrapping a GCC/EGLIBC pair, an empty ++# gnu/stubs.h is good enough. ++ifeq ($(install-bootstrap-headers),yes) ++$(inst_includedir)/gnu/stubs.h: include/stubs-bootstrap.h $(+force) ++ $(make-target-directory) ++ $(INSTALL_DATA) $< $@ ++ ++installed-stubs = ++else + ifndef abi-variants + installed-stubs = $(inst_includedir)/gnu/stubs.h + else +@@ -433,6 +452,7 @@ $(inst_includedir)/gnu/stubs.h: $(+force) + + install-others-nosubdir: $(installed-stubs) + endif ++endif + + + # Since stubs.h is never needed when building the library, we simplify the +diff --git a/include/stubs-bootstrap.h b/include/stubs-bootstrap.h +new file mode 100644 +index 0000000000..1d2b669aff +--- /dev/null ++++ b/include/stubs-bootstrap.h +@@ -0,0 +1,12 @@ ++/* Placeholder stubs.h file for bootstrapping. ++ ++ When bootstrapping a GCC/EGLIBC pair, GCC requires that the EGLIBC ++ headers be installed, but we can't fully build EGLIBC without that ++ GCC. So we run the command: ++ ++ make install-headers install-bootstrap-headers=yes ++ ++ to install the headers GCC needs, but avoid building certain ++ difficult headers. The 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. */ diff --git a/meta/recipes-core/glibc/glibc/0021-eglibc-Resolve-__fpscr_values-on-SH4.patch b/meta/recipes-core/glibc/glibc/0021-eglibc-Resolve-__fpscr_values-on-SH4.patch deleted file mode 100644 index 76551cf559..0000000000 --- a/meta/recipes-core/glibc/glibc/0021-eglibc-Resolve-__fpscr_values-on-SH4.patch +++ /dev/null @@ -1,56 +0,0 @@ -From b7290e54a1bda7a0212131655bc27926fc22de22 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Wed, 18 Mar 2015 00:55:53 +0000 -Subject: [PATCH 21/28] eglibc: Resolve __fpscr_values on SH4 - -2010-09-29 Nobuhiro Iwamatsu - Andrew Stubbs - - Resolve SH's __fpscr_values to symbol in libc.so. - - * sysdeps/sh/sh4/fpu/fpu_control.h: Add C++ __set_fpscr prototype. - * sysdeps/unix/sysv/linux/sh/Versions (GLIBC_2.2): Add __fpscr_values. - * sysdeps/unix/sysv/linux/sh/sysdep.S (___fpscr_values): New constant. - -Upstream-Status: Pending - -Signed-off-by: Khem Raj ---- - sysdeps/unix/sysv/linux/sh/Versions | 1 + - sysdeps/unix/sysv/linux/sh/sysdep.S | 11 +++++++++++ - 2 files changed, 12 insertions(+) - -diff --git a/sysdeps/unix/sysv/linux/sh/Versions b/sysdeps/unix/sysv/linux/sh/Versions -index e0938c4165..ca1d7da339 100644 ---- a/sysdeps/unix/sysv/linux/sh/Versions -+++ b/sysdeps/unix/sysv/linux/sh/Versions -@@ -2,6 +2,7 @@ libc { - GLIBC_2.2 { - # functions used in other libraries - __xstat64; __fxstat64; __lxstat64; -+ __fpscr_values; - - # a* - alphasort64; -diff --git a/sysdeps/unix/sysv/linux/sh/sysdep.S b/sysdeps/unix/sysv/linux/sh/sysdep.S -index 6ce36d6dd5..425811cc77 100644 ---- a/sysdeps/unix/sysv/linux/sh/sysdep.S -+++ b/sysdeps/unix/sysv/linux/sh/sysdep.S -@@ -30,3 +30,14 @@ ENTRY (__syscall_error) - - #define __syscall_error __syscall_error_1 - #include -+ -+ .data -+ .align 3 -+ .globl ___fpscr_values -+ .type ___fpscr_values, @object -+ .size ___fpscr_values, 8 -+___fpscr_values: -+ .long 0 -+ .long 0x80000 -+weak_alias (___fpscr_values, __fpscr_values) -+ --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0022-eglibc-Clear-cache-lines-on-ppc8xx.patch b/meta/recipes-core/glibc/glibc/0022-eglibc-Clear-cache-lines-on-ppc8xx.patch new file mode 100644 index 0000000000..913aea9563 --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0022-eglibc-Clear-cache-lines-on-ppc8xx.patch @@ -0,0 +1,80 @@ +From b397d653670dd02d8310e1d6f0f19a8da90ebafa Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Thu, 31 Dec 2015 15:15:09 -0800 +Subject: [PATCH] eglibc: Clear cache lines on ppc8xx + +2007-06-13 Nathan Sidwell + Mark Shinwell + + * sysdeps/unix/sysv/linux/powerpc/libc-start.c + (__libc_start_main): Detect 8xx parts and clear + __cache_line_size if detected. + * sysdeps/unix/sysv/linux/powerpc/dl-sysdep.c + (DL_PLATFORM_AUXV): Likewise. + +Upstream-Status: Pending + +Signed-off-by: Khem Raj +--- + sysdeps/unix/sysv/linux/powerpc/dl-sysdep.c | 14 +++++++++++++- + sysdeps/unix/sysv/linux/powerpc/libc-start.c | 16 +++++++++++++++- + 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 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; + /* Scan the Aux Vector for the "Data Cache Block Size" entry. If found + verify that the static extern __cache_line_size is defined by checking + for not NULL. If it is defined then assign the cache block size +- value to __cache_line_size. */ ++ value to __cache_line_size. This is used by memset to ++ optimize setting to zero. We have to detect 8xx processors, which ++ have buggy dcbz implementations that cannot report page faults ++ correctly. That requires reading SPR, which is a privileged ++ operation. Fortunately 2.2.18 and later emulates PowerPC mfspr ++ reads from the PVR register. */ + #define DL_PLATFORM_AUXV \ + case AT_DCACHEBSIZE: \ ++ if (__LINUX_KERNEL_VERSION >= 0x020218) \ ++ { \ ++ unsigned pvr = 0; \ ++ asm ("mfspr %0, 287" : "=r" (pvr)); \ ++ if ((pvr & 0xffff0000) == 0x00500000) \ ++ break; \ ++ } \ + __cache_line_size = av->a_un.a_val; \ + break; + +diff --git a/sysdeps/unix/sysv/linux/powerpc/libc-start.c b/sysdeps/unix/sysv/linux/powerpc/libc-start.c +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, + + /* Initialize the __cache_line_size variable from the aux vector. For the + static case, we also need _dl_hwcap, _dl_hwcap2 and _dl_platform, so we +- can call __tcb_parse_hwcap_and_convert_at_platform (). */ ++ can call __tcb_parse_hwcap_and_convert_at_platform (). ++ ++ This is used by memset to optimize setting to zero. We have to ++ detect 8xx processors, which have buggy dcbz implementations that ++ cannot report page faults correctly. That requires reading SPR, ++ which is a privileged operation. Fortunately 2.2.18 and later ++ emulates PowerPC mfspr reads from the PVR register. */ + for (ElfW (auxv_t) * av = auxvec; av->a_type != AT_NULL; ++av) + switch (av->a_type) + { + case AT_DCACHEBSIZE: ++ if (__LINUX_KERNEL_VERSION >= 0x020218) ++ { ++ unsigned pvr = 0; ++ ++ asm ("mfspr %0, 287" : "=r" (pvr) :); ++ if ((pvr & 0xffff0000) == 0x00500000) ++ break; ++ } + __cache_line_size = av->a_un.a_val; + break; + #ifndef SHARED diff --git a/meta/recipes-core/glibc/glibc/0022-eglibc-Forward-port-cross-locale-generation-support.patch b/meta/recipes-core/glibc/glibc/0022-eglibc-Forward-port-cross-locale-generation-support.patch deleted file mode 100644 index c46021a478..0000000000 --- a/meta/recipes-core/glibc/glibc/0022-eglibc-Forward-port-cross-locale-generation-support.patch +++ /dev/null @@ -1,566 +0,0 @@ -From be382b4e0c6de52573f7e037f2d4ff9b1b5bbb6b Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Wed, 18 Mar 2015 01:33:49 +0000 -Subject: [PATCH 22/28] eglibc: Forward port cross locale generation support - -Upstream-Status: Pending - -Signed-off-by: Khem Raj ---- - locale/Makefile | 3 +- - locale/catnames.c | 48 ++++++++++++++++++++++++++++ - locale/localeinfo.h | 2 +- - locale/programs/charmap-dir.c | 6 ++++ - locale/programs/ld-collate.c | 17 +++++----- - locale/programs/ld-ctype.c | 27 ++++++++-------- - locale/programs/ld-time.c | 31 ++++++++++++------ - locale/programs/linereader.c | 2 +- - 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(-) - create mode 100644 locale/catnames.c - -diff --git a/locale/Makefile b/locale/Makefile -index d78cf9b83a..e166f5252e 100644 ---- a/locale/Makefile -+++ b/locale/Makefile -@@ -26,7 +26,8 @@ headers = langinfo.h locale.h bits/locale.h \ - bits/types/locale_t.h bits/types/__locale_t.h - routines = setlocale findlocale loadlocale loadarchive \ - localeconv nl_langinfo nl_langinfo_l mb_cur_max \ -- newlocale duplocale freelocale uselocale -+ newlocale duplocale freelocale uselocale \ -+ catnames - tests = tst-C-locale tst-locname tst-duplocale - categories = ctype messages monetary numeric time paper name \ - address telephone measurement identification collate -diff --git a/locale/catnames.c b/locale/catnames.c -new file mode 100644 -index 0000000000..9fad357db1 ---- /dev/null -+++ b/locale/catnames.c -@@ -0,0 +1,48 @@ -+/* Copyright (C) 2006 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, write to the Free -+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -+ 02111-1307 USA. */ -+ -+#include "localeinfo.h" -+ -+/* Define an array of category names (also the environment variable names). */ -+const union catnamestr_t _nl_category_names attribute_hidden = -+ { -+ { -+#define DEFINE_CATEGORY(category, category_name, items, a) \ -+ 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__)), -+#include "categories.def" -+#undef DEFINE_CATEGORY -+ }; -+ -+/* An array of their lengths, for convenience. */ -+const uint8_t _nl_category_name_sizes[] attribute_hidden = -+ { -+#define DEFINE_CATEGORY(category, category_name, items, a) \ -+ [category] = sizeof (category_name) - 1, -+#include "categories.def" -+#undef DEFINE_CATEGORY -+ [LC_ALL] = sizeof ("LC_ALL") - 1 -+ }; -diff --git a/locale/localeinfo.h b/locale/localeinfo.h -index 53cb8bfc59..92c466200c 100644 ---- a/locale/localeinfo.h -+++ b/locale/localeinfo.h -@@ -224,7 +224,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. */ --#ifndef SHARED -+#if !defined SHARED && !defined IN_GLIBC_LOCALEDEF - # include - # define NL_CURRENT_INDIRECT 1 - #endif -diff --git a/locale/programs/charmap-dir.c b/locale/programs/charmap-dir.c -index 94c122df68..80e53e12c8 100644 ---- a/locale/programs/charmap-dir.c -+++ b/locale/programs/charmap-dir.c -@@ -18,7 +18,9 @@ - #include - #include - #include -+#ifndef NO_UNCOMPRESS - #include -+#endif - #include - #include - #include -@@ -154,6 +156,7 @@ charmap_closedir (CHARMAP_DIR *cdir) - return closedir (dir); - } - -+#ifndef NO_UNCOMPRESS - /* Creates a subprocess decompressing the given pathname, and returns - a stream reading its output (the decompressed data). */ - static -@@ -202,6 +205,7 @@ fopen_uncompressed (const char *pathname, const char *compressor) - } - return NULL; - } -+#endif - - /* Opens a charmap for reading, given its name (not an alias name). */ - FILE * -@@ -224,6 +228,7 @@ charmap_open (const char *directory, const char *name) - if (stream != NULL) - return stream; - -+#ifndef NO_UNCOMPRESS - memcpy (p, ".gz", 4); - stream = fopen_uncompressed (pathname, "gzip"); - if (stream != NULL) -@@ -233,6 +238,7 @@ charmap_open (const char *directory, const char *name) - stream = fopen_uncompressed (pathname, "bzip2"); - if (stream != NULL) - return stream; -+#endif - - return NULL; - } -diff --git a/locale/programs/ld-collate.c b/locale/programs/ld-collate.c -index 6baab6cfb0..b12a2fceab 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, - } - if (wcs != NULL) - { -- size_t nwcs = wcslen ((wchar_t *) wcs); -+ size_t nwcs = wcslen_uint32 (wcs); - uint32_t zero = 0; - /* Handle as a single character. */ - if (nwcs == 0) -@@ -1772,8 +1772,7 @@ symbol `%s' has the same encoding as"), (*eptr)->name); - - if ((*eptr)->nwcs == runp->nwcs) - { -- int c = wmemcmp ((wchar_t *) (*eptr)->wcs, -- (wchar_t *) runp->wcs, runp->nwcs); -+ int c = wmemcmp_uint32 ((*eptr)->wcs, runp->wcs, runp->nwcs); - - if (c == 0) - { -@@ -2000,9 +1999,9 @@ add_to_tablewc (uint32_t ch, struct element_t *runp) - one consecutive entry. */ - if (runp->wcnext != NULL - && runp->nwcs == runp->wcnext->nwcs -- && wmemcmp ((wchar_t *) runp->wcs, -- (wchar_t *)runp->wcnext->wcs, -- runp->nwcs - 1) == 0 -+ && wmemcmp_uint32 (runp->wcs, -+ runp->wcnext->wcs, -+ runp->nwcs - 1) == 0 - && (runp->wcs[runp->nwcs - 1] - == runp->wcnext->wcs[runp->nwcs - 1] + 1)) - { -@@ -2026,9 +2025,9 @@ add_to_tablewc (uint32_t ch, struct element_t *runp) - runp = runp->wcnext; - while (runp->wcnext != NULL - && runp->nwcs == runp->wcnext->nwcs -- && wmemcmp ((wchar_t *) runp->wcs, -- (wchar_t *)runp->wcnext->wcs, -- runp->nwcs - 1) == 0 -+ && wmemcmp_uint32 (runp->wcs, -+ runp->wcnext->wcs, -+ runp->nwcs - 1) == 0 - && (runp->wcs[runp->nwcs - 1] - == 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 ---- 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, - allocate_arrays (ctype, charmap, ctype->repertoire); - - default_missing_len = (ctype->default_missing -- ? wcslen ((wchar_t *) ctype->default_missing) -+ ? wcslen_uint32 (ctype->default_missing) - : 0); - - init_locale_data (&file, nelems); -@@ -1927,7 +1927,7 @@ read_translit_entry (struct linereader *ldfile, struct locale_ctype_t *ctype, - ignore = 1; - else - /* This value is usable. */ -- obstack_grow (ob, to_wstr, wcslen ((wchar_t *) to_wstr) * 4); -+ obstack_grow (ob, to_wstr, wcslen_uint32 (to_wstr) * 4); - - first = 0; - } -@@ -2461,8 +2461,8 @@ with character code range values one must use the absolute ellipsis `...'")); - } - - handle_tok_digit: -- class_bit = _ISwdigit; -- class256_bit = _ISdigit; -+ class_bit = BITw (tok_digit); -+ class256_bit = BIT (tok_digit); - handle_digits = 1; - goto read_charclass; - -@@ -3904,8 +3904,7 @@ allocate_arrays (struct locale_ctype_t *ctype, const struct charmap_t *charmap, - - while (idx < number) - { -- int res = wcscmp ((const wchar_t *) sorted[idx]->from, -- (const wchar_t *) runp->from); -+ int res = wcscmp_uint32 (sorted[idx]->from, runp->from); - if (res == 0) - { - replace = 1; -@@ -3942,11 +3941,11 @@ allocate_arrays (struct locale_ctype_t *ctype, const struct charmap_t *charmap, - for (size_t cnt = 0; cnt < number; ++cnt) - { - struct translit_to_t *srunp; -- from_len += wcslen ((const wchar_t *) sorted[cnt]->from) + 1; -+ from_len += wcslen_uint32 (sorted[cnt]->from) + 1; - srunp = sorted[cnt]->to; - while (srunp != NULL) - { -- to_len += wcslen ((const wchar_t *) srunp->str) + 1; -+ to_len += wcslen_uint32 (srunp->str) + 1; - srunp = srunp->next; - } - /* Plus one for the extra NUL character marking the end of -@@ -3970,18 +3969,18 @@ allocate_arrays (struct locale_ctype_t *ctype, const struct charmap_t *charmap, - ctype->translit_from_idx[cnt] = from_len; - ctype->translit_to_idx[cnt] = to_len; - -- len = wcslen ((const wchar_t *) sorted[cnt]->from) + 1; -- wmemcpy ((wchar_t *) &ctype->translit_from_tbl[from_len], -- (const wchar_t *) sorted[cnt]->from, len); -+ len = wcslen_uint32 (sorted[cnt]->from) + 1; -+ wmemcpy_uint32 (&ctype->translit_from_tbl[from_len], -+ sorted[cnt]->from, len); - from_len += len; - - ctype->translit_to_idx[cnt] = to_len; - srunp = sorted[cnt]->to; - while (srunp != NULL) - { -- len = wcslen ((const wchar_t *) srunp->str) + 1; -- wmemcpy ((wchar_t *) &ctype->translit_to_tbl[to_len], -- (const wchar_t *) srunp->str, len); -+ len = wcslen_uint32 (srunp->str) + 1; -+ wmemcpy_uint32 (&ctype->translit_to_tbl[to_len], -+ srunp->str, len); - to_len += len; - srunp = srunp->next; - } -diff --git a/locale/programs/ld-time.c b/locale/programs/ld-time.c -index 8e9849fdba..028d3efa9f 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"); - } - else - { -+ static const uint32_t wt_fmt_ampm[] -+ = { '%','I',':','%','M',':','%','S',' ','%','p',0 }; - time->t_fmt_ampm = "%I:%M:%S %p"; -- time->wt_fmt_ampm = (const uint32_t *) L"%I:%M:%S %p"; -+ time->wt_fmt_ampm = wt_fmt_ampm; - } - } - -@@ -231,7 +233,7 @@ No definition for %s category found"), "LC_TIME"); - const int days_per_month[12] = { 31, 29, 31, 30, 31, 30, - 31, 31, 30, 31 ,30, 31 }; - size_t idx; -- wchar_t *wstr; -+ uint32_t *wstr; - - time->era_entries = - (struct era_data *) xmalloc (time->num_era -@@ -457,18 +459,18 @@ No definition for %s category found"), "LC_TIME"); - } - - /* Now generate the wide character name and format. */ -- wstr = wcschr ((wchar_t *) time->wera[idx], L':');/* end direction */ -- wstr = wstr ? wcschr (wstr + 1, L':') : NULL; /* end offset */ -- wstr = wstr ? wcschr (wstr + 1, L':') : NULL; /* end start */ -- wstr = wstr ? wcschr (wstr + 1, L':') : NULL; /* end end */ -+ wstr = wcschr_uint32 (time->wera[idx], L':'); /* end direction */ -+ wstr = wstr ? wcschr_uint32 (wstr + 1, L':') : NULL; /* end offset */ -+ wstr = wstr ? wcschr_uint32 (wstr + 1, L':') : NULL; /* end start */ -+ wstr = wstr ? wcschr_uint32 (wstr + 1, L':') : NULL; /* end end */ - if (wstr != NULL) - { -- time->era_entries[idx].wname = (uint32_t *) wstr + 1; -- wstr = wcschr (wstr + 1, L':'); /* end name */ -+ time->era_entries[idx].wname = wstr + 1; -+ wstr = wcschr_uint32 (wstr + 1, L':'); /* end name */ - if (wstr != NULL) - { - *wstr = L'\0'; -- time->era_entries[idx].wformat = (uint32_t *) wstr + 1; -+ time->era_entries[idx].wformat = wstr + 1; - } - else - time->era_entries[idx].wname = -@@ -527,7 +529,16 @@ No definition for %s category found"), "LC_TIME"); - if (time->date_fmt == NULL) - time->date_fmt = "%a %b %e %H:%M:%S %Z %Y"; - if (time->wdate_fmt == NULL) -- time->wdate_fmt = (const uint32_t *) L"%a %b %e %H:%M:%S %Z %Y"; -+ { -+ static const uint32_t wdate_fmt[] = -+ { '%','a',' ', -+ '%','b',' ', -+ '%','e',' ', -+ '%','H',':','%','M',':','%','S',' ', -+ '%','Z',' ', -+ '%','Y',0 }; -+ time->wdate_fmt = wdate_fmt; -+ } - } - - -diff --git a/locale/programs/linereader.c b/locale/programs/linereader.c -index ed3a9731d0..3178ea057a 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, - { - int return_widestr = lr->return_widestr; - char *buf; -- wchar_t *buf2 = NULL; -+ uint32_t *buf2 = NULL; - size_t bufact; - size_t bufmax = 56; - -diff --git a/locale/programs/localedef.c b/locale/programs/localedef.c -index b7bcef8248..efeced1e0f 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; - #define OPT_NO_WARN 402 - #define OPT_WARN 403 - #define OPT_NO_HARD_LINKS 404 -+#define OPT_UINT32_ALIGN 405 - - /* Definitions of arguments for argp functions. */ - static const struct argp_option options[] = -@@ -153,6 +154,8 @@ static const struct argp_option options[] = - N_("Generate little-endian output") }, - { "big-endian", OPT_BIG_ENDIAN, NULL, 0, - N_("Generate big-endian output") }, -+ { "uint32-align", OPT_UINT32_ALIGN, "ALIGNMENT", 0, -+ N_("Set the target's uint32_t alignment in bytes (default 4)") }, - { NULL, 0, NULL, 0, NULL } - }; - -@@ -242,12 +245,14 @@ main (int argc, char *argv[]) - ctype locale. (P1003.2 4.35.5.2) */ - setlocale (LC_CTYPE, "POSIX"); - -+#ifndef NO_SYSCONF - /* Look whether the system really allows locale definitions. POSIX - defines error code 3 for this situation so I think it must be - a fatal error (see P1003.2 4.35.8). */ - if (sysconf (_SC_2_LOCALEDEF) < 0) - record_error (3, 0, _("\ - FATAL: system does not define `_POSIX2_LOCALEDEF'")); -+#endif - - /* Process charmap file. */ - charmap = charmap_read (charmap_file, verbose, 1, be_quiet, 1); -@@ -399,6 +404,9 @@ parse_opt (int key, char *arg, struct argp_state *state) - /* Do not hard link to other locales. */ - hard_links = false; - break; -+ case OPT_UINT32_ALIGN: -+ uint32_align_mask = strtol (arg, NULL, 0) - 1; -+ break; - case 'c': - force_output = 1; - break; -diff --git a/locale/programs/locfile.c b/locale/programs/locfile.c -index e4ba48e968..e7b0efe887 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, - machine running localedef. */ - bool swap_endianness_p; - -+/* The target's value of __align__(uint32_t) - 1. */ -+unsigned int uint32_align_mask = 3; -+ - /* When called outside a start_locale_structure/end_locale_structure - or start_locale_prelude/end_locale_prelude block, record that the - next byte in FILE's obstack will be the first byte of a new element. -@@ -621,7 +624,7 @@ add_locale_string (struct locale_file *file, const char *string) - void - add_locale_wstring (struct locale_file *file, const uint32_t *string) - { -- add_locale_uint32_array (file, string, wcslen ((const wchar_t *) string) + 1); -+ add_locale_uint32_array (file, string, wcslen_uint32 (string) + 1); - } - - /* 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 ---- a/locale/programs/locfile.h -+++ b/locale/programs/locfile.h -@@ -71,6 +71,8 @@ extern void write_all_categories (struct localedef_t *definitions, - - extern bool swap_endianness_p; - -+extern unsigned int uint32_align_mask; -+ - /* Change the output to be big-endian if BIG_ENDIAN is true and - little-endian otherwise. */ - static inline void -@@ -89,7 +91,8 @@ maybe_swap_uint32 (uint32_t value) - } - - /* Likewise, but munge an array of N uint32_ts starting at ARRAY. */ --static inline void -+static void -+__attribute__ ((unused)) - maybe_swap_uint32_array (uint32_t *array, size_t n) - { - if (swap_endianness_p) -@@ -99,7 +102,8 @@ maybe_swap_uint32_array (uint32_t *array, size_t n) - - /* Like maybe_swap_uint32_array, but the array of N elements is at - the end of OBSTACK's current object. */ --static inline void -+static void -+__attribute__ ((unused)) - maybe_swap_uint32_obstack (struct obstack *obstack, size_t n) - { - maybe_swap_uint32_array ((uint32_t *) obstack_next_free (obstack) - n, n); -@@ -276,4 +280,55 @@ extern void identification_output (struct localedef_t *locale, - const struct charmap_t *charmap, - const char *output_path); - -+static size_t wcslen_uint32 (const uint32_t *str) __attribute__ ((unused)); -+static uint32_t * wmemcpy_uint32 (uint32_t *s1, const uint32_t *s2, size_t n) __attribute__ ((unused)); -+static uint32_t * wcschr_uint32 (const uint32_t *s, uint32_t ch) __attribute__ ((unused)); -+static int wcscmp_uint32 (const uint32_t *s1, const uint32_t *s2) __attribute__ ((unused)); -+static int wmemcmp_uint32 (const uint32_t *s1, const uint32_t *s2, size_t n) __attribute__ ((unused)); -+ -+static size_t -+wcslen_uint32 (const uint32_t *str) -+{ -+ size_t len = 0; -+ while (str[len] != 0) -+ len++; -+ return len; -+} -+ -+static int -+wmemcmp_uint32 (const uint32_t *s1, const uint32_t *s2, size_t n) -+{ -+ while (n-- != 0) -+ { -+ int diff = *s1++ - *s2++; -+ if (diff != 0) -+ return diff; -+ } -+ return 0; -+} -+ -+static int -+wcscmp_uint32 (const uint32_t *s1, const uint32_t *s2) -+{ -+ while (*s1 != 0 && *s1 == *s2) -+ s1++, s2++; -+ return *s1 - *s2; -+} -+ -+static uint32_t * -+wmemcpy_uint32 (uint32_t *s1, const uint32_t *s2, size_t n) -+{ -+ return memcpy (s1, s2, n * sizeof (uint32_t)); -+} -+ -+static uint32_t * -+wcschr_uint32 (const uint32_t *s, uint32_t ch) -+{ -+ do -+ if (*s == ch) -+ return (uint32_t *) s; -+ while (*s++ != 0); -+ return 0; -+} -+ - #endif /* locfile.h */ -diff --git a/locale/setlocale.c b/locale/setlocale.c -index 9bd35454b9..2a67dc6589 100644 ---- a/locale/setlocale.c -+++ b/locale/setlocale.c -@@ -64,36 +64,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 = -- { -- { --#define DEFINE_CATEGORY(category, category_name, items, a) \ -- 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__)), --#include "categories.def" --#undef DEFINE_CATEGORY -- }; -- --/* An array of their lengths, for convenience. */ --const uint8_t _nl_category_name_sizes[] attribute_hidden = -- { --#define DEFINE_CATEGORY(category, category_name, items, a) \ -- [category] = sizeof (category_name) - 1, --#include "categories.def" --#undef DEFINE_CATEGORY -- [LC_ALL] = sizeof ("LC_ALL") - 1 -- }; -- -- - #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/0023-Define-DUMMY_LOCALE_T-if-not-defined.patch deleted file mode 100644 index 17667da99f..0000000000 --- a/meta/recipes-core/glibc/glibc/0023-Define-DUMMY_LOCALE_T-if-not-defined.patch +++ /dev/null @@ -1,32 +0,0 @@ -From afa8d6faeddeb80aca318b33edf49d9f8ce65761 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Wed, 20 Apr 2016 21:11:00 -0700 -Subject: [PATCH 23/28] Define DUMMY_LOCALE_T if not defined - -This is a hack to fix building the locale bits on an older -CentOs 5.X machine - -Upstream-Status: Inappropriate [other] - -Signed-off-by: Khem Raj ---- - locale/programs/config.h | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/locale/programs/config.h b/locale/programs/config.h -index a1e6e0ec3c..7f75528eae 100644 ---- a/locale/programs/config.h -+++ b/locale/programs/config.h -@@ -19,6 +19,9 @@ - #ifndef _LD_CONFIG_H - #define _LD_CONFIG_H 1 - -+#ifndef DUMMY_LOCALE_T -+#define DUMMY_LOCALE_T -+#endif - /* 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/0023-eglibc-Resolve-__fpscr_values-on-SH4.patch b/meta/recipes-core/glibc/glibc/0023-eglibc-Resolve-__fpscr_values-on-SH4.patch new file mode 100644 index 0000000000..cc8ddeea6f --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0023-eglibc-Resolve-__fpscr_values-on-SH4.patch @@ -0,0 +1,53 @@ +From 02b69fc14ae1d6309e4e17081842b1f89bd40338 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 18 Mar 2015 00:55:53 +0000 +Subject: [PATCH] eglibc: Resolve __fpscr_values on SH4 + +2010-09-29 Nobuhiro Iwamatsu + Andrew Stubbs + + Resolve SH's __fpscr_values to symbol in libc.so. + + * sysdeps/sh/sh4/fpu/fpu_control.h: Add C++ __set_fpscr prototype. + * sysdeps/unix/sysv/linux/sh/Versions (GLIBC_2.2): Add __fpscr_values. + * sysdeps/unix/sysv/linux/sh/sysdep.S (___fpscr_values): New constant. + +Upstream-Status: Pending + +Signed-off-by: Khem Raj +--- + sysdeps/unix/sysv/linux/sh/Versions | 1 + + sysdeps/unix/sysv/linux/sh/sysdep.S | 11 +++++++++++ + 2 files changed, 12 insertions(+) + +diff --git a/sysdeps/unix/sysv/linux/sh/Versions b/sysdeps/unix/sysv/linux/sh/Versions +index e0938c4165..ca1d7da339 100644 +--- a/sysdeps/unix/sysv/linux/sh/Versions ++++ b/sysdeps/unix/sysv/linux/sh/Versions +@@ -2,6 +2,7 @@ libc { + GLIBC_2.2 { + # functions used in other libraries + __xstat64; __fxstat64; __lxstat64; ++ __fpscr_values; + + # a* + alphasort64; +diff --git a/sysdeps/unix/sysv/linux/sh/sysdep.S b/sysdeps/unix/sysv/linux/sh/sysdep.S +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) + + #define __syscall_error __syscall_error_1 + #include ++ ++ .data ++ .align 3 ++ .globl ___fpscr_values ++ .type ___fpscr_values, @object ++ .size ___fpscr_values, 8 ++___fpscr_values: ++ .long 0 ++ .long 0x80000 ++weak_alias (___fpscr_values, __fpscr_values) ++ diff --git a/meta/recipes-core/glibc/glibc/0024-eglibc-Forward-port-cross-locale-generation-support.patch b/meta/recipes-core/glibc/glibc/0024-eglibc-Forward-port-cross-locale-generation-support.patch new file mode 100644 index 0000000000..72278a6822 --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0024-eglibc-Forward-port-cross-locale-generation-support.patch @@ -0,0 +1,560 @@ +From 42fc64ee872491667749499db50e3c51d6a4bfb3 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 18 Mar 2015 01:33:49 +0000 +Subject: [PATCH] eglibc: Forward port cross locale generation support + +Upstream-Status: Pending + +Signed-off-by: Khem Raj +--- + locale/Makefile | 3 +- + locale/catnames.c | 46 +++++++++++++++++++++++++++ + locale/localeinfo.h | 2 +- + locale/programs/charmap-dir.c | 6 ++++ + locale/programs/ld-collate.c | 17 +++++----- + locale/programs/ld-ctype.c | 27 ++++++++-------- + locale/programs/ld-time.c | 31 ++++++++++++------ + locale/programs/linereader.c | 2 +- + locale/programs/localedef.c | 8 +++++ + locale/programs/locfile.c | 5 ++- + locale/programs/locfile.h | 59 +++++++++++++++++++++++++++++++++-- + 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 c9694e236e..ba7105fad6 100644 +--- a/locale/Makefile ++++ b/locale/Makefile +@@ -26,7 +26,8 @@ headers = langinfo.h locale.h bits/locale.h \ + bits/types/locale_t.h bits/types/__locale_t.h + routines = setlocale findlocale loadlocale loadarchive \ + localeconv nl_langinfo nl_langinfo_l mb_cur_max \ +- newlocale duplocale freelocale uselocale ++ newlocale duplocale freelocale uselocale \ ++ catnames + tests = tst-C-locale tst-locname tst-duplocale + categories = ctype messages monetary numeric time paper name \ + address telephone measurement identification collate +diff --git a/locale/catnames.c b/locale/catnames.c +new file mode 100644 +index 0000000000..538f3f5edb +--- /dev/null ++++ b/locale/catnames.c +@@ -0,0 +1,46 @@ ++/* Copyright (C) 2006 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include "localeinfo.h" ++ ++/* Define an array of category names (also the environment variable names). */ ++const struct catnamestr_t _nl_category_names attribute_hidden = ++ { ++#define DEFINE_CATEGORY(category, category_name, items, a) \ ++ 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 (struct catnamestr_t, CATNAMEMF (__LINE__)), ++#include "categories.def" ++#undef DEFINE_CATEGORY ++ }; ++ ++/* An array of their lengths, for convenience. */ ++const uint8_t _nl_category_name_sizes[] attribute_hidden = ++ { ++#define DEFINE_CATEGORY(category, category_name, items, a) \ ++ [category] = sizeof (category_name) - 1, ++#include "categories.def" ++#undef DEFINE_CATEGORY ++ [LC_ALL] = sizeof ("LC_ALL") - 1 ++ }; +diff --git a/locale/localeinfo.h b/locale/localeinfo.h +index fdc283c69a..4eeed35f90 100644 +--- a/locale/localeinfo.h ++++ b/locale/localeinfo.h +@@ -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. */ +-#ifndef SHARED ++#if !defined SHARED && !defined IN_GLIBC_LOCALEDEF + # include + # define NL_CURRENT_INDIRECT 1 + #endif +diff --git a/locale/programs/charmap-dir.c b/locale/programs/charmap-dir.c +index 1a526a240d..0fb2daf936 100644 +--- a/locale/programs/charmap-dir.c ++++ b/locale/programs/charmap-dir.c +@@ -18,7 +18,9 @@ + #include + #include + #include ++#ifndef NO_UNCOMPRESS + #include ++#endif + #include + #include + #include +@@ -154,6 +156,7 @@ charmap_closedir (CHARMAP_DIR *cdir) + return closedir (dir); + } + ++#ifndef NO_UNCOMPRESS + /* Creates a subprocess decompressing the given pathname, and returns + a stream reading its output (the decompressed data). */ + static +@@ -202,6 +205,7 @@ fopen_uncompressed (const char *pathname, const char *compressor) + } + return NULL; + } ++#endif + + /* Opens a charmap for reading, given its name (not an alias name). */ + FILE * +@@ -224,6 +228,7 @@ charmap_open (const char *directory, const char *name) + if (stream != NULL) + return stream; + ++#ifndef NO_UNCOMPRESS + memcpy (p, ".gz", 4); + stream = fopen_uncompressed (pathname, "gzip"); + if (stream != NULL) +@@ -233,6 +238,7 @@ charmap_open (const char *directory, const char *name) + stream = fopen_uncompressed (pathname, "bzip2"); + if (stream != NULL) + return stream; ++#endif + + return NULL; + } +diff --git a/locale/programs/ld-collate.c b/locale/programs/ld-collate.c +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, + } + if (wcs != NULL) + { +- size_t nwcs = wcslen ((wchar_t *) wcs); ++ size_t nwcs = wcslen_uint32 (wcs); + uint32_t zero = 0; + /* Handle as a single character. */ + if (nwcs == 0) +@@ -1772,8 +1772,7 @@ symbol `%s' has the same encoding as"), (*eptr)->name); + + if ((*eptr)->nwcs == runp->nwcs) + { +- int c = wmemcmp ((wchar_t *) (*eptr)->wcs, +- (wchar_t *) runp->wcs, runp->nwcs); ++ int c = wmemcmp_uint32 ((*eptr)->wcs, runp->wcs, runp->nwcs); + + if (c == 0) + { +@@ -2000,9 +1999,9 @@ add_to_tablewc (uint32_t ch, struct element_t *runp) + one consecutive entry. */ + if (runp->wcnext != NULL + && runp->nwcs == runp->wcnext->nwcs +- && wmemcmp ((wchar_t *) runp->wcs, +- (wchar_t *)runp->wcnext->wcs, +- runp->nwcs - 1) == 0 ++ && wmemcmp_uint32 (runp->wcs, ++ runp->wcnext->wcs, ++ runp->nwcs - 1) == 0 + && (runp->wcs[runp->nwcs - 1] + == runp->wcnext->wcs[runp->nwcs - 1] + 1)) + { +@@ -2026,9 +2025,9 @@ add_to_tablewc (uint32_t ch, struct element_t *runp) + runp = runp->wcnext; + while (runp->wcnext != NULL + && runp->nwcs == runp->wcnext->nwcs +- && wmemcmp ((wchar_t *) runp->wcs, +- (wchar_t *)runp->wcnext->wcs, +- runp->nwcs - 1) == 0 ++ && wmemcmp_uint32 (runp->wcs, ++ runp->wcnext->wcs, ++ runp->nwcs - 1) == 0 + && (runp->wcs[runp->nwcs - 1] + == runp->wcnext->wcs[runp->nwcs - 1] + 1)); + +diff --git a/locale/programs/ld-ctype.c b/locale/programs/ld-ctype.c +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, + allocate_arrays (ctype, charmap, ctype->repertoire); + + default_missing_len = (ctype->default_missing +- ? wcslen ((wchar_t *) ctype->default_missing) ++ ? wcslen_uint32 (ctype->default_missing) + : 0); + + init_locale_data (&file, nelems); +@@ -1927,7 +1927,7 @@ read_translit_entry (struct linereader *ldfile, struct locale_ctype_t *ctype, + ignore = 1; + else + /* This value is usable. */ +- obstack_grow (ob, to_wstr, wcslen ((wchar_t *) to_wstr) * 4); ++ obstack_grow (ob, to_wstr, wcslen_uint32 (to_wstr) * 4); + + first = 0; + } +@@ -2461,8 +2461,8 @@ with character code range values one must use the absolute ellipsis `...'")); + } + + handle_tok_digit: +- class_bit = _ISwdigit; +- class256_bit = _ISdigit; ++ class_bit = BITw (tok_digit); ++ class256_bit = BIT (tok_digit); + handle_digits = 1; + goto read_charclass; + +@@ -3904,8 +3904,7 @@ allocate_arrays (struct locale_ctype_t *ctype, const struct charmap_t *charmap, + + while (idx < number) + { +- int res = wcscmp ((const wchar_t *) sorted[idx]->from, +- (const wchar_t *) runp->from); ++ int res = wcscmp_uint32 (sorted[idx]->from, runp->from); + if (res == 0) + { + replace = 1; +@@ -3942,11 +3941,11 @@ allocate_arrays (struct locale_ctype_t *ctype, const struct charmap_t *charmap, + for (size_t cnt = 0; cnt < number; ++cnt) + { + struct translit_to_t *srunp; +- from_len += wcslen ((const wchar_t *) sorted[cnt]->from) + 1; ++ from_len += wcslen_uint32 (sorted[cnt]->from) + 1; + srunp = sorted[cnt]->to; + while (srunp != NULL) + { +- to_len += wcslen ((const wchar_t *) srunp->str) + 1; ++ to_len += wcslen_uint32 (srunp->str) + 1; + srunp = srunp->next; + } + /* Plus one for the extra NUL character marking the end of +@@ -3970,18 +3969,18 @@ allocate_arrays (struct locale_ctype_t *ctype, const struct charmap_t *charmap, + ctype->translit_from_idx[cnt] = from_len; + ctype->translit_to_idx[cnt] = to_len; + +- len = wcslen ((const wchar_t *) sorted[cnt]->from) + 1; +- wmemcpy ((wchar_t *) &ctype->translit_from_tbl[from_len], +- (const wchar_t *) sorted[cnt]->from, len); ++ len = wcslen_uint32 (sorted[cnt]->from) + 1; ++ wmemcpy_uint32 (&ctype->translit_from_tbl[from_len], ++ sorted[cnt]->from, len); + from_len += len; + + ctype->translit_to_idx[cnt] = to_len; + srunp = sorted[cnt]->to; + while (srunp != NULL) + { +- len = wcslen ((const wchar_t *) srunp->str) + 1; +- wmemcpy ((wchar_t *) &ctype->translit_to_tbl[to_len], +- (const wchar_t *) srunp->str, len); ++ len = wcslen_uint32 (srunp->str) + 1; ++ wmemcpy_uint32 (&ctype->translit_to_tbl[to_len], ++ srunp->str, len); + to_len += len; + srunp = srunp->next; + } +diff --git a/locale/programs/ld-time.c b/locale/programs/ld-time.c +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"); + } + else + { ++ static const uint32_t wt_fmt_ampm[] ++ = { '%','I',':','%','M',':','%','S',' ','%','p',0 }; + time->t_fmt_ampm = "%I:%M:%S %p"; +- time->wt_fmt_ampm = (const uint32_t *) L"%I:%M:%S %p"; ++ time->wt_fmt_ampm = wt_fmt_ampm; + } + } + +@@ -231,7 +233,7 @@ No definition for %s category found"), "LC_TIME"); + const int days_per_month[12] = { 31, 29, 31, 30, 31, 30, + 31, 31, 30, 31 ,30, 31 }; + size_t idx; +- wchar_t *wstr; ++ uint32_t *wstr; + + time->era_entries = + (struct era_data *) xmalloc (time->num_era +@@ -457,18 +459,18 @@ No definition for %s category found"), "LC_TIME"); + } + + /* Now generate the wide character name and format. */ +- wstr = wcschr ((wchar_t *) time->wera[idx], L':');/* end direction */ +- wstr = wstr ? wcschr (wstr + 1, L':') : NULL; /* end offset */ +- wstr = wstr ? wcschr (wstr + 1, L':') : NULL; /* end start */ +- wstr = wstr ? wcschr (wstr + 1, L':') : NULL; /* end end */ ++ wstr = wcschr_uint32 (time->wera[idx], L':'); /* end direction */ ++ wstr = wstr ? wcschr_uint32 (wstr + 1, L':') : NULL; /* end offset */ ++ wstr = wstr ? wcschr_uint32 (wstr + 1, L':') : NULL; /* end start */ ++ wstr = wstr ? wcschr_uint32 (wstr + 1, L':') : NULL; /* end end */ + if (wstr != NULL) + { +- time->era_entries[idx].wname = (uint32_t *) wstr + 1; +- wstr = wcschr (wstr + 1, L':'); /* end name */ ++ time->era_entries[idx].wname = wstr + 1; ++ wstr = wcschr_uint32 (wstr + 1, L':'); /* end name */ + if (wstr != NULL) + { + *wstr = L'\0'; +- time->era_entries[idx].wformat = (uint32_t *) wstr + 1; ++ time->era_entries[idx].wformat = wstr + 1; + } + else + time->era_entries[idx].wname = +@@ -527,7 +529,16 @@ No definition for %s category found"), "LC_TIME"); + if (time->date_fmt == NULL) + time->date_fmt = "%a %b %e %H:%M:%S %Z %Y"; + if (time->wdate_fmt == NULL) +- time->wdate_fmt = (const uint32_t *) L"%a %b %e %H:%M:%S %Z %Y"; ++ { ++ static const uint32_t wdate_fmt[] = ++ { '%','a',' ', ++ '%','b',' ', ++ '%','e',' ', ++ '%','H',':','%','M',':','%','S',' ', ++ '%','Z',' ', ++ '%','Y',0 }; ++ time->wdate_fmt = wdate_fmt; ++ } + } + + +diff --git a/locale/programs/linereader.c b/locale/programs/linereader.c +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, + { + int return_widestr = lr->return_widestr; + char *buf; +- wchar_t *buf2 = NULL; ++ uint32_t *buf2 = NULL; + size_t bufact; + size_t bufmax = 56; + +diff --git a/locale/programs/localedef.c b/locale/programs/localedef.c +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; + #define OPT_NO_WARN 402 + #define OPT_WARN 403 + #define OPT_NO_HARD_LINKS 404 ++#define OPT_UINT32_ALIGN 405 + + /* Definitions of arguments for argp functions. */ + static const struct argp_option options[] = +@@ -153,6 +154,8 @@ static const struct argp_option options[] = + N_("Generate little-endian output") }, + { "big-endian", OPT_BIG_ENDIAN, NULL, 0, + N_("Generate big-endian output") }, ++ { "uint32-align", OPT_UINT32_ALIGN, "ALIGNMENT", 0, ++ N_("Set the target's uint32_t alignment in bytes (default 4)") }, + { NULL, 0, NULL, 0, NULL } + }; + +@@ -242,12 +245,14 @@ main (int argc, char *argv[]) + ctype locale. (P1003.2 4.35.5.2) */ + setlocale (LC_CTYPE, "POSIX"); + ++#ifndef NO_SYSCONF + /* Look whether the system really allows locale definitions. POSIX + defines error code 3 for this situation so I think it must be + a fatal error (see P1003.2 4.35.8). */ + if (sysconf (_SC_2_LOCALEDEF) < 0) + record_error (3, 0, _("\ + FATAL: system does not define `_POSIX2_LOCALEDEF'")); ++#endif + + /* Process charmap file. */ + charmap = charmap_read (charmap_file, verbose, 1, be_quiet, 1); +@@ -399,6 +404,9 @@ parse_opt (int key, char *arg, struct argp_state *state) + /* Do not hard link to other locales. */ + hard_links = false; + break; ++ case OPT_UINT32_ALIGN: ++ uint32_align_mask = strtol (arg, NULL, 0) - 1; ++ break; + case 'c': + force_output = 1; + break; +diff --git a/locale/programs/locfile.c b/locale/programs/locfile.c +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, + machine running localedef. */ + bool swap_endianness_p; + ++/* The target's value of __align__(uint32_t) - 1. */ ++unsigned int uint32_align_mask = 3; ++ + /* When called outside a start_locale_structure/end_locale_structure + or start_locale_prelude/end_locale_prelude block, record that the + next byte in FILE's obstack will be the first byte of a new element. +@@ -621,7 +624,7 @@ add_locale_string (struct locale_file *file, const char *string) + void + add_locale_wstring (struct locale_file *file, const uint32_t *string) + { +- add_locale_uint32_array (file, string, wcslen ((const wchar_t *) string) + 1); ++ add_locale_uint32_array (file, string, wcslen_uint32 (string) + 1); + } + + /* 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 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, + + extern bool swap_endianness_p; + ++extern unsigned int uint32_align_mask; ++ + /* Change the output to be big-endian if BIG_ENDIAN is true and + little-endian otherwise. */ + static inline void +@@ -89,7 +91,8 @@ maybe_swap_uint32 (uint32_t value) + } + + /* Likewise, but munge an array of N uint32_ts starting at ARRAY. */ +-static inline void ++static void ++__attribute__ ((unused)) + maybe_swap_uint32_array (uint32_t *array, size_t n) + { + if (swap_endianness_p) +@@ -99,7 +102,8 @@ maybe_swap_uint32_array (uint32_t *array, size_t n) + + /* Like maybe_swap_uint32_array, but the array of N elements is at + the end of OBSTACK's current object. */ +-static inline void ++static void ++__attribute__ ((unused)) + maybe_swap_uint32_obstack (struct obstack *obstack, size_t n) + { + maybe_swap_uint32_array ((uint32_t *) obstack_next_free (obstack) - n, n); +@@ -276,4 +280,55 @@ extern void identification_output (struct localedef_t *locale, + const struct charmap_t *charmap, + const char *output_path); + ++static size_t wcslen_uint32 (const uint32_t *str) __attribute__ ((unused)); ++static uint32_t * wmemcpy_uint32 (uint32_t *s1, const uint32_t *s2, size_t n) __attribute__ ((unused)); ++static uint32_t * wcschr_uint32 (const uint32_t *s, uint32_t ch) __attribute__ ((unused)); ++static int wcscmp_uint32 (const uint32_t *s1, const uint32_t *s2) __attribute__ ((unused)); ++static int wmemcmp_uint32 (const uint32_t *s1, const uint32_t *s2, size_t n) __attribute__ ((unused)); ++ ++static size_t ++wcslen_uint32 (const uint32_t *str) ++{ ++ size_t len = 0; ++ while (str[len] != 0) ++ len++; ++ return len; ++} ++ ++static int ++wmemcmp_uint32 (const uint32_t *s1, const uint32_t *s2, size_t n) ++{ ++ while (n-- != 0) ++ { ++ int diff = *s1++ - *s2++; ++ if (diff != 0) ++ return diff; ++ } ++ return 0; ++} ++ ++static int ++wcscmp_uint32 (const uint32_t *s1, const uint32_t *s2) ++{ ++ while (*s1 != 0 && *s1 == *s2) ++ s1++, s2++; ++ return *s1 - *s2; ++} ++ ++static uint32_t * ++wmemcpy_uint32 (uint32_t *s1, const uint32_t *s2, size_t n) ++{ ++ return memcpy (s1, s2, n * sizeof (uint32_t)); ++} ++ ++static uint32_t * ++wcschr_uint32 (const uint32_t *s, uint32_t ch) ++{ ++ do ++ if (*s == ch) ++ return (uint32_t *) s; ++ while (*s++ != 0); ++ return 0; ++} ++ + #endif /* locfile.h */ +diff --git a/locale/setlocale.c b/locale/setlocale.c +index 030f1727bd..096d8ed895 100644 +--- a/locale/setlocale.c ++++ b/locale/setlocale.c +@@ -63,35 +63,6 @@ static char *const _nl_current_used[] = + + #endif + +- +-/* Define an array of category names (also the environment variable names). */ +-const struct catnamestr_t _nl_category_names attribute_hidden = +- { +-#define DEFINE_CATEGORY(category, category_name, items, a) \ +- 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 (struct catnamestr_t, CATNAMEMF (__LINE__)), +-#include "categories.def" +-#undef DEFINE_CATEGORY +- }; +- +-/* An array of their lengths, for convenience. */ +-const uint8_t _nl_category_name_sizes[] attribute_hidden = +- { +-#define DEFINE_CATEGORY(category, category_name, items, a) \ +- [category] = sizeof (category_name) - 1, +-#include "categories.def" +-#undef DEFINE_CATEGORY +- [LC_ALL] = sizeof ("LC_ALL") - 1 +- }; +- +- + #ifdef NL_CURRENT_INDIRECT + # define WEAK_POSTLOAD(postload) weak_extern (postload) + #else 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/0024-localedef-add-to-archive-uses-a-hard-coded-locale-pa.patch deleted file mode 100644 index f68e4f4fa6..0000000000 --- a/meta/recipes-core/glibc/glibc/0024-localedef-add-to-archive-uses-a-hard-coded-locale-pa.patch +++ /dev/null @@ -1,84 +0,0 @@ -From c13e18adb634a6fd59129150ab7f9468f64dc931 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 3 Aug 2018 09:42:06 -0700 -Subject: [PATCH 24/28] 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. - -Add a fallback of $LOCALEARCHIVE from the environment, and allow -creation of new locale archives that are not the system archive. - -Upstream-Status: Inappropriate (OE-specific) - -Signed-off-by: Ross Burton -Signed-off-by: Khem Raj ---- - locale/programs/locarchive.c | 35 +++++++++++++++++++++++++---------- - 1 file changed, 25 insertions(+), 10 deletions(-) - -diff --git a/locale/programs/locarchive.c b/locale/programs/locarchive.c -index e6310b18be..f54a76eade 100644 ---- a/locale/programs/locarchive.c -+++ b/locale/programs/locarchive.c -@@ -340,12 +340,24 @@ enlarge_archive (struct locarhandle *ah, const struct locarhead *head) - struct namehashent *oldnamehashtab; - struct locarhandle new_ah; - size_t prefix_len = output_prefix ? strlen (output_prefix) : 0; -- char archivefname[prefix_len + sizeof (ARCHIVE_NAME)]; -- char fname[prefix_len + sizeof (ARCHIVE_NAME) + sizeof (".XXXXXX") - 1]; -+ char *archivefname; -+ char *fname; -+ char *envarchive = getenv("LOCALEARCHIVE"); - -- if (output_prefix) -- memcpy (archivefname, output_prefix, prefix_len); -- strcpy (archivefname + prefix_len, ARCHIVE_NAME); -+ if (envarchive != NULL) -+ { -+ archivefname = xmalloc(strlen(envarchive) + 1); -+ fname = xmalloc(strlen(envarchive) + sizeof (".XXXXXX")); -+ strcpy (archivefname, envarchive); -+ } -+ else -+ { -+ archivefname = xmalloc(prefix_len + sizeof (ARCHIVE_NAME)); -+ fname = xmalloc(prefix_len + sizeof (ARCHIVE_NAME) + sizeof (".XXXXXX") - 1); -+ if (output_prefix) -+ memcpy (archivefname, output_prefix, prefix_len); -+ strcpy (archivefname + prefix_len, ARCHIVE_NAME); -+ } - strcpy (stpcpy (fname, archivefname), ".XXXXXX"); - - /* Not all of the old file has to be mapped. Change this now this -@@ -569,10 +581,13 @@ open_archive (struct locarhandle *ah, bool readonly) - /* If ah has a non-NULL fname open that otherwise open the default. */ - if (archivefname == NULL) - { -- archivefname = default_fname; -- if (output_prefix) -- memcpy (default_fname, output_prefix, prefix_len); -- strcpy (default_fname + prefix_len, ARCHIVE_NAME); -+ archivefname = getenv("LOCALEARCHIVE"); -+ if (archivefname == NULL) { -+ archivefname = default_fname; -+ if (output_prefix) -+ memcpy (default_fname, output_prefix, prefix_len); -+ strcpy (default_fname + prefix_len, ARCHIVE_NAME); -+ } - } - - while (1) -@@ -585,7 +600,7 @@ open_archive (struct locarhandle *ah, bool readonly) - the default locale archive we ignore the failure and - list an empty archive, otherwise we print an error - and exit. */ -- if (errno == ENOENT && archivefname == default_fname) -+ if (errno == ENOENT) - { - if (readonly) - { --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0025-Define-DUMMY_LOCALE_T-if-not-defined.patch b/meta/recipes-core/glibc/glibc/0025-Define-DUMMY_LOCALE_T-if-not-defined.patch new file mode 100644 index 0000000000..d359518751 --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0025-Define-DUMMY_LOCALE_T-if-not-defined.patch @@ -0,0 +1,29 @@ +From 5e565710aa061ffffd34d8400910c35a8d50a4ec Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 20 Apr 2016 21:11:00 -0700 +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 + +Upstream-Status: Inappropriate [other] + +Signed-off-by: Khem Raj +--- + locale/programs/config.h | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/locale/programs/config.h b/locale/programs/config.h +index d76d9f7e8b..92b56d7df3 100644 +--- a/locale/programs/config.h ++++ b/locale/programs/config.h +@@ -19,6 +19,9 @@ + #ifndef _LD_CONFIG_H + #define _LD_CONFIG_H 1 + ++#ifndef DUMMY_LOCALE_T ++#define DUMMY_LOCALE_T ++#endif + /* Use the internal textdomain used for libc messages. */ + #define PACKAGE _libc_intl_domainname + #ifndef VERSION 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/0025-elf-dl-deps.c-Make-_dl_build_local_scope-breadth-fir.patch deleted file mode 100644 index 76a9eb2563..0000000000 --- a/meta/recipes-core/glibc/glibc/0025-elf-dl-deps.c-Make-_dl_build_local_scope-breadth-fir.patch +++ /dev/null @@ -1,56 +0,0 @@ -From 7c9ebe966bb97dd14de5719905b61311211ae3c8 Mon Sep 17 00:00:00 2001 -From: Mark Hatle -Date: Thu, 18 Aug 2016 14:07:58 -0500 -Subject: [PATCH 25/28] elf/dl-deps.c: Make _dl_build_local_scope breadth first - -According to the ELF specification: - -When resolving symbolic references, the dynamic linker examines the symbol -tables with a breadth-first search. - -This function was using a depth first search. By doing so the conflict -resolution reported to the prelinker (when LD_TRACE_PRELINKING=1 is set) -was incorrect. This caused problems when their were various circular -dependencies between libraries. The problem usually manifested itself by -the wrong IFUNC being executed. - -[BZ# 20488] - -Upstream-Status: Submitted [libc-alpha] - -Signed-off-by: Mark Hatle ---- - elf/dl-deps.c | 14 ++++++++++---- - 1 file changed, 10 insertions(+), 4 deletions(-) - -diff --git a/elf/dl-deps.c b/elf/dl-deps.c -index e12c353158..9234daac05 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) - { - struct link_map **p = list; - struct link_map **q; -+ struct link_map **r; - - *p++ = map; - map->l_reserved = 1; -- if (map->l_initfini) -- for (q = map->l_initfini + 1; *q; ++q) -- if (! (*q)->l_reserved) -- p += _dl_build_local_scope (p, *q); -+ -+ for (r = list; r < p; ++r) -+ if ((*r)->l_initfini) -+ for (q = (*r)->l_initfini + 1; *q; ++q) -+ if (! (*q)->l_reserved) -+ { -+ *p++ = *q; -+ (*q)->l_reserved = 1; -+ } - 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/0026-intl-Emit-no-lines-in-bison-generated-files.patch deleted file mode 100644 index 7589e11d57..0000000000 --- a/meta/recipes-core/glibc/glibc/0026-intl-Emit-no-lines-in-bison-generated-files.patch +++ /dev/null @@ -1,34 +0,0 @@ -From aa5c758fbb7dbb026df33fc6bdc05548547bdb17 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 3 Aug 2018 09:44:00 -0700 -Subject: [PATCH 26/28] intl: Emit no lines in bison generated files - -Improve reproducibility: -Do not put any #line preprocessor commands in bison generated files. -These lines contain absolute paths containing file locations on -the host build machine. - -Upstream-Status: Pending - -Signed-off-by: Juro Bystricky -Signed-off-by: Khem Raj ---- - intl/Makefile | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/intl/Makefile b/intl/Makefile -index 9eea8d57e3..627dce4cf1 100644 ---- a/intl/Makefile -+++ b/intl/Makefile -@@ -155,7 +155,7 @@ $(objpfx)tst-gettext6.out: $(objpfx)tst-gettext.out - - CPPFLAGS += -D'LOCALEDIR="$(localedir)"' \ - -D'LOCALE_ALIAS_PATH="$(localedir)"' --BISONFLAGS = --yacc --name-prefix=__gettext --output -+BISONFLAGS = --yacc --no-lines --name-prefix=__gettext --output - - $(inst_localedir)/locale.alias: locale.alias $(+force) - $(do-install) --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0026-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 new file mode 100644 index 0000000000..8df09d82ee --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0026-localedef-add-to-archive-uses-a-hard-coded-locale-pa.patch @@ -0,0 +1,80 @@ +From c5b63c8eafc00e01556edd2acff4c541448924cf Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Fri, 3 Aug 2018 09:42:06 -0700 +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. + +Add a fallback of $LOCALEARCHIVE from the environment, and allow +creation of new locale archives that are not the system archive. + +Upstream-Status: Inappropriate (OE-specific) + +Signed-off-by: Ross Burton +Signed-off-by: Khem Raj +--- + locale/programs/locarchive.c | 35 +++++++++++++++++++++++++---------- + 1 file changed, 25 insertions(+), 10 deletions(-) + +diff --git a/locale/programs/locarchive.c b/locale/programs/locarchive.c +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) + struct namehashent *oldnamehashtab; + struct locarhandle new_ah; + size_t prefix_len = output_prefix ? strlen (output_prefix) : 0; +- char archivefname[prefix_len + sizeof (ARCHIVE_NAME)]; +- char fname[prefix_len + sizeof (ARCHIVE_NAME) + sizeof (".XXXXXX") - 1]; ++ char *archivefname; ++ char *fname; ++ char *envarchive = getenv("LOCALEARCHIVE"); + +- if (output_prefix) +- memcpy (archivefname, output_prefix, prefix_len); +- strcpy (archivefname + prefix_len, ARCHIVE_NAME); ++ if (envarchive != NULL) ++ { ++ archivefname = xmalloc(strlen(envarchive) + 1); ++ fname = xmalloc(strlen(envarchive) + sizeof (".XXXXXX")); ++ strcpy (archivefname, envarchive); ++ } ++ else ++ { ++ archivefname = xmalloc(prefix_len + sizeof (ARCHIVE_NAME)); ++ fname = xmalloc(prefix_len + sizeof (ARCHIVE_NAME) + sizeof (".XXXXXX") - 1); ++ if (output_prefix) ++ memcpy (archivefname, output_prefix, prefix_len); ++ strcpy (archivefname + prefix_len, ARCHIVE_NAME); ++ } + strcpy (stpcpy (fname, archivefname), ".XXXXXX"); + + /* Not all of the old file has to be mapped. Change this now this +@@ -569,10 +581,13 @@ open_archive (struct locarhandle *ah, bool readonly) + /* If ah has a non-NULL fname open that otherwise open the default. */ + if (archivefname == NULL) + { +- archivefname = default_fname; +- if (output_prefix) +- memcpy (default_fname, output_prefix, prefix_len); +- strcpy (default_fname + prefix_len, ARCHIVE_NAME); ++ archivefname = getenv("LOCALEARCHIVE"); ++ if (archivefname == NULL) { ++ archivefname = default_fname; ++ if (output_prefix) ++ memcpy (default_fname, output_prefix, prefix_len); ++ strcpy (default_fname + prefix_len, ARCHIVE_NAME); ++ } + } + + while (1) +@@ -585,7 +600,7 @@ open_archive (struct locarhandle *ah, bool readonly) + the default locale archive we ignore the failure and + list an empty archive, otherwise we print an error + and exit. */ +- if (errno == ENOENT && archivefname == default_fname) ++ if (errno == ENOENT) + { + if (readonly) + { diff --git a/meta/recipes-core/glibc/glibc/0027-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 new file mode 100644 index 0000000000..55250d8d8e --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0027-elf-dl-deps.c-Make-_dl_build_local_scope-breadth-fir.patch @@ -0,0 +1,53 @@ +From d3349ae8d9b17fecf6ef560b845d04d682db291c Mon Sep 17 00:00:00 2001 +From: Mark Hatle +Date: Thu, 18 Aug 2016 14:07:58 -0500 +Subject: [PATCH] elf/dl-deps.c: Make _dl_build_local_scope breadth first + +According to the ELF specification: + +When resolving symbolic references, the dynamic linker examines the symbol +tables with a breadth-first search. + +This function was using a depth first search. By doing so the conflict +resolution reported to the prelinker (when LD_TRACE_PRELINKING=1 is set) +was incorrect. This caused problems when their were various circular +dependencies between libraries. The problem usually manifested itself by +the wrong IFUNC being executed. + +[BZ# 20488] + +Upstream-Status: Submitted [libc-alpha] + +Signed-off-by: Mark Hatle +--- + elf/dl-deps.c | 14 ++++++++++---- + 1 file changed, 10 insertions(+), 4 deletions(-) + +diff --git a/elf/dl-deps.c b/elf/dl-deps.c +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) + { + struct link_map **p = list; + struct link_map **q; ++ struct link_map **r; + + *p++ = map; + map->l_reserved = 1; +- if (map->l_initfini) +- for (q = map->l_initfini + 1; *q; ++q) +- if (! (*q)->l_reserved) +- p += _dl_build_local_scope (p, *q); ++ ++ for (r = list; r < p; ++r) ++ if ((*r)->l_initfini) ++ for (q = (*r)->l_initfini + 1; *q; ++q) ++ if (! (*q)->l_reserved) ++ { ++ *p++ = *q; ++ (*q)->l_reserved = 1; ++ } + return p - list; + } + diff --git a/meta/recipes-core/glibc/glibc/0027-inject-file-assembly-directives.patch b/meta/recipes-core/glibc/glibc/0027-inject-file-assembly-directives.patch deleted file mode 100644 index dc205a833f..0000000000 --- a/meta/recipes-core/glibc/glibc/0027-inject-file-assembly-directives.patch +++ /dev/null @@ -1,304 +0,0 @@ -From fecd98040a2ae1bc5943a40a1623d76a696e0785 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Thu, 29 Nov 2018 17:29:35 -0800 -Subject: [PATCH 27/28] 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 -.S assembler files during the glibc build. No STT_FILE section is added -during the assembly but when linking, ld decides to add one to aid -debugging and ensure references between the different object files its -linking remain clear. - -We can avoid this by injecting a file header into the assembler files -ahead of time, choosing a filename which does not contain build system -paths. - -This is a bit of a workaround/hack but does significantly reduce the -build system references in target binaries for the non-IA architectures -which use .S files. - -RP -2018/10/3 - -Upstream-Status: Pending - -Signed-off-by: Khem Raj ---- - csu/abi-note.S | 2 ++ - sysdeps/aarch64/crti.S | 2 ++ - sysdeps/aarch64/crtn.S | 2 ++ - sysdeps/aarch64/dl-tlsdesc.S | 2 ++ - sysdeps/aarch64/dl-trampoline.S | 2 ++ - sysdeps/aarch64/start.S | 2 ++ - sysdeps/arm/abi-note.S | 2 ++ - sysdeps/arm/crti.S | 2 ++ - sysdeps/arm/crtn.S | 2 ++ - sysdeps/arm/dl-tlsdesc.S | 2 ++ - sysdeps/arm/dl-trampoline.S | 2 ++ - sysdeps/arm/start.S | 2 ++ - sysdeps/mips/start.S | 2 ++ - sysdeps/powerpc/powerpc32/dl-start.S | 2 ++ - sysdeps/powerpc/powerpc32/start.S | 2 ++ - sysdeps/powerpc/powerpc64/start.S | 2 ++ - sysdeps/unix/sysv/linux/aarch64/__read_tp.S | 2 ++ - sysdeps/unix/sysv/linux/arm/aeabi_read_tp.S | 2 ++ - sysdeps/unix/sysv/linux/arm/libc-do-syscall.S | 2 ++ - sysdeps/unix/sysv/linux/powerpc/dl-brk.S | 2 ++ - 20 files changed, 40 insertions(+) - -diff --git a/csu/abi-note.S b/csu/abi-note.S -index fa1f014a88..098731362a 100644 ---- a/csu/abi-note.S -+++ b/csu/abi-note.S -@@ -56,6 +56,8 @@ offset length contents - #include - #include /* OS-specific ABI tag value */ - -+ .file "abi-note.S" -+ - /* The linker (GNU ld 2.8 and later) recognizes an allocated section whose - 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 ---- a/sysdeps/aarch64/crti.S -+++ b/sysdeps/aarch64/crti.S -@@ -50,6 +50,8 @@ - # define PREINIT_FUNCTION_WEAK 1 - #endif - -+ .file "crti.S" -+ - #if PREINIT_FUNCTION_WEAK - weak_extern (PREINIT_FUNCTION) - #else -diff --git a/sysdeps/aarch64/crtn.S b/sysdeps/aarch64/crtn.S -index 363f752460..2fb06fba62 100644 ---- a/sysdeps/aarch64/crtn.S -+++ b/sysdeps/aarch64/crtn.S -@@ -37,6 +37,8 @@ - /* crtn.S puts function epilogues in the .init and .fini sections - corresponding to the prologues in crti.S. */ - -+ .file "crtn.S" -+ - .section .init,"ax",%progbits - ldp x29, x30, [sp], 16 - RET -diff --git a/sysdeps/aarch64/dl-tlsdesc.S b/sysdeps/aarch64/dl-tlsdesc.S -index 4abe6b82a3..8c44b2ff8a 100644 ---- a/sysdeps/aarch64/dl-tlsdesc.S -+++ b/sysdeps/aarch64/dl-tlsdesc.S -@@ -22,6 +22,8 @@ - #include - #include "tlsdesc.h" - -+ .file "dl-tlsdesc.S" -+ - #define NSAVEDQREGPAIRS 16 - #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 ---- a/sysdeps/aarch64/dl-trampoline.S -+++ b/sysdeps/aarch64/dl-trampoline.S -@@ -21,6 +21,8 @@ - - #include "dl-link.h" - -+ .file "dl-trampoline.S" -+ - #define ip0 x16 - #define ip0l PTR_REG (16) - #define ip1 x17 -diff --git a/sysdeps/aarch64/start.S b/sysdeps/aarch64/start.S -index f5e9b9c223..ae3e22a6a5 100644 ---- a/sysdeps/aarch64/start.S -+++ b/sysdeps/aarch64/start.S -@@ -18,6 +18,8 @@ - - #include - -+ .file "start.S" -+ - /* This is the canonical entry point, usually the first thing in the text - segment. - -diff --git a/sysdeps/arm/abi-note.S b/sysdeps/arm/abi-note.S -index 07bd4c4619..7213b16f27 100644 ---- a/sysdeps/arm/abi-note.S -+++ b/sysdeps/arm/abi-note.S -@@ -1,3 +1,5 @@ -+ .file "abi-note.S" -+ - /* Tag_ABI_align8_preserved: This code preserves 8-byte - alignment in any callee. */ - .eabi_attribute 25, 1 -diff --git a/sysdeps/arm/crti.S b/sysdeps/arm/crti.S -index 26dbba66a3..dd84ecd566 100644 ---- a/sysdeps/arm/crti.S -+++ b/sysdeps/arm/crti.S -@@ -57,6 +57,8 @@ - .hidden PREINIT_FUNCTION - #endif - -+ .file "crti.S" -+ - #if PREINIT_FUNCTION_WEAK - .p2align 2 - .type call_weak_fn, %function -diff --git a/sysdeps/arm/crtn.S b/sysdeps/arm/crtn.S -index 8f91c8d88b..a87fe49e07 100644 ---- a/sysdeps/arm/crtn.S -+++ b/sysdeps/arm/crtn.S -@@ -37,6 +37,8 @@ - #define NO_THUMB - #include - -+ .file "crtn.S" -+ - /* crtn.S puts function epilogues in the .init and .fini sections - 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 ---- a/sysdeps/arm/dl-tlsdesc.S -+++ b/sysdeps/arm/dl-tlsdesc.S -@@ -21,6 +21,8 @@ - #include - #include "tlsdesc.h" - -+ .file "dl-tlsdesc.S" -+ - .text - @ 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 ---- a/sysdeps/arm/dl-trampoline.S -+++ b/sysdeps/arm/dl-trampoline.S -@@ -21,6 +21,8 @@ - #include - #include - -+ .file "dl-trampoline.S" -+ - .text - .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 ---- a/sysdeps/arm/start.S -+++ b/sysdeps/arm/start.S -@@ -57,6 +57,8 @@ - NULL - */ - -+ .file "start.S" -+ - /* Tag_ABI_align8_preserved: This code preserves 8-byte - alignment in any callee. */ - .eabi_attribute 25, 1 -diff --git a/sysdeps/mips/start.S b/sysdeps/mips/start.S -index 8638e5b545..93f6564aec 100644 ---- a/sysdeps/mips/start.S -+++ b/sysdeps/mips/start.S -@@ -38,6 +38,8 @@ - #include - #include - -+ .file "start.S" -+ - #ifndef ENTRY_POINT - #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 ---- a/sysdeps/powerpc/powerpc32/dl-start.S -+++ b/sysdeps/powerpc/powerpc32/dl-start.S -@@ -18,6 +18,8 @@ - - #include - -+ .file "dl-start.S" -+ - /* Initial entry point code for the dynamic linker. - 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 ---- a/sysdeps/powerpc/powerpc32/start.S -+++ b/sysdeps/powerpc/powerpc32/start.S -@@ -35,6 +35,8 @@ - - #include - -+ .file "start.S" -+ - /* We do not want .eh_frame info for crt1.o since crt1.o is linked - 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 ---- a/sysdeps/powerpc/powerpc64/start.S -+++ b/sysdeps/powerpc/powerpc64/start.S -@@ -35,6 +35,8 @@ - - #include - -+ .file "start.S" -+ - /* We do not want .eh_frame info for crt1.o since crt1.o is linked - 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 ---- a/sysdeps/unix/sysv/linux/aarch64/__read_tp.S -+++ b/sysdeps/unix/sysv/linux/aarch64/__read_tp.S -@@ -18,6 +18,8 @@ - - #include - -+ .file "__read_tp.S" -+ - .hidden __read_tp - 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 ---- a/sysdeps/unix/sysv/linux/arm/aeabi_read_tp.S -+++ b/sysdeps/unix/sysv/linux/arm/aeabi_read_tp.S -@@ -39,6 +39,8 @@ - a normal function call) in a high page of memory; tail call to the - helper. */ - -+ .file "aeabi_read_tp.S" -+ - .hidden __aeabi_read_tp - 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 ---- a/sysdeps/unix/sysv/linux/arm/libc-do-syscall.S -+++ b/sysdeps/unix/sysv/linux/arm/libc-do-syscall.S -@@ -27,6 +27,8 @@ - ARM unwind tables for register to register moves, the actual opcodes - are not defined. */ - -+ .file "libc-do-syscall.S" -+ - #if defined(__thumb__) - .thumb - .syntax unified -diff --git a/sysdeps/unix/sysv/linux/powerpc/dl-brk.S b/sysdeps/unix/sysv/linux/powerpc/dl-brk.S -index eeb96544e3..da182b28f8 100644 ---- a/sysdeps/unix/sysv/linux/powerpc/dl-brk.S -+++ b/sysdeps/unix/sysv/linux/powerpc/dl-brk.S -@@ -1 +1,3 @@ -+ .file "dl-brk.S" -+ - #include --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0028-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 new file mode 100644 index 0000000000..06d23c988d --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0028-intl-Emit-no-lines-in-bison-generated-files.patch @@ -0,0 +1,31 @@ +From 3650ad7f01509138aa72f235e680c9d4f6c09a7d Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Fri, 3 Aug 2018 09:44:00 -0700 +Subject: [PATCH] intl: Emit no lines in bison generated files + +Improve reproducibility: +Do not put any #line preprocessor commands in bison generated files. +These lines contain absolute paths containing file locations on +the host build machine. + +Upstream-Status: Pending + +Signed-off-by: Juro Bystricky +Signed-off-by: Khem Raj +--- + intl/Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/intl/Makefile b/intl/Makefile +index ce3072420f..58457840d9 100644 +--- a/intl/Makefile ++++ b/intl/Makefile +@@ -155,7 +155,7 @@ $(objpfx)tst-gettext6.out: $(objpfx)tst-gettext.out + + CPPFLAGS += -D'LOCALEDIR="$(localedir)"' \ + -D'LOCALE_ALIAS_PATH="$(localedir)"' +-BISONFLAGS = --yacc --name-prefix=__gettext --output ++BISONFLAGS = --yacc --no-lines --name-prefix=__gettext --output + + $(inst_localedir)/locale.alias: locale.alias $(+force) + $(do-install) diff --git a/meta/recipes-core/glibc/glibc/0028-locale-prevent-maybe-uninitialized-errors-with-Os-BZ.patch b/meta/recipes-core/glibc/glibc/0028-locale-prevent-maybe-uninitialized-errors-with-Os-BZ.patch deleted file mode 100644 index 6c49066fd1..0000000000 --- a/meta/recipes-core/glibc/glibc/0028-locale-prevent-maybe-uninitialized-errors-with-Os-BZ.patch +++ /dev/null @@ -1,56 +0,0 @@ -From d934788e3221c28c9a1892235cbe4cfd1b28ced0 Mon Sep 17 00:00:00 2001 -From: Martin Jansa -Date: Mon, 17 Dec 2018 21:36:18 +0000 -Subject: [PATCH 28/28] locale: prevent maybe-uninitialized errors with -Os [BZ - #19444] - -Fixes following error when building for aarch64 with -Os: -| In file included from strcoll_l.c:43: -| strcoll_l.c: In function '__strcoll_l': -| ../locale/weight.h:31:26: error: 'seq2.back_us' may be used uninitialized in this function [-Werror=maybe-uninitialized] -| int_fast32_t i = table[*(*cpp)++]; -| ^~~~~~~~~ -| strcoll_l.c:304:18: note: 'seq2.back_us' was declared here -| coll_seq seq1, seq2; -| ^~~~ -| In file included from strcoll_l.c:43: -| ../locale/weight.h:31:26: error: 'seq1.back_us' may be used uninitialized in this function [-Werror=maybe-uninitialized] -| int_fast32_t i = table[*(*cpp)++]; -| ^~~~~~~~~ -| strcoll_l.c:304:12: note: 'seq1.back_us' was declared here -| coll_seq seq1, seq2; -| ^~~~ - - Partial fix for [BZ #19444] - * locale/weight.h: Fix build with -Os. - -Upstream-Status: Submitted [https://patchwork.ozlabs.org/patch/1014766] - -Signed-off-by: Martin Jansa -Signed-off-by: Khem Raj ---- - locale/weight.h | 7 +++++++ - 1 file changed, 7 insertions(+) - -diff --git a/locale/weight.h b/locale/weight.h -index 7ca81498b2..d608ca70bb 100644 ---- a/locale/weight.h -+++ b/locale/weight.h -@@ -28,7 +28,14 @@ findidx (const int32_t *table, - const unsigned char *extra, - const unsigned char **cpp, size_t len) - { -+ /* With GCC 8 when compiling with -Os the compiler warns that -+ seq1.back_us and seq2.back_us might be used uninitialized. -+ This uninitialized use is impossible for the same reason -+ as described in comments in locale/weightwc.h. */ -+ DIAG_PUSH_NEEDS_COMMENT; -+ DIAG_IGNORE_Os_NEEDS_COMMENT (8, "-Wmaybe-uninitialized"); - int_fast32_t i = table[*(*cpp)++]; -+ DIAG_POP_NEEDS_COMMENT; - const unsigned char *cp; - const unsigned char *usrc; - --- -2.22.0 - diff --git a/meta/recipes-core/glibc/glibc/0029-Add-hardlink-resolver-from-util-linux.patch b/meta/recipes-core/glibc/glibc/0029-Add-hardlink-resolver-from-util-linux.patch deleted file mode 100644 index b7fb0321c4..0000000000 --- a/meta/recipes-core/glibc/glibc/0029-Add-hardlink-resolver-from-util-linux.patch +++ /dev/null @@ -1,1130 +0,0 @@ -From 9e5e5297d9a5ef66b3920313356bf7f25955dff3 Mon Sep 17 00:00:00 2001 -From: Jason Wessel -Date: Sat, 7 Dec 2019 09:59:22 -0800 -Subject: [PATCH] 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 -in parallel) and perform a creation of a .tmp file and remove the -original and move the .tmp file in. The problem is that if a probe -occurs a hard link can be requested to the file that is being removed. -This will lead to a stray copy or potentially, on a loaded system -cause race condition which pseudo cannot deal with, where it is left -with a hard link request to a file that no longer exists. In this -situation psuedo will inherit the permissions of what ever the target -inode had to offer. - -In short, there are two problems: - -1) You will be left with stray copies when using the hard link -resolution that is built in while running in parallel with -localedef. - -2) When running under pseudo the possibility exists for uid/gid -leakage when the source file is removed before the hard link can -be completed. - -The solution is to call localedef with --no-hard-links and separately -process the hardlinks at a later point. To do this requires the -inclusion of the hardlink utility found in modern versions of -util-linux. Most host systems do not have this, so it will be -included with the cross-localedef binary. - -[YOCTO #11299] -[YOCTO #12434] - -Upstream-Status: Pending - -Signed-off-by: Jason Wessel -Signed-off-by: Khem Raj ---- - locale/programs/c.h | 407 ++++++++++++++++ - locale/programs/cross-localedef-hardlink.c | 528 +++++++++++++++++++++ - locale/programs/xalloc.h | 129 +++++ - 3 files changed, 1064 insertions(+) - create mode 100644 locale/programs/c.h - create mode 100644 locale/programs/cross-localedef-hardlink.c - create mode 100644 locale/programs/xalloc.h - -diff --git a/locale/programs/c.h b/locale/programs/c.h -new file mode 100644 -index 0000000000..d0a402e90e ---- /dev/null -+++ b/locale/programs/c.h -@@ -0,0 +1,407 @@ -+/* -+ * Fundamental C definitions. -+ */ -+ -+#ifndef UTIL_LINUX_C_H -+#define UTIL_LINUX_C_H -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include -+ -+#ifdef HAVE_ERR_H -+# include -+#endif -+ -+#ifdef HAVE_SYS_SYSMACROS_H -+# include /* for major, minor */ -+#endif -+ -+#ifndef LOGIN_NAME_MAX -+# define LOGIN_NAME_MAX 256 -+#endif -+ -+#ifndef NAME_MAX -+# define NAME_MAX PATH_MAX -+#endif -+ -+/* -+ * __GNUC_PREREQ is deprecated in favour of __has_attribute() and -+ * __has_feature(). The __has macros are supported by clang and gcc>=5. -+ */ -+#ifndef __GNUC_PREREQ -+# if defined __GNUC__ && defined __GNUC_MINOR__ -+# define __GNUC_PREREQ(maj, min) \ -+ ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) -+# else -+# define __GNUC_PREREQ(maj, min) 0 -+# endif -+#endif -+ -+#ifdef __GNUC__ -+ -+/* &a[0] degrades to a pointer: a different type from an array */ -+# define __must_be_array(a) \ -+ UL_BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(__typeof__(a), __typeof__(&a[0]))) -+ -+# define ignore_result(x) __extension__ ({ \ -+ __typeof__(x) __dummy __attribute__((__unused__)) = (x); (void) __dummy; \ -+}) -+ -+#else /* !__GNUC__ */ -+# define __must_be_array(a) 0 -+# define __attribute__(_arg_) -+# define ignore_result(x) ((void) (x)) -+#endif /* !__GNUC__ */ -+ -+/* -+ * It evaluates to 1 if the attribute/feature is supported by the current -+ * compilation targed. Fallback for old compilers. -+ */ -+#ifndef __has_attribute -+ #define __has_attribute(x) 0 -+#endif -+ -+#ifndef __has_feature -+ #define __has_feature(x) 0 -+#endif -+ -+/* -+ * Function attributes -+ */ -+#ifndef __ul_alloc_size -+# if (__has_attribute(alloc_size) && __has_attribute(warn_unused_result)) || __GNUC_PREREQ (4, 3) -+# define __ul_alloc_size(s) __attribute__((alloc_size(s), warn_unused_result)) -+# else -+# define __ul_alloc_size(s) -+# endif -+#endif -+ -+#ifndef __ul_calloc_size -+# if (__has_attribute(alloc_size) && __has_attribute(warn_unused_result)) || __GNUC_PREREQ (4, 3) -+# define __ul_calloc_size(n, s) __attribute__((alloc_size(n, s), warn_unused_result)) -+# else -+# define __ul_calloc_size(n, s) -+# endif -+#endif -+ -+#if __has_attribute(returns_nonnull) || __GNUC_PREREQ (4, 9) -+# define __ul_returns_nonnull __attribute__((returns_nonnull)) -+#else -+# define __ul_returns_nonnull -+#endif -+ -+/* -+ * Force a compilation error if condition is true, but also produce a -+ * result (of value 0 and type size_t), so the expression can be used -+ * e.g. in a structure initializer (or wherever else comma expressions -+ * aren't permitted). -+ */ -+#define UL_BUILD_BUG_ON_ZERO(e) __extension__ (sizeof(struct { int:-!!(e); })) -+#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); })) -+ -+#ifndef ARRAY_SIZE -+# define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) -+#endif -+ -+#ifndef PATH_MAX -+# define PATH_MAX 4096 -+#endif -+ -+#ifndef TRUE -+# define TRUE 1 -+#endif -+ -+#ifndef FALSE -+# define FALSE 0 -+#endif -+ -+#ifndef min -+# define min(x, y) __extension__ ({ \ -+ __typeof__(x) _min1 = (x); \ -+ __typeof__(y) _min2 = (y); \ -+ (void) (&_min1 == &_min2); \ -+ _min1 < _min2 ? _min1 : _min2; }) -+#endif -+ -+#ifndef max -+# define max(x, y) __extension__ ({ \ -+ __typeof__(x) _max1 = (x); \ -+ __typeof__(y) _max2 = (y); \ -+ (void) (&_max1 == &_max2); \ -+ _max1 > _max2 ? _max1 : _max2; }) -+#endif -+ -+#ifndef cmp_numbers -+# define cmp_numbers(x, y) __extension__ ({ \ -+ __typeof__(x) _a = (x); \ -+ __typeof__(y) _b = (y); \ -+ (void) (&_a == &_b); \ -+ _a == _b ? 0 : _a > _b ? 1 : -1; }) -+#endif -+ -+#ifndef offsetof -+#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) -+#endif -+ -+/* -+ * container_of - cast a member of a structure out to the containing structure -+ * @ptr: the pointer to the member. -+ * @type: the type of the container struct this is embedded in. -+ * @member: the name of the member within the struct. -+ */ -+#ifndef container_of -+#define container_of(ptr, type, member) __extension__ ({ \ -+ const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \ -+ (type *)( (char *)__mptr - offsetof(type,member) );}) -+#endif -+ -+#ifndef HAVE_PROGRAM_INVOCATION_SHORT_NAME -+# ifdef HAVE___PROGNAME -+extern char *__progname; -+# define program_invocation_short_name __progname -+# else -+# ifdef HAVE_GETEXECNAME -+# define program_invocation_short_name \ -+ prog_inv_sh_nm_from_file(getexecname(), 0) -+# else -+# define program_invocation_short_name \ -+ prog_inv_sh_nm_from_file(__FILE__, 1) -+# endif -+static char prog_inv_sh_nm_buf[256]; -+static inline char * -+prog_inv_sh_nm_from_file(char *f, char stripext) -+{ -+ char *t; -+ -+ if ((t = strrchr(f, '/')) != NULL) -+ t++; -+ else -+ t = f; -+ -+ strncpy(prog_inv_sh_nm_buf, t, sizeof(prog_inv_sh_nm_buf) - 1); -+ prog_inv_sh_nm_buf[sizeof(prog_inv_sh_nm_buf) - 1] = '\0'; -+ -+ if (stripext && (t = strrchr(prog_inv_sh_nm_buf, '.')) != NULL) -+ *t = '\0'; -+ -+ return prog_inv_sh_nm_buf; -+} -+# endif -+#endif -+ -+ -+#ifndef HAVE_ERR_H -+static inline void -+errmsg(char doexit, int excode, char adderr, const char *fmt, ...) -+{ -+ fprintf(stderr, "%s: ", program_invocation_short_name); -+ if (fmt != NULL) { -+ va_list argp; -+ va_start(argp, fmt); -+ vfprintf(stderr, fmt, argp); -+ va_end(argp); -+ if (adderr) -+ fprintf(stderr, ": "); -+ } -+ if (adderr) -+ fprintf(stderr, "%m"); -+ fprintf(stderr, "\n"); -+ if (doexit) -+ exit(excode); -+} -+ -+#ifndef HAVE_ERR -+# define err(E, FMT...) errmsg(1, E, 1, FMT) -+#endif -+ -+#ifndef HAVE_ERRX -+# define errx(E, FMT...) errmsg(1, E, 0, FMT) -+#endif -+ -+#ifndef HAVE_WARN -+# define warn(FMT...) errmsg(0, 0, 1, FMT) -+#endif -+ -+#ifndef HAVE_WARNX -+# define warnx(FMT...) errmsg(0, 0, 0, FMT) -+#endif -+#endif /* !HAVE_ERR_H */ -+ -+ -+/* Don't use inline function to avoid '#include "nls.h"' in c.h -+ */ -+#define errtryhelp(eval) __extension__ ({ \ -+ fprintf(stderr, _("Try '%s --help' for more information.\n"), \ -+ program_invocation_short_name); \ -+ exit(eval); \ -+}) -+ -+/* After failed execvp() */ -+#define EX_EXEC_FAILED 126 /* Program located, but not usable. */ -+#define EX_EXEC_ENOENT 127 /* Could not find program to exec. */ -+#define errexec(name) err(errno == ENOENT ? EX_EXEC_ENOENT : EX_EXEC_FAILED, \ -+ _("failed to execute %s"), name) -+ -+ -+static inline __attribute__((const)) int is_power_of_2(unsigned long num) -+{ -+ return (num != 0 && ((num & (num - 1)) == 0)); -+} -+ -+#ifndef HAVE_LOFF_T -+typedef int64_t loff_t; -+#endif -+ -+#if !defined(HAVE_DIRFD) && (!defined(HAVE_DECL_DIRFD) || HAVE_DECL_DIRFD == 0) && defined(HAVE_DIR_DD_FD) -+#include -+#include -+static inline int dirfd(DIR *d) -+{ -+ return d->dd_fd; -+} -+#endif -+ -+/* -+ * Fallback defines for old versions of glibc -+ */ -+#include -+ -+#ifdef O_CLOEXEC -+#define UL_CLOEXECSTR "e" -+#else -+#define UL_CLOEXECSTR "" -+#endif -+ -+#ifndef O_CLOEXEC -+#define O_CLOEXEC 0 -+#endif -+ -+#ifdef __FreeBSD_kernel__ -+#ifndef F_DUPFD_CLOEXEC -+#define F_DUPFD_CLOEXEC 17 /* Like F_DUPFD, but FD_CLOEXEC is set */ -+#endif -+#endif -+ -+ -+#ifndef AI_ADDRCONFIG -+#define AI_ADDRCONFIG 0x0020 -+#endif -+ -+#ifndef IUTF8 -+#define IUTF8 0040000 -+#endif -+ -+/* -+ * MAXHOSTNAMELEN replacement -+ */ -+static inline size_t get_hostname_max(void) -+{ -+ long len = sysconf(_SC_HOST_NAME_MAX); -+ -+ if (0 < len) -+ return len; -+ -+#ifdef MAXHOSTNAMELEN -+ return MAXHOSTNAMELEN; -+#elif HOST_NAME_MAX -+ return HOST_NAME_MAX; -+#endif -+ return 64; -+} -+ -+ -+/* -+ * Constant strings for usage() functions. For more info see -+ * Documentation/{howto-usage-function.txt,boilerplate.c} -+ */ -+#define USAGE_HEADER ("\nUsage:\n") -+#define USAGE_OPTIONS ("\nOptions:\n") -+#define USAGE_FUNCTIONS ("\nFunctions:\n") -+#define USAGE_COMMANDS ("\nCommands:\n") -+#define USAGE_COLUMNS ("\nAvailable output columns:\n") -+#define USAGE_SEPARATOR "\n" -+ -+#define USAGE_OPTSTR_HELP ("display this help") -+#define USAGE_OPTSTR_VERSION ("display version") -+ -+#define USAGE_HELP_OPTIONS(marg_dsc) \ -+ "%-" #marg_dsc "s%s\n" \ -+ "%-" #marg_dsc "s%s\n" \ -+ , " -h, --help", USAGE_OPTSTR_HELP \ -+ , " -V, --version", USAGE_OPTSTR_VERSION -+ -+#define USAGE_MAN_TAIL(_man) ("\nFor more details see %s.\n"), _man -+ -+#define UTIL_LINUX_VERSION ("%s from %s\n"), program_invocation_short_name, PACKAGE_STRING -+ -+#define print_version(eval) __extension__ ({ \ -+ printf(UTIL_LINUX_VERSION); \ -+ exit(eval); \ -+}) -+ -+/* -+ * scanf modifiers for "strings allocation" -+ */ -+#ifdef HAVE_SCANF_MS_MODIFIER -+#define UL_SCNsA "%ms" -+#elif defined(HAVE_SCANF_AS_MODIFIER) -+#define UL_SCNsA "%as" -+#endif -+ -+/* -+ * seek stuff -+ */ -+#ifndef SEEK_DATA -+# define SEEK_DATA 3 -+#endif -+#ifndef SEEK_HOLE -+# define SEEK_HOLE 4 -+#endif -+ -+ -+/* -+ * Macros to convert #define'itions to strings, for example -+ * #define XYXXY 42 -+ * printf ("%s=%s\n", stringify(XYXXY), stringify_value(XYXXY)); -+ */ -+#define stringify_value(s) stringify(s) -+#define stringify(s) #s -+ -+/* -+ * UL_ASAN_BLACKLIST is a macro to tell AddressSanitizer (a compile-time -+ * instrumentation shipped with Clang and GCC) to not instrument the -+ * annotated function. Furthermore, it will prevent the compiler from -+ * inlining the function because inlining currently breaks the blacklisting -+ * mechanism of AddressSanitizer. -+ */ -+#if __has_feature(address_sanitizer) && __has_attribute(no_sanitize_memory) && __has_attribute(no_sanitize_address) -+# define UL_ASAN_BLACKLIST __attribute__((noinline)) __attribute__((no_sanitize_memory)) __attribute__((no_sanitize_address)) -+#else -+# define UL_ASAN_BLACKLIST /* nothing */ -+#endif -+ -+/* -+ * Note that sysconf(_SC_GETPW_R_SIZE_MAX) returns *initial* suggested size for -+ * pwd buffer and in some cases it is not large enough. See POSIX and -+ * getpwnam_r man page for more details. -+ */ -+#define UL_GETPW_BUFSIZ (16 * 1024) -+ -+/* -+ * Darwin or other BSDs may only have MAP_ANON. To get it on Darwin we must -+ * define _DARWIN_C_SOURCE before including sys/mman.h. We do this in config.h. -+ */ -+#if !defined MAP_ANONYMOUS && defined MAP_ANON -+# define MAP_ANONYMOUS (MAP_ANON) -+#endif -+ -+#endif /* UTIL_LINUX_C_H */ -diff --git a/locale/programs/cross-localedef-hardlink.c b/locale/programs/cross-localedef-hardlink.c -new file mode 100644 -index 0000000000..63615896b0 ---- /dev/null -+++ b/locale/programs/cross-localedef-hardlink.c -@@ -0,0 +1,528 @@ -+/* -+ * hardlink - consolidate duplicate files via hardlinks -+ * -+ * Copyright (C) 2018 Red Hat, Inc. All rights reserved. -+ * Written by Jakub Jelinek -+ * -+ * Copyright (C) 2019 Karel Zak -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it would be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License along -+ * with this program; if not, write to the Free Software Foundation, Inc., -+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -+ */ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#ifdef HAVE_PCRE -+# define PCRE2_CODE_UNIT_WIDTH 8 -+# include -+#endif -+ -+#include "c.h" -+#include "xalloc.h" -+#include "nls.h" -+#include "closestream.h" -+ -+#define NHASH (1<<17) /* Must be a power of 2! */ -+#define NBUF 64 -+ -+struct hardlink_file; -+ -+struct hardlink_hash { -+ struct hardlink_hash *next; -+ struct hardlink_file *chain; -+ off_t size; -+ time_t mtime; -+}; -+ -+struct hardlink_dir { -+ struct hardlink_dir *next; -+ char name[]; -+}; -+ -+struct hardlink_file { -+ struct hardlink_file *next; -+ ino_t ino; -+ dev_t dev; -+ unsigned int cksum; -+ char name[]; -+}; -+ -+struct hardlink_dynstr { -+ char *buf; -+ size_t alloc; -+}; -+ -+struct hardlink_ctl { -+ struct hardlink_dir *dirs; -+ struct hardlink_hash *hps[NHASH]; -+ char iobuf1[BUFSIZ]; -+ char iobuf2[BUFSIZ]; -+ /* summary counters */ -+ unsigned long long ndirs; -+ unsigned long long nobjects; -+ unsigned long long nregfiles; -+ unsigned long long ncomp; -+ unsigned long long nlinks; -+ unsigned long long nsaved; -+ /* current device */ -+ dev_t dev; -+ /* flags */ -+ unsigned int verbose; -+ unsigned int -+ no_link:1, -+ content_only:1, -+ force:1; -+}; -+/* ctl is in global scope due use in atexit() */ -+struct hardlink_ctl global_ctl; -+ -+__attribute__ ((always_inline)) -+static inline unsigned int hash(off_t size, time_t mtime) -+{ -+ return (size ^ mtime) & (NHASH - 1); -+} -+ -+__attribute__ ((always_inline)) -+static inline int stcmp(struct stat *st1, struct stat *st2, int content_scope) -+{ -+ if (content_scope) -+ return st1->st_size != st2->st_size; -+ -+ return st1->st_mode != st2->st_mode -+ || st1->st_uid != st2->st_uid -+ || st1->st_gid != st2->st_gid -+ || st1->st_size != st2->st_size -+ || st1->st_mtime != st2->st_mtime; -+} -+ -+static void print_summary(void) -+{ -+ struct hardlink_ctl const *const ctl = &global_ctl; -+ -+ if (!ctl->verbose) -+ return; -+ -+ if (ctl->verbose > 1 && ctl->nlinks) -+ fputc('\n', stdout); -+ -+ printf(_("Directories: %9lld\n"), ctl->ndirs); -+ printf(_("Objects: %9lld\n"), ctl->nobjects); -+ printf(_("Regular files: %9lld\n"), ctl->nregfiles); -+ printf(_("Comparisons: %9lld\n"), ctl->ncomp); -+ printf( "%s%9lld\n", (ctl->no_link ? -+ _("Would link: ") : -+ _("Linked: ")), ctl->nlinks); -+ printf( "%s %9lld\n", (ctl->no_link ? -+ _("Would save: ") : -+ _("Saved: ")), ctl->nsaved); -+} -+ -+static void __attribute__((__noreturn__)) usage(void) -+{ -+ fputs(USAGE_HEADER, stdout); -+ printf(_(" %s [options] directory...\n"), program_invocation_short_name); -+ -+ fputs(USAGE_SEPARATOR, stdout); -+ puts(_("Consolidate duplicate files using hardlinks.")); -+ -+ fputs(USAGE_OPTIONS, stdout); -+ puts(_(" -c, --content compare only contents, ignore permission, etc.")); -+ puts(_(" -n, --dry-run don't actually link anything")); -+ puts(_(" -v, --verbose print summary after hardlinking")); -+ puts(_(" -vv print every hardlinked file and summary")); -+ puts(_(" -f, --force force hardlinking across filesystems")); -+ puts(_(" -x, --exclude exclude files matching pattern")); -+ -+ fputs(USAGE_SEPARATOR, stdout); -+ printf(USAGE_HELP_OPTIONS(16)); /* char offset to align option descriptions */ -+ printf(USAGE_MAN_TAIL("hardlink(1)")); -+ exit(EXIT_SUCCESS); -+} -+ -+__attribute__ ((always_inline)) -+static inline size_t add2(size_t a, size_t b) -+{ -+ size_t sum = a + b; -+ -+ if (sum < a) -+ errx(EXIT_FAILURE, _("integer overflow")); -+ return sum; -+} -+ -+__attribute__ ((always_inline)) -+static inline size_t add3(size_t a, size_t b, size_t c) -+{ -+ return add2(add2(a, b), c); -+} -+ -+static void growstr(struct hardlink_dynstr *str, size_t newlen) -+{ -+ if (newlen < str->alloc) -+ return; -+ str->buf = xrealloc(str->buf, str->alloc = add2(newlen, 1)); -+} -+ -+static void process_path(struct hardlink_ctl *ctl, const char *name) -+{ -+ struct stat st, st2, st3; -+ const size_t namelen = strlen(name); -+ -+ ctl->nobjects++; -+ if (lstat(name, &st)) -+ return; -+ -+ if (st.st_dev != ctl->dev && !ctl->force) { -+ if (ctl->dev) -+ errx(EXIT_FAILURE, -+ _("%s is on different filesystem than the rest " -+ "(use -f option to override)."), name); -+ ctl->dev = st.st_dev; -+ } -+ if (S_ISDIR(st.st_mode)) { -+ struct hardlink_dir *dp = xmalloc(add3(sizeof(*dp), namelen, 1)); -+ memcpy(dp->name, name, namelen + 1); -+ dp->next = ctl->dirs; -+ ctl->dirs = dp; -+ -+ } else if (S_ISREG(st.st_mode)) { -+ int fd, i; -+ struct hardlink_file *fp, *fp2; -+ struct hardlink_hash *hp; -+ const char *n1, *n2; -+ unsigned int buf[NBUF]; -+ int cksumsize = sizeof(buf); -+ unsigned int cksum; -+ time_t mtime = ctl->content_only ? 0 : st.st_mtime; -+ unsigned int hsh = hash(st.st_size, mtime); -+ off_t fsize; -+ -+ ctl->nregfiles++; -+ if (ctl->verbose > 1) -+ printf("%s\n", name); -+ -+ fd = open(name, O_RDONLY); -+ if (fd < 0) -+ return; -+ -+ if ((size_t)st.st_size < sizeof(buf)) { -+ cksumsize = st.st_size; -+ memset(((char *)buf) + cksumsize, 0, -+ (sizeof(buf) - cksumsize) % sizeof(buf[0])); -+ } -+ if (read(fd, buf, cksumsize) != cksumsize) { -+ close(fd); -+ return; -+ } -+ cksumsize = (cksumsize + sizeof(buf[0]) - 1) / sizeof(buf[0]); -+ for (i = 0, cksum = 0; i < cksumsize; i++) { -+ if (cksum + buf[i] < cksum) -+ cksum += buf[i] + 1; -+ else -+ cksum += buf[i]; -+ } -+ for (hp = ctl->hps[hsh]; hp; hp = hp->next) { -+ if (hp->size == st.st_size && hp->mtime == mtime) -+ break; -+ } -+ if (!hp) { -+ hp = xmalloc(sizeof(*hp)); -+ hp->size = st.st_size; -+ hp->mtime = mtime; -+ hp->chain = NULL; -+ hp->next = ctl->hps[hsh]; -+ ctl->hps[hsh] = hp; -+ } -+ for (fp = hp->chain; fp; fp = fp->next) { -+ if (fp->cksum == cksum) -+ break; -+ } -+ for (fp2 = fp; fp2 && fp2->cksum == cksum; fp2 = fp2->next) { -+ if (fp2->ino == st.st_ino && fp2->dev == st.st_dev) { -+ close(fd); -+ return; -+ } -+ } -+ for (fp2 = fp; fp2 && fp2->cksum == cksum; fp2 = fp2->next) { -+ -+ if (!lstat(fp2->name, &st2) && S_ISREG(st2.st_mode) && -+ !stcmp(&st, &st2, ctl->content_only) && -+ st2.st_ino != st.st_ino && -+ st2.st_dev == st.st_dev) { -+ -+ int fd2 = open(fp2->name, O_RDONLY); -+ if (fd2 < 0) -+ continue; -+ -+ if (fstat(fd2, &st2) || !S_ISREG(st2.st_mode) -+ || st2.st_size == 0) { -+ close(fd2); -+ continue; -+ } -+ ctl->ncomp++; -+ lseek(fd, 0, SEEK_SET); -+ -+ for (fsize = st.st_size; fsize > 0; -+ fsize -= (off_t)sizeof(ctl->iobuf1)) { -+ ssize_t xsz; -+ ssize_t rsize = fsize > (ssize_t) sizeof(ctl->iobuf1) ? -+ (ssize_t) sizeof(ctl->iobuf1) : fsize; -+ -+ if ((xsz = read(fd, ctl->iobuf1, rsize)) != rsize) -+ warn(_("cannot read %s"), name); -+ else if ((xsz = read(fd2, ctl->iobuf2, rsize)) != rsize) -+ warn(_("cannot read %s"), fp2->name); -+ -+ if (xsz != rsize) { -+ close(fd); -+ close(fd2); -+ return; -+ } -+ if (memcmp(ctl->iobuf1, ctl->iobuf2, rsize)) -+ break; -+ } -+ close(fd2); -+ if (fsize > 0) -+ continue; -+ if (lstat(name, &st3)) { -+ warn(_("cannot stat %s"), name); -+ close(fd); -+ return; -+ } -+ st3.st_atime = st.st_atime; -+ if (stcmp(&st, &st3, 0)) { -+ warnx(_("file %s changed underneath us"), name); -+ close(fd); -+ return; -+ } -+ n1 = fp2->name; -+ n2 = name; -+ -+ if (!ctl->no_link) { -+ const char *suffix = -+ ".$$$___cleanit___$$$"; -+ const size_t suffixlen = strlen(suffix); -+ size_t n2len = strlen(n2); -+ struct hardlink_dynstr nam2 = { NULL, 0 }; -+ -+ growstr(&nam2, add2(n2len, suffixlen)); -+ memcpy(nam2.buf, n2, n2len); -+ memcpy(&nam2.buf[n2len], suffix, -+ suffixlen + 1); -+ /* First create a temporary link to n1 under a new name */ -+ if (link(n1, nam2.buf)) { -+ warn(_("failed to hardlink %s to %s (create temporary link as %s failed)"), -+ n1, n2, nam2.buf); -+ free(nam2.buf); -+ continue; -+ } -+ /* Then rename into place over the existing n2 */ -+ if (rename(nam2.buf, n2)) { -+ warn(_("failed to hardlink %s to %s (rename temporary link to %s failed)"), -+ n1, n2, n2); -+ /* Something went wrong, try to remove the now redundant temporary link */ -+ if (unlink(nam2.buf)) -+ warn(_("failed to remove temporary link %s"), nam2.buf); -+ free(nam2.buf); -+ continue; -+ } -+ free(nam2.buf); -+ } -+ ctl->nlinks++; -+ if (st3.st_nlink > 1) { -+ /* We actually did not save anything this time, since the link second argument -+ had some other links as well. */ -+ if (ctl->verbose > 1) -+ printf(_(" %s %s to %s\n"), -+ (ctl->no_link ? _("Would link") : _("Linked")), -+ n1, n2); -+ } else { -+ ctl->nsaved += ((st.st_size + 4095) / 4096) * 4096; -+ if (ctl->verbose > 1) -+ printf(_(" %s %s to %s, %s %jd\n"), -+ (ctl->no_link ? _("Would link") : _("Linked")), -+ n1, n2, -+ (ctl->no_link ? _("would save") : _("saved")), -+ (intmax_t)st.st_size); -+ } -+ close(fd); -+ return; -+ } -+ } -+ fp2 = xmalloc(add3(sizeof(*fp2), namelen, 1)); -+ close(fd); -+ fp2->ino = st.st_ino; -+ fp2->dev = st.st_dev; -+ fp2->cksum = cksum; -+ memcpy(fp2->name, name, namelen + 1); -+ -+ if (fp) { -+ fp2->next = fp->next; -+ fp->next = fp2; -+ } else { -+ fp2->next = hp->chain; -+ hp->chain = fp2; -+ } -+ return; -+ } -+} -+ -+int main(int argc, char **argv) -+{ -+ int ch; -+ int i; -+#ifdef HAVE_PCRE -+ int errornumber; -+ PCRE2_SIZE erroroffset; -+ pcre2_code *re = NULL; -+ PCRE2_SPTR exclude_pattern = NULL; -+ pcre2_match_data *match_data = NULL; -+#endif -+ struct hardlink_dynstr nam1 = { NULL, 0 }; -+ struct hardlink_ctl *ctl = &global_ctl; -+ -+ static const struct option longopts[] = { -+ { "content", no_argument, NULL, 'c' }, -+ { "dry-run", no_argument, NULL, 'n' }, -+ { "exclude", required_argument, NULL, 'x' }, -+ { "force", no_argument, NULL, 'f' }, -+ { "help", no_argument, NULL, 'h' }, -+ { "verbose", no_argument, NULL, 'v' }, -+ { "version", no_argument, NULL, 'V' }, -+ { NULL, 0, NULL, 0 }, -+ }; -+ -+ setlocale(LC_ALL, ""); -+ bindtextdomain(PACKAGE, LOCALEDIR); -+ textdomain(PACKAGE); -+ close_stdout_atexit(); -+ -+ while ((ch = getopt_long(argc, argv, "cnvfx:Vh", longopts, NULL)) != -1) { -+ switch (ch) { -+ case 'n': -+ ctl->no_link = 1; -+ break; -+ case 'v': -+ ctl->verbose++; -+ break; -+ case 'c': -+ ctl->content_only = 1; -+ break; -+ case 'f': -+ ctl->force = 1; -+ break; -+ case 'x': -+#ifdef HAVE_PCRE -+ exclude_pattern = (PCRE2_SPTR) optarg; -+#else -+ errx(EXIT_FAILURE, -+ _("option --exclude not supported (built without pcre2)")); -+#endif -+ break; -+ case 'V': -+ print_version(EXIT_SUCCESS); -+ case 'h': -+ usage(); -+ default: -+ errtryhelp(EXIT_FAILURE); -+ } -+ } -+ -+ if (optind == argc) { -+ warnx(_("no directory specified")); -+ errtryhelp(EXIT_FAILURE); -+ } -+ -+#ifdef HAVE_PCRE -+ if (exclude_pattern) { -+ re = pcre2_compile(exclude_pattern, /* the pattern */ -+ PCRE2_ZERO_TERMINATED, /* indicates pattern is zero-terminate */ -+ 0, /* default options */ -+ &errornumber, &erroroffset, NULL); /* use default compile context */ -+ if (!re) { -+ PCRE2_UCHAR buffer[256]; -+ pcre2_get_error_message(errornumber, buffer, -+ sizeof(buffer)); -+ errx(EXIT_FAILURE, _("pattern error at offset %d: %s"), -+ (int)erroroffset, buffer); -+ } -+ match_data = pcre2_match_data_create_from_pattern(re, NULL); -+ } -+#endif -+ atexit(print_summary); -+ -+ for (i = optind; i < argc; i++) -+ process_path(ctl, argv[i]); -+ -+ while (ctl->dirs) { -+ DIR *dh; -+ struct dirent *di; -+ struct hardlink_dir *dp = ctl->dirs; -+ size_t nam1baselen = strlen(dp->name); -+ -+ ctl->dirs = dp->next; -+ growstr(&nam1, add2(nam1baselen, 1)); -+ memcpy(nam1.buf, dp->name, nam1baselen); -+ free(dp); -+ nam1.buf[nam1baselen++] = '/'; -+ nam1.buf[nam1baselen] = 0; -+ dh = opendir(nam1.buf); -+ -+ if (dh == NULL) -+ continue; -+ ctl->ndirs++; -+ -+ while ((di = readdir(dh)) != NULL) { -+ if (!di->d_name[0]) -+ continue; -+ if (di->d_name[0] == '.') { -+ if (!di->d_name[1] || !strcmp(di->d_name, "..")) -+ continue; -+ } -+#ifdef HAVE_PCRE -+ if (re && pcre2_match(re, /* compiled regex */ -+ (PCRE2_SPTR) di->d_name, strlen(di->d_name), 0, /* start at offset 0 */ -+ 0, /* default options */ -+ match_data, /* block for storing the result */ -+ NULL) /* use default match context */ -+ >=0) { -+ if (ctl->verbose) { -+ nam1.buf[nam1baselen] = 0; -+ printf(_("Skipping %s%s\n"), nam1.buf, di->d_name); -+ } -+ continue; -+ } -+#endif -+ { -+ size_t subdirlen; -+ growstr(&nam1, -+ add2(nam1baselen, subdirlen = -+ strlen(di->d_name))); -+ memcpy(&nam1.buf[nam1baselen], di->d_name, -+ add2(subdirlen, 1)); -+ } -+ process_path(ctl, nam1.buf); -+ } -+ closedir(dh); -+ } -+ -+ return 0; -+} -diff --git a/locale/programs/xalloc.h b/locale/programs/xalloc.h -new file mode 100644 -index 0000000000..0129a85e2e ---- /dev/null -+++ b/locale/programs/xalloc.h -@@ -0,0 +1,129 @@ -+/* -+ * Copyright (C) 2010 Davidlohr Bueso -+ * -+ * This file may be redistributed under the terms of the -+ * GNU Lesser General Public License. -+ * -+ * General memory allocation wrappers for malloc, realloc, calloc and strdup -+ */ -+ -+#ifndef UTIL_LINUX_XALLOC_H -+#define UTIL_LINUX_XALLOC_H -+ -+#include -+#include -+ -+#include "c.h" -+ -+#ifndef XALLOC_EXIT_CODE -+# define XALLOC_EXIT_CODE EXIT_FAILURE -+#endif -+ -+static inline void __attribute__((__noreturn__)) -+__err_oom(const char *file, unsigned int line) -+{ -+ err(XALLOC_EXIT_CODE, "%s: %u: cannot allocate memory", file, line); -+} -+ -+#define err_oom() __err_oom(__FILE__, __LINE__) -+ -+static inline __ul_alloc_size(1) __ul_returns_nonnull -+void *xmalloc(const size_t size) -+{ -+ void *ret = malloc(size); -+ -+ if (!ret && size) -+ err(XALLOC_EXIT_CODE, "cannot allocate %zu bytes", size); -+ return ret; -+} -+ -+static inline __ul_alloc_size(2) __ul_returns_nonnull -+void *xrealloc(void *ptr, const size_t size) -+{ -+ void *ret = realloc(ptr, size); -+ -+ if (!ret && size) -+ err(XALLOC_EXIT_CODE, "cannot allocate %zu bytes", size); -+ return ret; -+} -+ -+static inline __ul_calloc_size(1, 2) __ul_returns_nonnull -+void *xcalloc(const size_t nelems, const size_t size) -+{ -+ void *ret = calloc(nelems, size); -+ -+ if (!ret && size && nelems) -+ err(XALLOC_EXIT_CODE, "cannot allocate %zu bytes", size); -+ return ret; -+} -+ -+static inline char __attribute__((warn_unused_result)) __ul_returns_nonnull -+*xstrdup(const char *str) -+{ -+ char *ret; -+ -+ if (!str) -+ return NULL; -+ -+ ret = strdup(str); -+ -+ if (!ret) -+ err(XALLOC_EXIT_CODE, "cannot duplicate string"); -+ return ret; -+} -+ -+static inline char * __attribute__((warn_unused_result)) __ul_returns_nonnull -+xstrndup(const char *str, size_t size) -+{ -+ char *ret; -+ -+ if (!str) -+ return NULL; -+ -+ ret = strndup(str, size); -+ -+ if (!ret) -+ err(XALLOC_EXIT_CODE, "cannot duplicate string"); -+ return ret; -+} -+ -+ -+static inline int __attribute__ ((__format__(printf, 2, 3))) -+ xasprintf(char **strp, const char *fmt, ...) -+{ -+ int ret; -+ va_list args; -+ va_start(args, fmt); -+ ret = vasprintf(&(*strp), fmt, args); -+ va_end(args); -+ if (ret < 0) -+ err(XALLOC_EXIT_CODE, "cannot allocate string"); -+ return ret; -+} -+ -+static inline int __attribute__ ((__format__(printf, 2, 0))) -+xvasprintf(char **strp, const char *fmt, va_list ap) -+{ -+ int ret = vasprintf(&(*strp), fmt, ap); -+ if (ret < 0) -+ err(XALLOC_EXIT_CODE, "cannot allocate string"); -+ return ret; -+} -+ -+ -+static inline char * __attribute__((warn_unused_result)) xgethostname(void) -+{ -+ char *name; -+ size_t sz = get_hostname_max() + 1; -+ -+ name = xmalloc(sizeof(char) * sz); -+ -+ if (gethostname(name, sz) != 0) { -+ free(name); -+ return NULL; -+ } -+ name[sz - 1] = '\0'; -+ return name; -+} -+ -+#endif diff --git a/meta/recipes-core/glibc/glibc/0029-inject-file-assembly-directives.patch b/meta/recipes-core/glibc/glibc/0029-inject-file-assembly-directives.patch new file mode 100644 index 0000000000..62e615786d --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0029-inject-file-assembly-directives.patch @@ -0,0 +1,301 @@ +From a9be0c7c67e67d870e2c5e0ece4f6ac76e5c0fe2 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Thu, 29 Nov 2018 17:29:35 -0800 +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 +.S assembler files during the glibc build. No STT_FILE section is added +during the assembly but when linking, ld decides to add one to aid +debugging and ensure references between the different object files its +linking remain clear. + +We can avoid this by injecting a file header into the assembler files +ahead of time, choosing a filename which does not contain build system +paths. + +This is a bit of a workaround/hack but does significantly reduce the +build system references in target binaries for the non-IA architectures +which use .S files. + +RP +2018/10/3 + +Upstream-Status: Pending + +Signed-off-by: Khem Raj +--- + csu/abi-note.S | 2 ++ + sysdeps/aarch64/crti.S | 2 ++ + sysdeps/aarch64/crtn.S | 2 ++ + sysdeps/aarch64/dl-tlsdesc.S | 2 ++ + sysdeps/aarch64/dl-trampoline.S | 2 ++ + sysdeps/aarch64/start.S | 2 ++ + sysdeps/arm/abi-note.S | 2 ++ + sysdeps/arm/crti.S | 2 ++ + sysdeps/arm/crtn.S | 2 ++ + sysdeps/arm/dl-tlsdesc.S | 2 ++ + sysdeps/arm/dl-trampoline.S | 2 ++ + sysdeps/arm/start.S | 2 ++ + sysdeps/mips/start.S | 2 ++ + sysdeps/powerpc/powerpc32/dl-start.S | 2 ++ + sysdeps/powerpc/powerpc32/start.S | 2 ++ + sysdeps/powerpc/powerpc64/start.S | 2 ++ + sysdeps/unix/sysv/linux/aarch64/__read_tp.S | 2 ++ + sysdeps/unix/sysv/linux/arm/aeabi_read_tp.S | 2 ++ + sysdeps/unix/sysv/linux/arm/libc-do-syscall.S | 2 ++ + sysdeps/unix/sysv/linux/powerpc/dl-brk.S | 2 ++ + 20 files changed, 40 insertions(+) + +diff --git a/csu/abi-note.S b/csu/abi-note.S +index 2b4b5f8824..964843016c 100644 +--- a/csu/abi-note.S ++++ b/csu/abi-note.S +@@ -56,6 +56,8 @@ offset length contents + #include + #include /* OS-specific ABI tag value */ + ++ .file "abi-note.S" ++ + /* The linker (GNU ld 2.8 and later) recognizes an allocated section whose + 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 1728eac37a..76a8ab590b 100644 +--- a/sysdeps/aarch64/crti.S ++++ b/sysdeps/aarch64/crti.S +@@ -50,6 +50,8 @@ + # define PREINIT_FUNCTION_WEAK 1 + #endif + ++ .file "crti.S" ++ + #if PREINIT_FUNCTION_WEAK + weak_extern (PREINIT_FUNCTION) + #else +diff --git a/sysdeps/aarch64/crtn.S b/sysdeps/aarch64/crtn.S +index c3e97cc449..fc2e5c2df8 100644 +--- a/sysdeps/aarch64/crtn.S ++++ b/sysdeps/aarch64/crtn.S +@@ -37,6 +37,8 @@ + /* crtn.S puts function epilogues in the .init and .fini sections + corresponding to the prologues in crti.S. */ + ++ .file "crtn.S" ++ + .section .init,"ax",%progbits + ldp x29, x30, [sp], 16 + RET +diff --git a/sysdeps/aarch64/dl-tlsdesc.S b/sysdeps/aarch64/dl-tlsdesc.S +index 557ad1d505..194a8531da 100644 +--- a/sysdeps/aarch64/dl-tlsdesc.S ++++ b/sysdeps/aarch64/dl-tlsdesc.S +@@ -22,6 +22,8 @@ + #include + #include "tlsdesc.h" + ++ .file "dl-tlsdesc.S" ++ + #define NSAVEDQREGPAIRS 16 + #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 94e965c096..ba18742f3e 100644 +--- a/sysdeps/aarch64/dl-trampoline.S ++++ b/sysdeps/aarch64/dl-trampoline.S +@@ -21,6 +21,8 @@ + + #include "dl-link.h" + ++ .file "dl-trampoline.S" ++ + #define ip0 x16 + #define ip0l PTR_REG (16) + #define ip1 x17 +diff --git a/sysdeps/aarch64/start.S b/sysdeps/aarch64/start.S +index d96cf57e2d..07a523978a 100644 +--- a/sysdeps/aarch64/start.S ++++ b/sysdeps/aarch64/start.S +@@ -18,6 +18,8 @@ + + #include + ++ .file "start.S" ++ + /* This is the canonical entry point, usually the first thing in the text + segment. + +diff --git a/sysdeps/arm/abi-note.S b/sysdeps/arm/abi-note.S +index 07bd4c4619..7213b16f27 100644 +--- a/sysdeps/arm/abi-note.S ++++ b/sysdeps/arm/abi-note.S +@@ -1,3 +1,5 @@ ++ .file "abi-note.S" ++ + /* Tag_ABI_align8_preserved: This code preserves 8-byte + alignment in any callee. */ + .eabi_attribute 25, 1 +diff --git a/sysdeps/arm/crti.S b/sysdeps/arm/crti.S +index 8169783267..f56e0c85a6 100644 +--- a/sysdeps/arm/crti.S ++++ b/sysdeps/arm/crti.S +@@ -57,6 +57,8 @@ + .hidden PREINIT_FUNCTION + #endif + ++ .file "crti.S" ++ + #if PREINIT_FUNCTION_WEAK + .p2align 2 + .type call_weak_fn, %function +diff --git a/sysdeps/arm/crtn.S b/sysdeps/arm/crtn.S +index d60f9f05de..1e10ec439f 100644 +--- a/sysdeps/arm/crtn.S ++++ b/sysdeps/arm/crtn.S +@@ -37,6 +37,8 @@ + #define NO_THUMB + #include + ++ .file "crtn.S" ++ + /* crtn.S puts function epilogues in the .init and .fini sections + corresponding to the prologues in crti.S. */ + +diff --git a/sysdeps/arm/dl-tlsdesc.S b/sysdeps/arm/dl-tlsdesc.S +index 8415e47607..29c2cb8128 100644 +--- a/sysdeps/arm/dl-tlsdesc.S ++++ b/sysdeps/arm/dl-tlsdesc.S +@@ -21,6 +21,8 @@ + #include + #include "tlsdesc.h" + ++ .file "dl-tlsdesc.S" ++ + .text + @ 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 a20baf555e..2dd3bef04e 100644 +--- a/sysdeps/arm/dl-trampoline.S ++++ b/sysdeps/arm/dl-trampoline.S +@@ -21,6 +21,8 @@ + #include + #include + ++ .file "dl-trampoline.S" ++ + .text + .globl _dl_runtime_resolve + .type _dl_runtime_resolve, #function +diff --git a/sysdeps/arm/start.S b/sysdeps/arm/start.S +index 2ff56179d2..c118046ec6 100644 +--- a/sysdeps/arm/start.S ++++ b/sysdeps/arm/start.S +@@ -57,6 +57,8 @@ + NULL + */ + ++ .file "start.S" ++ + /* Tag_ABI_align8_preserved: This code preserves 8-byte + alignment in any callee. */ + .eabi_attribute 25, 1 +diff --git a/sysdeps/mips/start.S b/sysdeps/mips/start.S +index fabc8080df..83c6b91d7d 100644 +--- a/sysdeps/mips/start.S ++++ b/sysdeps/mips/start.S +@@ -38,6 +38,8 @@ + #include + #include + ++ .file "start.S" ++ + #ifndef ENTRY_POINT + #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 c15242d3bc..6ca27715a4 100644 +--- a/sysdeps/powerpc/powerpc32/dl-start.S ++++ b/sysdeps/powerpc/powerpc32/dl-start.S +@@ -18,6 +18,8 @@ + + #include + ++ .file "dl-start.S" ++ + /* Initial entry point code for the dynamic linker. + 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 b7b9a133a2..8df714f81a 100644 +--- a/sysdeps/powerpc/powerpc32/start.S ++++ b/sysdeps/powerpc/powerpc32/start.S +@@ -35,6 +35,8 @@ + + #include + ++ .file "start.S" ++ + /* We do not want .eh_frame info for crt1.o since crt1.o is linked + 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 94bf771e83..cffb99500a 100644 +--- a/sysdeps/powerpc/powerpc64/start.S ++++ b/sysdeps/powerpc/powerpc64/start.S +@@ -35,6 +35,8 @@ + + #include + ++ .file "start.S" ++ + /* We do not want .eh_frame info for crt1.o since crt1.o is linked + 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 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 @@ + + #include + ++ .file "__read_tp.S" ++ + .hidden __read_tp + 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 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 @@ + a normal function call) in a high page of memory; tail call to the + helper. */ + ++ .file "aeabi_read_tp.S" ++ + .hidden __aeabi_read_tp + 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 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 @@ + ARM unwind tables for register to register moves, the actual opcodes + are not defined. */ + ++ .file "libc-do-syscall.S" ++ + #if defined(__thumb__) + .thumb + .syntax unified +diff --git a/sysdeps/unix/sysv/linux/powerpc/dl-brk.S b/sysdeps/unix/sysv/linux/powerpc/dl-brk.S +index eeb96544e3..da182b28f8 100644 +--- a/sysdeps/unix/sysv/linux/powerpc/dl-brk.S ++++ b/sysdeps/unix/sysv/linux/powerpc/dl-brk.S +@@ -1 +1,3 @@ ++ .file "dl-brk.S" ++ + #include diff --git a/meta/recipes-core/glibc/glibc/0030-hardlink-fix-ups-to-make-it-compile.patch b/meta/recipes-core/glibc/glibc/0030-hardlink-fix-ups-to-make-it-compile.patch deleted file mode 100644 index 1a5f6b6825..0000000000 --- a/meta/recipes-core/glibc/glibc/0030-hardlink-fix-ups-to-make-it-compile.patch +++ /dev/null @@ -1,238 +0,0 @@ -From d08f436635cb9d627ebae4512105708d28fc36fe Mon Sep 17 00:00:00 2001 -From: Jason Wessel -Date: Sat, 7 Dec 2019 10:01:37 -0800 -Subject: [PATCH] hardlink: fix-ups to make it compile - -Upstream-Status: Pending -Signed-off-by: Jason Wessel -Signed-off-by: Khem Raj ---- - locale/programs/c.h | 2 +- - locale/programs/cross-localedef-hardlink.c | 79 +++++++++++----------- - 2 files changed, 39 insertions(+), 42 deletions(-) - -diff --git a/locale/programs/c.h b/locale/programs/c.h -index d0a402e90e..1804d31c73 100644 ---- a/locale/programs/c.h -+++ b/locale/programs/c.h -@@ -240,7 +240,7 @@ errmsg(char doexit, int excode, char adderr, const char *fmt, ...) - /* Don't use inline function to avoid '#include "nls.h"' in c.h - */ - #define errtryhelp(eval) __extension__ ({ \ -- fprintf(stderr, _("Try '%s --help' for more information.\n"), \ -+ fprintf(stderr, ("Try '%s --help' for more information.\n"), \ - program_invocation_short_name); \ - exit(eval); \ - }) -diff --git a/locale/programs/cross-localedef-hardlink.c b/locale/programs/cross-localedef-hardlink.c -index 63615896b0..726e6dd948 100644 ---- a/locale/programs/cross-localedef-hardlink.c -+++ b/locale/programs/cross-localedef-hardlink.c -@@ -20,6 +20,8 @@ - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -+ -+#undef HAVE_PCRE - #include - #include - #include -@@ -38,8 +40,8 @@ - - #include "c.h" - #include "xalloc.h" --#include "nls.h" --#include "closestream.h" -+//#include "nls.h" -+//#include "closestream.h" - - #define NHASH (1<<17) /* Must be a power of 2! */ - #define NBUF 64 -@@ -124,33 +126,33 @@ static void print_summary(void) - if (ctl->verbose > 1 && ctl->nlinks) - fputc('\n', stdout); - -- printf(_("Directories: %9lld\n"), ctl->ndirs); -- printf(_("Objects: %9lld\n"), ctl->nobjects); -- printf(_("Regular files: %9lld\n"), ctl->nregfiles); -- printf(_("Comparisons: %9lld\n"), ctl->ncomp); -+ printf(("Directories: %9lld\n"), ctl->ndirs); -+ printf(("Objects: %9lld\n"), ctl->nobjects); -+ printf(("Regular files: %9lld\n"), ctl->nregfiles); -+ printf(("Comparisons: %9lld\n"), ctl->ncomp); - printf( "%s%9lld\n", (ctl->no_link ? -- _("Would link: ") : -- _("Linked: ")), ctl->nlinks); -+ ("Would link: ") : -+ ("Linked: ")), ctl->nlinks); - printf( "%s %9lld\n", (ctl->no_link ? -- _("Would save: ") : -- _("Saved: ")), ctl->nsaved); -+ ("Would save: ") : -+ ("Saved: ")), ctl->nsaved); - } - - static void __attribute__((__noreturn__)) usage(void) - { - fputs(USAGE_HEADER, stdout); -- printf(_(" %s [options] directory...\n"), program_invocation_short_name); -+ printf((" %s [options] directory...\n"), program_invocation_short_name); - - fputs(USAGE_SEPARATOR, stdout); -- puts(_("Consolidate duplicate files using hardlinks.")); -+ puts(("Consolidate duplicate files using hardlinks.")); - - fputs(USAGE_OPTIONS, stdout); -- puts(_(" -c, --content compare only contents, ignore permission, etc.")); -- puts(_(" -n, --dry-run don't actually link anything")); -- puts(_(" -v, --verbose print summary after hardlinking")); -- puts(_(" -vv print every hardlinked file and summary")); -- puts(_(" -f, --force force hardlinking across filesystems")); -- puts(_(" -x, --exclude exclude files matching pattern")); -+ puts((" -c, --content compare only contents, ignore permission, etc.")); -+ puts((" -n, --dry-run don't actually link anything")); -+ puts((" -v, --verbose print summary after hardlinking")); -+ puts((" -vv print every hardlinked file and summary")); -+ puts((" -f, --force force hardlinking across filesystems")); -+ puts((" -x, --exclude exclude files matching pattern")); - - fputs(USAGE_SEPARATOR, stdout); - printf(USAGE_HELP_OPTIONS(16)); /* char offset to align option descriptions */ -@@ -164,7 +166,7 @@ static inline size_t add2(size_t a, size_t b) - size_t sum = a + b; - - if (sum < a) -- errx(EXIT_FAILURE, _("integer overflow")); -+ errx(EXIT_FAILURE, ("integer overflow")); - return sum; - } - -@@ -193,7 +195,7 @@ static void process_path(struct hardlink_ctl *ctl, const char *name) - if (st.st_dev != ctl->dev && !ctl->force) { - if (ctl->dev) - errx(EXIT_FAILURE, -- _("%s is on different filesystem than the rest " -+ ("%s is on different filesystem than the rest " - "(use -f option to override)."), name); - ctl->dev = st.st_dev; - } -@@ -287,9 +289,9 @@ static void process_path(struct hardlink_ctl *ctl, const char *name) - (ssize_t) sizeof(ctl->iobuf1) : fsize; - - if ((xsz = read(fd, ctl->iobuf1, rsize)) != rsize) -- warn(_("cannot read %s"), name); -+ warn(("cannot read %s"), name); - else if ((xsz = read(fd2, ctl->iobuf2, rsize)) != rsize) -- warn(_("cannot read %s"), fp2->name); -+ warn(("cannot read %s"), fp2->name); - - if (xsz != rsize) { - close(fd); -@@ -303,13 +305,13 @@ static void process_path(struct hardlink_ctl *ctl, const char *name) - if (fsize > 0) - continue; - if (lstat(name, &st3)) { -- warn(_("cannot stat %s"), name); -+ warn(("cannot stat %s"), name); - close(fd); - return; - } - st3.st_atime = st.st_atime; - if (stcmp(&st, &st3, 0)) { -- warnx(_("file %s changed underneath us"), name); -+ warnx(("file %s changed underneath us"), name); - close(fd); - return; - } -@@ -329,18 +331,18 @@ static void process_path(struct hardlink_ctl *ctl, const char *name) - suffixlen + 1); - /* First create a temporary link to n1 under a new name */ - if (link(n1, nam2.buf)) { -- warn(_("failed to hardlink %s to %s (create temporary link as %s failed)"), -+ warn(("failed to hardlink %s to %s (create temporary link as %s failed)"), - n1, n2, nam2.buf); - free(nam2.buf); - continue; - } - /* Then rename into place over the existing n2 */ - if (rename(nam2.buf, n2)) { -- warn(_("failed to hardlink %s to %s (rename temporary link to %s failed)"), -+ warn(("failed to hardlink %s to %s (rename temporary link to %s failed)"), - n1, n2, n2); - /* Something went wrong, try to remove the now redundant temporary link */ - if (unlink(nam2.buf)) -- warn(_("failed to remove temporary link %s"), nam2.buf); -+ warn(("failed to remove temporary link %s"), nam2.buf); - free(nam2.buf); - continue; - } -@@ -351,16 +353,16 @@ static void process_path(struct hardlink_ctl *ctl, const char *name) - /* We actually did not save anything this time, since the link second argument - had some other links as well. */ - if (ctl->verbose > 1) -- printf(_(" %s %s to %s\n"), -- (ctl->no_link ? _("Would link") : _("Linked")), -+ printf((" %s %s to %s\n"), -+ (ctl->no_link ? ("Would link") : ("Linked")), - n1, n2); - } else { - ctl->nsaved += ((st.st_size + 4095) / 4096) * 4096; - if (ctl->verbose > 1) -- printf(_(" %s %s to %s, %s %jd\n"), -- (ctl->no_link ? _("Would link") : _("Linked")), -+ printf((" %s %s to %s, %s %jd\n"), -+ (ctl->no_link ? ("Would link") : ("Linked")), - n1, n2, -- (ctl->no_link ? _("would save") : _("saved")), -+ (ctl->no_link ? ("would save") : ("saved")), - (intmax_t)st.st_size); - } - close(fd); -@@ -410,11 +412,6 @@ int main(int argc, char **argv) - { NULL, 0, NULL, 0 }, - }; - -- setlocale(LC_ALL, ""); -- bindtextdomain(PACKAGE, LOCALEDIR); -- textdomain(PACKAGE); -- close_stdout_atexit(); -- - while ((ch = getopt_long(argc, argv, "cnvfx:Vh", longopts, NULL)) != -1) { - switch (ch) { - case 'n': -@@ -434,7 +431,7 @@ int main(int argc, char **argv) - exclude_pattern = (PCRE2_SPTR) optarg; - #else - errx(EXIT_FAILURE, -- _("option --exclude not supported (built without pcre2)")); -+ ("option --exclude not supported (built without pcre2)")); - #endif - break; - case 'V': -@@ -447,7 +444,7 @@ int main(int argc, char **argv) - } - - if (optind == argc) { -- warnx(_("no directory specified")); -+ warnx(("no directory specified")); - errtryhelp(EXIT_FAILURE); - } - -@@ -461,7 +458,7 @@ int main(int argc, char **argv) - PCRE2_UCHAR buffer[256]; - pcre2_get_error_message(errornumber, buffer, - sizeof(buffer)); -- errx(EXIT_FAILURE, _("pattern error at offset %d: %s"), -+ errx(EXIT_FAILURE, ("pattern error at offset %d: %s"), - (int)erroroffset, buffer); - } - match_data = pcre2_match_data_create_from_pattern(re, NULL); -@@ -506,7 +503,7 @@ int main(int argc, char **argv) - >=0) { - if (ctl->verbose) { - nam1.buf[nam1baselen] = 0; -- printf(_("Skipping %s%s\n"), nam1.buf, di->d_name); -+ printf(("Skipping %s%s\n"), nam1.buf, di->d_name); - } - continue; - } diff --git a/meta/recipes-core/glibc/glibc/0030-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 new file mode 100644 index 0000000000..195b1b0081 --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0030-locale-prevent-maybe-uninitialized-errors-with-Os-BZ.patch @@ -0,0 +1,53 @@ +From eaa1e89df6d760c3719e7060662c60b41ab6e87b Mon Sep 17 00:00:00 2001 +From: Martin Jansa +Date: Mon, 17 Dec 2018 21:36:18 +0000 +Subject: [PATCH] locale: prevent maybe-uninitialized errors with -Os [BZ + #19444] + +Fixes following error when building for aarch64 with -Os: +| In file included from strcoll_l.c:43: +| strcoll_l.c: In function '__strcoll_l': +| ../locale/weight.h:31:26: error: 'seq2.back_us' may be used uninitialized in this function [-Werror=maybe-uninitialized] +| int_fast32_t i = table[*(*cpp)++]; +| ^~~~~~~~~ +| strcoll_l.c:304:18: note: 'seq2.back_us' was declared here +| coll_seq seq1, seq2; +| ^~~~ +| In file included from strcoll_l.c:43: +| ../locale/weight.h:31:26: error: 'seq1.back_us' may be used uninitialized in this function [-Werror=maybe-uninitialized] +| int_fast32_t i = table[*(*cpp)++]; +| ^~~~~~~~~ +| strcoll_l.c:304:12: note: 'seq1.back_us' was declared here +| coll_seq seq1, seq2; +| ^~~~ + + Partial fix for [BZ #19444] + * locale/weight.h: Fix build with -Os. + +Upstream-Status: Submitted [https://patchwork.ozlabs.org/patch/1014766] + +Signed-off-by: Martin Jansa +Signed-off-by: Khem Raj +--- + locale/weight.h | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/locale/weight.h b/locale/weight.h +index e071253f85..2889c395f1 100644 +--- a/locale/weight.h ++++ b/locale/weight.h +@@ -28,7 +28,14 @@ findidx (const int32_t *table, + const unsigned char *extra, + const unsigned char **cpp, size_t len) + { ++ /* With GCC 8 when compiling with -Os the compiler warns that ++ seq1.back_us and seq2.back_us might be used uninitialized. ++ This uninitialized use is impossible for the same reason ++ as described in comments in locale/weightwc.h. */ ++ DIAG_PUSH_NEEDS_COMMENT; ++ DIAG_IGNORE_Os_NEEDS_COMMENT (8, "-Wmaybe-uninitialized"); + int_fast32_t i = table[*(*cpp)++]; ++ DIAG_POP_NEEDS_COMMENT; + const unsigned char *cp; + const unsigned char *usrc; + diff --git a/meta/recipes-core/glibc/glibc/0031-Add-hardlink-resolver-to-build.patch b/meta/recipes-core/glibc/glibc/0031-Add-hardlink-resolver-to-build.patch deleted file mode 100644 index e87a3bfb6f..0000000000 --- a/meta/recipes-core/glibc/glibc/0031-Add-hardlink-resolver-to-build.patch +++ /dev/null @@ -1,55 +0,0 @@ -From 1ef58f566e6ed575f7caee35308025e2b0f4101c Mon Sep 17 00:00:00 2001 -From: Jason Wessel -Date: Sat, 7 Dec 2019 09:56:23 -0800 -Subject: [PATCH] Add hardlink resolver to build - -The sourcecode for this is imported from util-linux and is kept with -glibc sources - -Upstream-Status: Pending -Signed-off-by: Jason Wessel -Signed-off-by: Khem Raj ---- - Makefile.in | 8 +++++++- - 1 file changed, 7 insertions(+), 1 deletion(-) - -diff --git a/localedef/Makefile.in b/localedef/Makefile.in -index 77fbded..a87e5b2 100644 ---- a/localedef/Makefile.in -+++ b/localedef/Makefile.in -@@ -40,6 +40,8 @@ WARNFLAGS = -Wall -Wno-format - FULLCC = $(CC) $(CPPFLAGS) $(CFLAGS) \ - $(DEFINES) $(INCLUDES) $(WARNFLAGS) - -+CROSS_LOCALEDEF_HARDLINK_OBJS = cross-localedef-hardlink.o -+ - LOCALEDEF_OBJS = charmap.o charmap-dir.o ld-address.o ld-collate.o \ - ld-ctype.o ld-identification.o ld-measurement.o \ - ld-messages.o ld-monetary.o ld-name.o ld-numeric.o \ -@@ -54,11 +56,14 @@ LOCALEDEF_OBJS = charmap.o charmap-dir.o ld-address.o ld-collate.o \ - asprintf.o getdelim.o localedef_extra.o \ - obstack_printf.o vasprintf.o - --all: localedef$(EXEEXT) -+all: localedef$(EXEEXT) cross-localedef-hardlink$(EXEEXT) - - localedef$(EXEEXT): $(LOCALEDEF_OBJS) - $(CC) -o $@ $(LOCALEDEF_OBJS) $(LIBS) - -+cross-localedef-hardlink$(EXEEXT): $(CROSS_LOCALEDEF_HARDLINK_OBJS) -+ $(CC) -o $@ $(CROSS_LOCALEDEF_HARDLINK_OBJS) $(LIBS) -+ - clean: - rm -f locale$(EXEEXT) $(LOCALEDEF_OBJS) - -@@ -77,6 +82,7 @@ clean: - %.o: $(srcdir)/%.c - $(FULLCC) -c -o $@ $< - -+cross-localedef-hardlink.o: glibc/locale/programs/cross-localedef-hardlink.c - 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/0031-Refactor-FORTIFY-in-glibc.patch b/meta/recipes-core/glibc/glibc/0031-Refactor-FORTIFY-in-glibc.patch new file mode 100644 index 0000000000..fe10218c31 --- /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 +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 +Signed-off-by: Khem Raj +--- + 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 + #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 directly; use 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 + #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 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 directly; include 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 +@@ -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 directly; use 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 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 aead04c485..0000000000 --- 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?= -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 ---- -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.30.bb deleted file mode 100644 index 7913bc2812..0000000000 --- a/meta/recipes-core/glibc/glibc_2.30.bb +++ /dev/null @@ -1,113 +0,0 @@ -require glibc.inc -require glibc-version.inc - -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 \ -" - -SRC_URI = "${GLIBC_GIT_URI};branch=${SRCBRANCH};name=glibc \ - file://etc/ld.so.conf \ - file://generate-supported.mk \ - 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 \ - " -S = "${WORKDIR}/git" -B = "${WORKDIR}/build-${TARGET_SYS}" - -PACKAGES_DYNAMIC = "" - -# the -isystem in bitbake.conf screws up glibc do_stage -BUILD_CPPFLAGS = "-I${STAGING_INCDIR_NATIVE}" -TARGET_CPPFLAGS = "-I${STAGING_DIR_TARGET}${includedir}" - -GLIBC_BROKEN_LOCALES = "" - -GLIBCPIE ??= "" - -EXTRA_OECONF = "--enable-kernel=${OLDEST_KERNEL} \ - --disable-profile \ - --disable-debug --without-gd \ - --enable-clocale=gnu \ - --with-headers=${STAGING_INCDIR} \ - --without-selinux \ - --enable-tunables \ - --enable-bind-now \ - --enable-stack-protector=strong \ - --enable-stackguard-randomization \ - --disable-crypt \ - --with-default-link \ - --enable-nscd \ - ${@bb.utils.contains_any('SELECTED_OPTIMIZATION', '-O0 -Og', '--disable-werror', '', d)} \ - ${GLIBCPIE} \ - ${GLIBC_EXTRA_OECONF}" - -EXTRA_OECONF += "${@get_libc_fpu_setting(bb, d)}" - -do_patch_append() { - bb.build.exec_func('do_fix_readlib_c', d) -} - -do_fix_readlib_c () { - sed -i -e 's#OECORE_KNOWN_INTERPRETER_NAMES#${EGLIBC_KNOWN_INTERPRETER_NAMES}#' ${S}/elf/readlib.c -} - -do_configure () { -# override this function to avoid the autoconf/automake/aclocal/autoheader -# calls for now -# don't pass CPPFLAGS into configure, since it upsets the kernel-headers -# version check and doesn't really help with anything - (cd ${S} && gnu-configize) || die "failure in running gnu-configize" - find ${S} -name "configure" | xargs touch - CPPFLAGS="" oe_runconf -} - -do_compile () { - # -Wl,-rpath-link /lib in LDFLAGS can cause breakage if another glibc is in staging - LDFLAGS="-fuse-ld=bfd" - base_do_compile - echo "Adjust ldd script" - if [ -n "${RTLDLIST}" ] - then - prevrtld=`cat ${B}/elf/ldd | grep "^RTLDLIST=" | sed 's#^RTLDLIST="\?\([^"]*\)"\?$#\1#'` - # remove duplicate entries - newrtld=`echo $(printf '%s\n' ${prevrtld} ${RTLDLIST} | LC_ALL=C sort -u)` - echo "ldd \"${prevrtld} ${RTLDLIST}\" -> \"${newrtld}\"" - sed -i ${B}/elf/ldd -e "s#^RTLDLIST=.*\$#RTLDLIST=\"${newrtld}\"#" - fi -} - -require glibc-package.inc - -BBCLASSEXTEND = "nativesdk" diff --git a/meta/recipes-core/glibc/glibc_2.31.bb b/meta/recipes-core/glibc/glibc_2.31.bb new file mode 100644 index 0000000000..b8c570db52 --- /dev/null +++ b/meta/recipes-core/glibc/glibc_2.31.bb @@ -0,0 +1,113 @@ +require glibc.inc +require glibc-version.inc + +DEPENDS += "gperf-native bison-native make-native" + +NATIVESDKFIXES ?= "" +NATIVESDKFIXES_class-nativesdk = "\ + 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 \ + file://etc/ld.so.conf \ + file://generate-supported.mk \ + file://makedbs.sh \ + \ + ${NATIVESDKFIXES} \ + 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}" + +PACKAGES_DYNAMIC = "" + +# the -isystem in bitbake.conf screws up glibc do_stage +BUILD_CPPFLAGS = "-I${STAGING_INCDIR_NATIVE}" +TARGET_CPPFLAGS = "-I${STAGING_DIR_TARGET}${includedir}" + +GLIBC_BROKEN_LOCALES = "" + +GLIBCPIE ??= "" + +EXTRA_OECONF = "--enable-kernel=${OLDEST_KERNEL} \ + --disable-profile \ + --disable-debug --without-gd \ + --enable-clocale=gnu \ + --with-headers=${STAGING_INCDIR} \ + --without-selinux \ + --enable-tunables \ + --enable-bind-now \ + --enable-stack-protector=strong \ + --enable-stackguard-randomization \ + --disable-crypt \ + --with-default-link \ + --enable-nscd \ + ${@bb.utils.contains_any('SELECTED_OPTIMIZATION', '-O0 -Og', '--disable-werror', '', d)} \ + ${GLIBCPIE} \ + ${GLIBC_EXTRA_OECONF}" + +EXTRA_OECONF += "${@get_libc_fpu_setting(bb, d)}" + +do_patch_append() { + bb.build.exec_func('do_fix_readlib_c', d) +} + +do_fix_readlib_c () { + sed -i -e 's#OECORE_KNOWN_INTERPRETER_NAMES#${EGLIBC_KNOWN_INTERPRETER_NAMES}#' ${S}/elf/readlib.c +} + +do_configure () { +# override this function to avoid the autoconf/automake/aclocal/autoheader +# calls for now +# don't pass CPPFLAGS into configure, since it upsets the kernel-headers +# version check and doesn't really help with anything + (cd ${S} && gnu-configize) || die "failure in running gnu-configize" + find ${S} -name "configure" | xargs touch + CPPFLAGS="" oe_runconf +} + +do_compile () { + # -Wl,-rpath-link /lib in LDFLAGS can cause breakage if another glibc is in staging + LDFLAGS="-fuse-ld=bfd" + base_do_compile + echo "Adjust ldd script" + if [ -n "${RTLDLIST}" ] + then + prevrtld=`cat ${B}/elf/ldd | grep "^RTLDLIST=" | sed 's#^RTLDLIST="\?\([^"]*\)"\?$#\1#'` + # remove duplicate entries + newrtld=`echo $(printf '%s\n' ${prevrtld} ${RTLDLIST} | LC_ALL=C sort -u)` + echo "ldd \"${prevrtld} ${RTLDLIST}\" -> \"${newrtld}\"" + sed -i ${B}/elf/ldd -e "s#^RTLDLIST=.*\$#RTLDLIST=\"${newrtld}\"#" + fi +} + +require glibc-package.inc + +BBCLASSEXTEND = "nativesdk" -- cgit 1.2.3-korg