Browse Source

Merge branch 'starfive-kirkstone-dubhe-ace-wo-openocd-patch' into 'starfive-kirkstone'

starfive-kirkstone: Dubhe ACE toolchain update.

See merge request starfive-tech/meta-starfive!27
Rebecca Chang 1 year ago
parent
commit
5a9010e6ed
100 changed files with 6013 additions and 6661 deletions
  1. 3 5
      conf/machine/starfive-dubhe.conf
  2. BIN
      recipes-bsp/deploy-bootfiles/files/bootcode.bin
  3. 6 4
      recipes-bsp/opensbi/opensbi-payloads.inc
  4. 5 0
      recipes-bsp/opensbi/opensbi_1.1.bb
  5. 13 11
      recipes-core/glibc/cross-localedef-native_2.36.bb
  6. 2 2
      recipes-core/glibc/glibc-common.inc
  7. 5 11
      recipes-core/glibc/glibc-locale.inc
  8. 0 0
      recipes-core/glibc/glibc-locale_2.36.bb
  9. 0 0
      recipes-core/glibc/glibc-mtrace_2.36.bb
  10. 15 12
      recipes-core/glibc/glibc-package.inc
  11. 0 0
      recipes-core/glibc/glibc-scripts_2.36.bb
  12. 119 0
      recipes-core/glibc/glibc-tests_2.36.bb
  13. 0 0
      recipes-core/glibc/glibc-testsuite_2.36.bb
  14. 4 4
      recipes-core/glibc/glibc-version.inc
  15. 4 0
      recipes-core/glibc/glibc.inc
  16. 0 59
      recipes-core/glibc/glibc/0001-Add-array_length-support.patch
  17. 0 43
      recipes-core/glibc/glibc/0001-CVE-2021-38604.patch
  18. 528 0
      recipes-core/glibc/glibc/0001-Linux-Add-ppoll-fortify-symbol-for-64-bit-time_t-BZ-.patch
  19. 0 55
      recipes-core/glibc/glibc/0001-RISC-V-Remove-riscv-specific-sigcontext.h.patch
  20. 1 1
      recipes-core/glibc/glibc/0001-localedef-Add-hardlink-resolver-from-util-linux.patch
  21. 74 81
      recipes-core/glibc/glibc/0001-modify-and-merge-sifive-patches-to-support-V.patch
  22. 0 150
      recipes-core/glibc/glibc/0002-CVE-2021-38604.patch
  23. 0 30
      recipes-core/glibc/glibc/0002-RISC-V-Reserve-about-5K-space-in-mcontext_t-to-suppo.patch
  24. 3 3
      recipes-core/glibc/glibc/0002-add-vector-support-for-memset-memcmp-memmove-memcpy-.patch
  25. 1 1
      recipes-core/glibc/glibc/0002-localedef-fix-ups-hardlink-to-make-it-compile.patch
  26. 6 6
      recipes-core/glibc/glibc/0003-add-NT_RISCV_VECTOR-macro-definition-to-align-with-l.patch
  27. 4 4
      recipes-core/glibc/glibc/0003-nativesdk-glibc-Look-for-host-system-ld.so.cache-as-.patch
  28. 0 61
      recipes-core/glibc/glibc/0004-RISC-V-Extend-MINSIGSTKSZ-and-SIGSTKSZ-to-backup-RVV.patch
  29. 3 3
      recipes-core/glibc/glibc/0004-fix-the-bcmp-unrecognized-issue.patch
  30. 3 3
      recipes-core/glibc/glibc/0004-nativesdk-glibc-Fix-buffer-overrun-with-a-relocated-.patch
  31. 0 93
      recipes-core/glibc/glibc/0005-RISC-V-Expand-PTHREAD_STACK_MIN-to-support-RVV-envir.patch
  32. 14 14
      recipes-core/glibc/glibc/0005-nativesdk-glibc-Raise-the-size-of-arrays-containing-.patch
  33. 7 7
      recipes-core/glibc/glibc/0005-riscv-Resolve-symbols-directly-for-symbols-with-STO_.patch
  34. 3 3
      recipes-core/glibc/glibc/0006-change-memcpy_vector-LMUL-to-m8.patch
  35. 9 5
      recipes-core/glibc/glibc/0006-nativesdk-glibc-Allow-64-bit-atomics-for-x86.patch
  36. 182 0
      recipes-core/glibc/glibc/0007-add-header-files-for-vector-support.patch
  37. 11 11
      recipes-core/glibc/glibc/0007-nativesdk-glibc-Make-relocatable-install-for-locales.patch
  38. 2 2
      recipes-core/glibc/glibc/0008-nativesdk-glibc-Fall-back-to-faccessat-on-faccess2-r.patch
  39. 598 0
      recipes-core/glibc/glibc/0008-prohibit-from-generating-plt-table-when-static-linki.patch
  40. 0 27
      recipes-core/glibc/glibc/0009-Revert-RISC-V-Reserve-about-5K-space-in-mcontext_t-t.patch
  41. 0 1581
      recipes-core/glibc/glibc/0009-fsl-e500-e5500-e6500-603e-fsqrt-implementation.patch
  42. 25 0
      recipes-core/glibc/glibc/0009-resolve-__memcmpeq-aliased-to-undefined-symbol-memcm.patch
  43. 15 15
      recipes-core/glibc/glibc/0009-yes-within-the-path-sets-wrong-config-variables.patch
  44. 1 1
      recipes-core/glibc/glibc/0010-eglibc-Cross-building-and-testing-instructions.patch
  45. 1382 0
      recipes-core/glibc/glibc/0010-merge-demin-s-mem_xxx-optimization.patch
  46. 0 205
      recipes-core/glibc/glibc/0010-ppc-sqrt-Fix-undefined-reference-to-__sqrt_finite.patch
  47. 0 384
      recipes-core/glibc/glibc/0011-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch
  48. 32 0
      recipes-core/glibc/glibc/0011-add-alias-to-bcmp.patch
  49. 4 4
      recipes-core/glibc/glibc/0011-eglibc-Help-bootstrap-cross-toolchain.patch
  50. 0 58
      recipes-core/glibc/glibc/0012-Quote-from-bug-1443-which-explains-what-the-patch-do.patch
  51. 0 49
      recipes-core/glibc/glibc/0012-add-hwcap.h-header-file.patch
  52. 2 2
      recipes-core/glibc/glibc/0012-eglibc-Resolve-__fpscr_values-on-SH4.patch
  53. 30 56
      recipes-core/glibc/glibc/0012-remove-unnecessary-changes-to-support-v.patch
  54. 41 41
      recipes-core/glibc/glibc/0013-eglibc-Forward-port-cross-locale-generation-support.patch
  55. 0 33
      recipes-core/glibc/glibc/0013-eglibc-run-libm-err-tab.pl-with-specific-dirs-in-S.patch
  56. 46 0
      recipes-core/glibc/glibc/0013-fix-compiling-error-when-march-not-include-b-ext.patch
  57. 0 58
      recipes-core/glibc/glibc/0014-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch
  58. 53 0
      recipes-core/glibc/glibc/0014-fix-memcmp-bug-relate-to-use-jmp-table.patch
  59. 5 5
      recipes-core/glibc/glibc/0014-localedef-add-to-archive-uses-a-hard-coded-locale-pa.patch
  60. 4 4
      recipes-core/glibc/glibc/0015-locale-prevent-maybe-uninitialized-errors-with-Os-BZ.patch
  61. 980 0
      recipes-core/glibc/glibc/0015-memxxx-align-version-with-merge-tech-or-B-ext.patch
  62. 3 3
      recipes-core/glibc/glibc/0016-readlib-Add-OECORE_KNOWN_INTERPRETER_NAMES-to-known-.patch
  63. 675 0
      recipes-core/glibc/glibc/0016-strxxx-B-ext-opt-version.patch
  64. 28 0
      recipes-core/glibc/glibc/0017-fix-strchr-missing-index-weak-alias.patch
  65. 1 1
      recipes-core/glibc/glibc/0017-powerpc-Do-not-ask-compiler-for-finding-arch.patch
  66. 0 34
      recipes-core/glibc/glibc/0017-timezone-re-written-tzselect-as-posix-sh.patch
  67. 25 0
      recipes-core/glibc/glibc/0018-fix-memmove-align-fail-because-of-typo.patch
  68. 8 8
      recipes-core/glibc/glibc/0018-wordsize.h-Unify-the-header-between-arm-and-aarch64.patch
  69. 26 19
      recipes-core/glibc/glibc/0019-Replace-echo-with-printf-builtin-in-nscd-init-script.patch
  70. 123 0
      recipes-core/glibc/glibc/0019-fix-missing-alias-functions.patch
  71. 9 8
      recipes-core/glibc/glibc/0020-sysdeps-gnu-configure.ac-Set-libc_cv_rootsbindir-onl.patch
  72. 47 0
      recipes-core/glibc/glibc/0021-timezone-Make-shell-interpreter-overridable-in-tzsel.patch
  73. 27 0
      recipes-core/glibc/glibc/0022-tzselect.ksh-Use-bin-sh-default-shell-interpreter.patch
  74. 13 6
      recipes-core/glibc/glibc/0023-fix-create-thread-failed-in-unprivileged-process-BZ-.patch
  75. 32 0
      recipes-core/glibc/glibc/0024-Avoid-hardcoded-build-time-paths-in-the-output-binar.patch
  76. 0 53
      recipes-core/glibc/glibc/0025-elf-dl-deps.c-Make-_dl_build_local_scope-breadth-fir.patch
  77. 28 0
      recipes-core/glibc/glibc/0025-startup-Force-O2.patch
  78. 0 31
      recipes-core/glibc/glibc/0026-intl-Emit-no-lines-in-bison-generated-files.patch
  79. 490 0
      recipes-core/glibc/glibc/1f34a2328890aa192141f96449d25b77f666bf47.patch
  80. 0 184
      recipes-core/glibc/glibc/CVE-2021-43396.patch
  81. 37 0
      recipes-core/glibc/glibc/run-ptest
  82. 44 39
      recipes-core/glibc/glibc_2.36.bb
  83. 1 1
      recipes-core/glibc/ldconfig-native_2.12.1.bb
  84. 0 42
      recipes-devtools/binutils/binutils-2.37.inc
  85. 63 0
      recipes-devtools/binutils/binutils-2.39.inc
  86. 3 3
      recipes-devtools/binutils/binutils-cross-canadian.inc
  87. 0 27
      recipes-devtools/binutils/binutils-cross-canadian_2.37.bb
  88. 3 0
      recipes-devtools/binutils/binutils-cross-canadian_2.39.bb
  89. 0 24
      recipes-devtools/binutils/binutils-cross-testsuite_2.39.bb
  90. 1 0
      recipes-devtools/binutils/binutils-cross.inc
  91. 0 27
      recipes-devtools/binutils/binutils-cross_2.37.bb
  92. 3 0
      recipes-devtools/binutils/binutils-cross_2.39.bb
  93. 0 7
      recipes-devtools/binutils/binutils-crosssdk_2.39.bb
  94. 20 1
      recipes-devtools/binutils/binutils.inc
  95. 25 0
      recipes-devtools/binutils/binutils/0001-Automatic-date-update-in-version.in.patch
  96. 0 2001
      recipes-devtools/binutils/binutils/0001-CVE-2021-42574.patch
  97. 6 6
      recipes-devtools/binutils/binutils/0001-binutils-crosssdk-Generate-relocatable-SDKs.patch
  98. 0 927
      recipes-devtools/binutils/binutils/0001-merge-from-dubhe-pr-06-30-to-support-b0.94.patch
  99. 25 0
      recipes-devtools/binutils/binutils/0002-Automatic-date-update-in-version.in.patch
  100. 2 2
      recipes-devtools/binutils/binutils/0002-binutils-cross-Do-not-generate-linker-script-directo.patch

+ 3 - 5
conf/machine/starfive-dubhe.conf

@@ -42,12 +42,10 @@ RISCV_SBI_PAYLOAD = "${@oe.utils.conditional('ENABLE_NFS','1','Image-starfive-du
 
 QEMU_EXTRAOPTIONS:riscv64 = " -cpu rv64,x-b=true,x-v=true"
 
-GLIBCVERSION = "2.35"
-
-BINUVERSION = "2.37"
-
+GLIBCVERSION = "2.36"
+BINUVERSION = "2.39"
+GCCVERSION = "12.1.0"
 QEMUVERSION = "6.0.0"
-
 PREFERRED_VERSION_opensbi = "1.1"
 #
 ###IMAGE_FSTYPES += "wic.gz wic.bmap ext4 cpio"

BIN
recipes-bsp/deploy-bootfiles/files/bootcode.bin


+ 6 - 4
recipes-bsp/opensbi/opensbi-payloads.inc

@@ -17,18 +17,20 @@ def riscv_get_extra_oemake_fdt(d):
     return "FW_FDT_PATH=" + deploy_dir + "/" + sbi_fdt
 
 def riscv_get_do_compile_depends(d):
-    sbi_payload = d.getVar('RISCV_SBI_PAYLOAD')
-    sbi_fdt = d.getVar('RISCV_SBI_FDT')
+    sbi_payload = d.getVar('RISCV_SBI_PAYLOAD') or ""
+    sbi_fdt = d.getVar('RISCV_SBI_FDT') or ""
 
-    if sbi_payload is None and sbi_fdt is None:
+    if sbi_payload == "" and sbi_fdt == "":
         return ""
 
-    if sbi_fdt is not None and 'u-boot.bin' in sbi_payload:
+    if sbi_fdt != "" and 'u-boot.bin' in sbi_payload:
         return "virtual/kernel:do_deploy virtual/bootloader:do_deploy"
 
     if 'linux' in sbi_payload or 'Image' in sbi_payload:
         return "virtual/kernel:do_deploy"
     if 'u-boot.bin' in sbi_payload:
         return "virtual/bootloader:do_deploy"
+    if sbi_fdt != "":
+        return "virtual/kernel:do_deploy"
 
     return ""

+ 5 - 0
recipes-bsp/opensbi/opensbi_1.1.bb

@@ -11,6 +11,11 @@ inherit autotools-brokensep deploy
 SRCREV = "bee8253d8f04c56017860386d1b2132cf4f4b7c5"
 SRC_URI = "git://git@192.168.110.45/starfive-tech/opensbi.git;protocol=ssh;branch=starfive-v1.1-dubhe"
 
+SRC_URI:remove:nezha = " \
+    file://0001-lib-utils-fdt-Require-match-data-to-be-const.patch \
+    file://0002-lib-utils-timer-Add-a-separate-compatible-for-the-D1.patch \
+"
+
 S = "${WORKDIR}/git"
 
 EXTRA_OEMAKE += "PLATFORM=${RISCV_SBI_PLAT} I=${D} FW_PIC=n CLANG_TARGET= "

+ 13 - 11
recipes-core/glibc/cross-localedef-native_2.35.bb → recipes-core/glibc/cross-localedef-native_2.36.bb

@@ -1,7 +1,7 @@
 SUMMARY = "Cross locale generation tool for glibc"
 HOMEPAGE = "http://www.gnu.org/software/libc/libc.html"
 SECTION = "libs"
-LICENSE = "LGPL-2.1"
+LICENSE = "LGPL-2.1-only"
 
 LIC_FILES_CHKSUM = "file://LICENSES;md5=1541fd8f5e8f1579512bf05f533371ba \
       file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
@@ -25,15 +25,14 @@ SRC_URI = "${GLIBC_GIT_URI};branch=${SRCBRANCH};name=glibc \
            file://0001-localedef-Add-hardlink-resolver-from-util-linux.patch \
            file://0002-localedef-fix-ups-hardlink-to-make-it-compile.patch \
            \
-           file://0017-timezone-re-written-tzselect-as-posix-sh.patch \
-           file://0018-Remove-bash-dependency-for-nscd-init-script.patch \
-           file://0019-eglibc-Cross-building-and-testing-instructions.patch \
-           file://0020-eglibc-Help-bootstrap-cross-toolchain.patch \
-           file://0021-eglibc-Resolve-__fpscr_values-on-SH4.patch \
-           file://0022-eglibc-Forward-port-cross-locale-generation-support.patch \
-           file://0024-localedef-add-to-archive-uses-a-hard-coded-locale-pa.patch \
-           file://0001-Add-array_length-support.patch \
-"
+           file://0010-eglibc-Cross-building-and-testing-instructions.patch \
+           file://0011-eglibc-Help-bootstrap-cross-toolchain.patch \
+           file://0012-eglibc-Resolve-__fpscr_values-on-SH4.patch \
+           file://0013-eglibc-Forward-port-cross-locale-generation-support.patch \
+           file://0014-localedef-add-to-archive-uses-a-hard-coded-locale-pa.patch \
+           file://0019-Replace-echo-with-printf-builtin-in-nscd-init-script.patch \
+           file://0021-timezone-Make-shell-interpreter-overridable-in-tzsel.patch \
+           "
 # Makes for a rather long rev (22 characters), but...
 #
 SRCREV_FORMAT = "glibc_localedef"
@@ -41,9 +40,12 @@ SRCREV_FORMAT = "glibc_localedef"
 S = "${WORKDIR}/git"
 
 EXTRA_OECONF = "--with-glibc=${S}"
-CFLAGS += "-fgnu89-inline -std=gnu99 -DIS_IN\(x\)='0'"
 
+# We do not need bash to run tzselect script, the default is to use
+# bash but it can be configured by setting KSHELL Makefile variable
+EXTRA_OEMAKE += "KSHELL=/bin/sh"
 
+CFLAGS += "-fgnu89-inline -std=gnu99 -DIS_IN\(x\)='0'"
 
 do_install() {
 	install -d ${D}${bindir}

+ 2 - 2
recipes-core/glibc/glibc-common.inc

@@ -2,7 +2,7 @@ SUMMARY = "GLIBC (GNU C Library)"
 DESCRIPTION = "The GNU C Library is used as the system C library in most systems with the Linux kernel."
 HOMEPAGE = "http://www.gnu.org/software/libc/libc.html"
 SECTION = "libs"
-LICENSE = "GPLv2 & LGPLv2.1"
+LICENSE = "GPL-2.0-only & LGPL-2.1-only"
 
 LIC_FILES_CHKSUM ?= "file://LICENSES;md5=1541fd8f5e8f1579512bf05f533371ba \
       file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
@@ -22,4 +22,4 @@ ARM_INSTRUCTION_SET:armv6 = "arm"
 #
 COMPATIBLE_HOST:libc-musl:class-target = "null"
 
-PV = "2.35"
+PV = "2.36"

+ 5 - 11
recipes-core/glibc/glibc-locale.inc

@@ -5,14 +5,9 @@ SUMMARY = "Locale data from glibc"
 BPN = "glibc"
 LOCALEBASEPN = "${MLPREFIX}glibc"
 
-# glibc-collateral.inc inhibits all default deps, but do_package needs objcopy
-# ERROR: objcopy failed with exit code 127 (cmd was 'i586-webos-linux-objcopy' --only-keep-debug 'glibc-locale/2.17-r0/package/usr/lib/gconv/IBM1166.so' 'glibc-locale/2.17-r0/package/usr/lib/gconv/.debug/IBM1166.so')
-# ERROR: Function failed: split_and_strip_files
-BINUTILSDEP = "virtual/${MLPREFIX}${TARGET_PREFIX}binutils:do_populate_sysroot"
-BINUTILSDEP:class-nativesdk = "virtual/${TARGET_PREFIX}binutils-crosssdk:do_populate_sysroot"
-do_package[depends] += "${BINUTILSDEP}"
-
-DEPENDS += "virtual/libc"
+# Do not inhibit default deps, do_package requires binutils/gcc for
+# objcopy/gcc-nm and glibc-locale depends on virtual/libc directly.
+INHIBIT_DEFAULT_DEPS = ""
 
 # Binary locales are generated at build time if ENABLE_BINARY_LOCALE_GENERATION
 # is set. The idea is to avoid running localedef on the target (at first boot)
@@ -87,10 +82,9 @@ do_install() {
 	if [ ${PACKAGE_NO_GCONV} -eq 0 ]; then
 		copy_locale_files ${libdir}/gconv 0755
 		copy_locale_files ${datadir}/i18n 0644
-	else
-		# Remove the libdir if it is empty when gconv is not copied
-		find ${D}${libdir} -type d -empty -delete
 	fi
+	# Remove empty dirs in libdir when gconv or locales are not copied
+	find ${D}${libdir} -type d -empty -delete
 	copy_locale_files ${datadir}/locale 0644
 	install -m 0644 ${LOCALETREESRC}/SUPPORTED ${WORKDIR}/SUPPORTED
 }

+ 0 - 0
recipes-core/glibc/glibc-locale_2.35.bb → recipes-core/glibc/glibc-locale_2.36.bb


+ 0 - 0
recipes-core/glibc/glibc-mtrace_2.35.bb → recipes-core/glibc/glibc-mtrace_2.36.bb


+ 15 - 12
recipes-core/glibc/glibc-package.inc

@@ -1,6 +1,6 @@
 INHIBIT_SYSROOT_STRIP = "1"
 
-PACKAGES = "${PN}-dbg catchsegv sln nscd ldconfig ldd tzcode glibc-thread-db ${PN}-pic libmemusage malloc-debug libnss-db libsegfault ${PN}-pcprofile libsotruss ${PN} ${PN}-utils glibc-extra-nss ${PN}-dev ${PN}-staticdev ${PN}-doc ${PN}-src"
+PACKAGES = "${PN}-dbg sln nscd ldconfig ldd ldso tzcode glibc-thread-db ${PN}-pic libmemusage malloc-debug libnss-db ${PN}-pcprofile libsotruss ${PN} ${PN}-utils glibc-extra-nss ${PN}-dev ${PN}-staticdev ${PN}-doc ${PN}-src"
 
 # The ld.so in this glibc supports the GNU_HASH
 RPROVIDES:${PN} = "eglibc rtld(GNU_HASH)"
@@ -23,21 +23,22 @@ ARCH_DYNAMIC_LOADER:aarch64 = "ld-linux-${TARGET_ARCH}.so.1"
 libc_baselibs:append = " ${@oe.utils.conditional('ARCH_DYNAMIC_LOADER', '', '', '${root_prefix}/lib/${ARCH_DYNAMIC_LOADER}', d)}"
 INSANE_SKIP:${PN}:append:aarch64 = " libdir"
 INSANE_SKIP:${PN}-dev += "staticdev"
+INSANE_SKIP:${MLPREFIX}ldso:append = " dev-so libdir"
 
 FILES:${PN} = "${libc_baselibs} ${libexecdir}/* ${sysconfdir}/ld.so.conf"
 RRECOMMENDS:${PN} = "${@bb.utils.contains('DISTRO_FEATURES', 'ldconfig', '${MLPREFIX}ldconfig', '', d)}"
 FILES:ldconfig = "${base_sbindir}/ldconfig"
 FILES:ldd = "${bindir}/ldd"
-FILES:libsegfault = "${base_libdir}/libSegFault*"
+FILES:ldso = "${bindir}/${MLPREFIX}ld.so"
 FILES:libmemusage = "${base_libdir}/libmemusage.so"
 FILES:malloc-debug = "${base_libdir}/libc_malloc_debug.so.0"
 FILES:libnss-db = "${base_libdir}/libnss_db.so.* ${base_libdir}/libnss_db-*.so ${localstatedir}/db/Makefile ${localstatedir}/db/makedbs.sh"
-RDEPENDS_libnss-db = "${PN}-utils"
+RDEPENDS:libnss-db = "${PN}-utils"
 FILES:glibc-extra-nss = "${base_libdir}/libnss_*-*.so ${base_libdir}/libnss_*.so.*"
 FILES:sln = "${base_sbindir}/sln"
 FILES:${PN}-pic = "${libdir}/*_pic.a ${libdir}/*_pic.map ${libdir}/libc_pic/*.o"
 FILES:libsotruss = "${libdir}/audit/sotruss-lib.so"
-FILES:SOLIBSDEV = "${libdir}/lib*${SOLIBSDEV}"
+FILES_SOLIBSDEV = "${libdir}/lib*${SOLIBSDEV}"
 FILES:${PN}-dev += "${libdir}/libpthread.a ${libdir}/libdl.a ${libdir}/libutil.a ${libdir}/libanl.a ${libdir}/*_nonshared.a ${base_libdir}/*_nonshared.a ${base_libdir}/*.o ${datadir}/aclocal"
 RDEPENDS:${PN}-dev = "linux-libc-headers-dev"
 FILES:${PN}-staticdev += "${libdir}/*.a ${base_libdir}/*.a"
@@ -46,8 +47,6 @@ FILES:nscd = "${sbindir}/nscd* ${sysconfdir}/init.d/nscd ${systemd_system_unitdi
 FILES:${PN}-mtrace = "${bindir}/mtrace"
 FILES:tzcode = "${bindir}/tzselect ${sbindir}/zic ${bindir}/zdump"
 FILES:${PN}-utils = "${bindir}/* ${sbindir}/*"
-FILES:catchsegv = "${bindir}/catchsegv"
-RDEPENDS:catchsegv = "libsegfault"
 FILES:${PN}-pcprofile = "${base_libdir}/libpcprofile.so"
 FILES:glibc-thread-db = "${base_libdir}/libthread_db.so.* ${base_libdir}/libthread_db-*.so"
 RPROVIDES:${PN}-dev += "libc-dev"
@@ -58,7 +57,7 @@ DESCRIPTION:sln = "Similar to the 'ln' utility, but statically linked.  sln is u
 SUMMARY:nscd = "Name service cache daemon"
 DESCRIPTION:nscd = "nscd, name service cache daemon, caches name service lookups for the passwd, group and hosts information.  It can damatically improvide performance with remote, such as NIS or NIS+, name services."
 SUMMARY:glibc-extra-nss = "hesiod, NIS and NIS+ nss libraries"
-DESCRIPTION:glibc-extra-nss = "glibc_ nis, nisplus and hesiod search services."
+DESCRIPTION:glibc-extra-nss = "glibc: nis, nisplus and hesiod search services."
 SUMMARY:ldd = "print shared library dependencies"
 DESCRIPTION:ldd = "${bindir}/ldd prints shared library dependencies for each program or shared library specified on the command line."
 SUMMARY:${PN}-utils = "Miscellaneous utilities provided by glibc"
@@ -121,6 +120,9 @@ do_install() {
 	fi
         ln -rs ${D}${base_libdir}/libpthread.so.0 ${D}${libdir}/libpthread.so
         ln -rs ${D}${base_libdir}/librt.so.1 ${D}${libdir}/librt.so
+        if [ -n "${MLPREFIX}" ]; then
+                mv ${D}${bindir}/ld.so ${D}${bindir}/${MLPREFIX}ld.so
+        fi
 }
 
 def get_libc_fpu_setting(bb, d):
@@ -160,6 +162,7 @@ do_install_armmultilib () {
 	oe_multilib_header bits/shm.h bits/sigstack.h bits/stat.h bits/statfs.h bits/typesizes.h
 	oe_multilib_header bits/procfs-id.h bits/procfs.h bits/shmlba.h
 	oe_multilib_header bits/struct_stat.h bits/pthread_stack_min.h
+	oe_multilib_header bits/dl_find_object.h bits/rseq.h bits/timesize.h
 
 	oe_multilib_header fpu_control.h gnu/lib-names.h gnu/stubs.h ieee754.h
 
@@ -261,17 +264,17 @@ python populate_packages:prepend () {
         bpn = d.getVar('BPN')
         prefix = d.getVar('MLPREFIX') or ""
         # Set the base package...
-        d.setVar('PKG_' + prefix + bpn, prefix + 'libc6')
+        d.setVar('PKG:' + prefix + bpn, prefix + 'libc6')
         libcprefix = prefix + bpn + '-'
         for p in pkgs:
             # And all the subpackages.
             if p.startswith(libcprefix):
                 renamed = p.replace(bpn, 'libc6', 1)
-                d.setVar('PKG_' + p, renamed)
+                d.setVar('PKG:' + p, renamed)
         # For backward compatibility with old -dbg package
-        d.appendVar('RPROVIDES_' + libcprefix + 'dbg', ' ' + prefix + 'libc-dbg')
-        d.appendVar('RCONFLICTS_' + libcprefix + 'dbg', ' ' + prefix + 'libc-dbg')
-        d.appendVar('RREPLACES_' + libcprefix + 'dbg', ' ' + prefix + 'libc-dbg')
+        d.appendVar('RPROVIDES:' + libcprefix + 'dbg', ' ' + prefix + 'libc-dbg')
+        d.appendVar('RCONFLICTS:' + libcprefix + 'dbg', ' ' + prefix + 'libc-dbg')
+        d.appendVar('RREPLACES:' + libcprefix + 'dbg', ' ' + prefix + 'libc-dbg')
 }
 
 pkg_postinst:nscd () {

+ 0 - 0
recipes-core/glibc/glibc-scripts_2.35.bb → recipes-core/glibc/glibc-scripts_2.36.bb


+ 119 - 0
recipes-core/glibc/glibc-tests_2.36.bb

@@ -0,0 +1,119 @@
+require glibc_${PV}.bb
+require glibc-tests.inc
+
+inherit ptest features_check
+REQUIRED_DISTRO_FEATURES = "ptest"
+
+SRC_URI += "\
+	file://run-ptest \
+"
+
+SUMMARY = "glibc tests to be run with ptest"
+
+# Erase some variables already set by glibc_${PV}
+python __anonymous() {
+       # Remove packages provided by glibc build, we only need a subset of them
+       d.setVar("PACKAGES", "${PN} ${PN}-ptest")
+
+       d.setVar("PROVIDES", "${PN} ${PN}-ptest")
+
+       bbclassextend = d.getVar("BBCLASSEXTEND").replace("nativesdk", "").strip()
+       d.setVar("BBCLASSEXTEND", bbclassextend)
+       d.setVar("RRECOMMENDS", "")
+       d.setVar("SYSTEMD_SERVICE:nscd", "")
+       d.setVar("SYSTEMD_PACKAGES", "")
+}
+
+# Remove any leftovers from original glibc recipe
+RPROVIDES:${PN} = "${PN}"
+RRECOMMENDS:${PN} = ""
+RDEPENDS:${PN} = " glibc sed"
+RDEPENDS:${PN}-ptest = "${PN}"
+DEPENDS += "sed"
+
+export oe_srcdir="${exec_prefix}/src/debug/glibc/${PV}/"
+
+# Just build tests for target - do not run them
+do_check:append () {
+	oe_runmake -i check run-built-tests=no
+}
+addtask do_check after do_compile before do_install_ptest_base
+
+glibc_strip_build_directory () {
+	# Delete all non executable files from build directory
+	find ${B} ! -executable -type f -delete
+
+	# Remove build dynamic libraries and links to them as
+	# those are already installed in the target device
+	find ${B} -type f -name "*.so" -delete
+	find ${B} -type l -name "*.so*" -delete
+
+	# Remove headers (installed with glibc)
+	find ${B} -type f -name "*.h" -delete
+
+	find ${B} -type f -name "isomac" -delete
+	find ${B} -type f -name "annexc" -delete
+}
+
+do_install_ptest_base () {
+	glibc_strip_build_directory
+
+	ls -r ${B}/*/*-time64 > ${B}/tst_time64
+
+	# Remove '-time64' suffix - those tests are also time related
+	sed -e "s/-time64$//" ${B}/tst_time64 > ${B}/tst_time_tmp
+	tst_time=$(cat ${B}/tst_time_tmp ${B}/tst_time64)
+
+	rm ${B}/tst_time_tmp ${B}/tst_time64
+	echo "${tst_time}"
+
+	# Install build test programs to the image
+	install -d ${D}${PTEST_PATH}/tests/glibc-ptest/
+
+	for f in "${tst_time}"
+	do
+	    cp -r ${f} ${D}${PTEST_PATH}/tests/glibc-ptest/
+	done
+
+	install -d ${D}${PTEST_PATH}
+	cp ${WORKDIR}/run-ptest ${D}${PTEST_PATH}/
+
+}
+
+# The datadir directory is required to allow core (and reused)
+# glibc cleanup function to finish correctly, as this directory
+# is not created for ptests
+stash_locale_package_cleanup:prepend () {
+	mkdir -p ${PKGD}${datadir}
+}
+
+stash_locale_sysroot_cleanup:prepend () {
+	mkdir -p ${SYSROOT_DESTDIR}${datadir}
+}
+
+# Prevent the do_package() task to set 'libc6' prefix
+# for glibc tests related packages
+python populate_packages:prepend () {
+    if d.getVar('DEBIAN_NAMES'):
+        d.setVar('DEBIAN_NAMES', '')
+}
+
+FILES:${PN} = "${PTEST_PATH}/* /usr/src/debug/${PN}/*"
+
+EXCLUDE_FROM_SHLIBS = "1"
+
+# Install debug data in .debug and sources in /usr/src/debug
+# It is more handy to have _all_ the sources and symbols in one
+# place (package) as this recipe will be used for validation and
+# debugging.
+PACKAGE_DEBUG_SPLIT_STYLE = ".debug"
+
+# glibc test cases violate by default some Yocto/OE checks (staticdev,
+# textrel)
+# 'debug-files' - add everything (including debug) into one package
+#                 (no need to install/build *-src package)
+INSANE_SKIP:${PN} += "staticdev textrel debug-files rpaths"
+
+deltask do_stash_locale
+do_install[noexec] = "1"
+do_populate_sysroot[noexec] = "1"

+ 0 - 0
recipes-core/glibc/glibc-testsuite_2.35.bb → recipes-core/glibc/glibc-testsuite_2.36.bb


+ 4 - 4
recipes-core/glibc/glibc-version.inc

@@ -1,7 +1,7 @@
-SRCBRANCH ?= "master"
-PV = "2.35"
-SRCREV_glibc ?= "1d3decee997ba2fc24af81803299b2f4f3c47063"
-SRCREV_localedef ?= "95c0221703ad970a52445e9eaf91c4aff35eebef"
+SRCBRANCH ?= "release/2.36/master"
+PV = "2.36"
+SRCREV_glibc ?= "b3736d1a3c60a3ec9959bf3b38794958546bf6a2"
+SRCREV_localedef ?= "794da69788cbf9bf57b59a852f9f11307663fa87"
 
 GLIBC_GIT_URI ?= "git://sourceware.org/git/glibc.git"
 

+ 4 - 0
recipes-core/glibc/glibc.inc

@@ -41,6 +41,10 @@ PARALLEL_MAKE = ""
 # ensure make uses /bin/bash
 EXTRA_OEMAKE += "SHELL=/bin/bash"
 
+# We do not need bash to run tzselect script, the default is to use
+# bash but it can be configured by setting KSHELL Makefile variable
+EXTRA_OEMAKE += "KSHELL=/bin/sh"
+
 do_configure:prepend() {
 	sed -e "s#/bin/bash#/bin/sh#" -i ${S}/elf/ldd.bash.in
 }

+ 0 - 59
recipes-core/glibc/glibc/0001-Add-array_length-support.patch

@@ -1,59 +0,0 @@
-From ce34f0e215324455bbb1e4b18f5723b081cae801 Mon Sep 17 00:00:00 2001
-From: Jun Yuan Tan <junyuan.tan@starfivetech.com>
-Date: Tue, 23 Nov 2021 12:08:27 +0800
-Subject: [PATCH 1/1] Add array_length support
-
-This is needed to build localedef from glibc 2.35 in master branch.
-(Commit f5117c6504888fab5423282a4607c552b90fd3f9)
-
-Signed-off-by: Jun Yuan Tan <junyuan.tan@starfivetech.com>
----
- localedef/include/array_length.h | 36 ++++++++++++++++++++++++++++++++++++
- 1 file changed, 36 insertions(+)
- create mode 100644 localedef/include/array_length.h
-
-diff --git a/localedef/include/array_length.h b/localedef/include/array_length.h
-new file mode 100644
-index 0000000..12c5126
---- /dev/null
-+++ b/localedef/include/array_length.h
-@@ -0,0 +1,36 @@
-+/* The array_length and array_end macros.
-+   Copyright (C) 2017-2021 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, see
-+   <https://www.gnu.org/licenses/>.  */
-+
-+#ifndef _ARRAY_LENGTH_H
-+#define _ARRAY_LENGTH_H
-+
-+/* array_length (VAR) is the number of elements in the array VAR.  VAR
-+   must evaluate to an array, not a pointer.  */
-+#define array_length(var)                                               \
-+  (sizeof (var) / sizeof ((var)[0])                                     \
-+   + 0 * sizeof (struct {                                               \
-+       _Static_assert (!__builtin_types_compatible_p                    \
-+                       (__typeof (var), __typeof (&(var)[0])),          \
-+                       "argument must be an array");                    \
-+   }))
-+
-+/* array_end (VAR) is a pointer one past the end of the array VAR.
-+   VAR must evaluate to an array, not a pointer.  */
-+#define array_end(var) (&(var)[array_length (var)])
-+
-+#endif /* _ARRAY_LENGTH_H */
--- 
-2.33.1
-

+ 0 - 43
recipes-core/glibc/glibc/0001-CVE-2021-38604.patch

@@ -1,43 +0,0 @@
-From b805aebd42364fe696e417808a700fdb9800c9e8 Mon Sep 17 00:00:00 2001
-From: Nikita Popov <npv1310@gmail.com>
-Date: Mon, 9 Aug 2021 20:17:34 +0530
-Subject: [PATCH] librt: fix NULL pointer dereference (bug 28213)
-
-Helper thread frees copied attribute on NOTIFY_REMOVED message
-received from the OS kernel.  Unfortunately, it fails to check whether
-copied attribute actually exists (data.attr != NULL).  This worked
-earlier because free() checks passed pointer before actually
-attempting to release corresponding memory.  But
-__pthread_attr_destroy assumes pointer is not NULL.
-
-So passing NULL pointer to __pthread_attr_destroy will result in
-segmentation fault.  This scenario is possible if
-notification->sigev_notify_attributes == NULL (which means default
-thread attributes should be used).
-
-Upstream-Status: Backport [https://sourceware.org/git/?p=glibc.git;a=commit;h=b805aebd42364fe696e417808a700fdb9800c9e8]
-CVE: CVE-2021-38604
-
-Signed-off-by: Nikita Popov <npv1310@gmail.com>
-Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
-Signed-off-by: Vinay Kumar <vinay.m.engg@gmail.com>
----
- sysdeps/unix/sysv/linux/mq_notify.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/sysdeps/unix/sysv/linux/mq_notify.c b/sysdeps/unix/sysv/linux/mq_notify.c
-index 9799dcdaa4..eccae2e4c6 100644
---- a/sysdeps/unix/sysv/linux/mq_notify.c
-+++ b/sysdeps/unix/sysv/linux/mq_notify.c
-@@ -131,7 +131,7 @@ helper_thread (void *arg)
- 	       to wait until it is done with it.  */
- 	    (void) __pthread_barrier_wait (&notify_barrier);
- 	}
--      else if (data.raw[NOTIFY_COOKIE_LEN - 1] == NOTIFY_REMOVED)
-+      else if (data.raw[NOTIFY_COOKIE_LEN - 1] == NOTIFY_REMOVED && data.attr != NULL)
- 	{
- 	  /* The only state we keep is the copy of the thread attributes.  */
- 	  __pthread_attr_destroy (data.attr);
--- 
-2.31.1
-

+ 528 - 0
recipes-core/glibc/glibc/0001-Linux-Add-ppoll-fortify-symbol-for-64-bit-time_t-BZ-.patch

@@ -0,0 +1,528 @@
+From 69318192d16adc7d57adcd69fbbb1e3e107b2783 Mon Sep 17 00:00:00 2001
+From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
+Date: Fri, 4 Nov 2022 16:02:52 -0300
+Subject: [PATCH] Linux: Add ppoll fortify symbol for 64 bit time_t (BZ# 29746)
+
+Similar to ppoll, the poll.h header needs to redirect the poll call
+to a proper fortified ppoll with 64 bit time_t support.
+
+The implementation is straightforward, just need to add a similar
+check as __poll_chk and call the 64 bit time_t ppoll version.  The
+debug fortify tests are also extended to cover 64 bit time_t for
+affected ABIs.
+
+Unfortunately it requires an aditional symbol, which makes backport
+tricky.  One possibility is to add a static inline version if compiler
+supports is and call abort instead of __chk_fail, so fortified version
+will call __poll64 in the end.
+
+Another possibility is to just remove the fortify support for
+_TIME_BITS=64.
+
+Checked on i686-linux-gnu.
+
+Upstream-Status: Backport
+
+Signed-off-by: Ola Nilsson <olani@axis.com>
+---
+ debug/Makefile                                | 41 ++++++++++++------
+ include/sys/poll.h                            |  5 ++-
+ io/bits/poll2.h                               | 25 +++++++++++
+ sysdeps/unix/sysv/linux/Versions              |  5 +++
+ sysdeps/unix/sysv/linux/arm/be/libc.abilist   |  1 +
+ sysdeps/unix/sysv/linux/arm/le/libc.abilist   |  1 +
+ sysdeps/unix/sysv/linux/csky/libc.abilist     |  1 +
+ sysdeps/unix/sysv/linux/hppa/libc.abilist     |  1 +
+ sysdeps/unix/sysv/linux/i386/libc.abilist     |  1 +
+ .../sysv/linux/m68k/coldfire/libc.abilist     |  1 +
+ .../unix/sysv/linux/m68k/m680x0/libc.abilist  |  1 +
+ .../sysv/linux/microblaze/be/libc.abilist     |  1 +
+ .../sysv/linux/microblaze/le/libc.abilist     |  1 +
+ .../sysv/linux/mips/mips32/fpu/libc.abilist   |  1 +
+ .../sysv/linux/mips/mips32/nofpu/libc.abilist |  1 +
+ .../sysv/linux/mips/mips64/n32/libc.abilist   |  1 +
+ sysdeps/unix/sysv/linux/nios2/libc.abilist    |  1 +
+ .../linux/powerpc/powerpc32/fpu/libc.abilist  |  1 +
+ .../powerpc/powerpc32/nofpu/libc.abilist      |  1 +
+ sysdeps/unix/sysv/linux/ppoll.c               |  3 +-
+ sysdeps/unix/sysv/linux/ppoll_chk.c           | 42 +++++++++++++++++++
+ .../unix/sysv/linux/s390/s390-32/libc.abilist |  1 +
+ sysdeps/unix/sysv/linux/sh/be/libc.abilist    |  1 +
+ sysdeps/unix/sysv/linux/sh/le/libc.abilist    |  1 +
+ .../sysv/linux/sparc/sparc32/libc.abilist     |  1 +
+ 25 files changed, 125 insertions(+), 15 deletions(-)
+ create mode 100644 sysdeps/unix/sysv/linux/ppoll_chk.c
+
+diff --git a/debug/Makefile b/debug/Makefile
+index 456b349c4d..075a135a2b 100644
+--- a/debug/Makefile
++++ b/debug/Makefile
+@@ -120,8 +120,10 @@ CPPFLAGS-tst-read-chk-cancel.c += -D_FORTIFY_SOURCE=2
+ # CFLAGS for the file.
+ 
+ tests-all-chk = tst-fortify
+-tests-c-chk =
+-tests-cc-chk =
++tests-c-def-chk =
++tests-cc-def-chk =
++tests-c-time64-chk =
++tests-cc-time64-chk =
+ 
+ CFLAGS-tst-fortify.c += -Wno-format -Wno-deprecated-declarations -Wno-error
+ 
+@@ -130,11 +132,11 @@ define cflags-default
+ endef
+ 
+ define cflags-lfs
+-CFLAGS-tst-fortify-$(1)-lfs-$(2).$(1) += -D_FILE_OFFSET_BITS=64
++CFLAGS-tst-fortify-$(1)-lfs-$(2)-$(3).$(1) += -D_FILE_OFFSET_BITS=64
+ endef
+ 
+ define cflags-nongnu
+-CFLAGS-tst-fortify-$(1)-nongnu-$(2).$(1) += -D_LARGEFILE64_SOURCE=1
++CFLAGS-tst-fortify-$(1)-nongnu-$(2)-$(3).$(1) += -D_LARGEFILE64_SOURCE=1
+ endef
+ 
+ src-chk-nongnu = \#undef _GNU_SOURCE
+@@ -145,12 +147,12 @@ src-chk-nongnu = \#undef _GNU_SOURCE
+ # And they also generate warnings from warning attributes, which
+ # cannot be disabled via pragmas, so require -Wno-error to be used.
+ define gen-chk-test
+-tests-$(1)-chk += tst-fortify-$(1)-$(2)-$(3)
+-CFLAGS-tst-fortify-$(1)-$(2)-$(3).$(1) += -D_FORTIFY_SOURCE=$(3) -Wno-format \
++tests-$(1)-$(4)-chk += tst-fortify-$(1)-$(2)-$(3)-$(4)
++CFLAGS-tst-fortify-$(1)-$(2)-$(3)-$(4).$(1) += -D_FORTIFY_SOURCE=$(3) -Wno-format \
+ 					  -Wno-deprecated-declarations \
+ 					  -Wno-error
+-$(eval $(call cflags-$(2),$(1),$(3)))
+-$(objpfx)tst-fortify-$(1)-$(2)-$(3).$(1): tst-fortify.c Makefile
++$(eval $(call cflags-$(2),$(1),$(3),$(4)))
++$(objpfx)tst-fortify-$(1)-$(2)-$(3)-$(4).$(1): tst-fortify.c Makefile
+ 	( echo "/* Autogenerated from Makefile.  */"; \
+ 	  echo "$(src-chk-$(2))"; \
+ 	  echo "#include \"tst-fortify.c\"" ) > $$@.tmp
+@@ -159,19 +161,29 @@ endef
+ 
+ chk-extensions = c cc
+ chk-types = default lfs nongnu
++# 64 bit time_t implies LFS.
++chk-types-time64 = default nongnu
+ chk-levels = 1 2 3
+ 
+ $(foreach e,$(chk-extensions), \
+   $(foreach t,$(chk-types), \
+     $(foreach l,$(chk-levels), \
+-      $(eval $(call gen-chk-test,$(e),$(t),$(l))))))
++      $(eval $(call gen-chk-test,$(e),$(t),$(l),def)))))
+ 
+-tests-all-chk += $(tests-c-chk) $(tests-cc-chk)
++tests-all-chk += $(tests-c-def-chk) $(tests-cc-def-chk)
++
++$(foreach e,$(chk-extensions), \
++  $(foreach t,$(chk-types-time64), \
++    $(foreach l,$(chk-levels), \
++      $(eval $(call gen-chk-test,$(e),$(t),$(l),time64)))))
++
++tests-all-time64-chk += $(tests-c-time64-chk) $(tests-cc-time64-chk)
+ 
+ define link-cc
+ LDLIBS-$(1) = -lstdc++
+ endef
+-$(foreach t,$(tests-cc-chk), $(eval $(call link-cc,$(t))))
++$(foreach t,$(tests-cc-def-chk), $(eval $(call link-cc,$(t))))
++$(foreach t,$(tests-cc-time64-chk), $(eval $(call link-cc,$(t))))
+ 
+ # backtrace_symbols only works if we link with -rdynamic.  backtrace
+ # requires unwind tables on most architectures.
+@@ -201,6 +213,10 @@ tests = backtrace-tst \
+ 	tst-realpath-chk \
+ 	$(tests-all-chk)
+ 
++tests-time64 += \
++	$(tests-all-time64-chk) \
++	# tests-time64
++
+ ifeq ($(have-ssp),yes)
+ tests += tst-ssp-1
+ endif
+@@ -210,7 +226,7 @@ tests += tst-read-chk-cancel
+ endif
+ 
+ ifeq (,$(CXX))
+-tests-unsupported = $(tests-cc-chk)
++tests-unsupported = $(tests-cc-def-chk) $(test-cc-time64-chk)
+ endif
+ 
+ extra-libs = libpcprofile
+@@ -235,6 +251,7 @@ define chk-gen-locales
+ $(objpfx)$(1).out: $(gen-locales)
+ endef
+ $(foreach t, $(tests-all-chk), $(eval $(call chk-gen-locales,$(t))))
++$(foreach t, $(tests-all-time64-chk), $(eval $(call chk-gen-locales,$(t))))
+ endif
+ 
+ sLIBdir := $(shell echo $(slibdir) | sed 's,lib\(\|64\)$$,\\\\$$LIB,')
+diff --git a/include/sys/poll.h b/include/sys/poll.h
+index f904e21f89..228704fe79 100644
+--- a/include/sys/poll.h
++++ b/include/sys/poll.h
+@@ -2,13 +2,16 @@
+ # include <io/sys/poll.h>
+ 
+ #ifndef _ISOMAC
++#include <include/struct___timespec64.h>
++
+ extern int __poll (struct pollfd *__fds, unsigned long int __nfds,
+ 		   int __timeout);
+ libc_hidden_proto (__poll)
+ libc_hidden_proto (ppoll)
+ 
+ # if __TIMESIZE == 64
+-#  define __ppoll64 __ppoll
++#  define __ppoll64 ppoll
++#  define __ppoll64_chk __ppoll_chk
+ # else
+ # include <time.h>
+ # include <signal.h>
+diff --git a/io/bits/poll2.h b/io/bits/poll2.h
+index 3679d8451a..90f5574969 100644
+--- a/io/bits/poll2.h
++++ b/io/bits/poll2.h
+@@ -43,6 +43,30 @@ poll (struct pollfd *__fds, nfds_t __nfds, int __timeout)
+ 
+ 
+ #ifdef __USE_GNU
++# ifdef __USE_TIME_BITS64
++extern int __REDIRECT (__ppoll64_alias, (struct pollfd *__fds, nfds_t __nfds,
++				       const struct timespec *__timeout,
++				       const __sigset_t *__ss), __ppoll64);
++extern int __ppoll64_chk (struct pollfd *__fds, nfds_t __nfds,
++			  const struct timespec *__timeout,
++			  const __sigset_t *__ss, __SIZE_TYPE__ __fdslen)
++    __attr_access ((__write_only__, 1, 2));
++extern int __REDIRECT (__ppoll64_chk_warn, (struct pollfd *__fds, nfds_t __n,
++					    const struct timespec *__timeout,
++					    const __sigset_t *__ss,
++					    __SIZE_TYPE__ __fdslen),
++		       __ppoll64_chk)
++  __warnattr ("ppoll called with fds buffer too small file nfds entries");
++
++__fortify_function __fortified_attr_access (__write_only__, 1, 2) int
++ppoll (struct pollfd *__fds, nfds_t __nfds, const struct timespec *__timeout,
++       const __sigset_t *__ss)
++{
++  return __glibc_fortify (ppoll64, __nfds, sizeof (*__fds),
++			  __glibc_objsize (__fds),
++			  __fds, __nfds, __timeout, __ss);
++}
++# else
+ extern int __REDIRECT (__ppoll_alias, (struct pollfd *__fds, nfds_t __nfds,
+ 				       const struct timespec *__timeout,
+ 				       const __sigset_t *__ss), ppoll);
+@@ -65,6 +89,7 @@ ppoll (struct pollfd *__fds, nfds_t __nfds, const struct timespec *__timeout,
+ 			  __glibc_objsize (__fds),
+ 			  __fds, __nfds, __timeout, __ss);
+ }
++# endif
+ #endif
+ 
+ __END_DECLS
+diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions
+index 65d2ceda2c..ca6eb1a49e 100644
+--- a/sysdeps/unix/sysv/linux/Versions
++++ b/sysdeps/unix/sysv/linux/Versions
+@@ -313,6 +313,11 @@ libc {
+     process_madvise;
+     process_mrelease;
+   }
++  GLIBC_2.37 {
++%ifdef TIME64_NON_DEFAULT
++    __ppoll64_chk;
++%endif
++  }
+   GLIBC_PRIVATE {
+     # functions used in other libraries
+     __syscall_rt_sigqueueinfo;
+diff --git a/sysdeps/unix/sysv/linux/arm/be/libc.abilist b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
+index e0668a80cf..f28402fe03 100644
+--- a/sysdeps/unix/sysv/linux/arm/be/libc.abilist
++++ b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
+@@ -513,6 +513,7 @@ GLIBC_2.36 pidfd_open F
+ GLIBC_2.36 pidfd_send_signal F
+ GLIBC_2.36 process_madvise F
+ GLIBC_2.36 process_mrelease F
++GLIBC_2.37 __ppoll64_chk F
+ GLIBC_2.4 _Exit F
+ GLIBC_2.4 _IO_2_1_stderr_ D 0xa0
+ GLIBC_2.4 _IO_2_1_stdin_ D 0xa0
+diff --git a/sysdeps/unix/sysv/linux/arm/le/libc.abilist b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
+index d28e7c60b7..e2f56880ed 100644
+--- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist
++++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
+@@ -510,6 +510,7 @@ GLIBC_2.36 pidfd_open F
+ GLIBC_2.36 pidfd_send_signal F
+ GLIBC_2.36 process_madvise F
+ GLIBC_2.36 process_mrelease F
++GLIBC_2.37 __ppoll64_chk F
+ GLIBC_2.4 _Exit F
+ GLIBC_2.4 _IO_2_1_stderr_ D 0xa0
+ GLIBC_2.4 _IO_2_1_stdin_ D 0xa0
+diff --git a/sysdeps/unix/sysv/linux/csky/libc.abilist b/sysdeps/unix/sysv/linux/csky/libc.abilist
+index 922b05062f..319d92356e 100644
+--- a/sysdeps/unix/sysv/linux/csky/libc.abilist
++++ b/sysdeps/unix/sysv/linux/csky/libc.abilist
+@@ -2669,3 +2669,4 @@ GLIBC_2.36 pidfd_open F
+ GLIBC_2.36 pidfd_send_signal F
+ GLIBC_2.36 process_madvise F
+ GLIBC_2.36 process_mrelease F
++GLIBC_2.37 __ppoll64_chk F
+diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist
+index 412144f94c..6450e17ebe 100644
+--- a/sysdeps/unix/sysv/linux/hppa/libc.abilist
++++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist
+@@ -2618,6 +2618,7 @@ GLIBC_2.36 pidfd_open F
+ GLIBC_2.36 pidfd_send_signal F
+ GLIBC_2.36 process_madvise F
+ GLIBC_2.36 process_mrelease F
++GLIBC_2.37 __ppoll64_chk F
+ GLIBC_2.4 __confstr_chk F
+ GLIBC_2.4 __fgets_chk F
+ GLIBC_2.4 __fgets_unlocked_chk F
+diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist
+index 134393900a..0a24ec9afd 100644
+--- a/sysdeps/unix/sysv/linux/i386/libc.abilist
++++ b/sysdeps/unix/sysv/linux/i386/libc.abilist
+@@ -2802,6 +2802,7 @@ GLIBC_2.36 pidfd_open F
+ GLIBC_2.36 pidfd_send_signal F
+ GLIBC_2.36 process_madvise F
+ GLIBC_2.36 process_mrelease F
++GLIBC_2.37 __ppoll64_chk F
+ GLIBC_2.4 __confstr_chk F
+ GLIBC_2.4 __fgets_chk F
+ GLIBC_2.4 __fgets_unlocked_chk F
+diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
+index 0604029c68..16243a7a92 100644
+--- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
++++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
+@@ -514,6 +514,7 @@ GLIBC_2.36 pidfd_open F
+ GLIBC_2.36 pidfd_send_signal F
+ GLIBC_2.36 process_madvise F
+ GLIBC_2.36 process_mrelease F
++GLIBC_2.37 __ppoll64_chk F
+ GLIBC_2.4 _Exit F
+ GLIBC_2.4 _IO_2_1_stderr_ D 0x98
+ GLIBC_2.4 _IO_2_1_stdin_ D 0x98
+diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
+index af2be5c80d..564a553b27 100644
+--- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
++++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
+@@ -2745,6 +2745,7 @@ GLIBC_2.36 pidfd_open F
+ GLIBC_2.36 pidfd_send_signal F
+ GLIBC_2.36 process_madvise F
+ GLIBC_2.36 process_mrelease F
++GLIBC_2.37 __ppoll64_chk F
+ GLIBC_2.4 __confstr_chk F
+ GLIBC_2.4 __fgets_chk F
+ GLIBC_2.4 __fgets_unlocked_chk F
+diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
+index e090b8d48f..e850f47b21 100644
+--- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
++++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
+@@ -2718,3 +2718,4 @@ GLIBC_2.36 pidfd_open F
+ GLIBC_2.36 pidfd_send_signal F
+ GLIBC_2.36 process_madvise F
+ GLIBC_2.36 process_mrelease F
++GLIBC_2.37 __ppoll64_chk F
+diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
+index 8c5b2db243..37178c503f 100644
+--- a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
++++ b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
+@@ -2715,3 +2715,4 @@ GLIBC_2.36 pidfd_open F
+ GLIBC_2.36 pidfd_send_signal F
+ GLIBC_2.36 process_madvise F
+ GLIBC_2.36 process_mrelease F
++GLIBC_2.37 __ppoll64_chk F
+diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
+index 68847134a2..3b30b31466 100644
+--- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
++++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
+@@ -2710,6 +2710,7 @@ GLIBC_2.36 pidfd_open F
+ GLIBC_2.36 pidfd_send_signal F
+ GLIBC_2.36 process_madvise F
+ GLIBC_2.36 process_mrelease F
++GLIBC_2.37 __ppoll64_chk F
+ GLIBC_2.4 __confstr_chk F
+ GLIBC_2.4 __fgets_chk F
+ GLIBC_2.4 __fgets_unlocked_chk F
+diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
+index daa44e64fa..0e358570a2 100644
+--- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
++++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
+@@ -2708,6 +2708,7 @@ GLIBC_2.36 pidfd_open F
+ GLIBC_2.36 pidfd_send_signal F
+ GLIBC_2.36 process_madvise F
+ GLIBC_2.36 process_mrelease F
++GLIBC_2.37 __ppoll64_chk F
+ GLIBC_2.4 __confstr_chk F
+ GLIBC_2.4 __fgets_chk F
+ GLIBC_2.4 __fgets_unlocked_chk F
+diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
+index 6169188c96..59c598b98f 100644
+--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
++++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
+@@ -2716,6 +2716,7 @@ GLIBC_2.36 pidfd_open F
+ GLIBC_2.36 pidfd_send_signal F
+ GLIBC_2.36 process_madvise F
+ GLIBC_2.36 process_mrelease F
++GLIBC_2.37 __ppoll64_chk F
+ GLIBC_2.4 __confstr_chk F
+ GLIBC_2.4 __fgets_chk F
+ GLIBC_2.4 __fgets_unlocked_chk F
+diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist
+index 58e9b486b0..463e01ab84 100644
+--- a/sysdeps/unix/sysv/linux/nios2/libc.abilist
++++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist
+@@ -2757,3 +2757,4 @@ GLIBC_2.36 pidfd_open F
+ GLIBC_2.36 pidfd_send_signal F
+ GLIBC_2.36 process_madvise F
+ GLIBC_2.36 process_mrelease F
++GLIBC_2.37 __ppoll64_chk F
+diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
+index 8c9ca32cbe..405d40d11c 100644
+--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
++++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
+@@ -2772,6 +2772,7 @@ GLIBC_2.36 pidfd_open F
+ GLIBC_2.36 pidfd_send_signal F
+ GLIBC_2.36 process_madvise F
+ GLIBC_2.36 process_mrelease F
++GLIBC_2.37 __ppoll64_chk F
+ GLIBC_2.4 _IO_fprintf F
+ GLIBC_2.4 _IO_printf F
+ GLIBC_2.4 _IO_sprintf F
+diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
+index 08a6604aab..ce89602b93 100644
+--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
++++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
+@@ -2805,6 +2805,7 @@ GLIBC_2.36 pidfd_open F
+ GLIBC_2.36 pidfd_send_signal F
+ GLIBC_2.36 process_madvise F
+ GLIBC_2.36 process_mrelease F
++GLIBC_2.37 __ppoll64_chk F
+ GLIBC_2.4 _IO_fprintf F
+ GLIBC_2.4 _IO_printf F
+ GLIBC_2.4 _IO_sprintf F
+diff --git a/sysdeps/unix/sysv/linux/ppoll.c b/sysdeps/unix/sysv/linux/ppoll.c
+index 1105e29b00..2e173b931d 100644
+--- a/sysdeps/unix/sysv/linux/ppoll.c
++++ b/sysdeps/unix/sysv/linux/ppoll.c
+@@ -67,7 +67,7 @@ __ppoll64 (struct pollfd *fds, nfds_t nfds, const struct __timespec64 *timeout,
+ libc_hidden_def (__ppoll64)
+ 
+ int
+-__ppoll (struct pollfd *fds, nfds_t nfds, const struct timespec *timeout,
++ppoll (struct pollfd *fds, nfds_t nfds, const struct timespec *timeout,
+          const sigset_t *sigmask)
+ {
+   struct __timespec64 ts64;
+@@ -77,5 +77,4 @@ __ppoll (struct pollfd *fds, nfds_t nfds, const struct timespec *timeout,
+   return __ppoll64 (fds, nfds, timeout ? &ts64 : NULL, sigmask);
+ }
+ #endif
+-strong_alias (__ppoll, ppoll)
+ libc_hidden_def (ppoll)
+diff --git a/sysdeps/unix/sysv/linux/ppoll_chk.c b/sysdeps/unix/sysv/linux/ppoll_chk.c
+new file mode 100644
+index 0000000000..65c4b56671
+--- /dev/null
++++ b/sysdeps/unix/sysv/linux/ppoll_chk.c
+@@ -0,0 +1,42 @@
++/* Fortify ppoll implementation.  Linux version.
++   Copyright (C) 2022 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, see
++   <https://www.gnu.org/licenses/>.  */
++
++#include <poll.h>
++
++int
++__ppoll64_chk (struct pollfd *fds, nfds_t nfds,
++	       const struct __timespec64 *tmo, const __sigset_t *ss,
++	       __SIZE_TYPE__ fdslen)
++{
++  if (fdslen / sizeof (*fds) < nfds)
++    __chk_fail ();
++
++  return __ppoll64 (fds, nfds, tmo, ss);
++}
++
++#if __TIMESIZE != 64
++int
++__ppoll_chk (struct pollfd *fds, nfds_t nfds, const struct timespec *tmo,
++	     const __sigset_t *ss, __SIZE_TYPE__ fdslen)
++{
++  if (fdslen / sizeof (*fds) < nfds)
++    __chk_fail ();
++
++  return ppoll (fds, nfds, tmo, ss);
++}
++#endif
+diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
+index 009f22931e..5ca051a9eb 100644
+--- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
++++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
+@@ -2770,6 +2770,7 @@ GLIBC_2.36 pidfd_open F
+ GLIBC_2.36 pidfd_send_signal F
+ GLIBC_2.36 process_madvise F
+ GLIBC_2.36 process_mrelease F
++GLIBC_2.37 __ppoll64_chk F
+ GLIBC_2.4 _IO_fprintf F
+ GLIBC_2.4 _IO_printf F
+ GLIBC_2.4 _IO_sprintf F
+diff --git a/sysdeps/unix/sysv/linux/sh/be/libc.abilist b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
+index afb5bc37b1..5b48168ec6 100644
+--- a/sysdeps/unix/sysv/linux/sh/be/libc.abilist
++++ b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
+@@ -2625,6 +2625,7 @@ GLIBC_2.36 pidfd_open F
+ GLIBC_2.36 pidfd_send_signal F
+ GLIBC_2.36 process_madvise F
+ GLIBC_2.36 process_mrelease F
++GLIBC_2.37 __ppoll64_chk F
+ GLIBC_2.4 __confstr_chk F
+ GLIBC_2.4 __fgets_chk F
+ GLIBC_2.4 __fgets_unlocked_chk F
+diff --git a/sysdeps/unix/sysv/linux/sh/le/libc.abilist b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
+index 2b53a3cf92..c42b39cea8 100644
+--- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist
++++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
+@@ -2622,6 +2622,7 @@ GLIBC_2.36 pidfd_open F
+ GLIBC_2.36 pidfd_send_signal F
+ GLIBC_2.36 process_madvise F
+ GLIBC_2.36 process_mrelease F
++GLIBC_2.37 __ppoll64_chk F
+ GLIBC_2.4 __confstr_chk F
+ GLIBC_2.4 __fgets_chk F
+ GLIBC_2.4 __fgets_unlocked_chk F
+diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
+index 43b9844a99..5a0a662dee 100644
+--- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
++++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
+@@ -2765,6 +2765,7 @@ GLIBC_2.36 pidfd_open F
+ GLIBC_2.36 pidfd_send_signal F
+ GLIBC_2.36 process_madvise F
+ GLIBC_2.36 process_mrelease F
++GLIBC_2.37 __ppoll64_chk F
+ GLIBC_2.4 _IO_fprintf F
+ GLIBC_2.4 _IO_printf F
+ GLIBC_2.4 _IO_sprintf F

+ 0 - 55
recipes-core/glibc/glibc/0001-RISC-V-Remove-riscv-specific-sigcontext.h.patch

@@ -1,55 +0,0 @@
-From 4f78efecb2ef9e87a15a3dde8adbdaa53f0598d7 Mon Sep 17 00:00:00 2001
-From: Vincent Chen <vincent.chen@sifive.com>
-Date: Mon, 13 Sep 2021 09:41:14 +0800
-Subject: [PATCH 1/8] RISC-V: Remove riscv-specific sigcontext.h
-
-Remove riscv-specific sigcontext.h so that Glibc can directly use
-sigcontext.h provided by the kernel to reduce synchronization work
-when new extension support is introduced.
-
-Signed-off-by: max.ma <max.ma@starfivetech.com>
----
- .../unix/sysv/linux/riscv/bits/sigcontext.h   | 31 -------------------
- 1 file changed, 31 deletions(-)
- delete mode 100644 sysdeps/unix/sysv/linux/riscv/bits/sigcontext.h
-
-diff --git a/sysdeps/unix/sysv/linux/riscv/bits/sigcontext.h b/sysdeps/unix/sysv/linux/riscv/bits/sigcontext.h
-deleted file mode 100644
-index 14e4e06fac..0000000000
---- a/sysdeps/unix/sysv/linux/riscv/bits/sigcontext.h
-+++ /dev/null
-@@ -1,31 +0,0 @@
--/* Machine-dependent signal context structure for Linux.  RISC-V version.
--   Copyright (C) 1996-2021 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, see
--   <https://www.gnu.org/licenses/>.  */
--
--#ifndef _BITS_SIGCONTEXT_H
--#define _BITS_SIGCONTEXT_H 1
--
--#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H
--# error "Never use <bits/sigcontext.h> directly; include <signal.h> instead."
--#endif
--
--struct sigcontext {
--  /* gregs[0] holds the program counter.  */
--  unsigned long int gregs[32];
--  unsigned long long int fpregs[66] __attribute__ ((__aligned__ (16)));
--};
--
--#endif
--- 
-2.33.1
-

+ 1 - 1
recipes-core/glibc/glibc/0001-localedef-Add-hardlink-resolver-from-util-linux.patch

@@ -1,4 +1,4 @@
-From d34ba0833cd811f8869a6262044af55f9e7b59d8 Mon Sep 17 00:00:00 2001
+From c6dca721df6dd8c39ffe16e61623516bd8742d39 Mon Sep 17 00:00:00 2001
 From: Jason Wessel <jason.wessel@windriver.com>
 Date: Sat, 7 Dec 2019 09:59:22 -0800
 Subject: [PATCH] localedef: Add hardlink resolver from util-linux

+ 74 - 81
recipes-core/glibc/glibc/0003-RISC-V-Save-and-restore-VCSR-when-doing-user-context.patch → recipes-core/glibc/glibc/0001-modify-and-merge-sifive-patches-to-support-V.patch

@@ -1,30 +1,22 @@
-From 1c08ed548a24c41542bdb7309e05c1aef70f135d Mon Sep 17 00:00:00 2001
-From: Vincent Chen <vincent.chen@sifive.com>
-Date: Mon, 13 Sep 2021 09:41:16 +0800
-Subject: [PATCH 3/8] RISC-V: Save and restore VCSR when doing user context
- switch
+From d8b1bc0917a815fdb55457ad8e1eb14d0042f469 Mon Sep 17 00:00:00 2001
+From: "max.ma" <max.ma@starfivetech.com>
+Date: Mon, 5 Sep 2022 22:03:01 -0700
+Subject: [PATCH 01/19] modify &and merge sifive patches to support V
 
-According to the RISC-V V extension specification, all vector registers
-except VCSR are caller-saved registers. The VCSR (vxrm + vxsat) has thread
-storage duration. Therefore, only VCSR needs to be added to the user
-context operation.
-
-Signed-off-by: max.ma <max.ma@starfivetech.com>
 ---
- sysdeps/riscv/Makefile                       |  5 +++
- sysdeps/riscv/rtld-global-offsets.sym        |  7 ++++
- sysdeps/unix/sysv/linux/riscv/bits/hwcap.h   | 31 +++++++++++++++
- sysdeps/unix/sysv/linux/riscv/getcontext.S   | 22 ++++++++++-
- sysdeps/unix/sysv/linux/riscv/setcontext.S   | 22 +++++++++++
- sysdeps/unix/sysv/linux/riscv/swapcontext.S  | 41 ++++++++++++++++++++
- sysdeps/unix/sysv/linux/riscv/sysdep.h       |  1 +
- sysdeps/unix/sysv/linux/riscv/ucontext_i.sym |  6 +++
- 8 files changed, 134 insertions(+), 1 deletion(-)
- create mode 100644 sysdeps/riscv/rtld-global-offsets.sym
- create mode 100644 sysdeps/unix/sysv/linux/riscv/bits/hwcap.h
+ sysdeps/riscv/Makefile                        |  5 +++
+ .../unix/sysv/linux/riscv/bits/sigcontext.h   | 31 --------------
+ sysdeps/unix/sysv/linux/riscv/getcontext.S    | 24 ++++++++++-
+ sysdeps/unix/sysv/linux/riscv/setcontext.S    | 22 ++++++++++
+ sysdeps/unix/sysv/linux/riscv/swapcontext.S   | 41 +++++++++++++++++++
+ sysdeps/unix/sysv/linux/riscv/sys/ucontext.h  |  2 +
+ sysdeps/unix/sysv/linux/riscv/sysdep.h        |  1 +
+ sysdeps/unix/sysv/linux/riscv/ucontext_i.sym  |  5 +++
+ 8 files changed, 98 insertions(+), 33 deletions(-)
+ delete mode 100644 sysdeps/unix/sysv/linux/riscv/bits/sigcontext.h
 
 diff --git a/sysdeps/riscv/Makefile b/sysdeps/riscv/Makefile
-index 20a9968106..a5c2106a09 100644
+index 8fb10b164f..e2d84640d4 100644
 --- a/sysdeps/riscv/Makefile
 +++ b/sysdeps/riscv/Makefile
 @@ -2,6 +2,11 @@ ifeq ($(subdir),misc)
@@ -39,58 +31,45 @@ index 20a9968106..a5c2106a09 100644
  # RISC-V's assembler also needs to know about PIC as it changes the definition
  # of some assembler macros.
  ASFLAGS-.os += $(pic-ccflag)
-diff --git a/sysdeps/riscv/rtld-global-offsets.sym b/sysdeps/riscv/rtld-global-offsets.sym
-new file mode 100644
-index 0000000000..ff4e97f2a6
---- /dev/null
-+++ b/sysdeps/riscv/rtld-global-offsets.sym
-@@ -0,0 +1,7 @@
-+#define SHARED 1
-+
-+#include <ldsodefs.h>
-+
-+#define rtld_global_ro_offsetof(mem) offsetof (struct rtld_global_ro, mem)
-+
-+RTLD_GLOBAL_RO_DL_HWCAP_OFFSET	rtld_global_ro_offsetof (_dl_hwcap)
-diff --git a/sysdeps/unix/sysv/linux/riscv/bits/hwcap.h b/sysdeps/unix/sysv/linux/riscv/bits/hwcap.h
-new file mode 100644
-index 0000000000..e6c5ef5740
---- /dev/null
-+++ b/sysdeps/unix/sysv/linux/riscv/bits/hwcap.h
-@@ -0,0 +1,31 @@
-+/* Defines for bits in AT_HWCAP.  RISC-V Linux version.
-+   Copyright (C) 2021 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, see
-+   <http://www.gnu.org/licenses/>.  */
-+
-+#if !defined (_SYS_AUXV_H) && !defined (_LINUX_RISCV_SYSDEP_H)
-+# error "Never include <bits/hwcap.h> directly; use <sys/auxv.h> instead."
-+#endif
-+
-+/* The following must match the kernel's <asm/hwcap.h>.  */
-+#define HWCAP_ISA_I      0x100		//(1 << ('I' - 'A'))
-+#define HWCAP_ISA_M      0x1000 	//(1 << ('M' - 'A'))
-+#define HWCAP_ISA_A      0x1		//(1 << ('A' - 'A'))
-+#define HWCAP_ISA_F      0x20		//(1 << ('F' - 'A'))
-+#define HWCAP_ISA_D      0x8		//(1 << ('D' - 'A'))
-+#define HWCAP_ISA_C      0x4		//(1 << ('C' - 'A'))
-+#define HWCAP_ISA_V      0x200000	//(1 << ('V' - 'A'))
-+
+diff --git a/sysdeps/unix/sysv/linux/riscv/bits/sigcontext.h b/sysdeps/unix/sysv/linux/riscv/bits/sigcontext.h
+deleted file mode 100644
+index b6e15b5f62..0000000000
+--- a/sysdeps/unix/sysv/linux/riscv/bits/sigcontext.h
++++ /dev/null
+@@ -1,31 +0,0 @@
+-/* Machine-dependent signal context structure for Linux.  RISC-V version.
+-   Copyright (C) 1996-2022 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, see
+-   <https://www.gnu.org/licenses/>.  */
+-
+-#ifndef _BITS_SIGCONTEXT_H
+-#define _BITS_SIGCONTEXT_H 1
+-
+-#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H
+-# error "Never use <bits/sigcontext.h> directly; include <signal.h> instead."
+-#endif
+-
+-struct sigcontext {
+-  /* gregs[0] holds the program counter.  */
+-  unsigned long int gregs[32];
+-  unsigned long long int fpregs[66] __attribute__ ((__aligned__ (16)));
+-};
+-
+-#endif
 diff --git a/sysdeps/unix/sysv/linux/riscv/getcontext.S b/sysdeps/unix/sysv/linux/riscv/getcontext.S
-index d6a9bbca60..840d8feca4 100644
+index 499f70b65d..371ebd52a7 100644
 --- a/sysdeps/unix/sysv/linux/riscv/getcontext.S
 +++ b/sysdeps/unix/sysv/linux/riscv/getcontext.S
 @@ -16,6 +16,8 @@
@@ -133,9 +112,11 @@ index d6a9bbca60..840d8feca4 100644
  
  PSEUDO_END (__getcontext)
 -
- weak_alias (__getcontext, getcontext)
+-weak_alias (__getcontext, getcontext)
++weak_alias (__getcontext, getcontext)
+\ No newline at end of file
 diff --git a/sysdeps/unix/sysv/linux/riscv/setcontext.S b/sysdeps/unix/sysv/linux/riscv/setcontext.S
-index 9510518750..d2404fbe9c 100644
+index e3bc84a2e6..423d94df27 100644
 --- a/sysdeps/unix/sysv/linux/riscv/setcontext.S
 +++ b/sysdeps/unix/sysv/linux/riscv/setcontext.S
 @@ -16,6 +16,8 @@
@@ -175,7 +156,7 @@ index 9510518750..d2404fbe9c 100644
  	   unless makecontext() has been called.  */
  	RESTORE_INT_REG     (t1,   0, t0)
 diff --git a/sysdeps/unix/sysv/linux/riscv/swapcontext.S b/sysdeps/unix/sysv/linux/riscv/swapcontext.S
-index df0f69969c..94ae8e4bdc 100644
+index 4da615f6d4..16600f78df 100644
 --- a/sysdeps/unix/sysv/linux/riscv/swapcontext.S
 +++ b/sysdeps/unix/sysv/linux/riscv/swapcontext.S
 @@ -16,6 +16,8 @@
@@ -240,6 +221,19 @@ index df0f69969c..94ae8e4bdc 100644
  	/* Note the contents of argument registers will be random
  	   unless makecontext() has been called.  */
  	RESTORE_INT_REG (t1,   0, t0)
+diff --git a/sysdeps/unix/sysv/linux/riscv/sys/ucontext.h b/sysdeps/unix/sysv/linux/riscv/sys/ucontext.h
+index e226ee85ee..1b370f0f45 100644
+--- a/sysdeps/unix/sysv/linux/riscv/sys/ucontext.h
++++ b/sysdeps/unix/sysv/linux/riscv/sys/ucontext.h
+@@ -82,6 +82,8 @@ typedef struct mcontext_t
+   {
+     __riscv_mc_gp_state __gregs;
+     union  __riscv_mc_fp_state __fpregs;
++    /* 5K + 256 reserved for vector state and future expansion.  */
++    unsigned char __reserved[5376] __attribute__ ((__aligned__ (16)));
+   } mcontext_t;
+ 
+ /* Userlevel context.  */
 diff --git a/sysdeps/unix/sysv/linux/riscv/sysdep.h b/sysdeps/unix/sysv/linux/riscv/sysdep.h
 index 37ff07a0d7..c9f8fd8236 100644
 --- a/sysdeps/unix/sysv/linux/riscv/sysdep.h
@@ -253,7 +247,7 @@ index 37ff07a0d7..c9f8fd8236 100644
  
  # define ENTRY(name) LEAF(name)
 diff --git a/sysdeps/unix/sysv/linux/riscv/ucontext_i.sym b/sysdeps/unix/sysv/linux/riscv/ucontext_i.sym
-index be55b26310..4037473c9a 100644
+index be55b26310..b91945a080 100644
 --- a/sysdeps/unix/sysv/linux/riscv/ucontext_i.sym
 +++ b/sysdeps/unix/sysv/linux/riscv/ucontext_i.sym
 @@ -2,6 +2,7 @@
@@ -264,17 +258,16 @@ index be55b26310..4037473c9a 100644
  
  -- Constants used by the rt_sigprocmask call.
  
-@@ -27,5 +28,10 @@ STACK_FLAGS			stack (ss_flags)
+@@ -27,5 +28,9 @@ STACK_FLAGS			stack (ss_flags)
  
  MCONTEXT_GREGS			mcontext (__gregs)
  MCONTEXT_FPREGS			mcontext (__fpregs)
 +MCONTEXT_EXTENSION 		mcontext (__reserved)
  
  UCONTEXT_SIZE			sizeof (ucontext_t)
-+
 +VCSR_OFFSET			offsetof (struct __riscv_v_state, vcsr)
 +
 +RVV_MAGIC
 -- 
-2.33.1
+2.25.1
 

+ 0 - 150
recipes-core/glibc/glibc/0002-CVE-2021-38604.patch

@@ -1,150 +0,0 @@
-From 4cc79c217744743077bf7a0ec5e0a4318f1e6641 Mon Sep 17 00:00:00 2001
-From: Nikita Popov <npv1310@gmail.com>
-Date: Thu, 12 Aug 2021 16:09:50 +0530
-Subject: [PATCH] librt: add test (bug 28213)
-
-This test implements following logic:
-1) Create POSIX message queue.
-   Register a notification with mq_notify (using NULL attributes).
-   Then immediately unregister the notification with mq_notify.
-   Helper thread in a vulnerable version of glibc
-   should cause NULL pointer dereference after these steps.
-2) Once again, register the same notification.
-   Try to send a dummy message.
-   Test is considered successfulif the dummy message
-   is successfully received by the callback function.
-
-Upstream-Status: Backport [https://sourceware.org/git/?p=glibc.git;a=commit;h=4cc79c217744743077bf7a0ec5e0a4318f1e6641]
-CVE: CVE-2021-38604
-
-Signed-off-by: Nikita Popov <npv1310@gmail.com>
-Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
-Signed-off-by: Vinay Kumar <vinay.m.engg@gmail.com>
----
- rt/Makefile      |   1 +
- rt/tst-bz28213.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++
- 2 files changed, 102 insertions(+)
- create mode 100644 rt/tst-bz28213.c
-
-diff --git a/rt/Makefile b/rt/Makefile
-index 113cea03a5..910e775995 100644
---- a/rt/Makefile
-+++ b/rt/Makefile
-@@ -74,6 +74,7 @@ tests := tst-shm tst-timer tst-timer2 \
- 	 tst-aio7 tst-aio8 tst-aio9 tst-aio10 \
- 	 tst-mqueue1 tst-mqueue2 tst-mqueue3 tst-mqueue4 \
- 	 tst-mqueue5 tst-mqueue6 tst-mqueue7 tst-mqueue8 tst-mqueue9 \
-+	 tst-bz28213 \
- 	 tst-timer3 tst-timer4 tst-timer5 \
- 	 tst-cpuclock2 tst-cputimer1 tst-cputimer2 tst-cputimer3 \
- 	 tst-shm-cancel \
-diff --git a/rt/tst-bz28213.c b/rt/tst-bz28213.c
-new file mode 100644
-index 0000000000..0c096b5a0a
---- /dev/null
-+++ b/rt/tst-bz28213.c
-@@ -0,0 +1,101 @@
-+/* Bug 28213: test for NULL pointer dereference in mq_notify.
-+   Copyright (C) The GNU Toolchain Authors.
-+   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, see
-+   <https://www.gnu.org/licenses/>.  */
-+
-+#include <errno.h>
-+#include <sys/types.h>
-+#include <sys/stat.h>
-+#include <fcntl.h>
-+#include <unistd.h>
-+#include <mqueue.h>
-+#include <signal.h>
-+#include <stdlib.h>
-+#include <string.h>
-+#include <support/check.h>
-+
-+static mqd_t m = -1;
-+static const char msg[] = "hello";
-+
-+static void
-+check_bz28213_cb (union sigval sv)
-+{
-+  char buf[sizeof (msg)];
-+
-+  (void) sv;
-+
-+  TEST_VERIFY_EXIT ((size_t) mq_receive (m, buf, sizeof (buf), NULL)
-+		    == sizeof (buf));
-+  TEST_VERIFY_EXIT (memcmp (buf, msg, sizeof (buf)) == 0);
-+
-+  exit (0);
-+}
-+
-+static void
-+check_bz28213 (void)
-+{
-+  struct sigevent sev;
-+
-+  memset (&sev, '\0', sizeof (sev));
-+  sev.sigev_notify = SIGEV_THREAD;
-+  sev.sigev_notify_function = check_bz28213_cb;
-+
-+  /* Step 1: Register & unregister notifier.
-+     Helper thread should receive NOTIFY_REMOVED notification.
-+     In a vulnerable version of glibc, NULL pointer dereference follows. */
-+  TEST_VERIFY_EXIT (mq_notify (m, &sev) == 0);
-+  TEST_VERIFY_EXIT (mq_notify (m, NULL) == 0);
-+
-+  /* Step 2: Once again, register notification.
-+     Try to send one message.
-+     Test is considered successful, if the callback does exit (0). */
-+  TEST_VERIFY_EXIT (mq_notify (m, &sev) == 0);
-+  TEST_VERIFY_EXIT (mq_send (m, msg, sizeof (msg), 1) == 0);
-+
-+  /* Wait... */
-+  pause ();
-+}
-+
-+static int
-+do_test (void)
-+{
-+  static const char m_name[] = "/bz28213_queue";
-+  struct mq_attr m_attr;
-+
-+  memset (&m_attr, '\0', sizeof (m_attr));
-+  m_attr.mq_maxmsg = 1;
-+  m_attr.mq_msgsize = sizeof (msg);
-+
-+  m = mq_open (m_name,
-+               O_RDWR | O_CREAT | O_EXCL,
-+               0600,
-+               &m_attr);
-+
-+  if (m < 0)
-+    {
-+      if (errno == ENOSYS)
-+        FAIL_UNSUPPORTED ("POSIX message queues are not implemented\n");
-+      FAIL_EXIT1 ("Failed to create POSIX message queue: %m\n");
-+    }
-+
-+  TEST_VERIFY_EXIT (mq_unlink (m_name) == 0);
-+
-+  check_bz28213 ();
-+
-+  return 0;
-+}
-+
-+#include <support/test-driver.c>
--- 
-2.31.1
-

+ 0 - 30
recipes-core/glibc/glibc/0002-RISC-V-Reserve-about-5K-space-in-mcontext_t-to-suppo.patch

@@ -1,30 +0,0 @@
-From bcface37cf6df3f3b0800f79e4282a690122b0c8 Mon Sep 17 00:00:00 2001
-From: Vincent Chen <vincent.chen@sifive.com>
-Date: Mon, 13 Sep 2021 09:41:15 +0800
-Subject: [PATCH 2/8] RISC-V: Reserve about 5K space in mcontext_t to support
- future ISA expansion.
-
-Following the changes of struct sigcontext in Linux to reserve about 5K space
-to support future ISA expansion.
-
-Signed-off-by: max.ma <max.ma@starfivetech.com>
----
- sysdeps/unix/sysv/linux/riscv/sys/ucontext.h | 2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/sysdeps/unix/sysv/linux/riscv/sys/ucontext.h b/sysdeps/unix/sysv/linux/riscv/sys/ucontext.h
-index cfafa44f99..80caf078fc 100644
---- a/sysdeps/unix/sysv/linux/riscv/sys/ucontext.h
-+++ b/sysdeps/unix/sysv/linux/riscv/sys/ucontext.h
-@@ -82,6 +82,8 @@ typedef struct mcontext_t
-   {
-     __riscv_mc_gp_state __gregs;
-     union  __riscv_mc_fp_state __fpregs;
-+    /* 5K + 256 reserved for vector state and future expansion.  */
-+    unsigned char __reserved[5376] __attribute__ ((__aligned__ (16)));
-   } mcontext_t;
- 
- /* Userlevel context.  */
--- 
-2.33.1
-

+ 3 - 3
recipes-core/glibc/glibc/0006-add-vector-support-for-memset-memcmp-memmove-memcpy-.patch → recipes-core/glibc/glibc/0002-add-vector-support-for-memset-memcmp-memmove-memcpy-.patch

@@ -1,7 +1,7 @@
-From c4c3986117a0d2b5c4e093872f471b2b5b882cee Mon Sep 17 00:00:00 2001
+From 0d709adf42cb79137b8d125eff8c4a386cf69187 Mon Sep 17 00:00:00 2001
 From: "max.ma" <max.ma@starfivetech.com>
 Date: Tue, 21 Dec 2021 17:42:04 -0800
-Subject: [PATCH 6/8] add vector support for
+Subject: [PATCH 02/19] add vector support for
  memset/memcmp/memmove/memcpy/memchr/strlen/strcmp
 
 ---
@@ -1525,5 +1525,5 @@ index c9f8fd8236..7b75bdfee2 100644
  
  # define ENTRY(name) LEAF(name)
 -- 
-2.33.1
+2.25.1
 

+ 1 - 1
recipes-core/glibc/glibc/0002-localedef-fix-ups-hardlink-to-make-it-compile.patch

@@ -1,4 +1,4 @@
-From d7bb36a9a27e5e4c3be6378493b41286513750e9 Mon Sep 17 00:00:00 2001
+From 3e391efa9b179ae886dd0942202bd2a6698e2679 Mon Sep 17 00:00:00 2001
 From: Jason Wessel <jason.wessel@windriver.com>
 Date: Sat, 7 Dec 2019 10:01:37 -0800
 Subject: [PATCH] localedef: fix-ups hardlink to make it compile

+ 6 - 6
recipes-core/glibc/glibc/0007-add-NT_RISCV_VECTOR-macro-definition-to-align-with-l.patch → recipes-core/glibc/glibc/0003-add-NT_RISCV_VECTOR-macro-definition-to-align-with-l.patch

@@ -1,18 +1,18 @@
-From 4ca3f0f9517885ab7b6c60d9ec4e3a15b83d8d82 Mon Sep 17 00:00:00 2001
+From aa022f152236190a26964971ec3a7c6b62028ad1 Mon Sep 17 00:00:00 2001
 From: "max.ma" <max.ma@starfivetech.com>
 Date: Tue, 21 Dec 2021 18:39:15 -0800
-Subject: [PATCH 7/8] add NT_RISCV_VECTOR macro definition to align with linux
- elf.h
+Subject: [PATCH 03/19] add NT_RISCV_VECTOR macro definition to align with
+ linux elf.h
 
 ---
  elf/elf.h | 1 +
  1 file changed, 1 insertion(+)
 
 diff --git a/elf/elf.h b/elf/elf.h
-index 50f87baceb..27f46afa27 100644
+index 02a1b3f52f..7d1571043d 100644
 --- a/elf/elf.h
 +++ b/elf/elf.h
-@@ -822,6 +822,7 @@ typedef struct
+@@ -829,6 +829,7 @@ typedef struct
  #define NT_MIPS_DSP	0x800		/* MIPS DSP ASE registers.  */
  #define NT_MIPS_FP_MODE	0x801		/* MIPS floating-point mode.  */
  #define NT_MIPS_MSA	0x802		/* MIPS SIMD registers.  */
@@ -21,5 +21,5 @@ index 50f87baceb..27f46afa27 100644
  /* Legal values for the note segment descriptor types for object files.  */
  
 -- 
-2.33.1
+2.25.1
 

+ 4 - 4
recipes-core/glibc/glibc/0003-nativesdk-glibc-Look-for-host-system-ld.so.cache-as-.patch

@@ -1,4 +1,4 @@
-From 776a53db6afba8a7ff4412aba88b0679227877f9 Mon Sep 17 00:00:00 2001
+From a74ac72e6a25121c99f3875cf0245a435729e897 Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Wed, 18 Mar 2015 01:48:24 +0000
 Subject: [PATCH] nativesdk-glibc: Look for host system ld.so.cache as well
@@ -30,10 +30,10 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
  1 file changed, 8 insertions(+), 8 deletions(-)
 
 diff --git a/elf/dl-load.c b/elf/dl-load.c
-index a08df001af..d09daf9e41 100644
+index 1ad0868dad..c5e235d918 100644
 --- a/elf/dl-load.c
 +++ b/elf/dl-load.c
-@@ -2196,6 +2196,14 @@ _dl_map_object (struct link_map *loader, const char *name,
+@@ -2109,6 +2109,14 @@ _dl_map_object (struct link_map *loader, const char *name,
              }
          }
  
@@ -48,7 +48,7 @@ index a08df001af..d09daf9e41 100644
  #ifdef USE_LDCONFIG
        if (fd == -1
  	  && (__glibc_likely ((mode & __RTLD_SECURE) == 0)
-@@ -2254,14 +2262,6 @@ _dl_map_object (struct link_map *loader, const char *name,
+@@ -2167,14 +2175,6 @@ _dl_map_object (struct link_map *loader, const char *name,
  	}
  #endif
  

+ 0 - 61
recipes-core/glibc/glibc/0004-RISC-V-Extend-MINSIGSTKSZ-and-SIGSTKSZ-to-backup-RVV.patch

@@ -1,61 +0,0 @@
-From 05c65dd1e572b489bbd85488c2897af76a143a01 Mon Sep 17 00:00:00 2001
-From: Vincent Chen <vincent.chen@sifive.com>
-Date: Mon, 13 Sep 2021 09:41:17 +0800
-Subject: [PATCH 4/8] RISC-V: Extend MINSIGSTKSZ and SIGSTKSZ to backup RVV
- registers
-
-As using RVV extension, the original MINSIGSTKSZ is not enough to
-back up all RVV registers for the normal case. Therefore, the MINSIGSTKSZ
-is expanded to about 5K and the SIGSTKSZ is expanded to about 16K. This
-space is enough for the case that the VLENB of a vector register is 128
-bytes. For the case that VLENB > 128 bytes, users can use
-sysconf (_SC_MINSIGSTKSZ) and sysconf (_SC_SIGSTKSZ) to get the
-appropriate signal stack size.
-
-Signed-off-by: max.ma <max.ma@starfivetech.com>
----
- sysdeps/unix/sysv/linux/riscv/bits/sigstack.h | 32 +++++++++++++++++++
- 1 file changed, 32 insertions(+)
- create mode 100644 sysdeps/unix/sysv/linux/riscv/bits/sigstack.h
-
-diff --git a/sysdeps/unix/sysv/linux/riscv/bits/sigstack.h b/sysdeps/unix/sysv/linux/riscv/bits/sigstack.h
-new file mode 100644
-index 0000000000..c18512f083
---- /dev/null
-+++ b/sysdeps/unix/sysv/linux/riscv/bits/sigstack.h
-@@ -0,0 +1,32 @@
-+/* sigstack, sigaltstack definitions.
-+   Copyright (C) 2021 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, see
-+   <https://www.gnu.org/licenses/>.  */
-+
-+#ifndef _BITS_SIGSTACK_H
-+#define _BITS_SIGSTACK_H 1
-+
-+#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H
-+# error "Never include this file directly.  Use <signal.h> instead"
-+#endif
-+
-+/* Minimum stack size (5k+256 bytes) for a signal handler.  */
-+#define MINSIGSTKSZ	5376
-+
-+/* System default stack size.  */
-+#define SIGSTKSZ	16384
-+
-+#endif /* bits/sigstack.h */
--- 
-2.33.1
-

+ 3 - 3
recipes-core/glibc/glibc/0008-fix-the-bcmp-unrecognized-issue.patch → recipes-core/glibc/glibc/0004-fix-the-bcmp-unrecognized-issue.patch

@@ -1,7 +1,7 @@
-From 9f30b03a901457dd59b5c0f7740f8b413f653d5f Mon Sep 17 00:00:00 2001
+From d23b3456285b4276b439f207530208cebcb2ab44 Mon Sep 17 00:00:00 2001
 From: "max.ma" <max.ma@starfivetech.com>
 Date: Sun, 16 Jan 2022 16:56:07 -0800
-Subject: [PATCH 8/8] fix the bcmp unrecognized issue
+Subject: [PATCH 04/19] fix the bcmp unrecognized issue
 
 ---
  sysdeps/riscv/rv64/multiarch/aeabi_memcpy.c  | 2 --
@@ -29,5 +29,5 @@ index f6cbc1307b..fe89f92268 100644
  libc_hidden_builtin_def (memcmp)
  
 -- 
-2.33.1
+2.25.1
 

+ 3 - 3
recipes-core/glibc/glibc/0004-nativesdk-glibc-Fix-buffer-overrun-with-a-relocated-.patch

@@ -1,4 +1,4 @@
-From df18bae1eeee55ecb9db36d13fe67c58355682eb Mon Sep 17 00:00:00 2001
+From d2f16ab250dbb93ae21e9e9286ddf696141db735 Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Wed, 18 Mar 2015 01:50:00 +0000
 Subject: [PATCH] nativesdk-glibc: Fix buffer overrun with a relocated SDK
@@ -21,10 +21,10 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
  1 file changed, 12 insertions(+)
 
 diff --git a/elf/dl-load.c b/elf/dl-load.c
-index d09daf9e41..2c6270e2a7 100644
+index c5e235d918..ce3cbfa3c4 100644
 --- a/elf/dl-load.c
 +++ b/elf/dl-load.c
-@@ -1892,7 +1892,19 @@ open_path (const char *name, size_t namelen, int mode,
+@@ -1809,7 +1809,19 @@ open_path (const char *name, size_t namelen, int mode,
         given on the command line when rtld is run directly.  */
      return -1;
  

+ 0 - 93
recipes-core/glibc/glibc/0005-RISC-V-Expand-PTHREAD_STACK_MIN-to-support-RVV-envir.patch

@@ -1,93 +0,0 @@
-From 200ea75b0643350a162a22d3a7fa1f1a056337c1 Mon Sep 17 00:00:00 2001
-From: Vincent Chen <vincent.chen@sifive.com>
-Date: Mon, 13 Sep 2021 09:41:18 +0800
-Subject: [PATCH 5/8] RISC-V: Expand PTHREAD_STACK_MIN to support RVV
- environment
-
-In order to support all pthread operations in the RVV environment, here
-PTHREAD_STACK_MIN is set to 4 times GLRO(dl_minsigstacksize), and the
-default PTHREAD_STACK_MIN is expanded to 20K bytes.
-
-Signed-off-by: max.ma <max.ma@starfivetech.com>
----
- .../sysv/linux/riscv/bits/pthread_stack_min.h | 21 ++++++++++
- .../linux/riscv/sysconf-pthread_stack_min.h   | 39 +++++++++++++++++++
- 2 files changed, 60 insertions(+)
- create mode 100644 sysdeps/unix/sysv/linux/riscv/bits/pthread_stack_min.h
- create mode 100644 sysdeps/unix/sysv/linux/riscv/sysconf-pthread_stack_min.h
-
-diff --git a/sysdeps/unix/sysv/linux/riscv/bits/pthread_stack_min.h b/sysdeps/unix/sysv/linux/riscv/bits/pthread_stack_min.h
-new file mode 100644
-index 0000000000..83585b39f3
---- /dev/null
-+++ b/sysdeps/unix/sysv/linux/riscv/bits/pthread_stack_min.h
-@@ -0,0 +1,21 @@
-+/* Definition of PTHREAD_STACK_MIN.  Linux/riscv version.
-+   Copyright (C) 2021 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, see
-+   <https://www.gnu.org/licenses/>.  */
-+
-+/* Minimum size for a thread.  We are free to choose a reasonable value.  */
-+#define PTHREAD_STACK_MIN	20480
-diff --git a/sysdeps/unix/sysv/linux/riscv/sysconf-pthread_stack_min.h b/sysdeps/unix/sysv/linux/riscv/sysconf-pthread_stack_min.h
-new file mode 100644
-index 0000000000..53ba6a1142
---- /dev/null
-+++ b/sysdeps/unix/sysv/linux/riscv/sysconf-pthread_stack_min.h
-@@ -0,0 +1,39 @@
-+/* __get_pthread_stack_min ().  Linux version.
-+   Copyright (C) 2021 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, see
-+   <https://www.gnu.org/licenses/>.  */
-+
-+/* Return sysconf (_SC_THREAD_STACK_MIN).  */
-+
-+static inline long int
-+__get_pthread_stack_min (void)
-+{
-+  /* sysconf (_SC_THREAD_STACK_MIN) >= sysconf (_SC_MINSIGSTKSZ).  */
-+  long int pthread_stack_min = GLRO(dl_minsigstacksize) * 4;
-+  assert (pthread_stack_min != 0);
-+  _Static_assert (__builtin_constant_p (PTHREAD_STACK_MIN),
-+		  "PTHREAD_STACK_MIN is constant");
-+  /* Return MAX (PTHREAD_STACK_MIN, pthread_stack_min).  */
-+  if (pthread_stack_min < PTHREAD_STACK_MIN)
-+    pthread_stack_min = PTHREAD_STACK_MIN;
-+  /* We have a private interface, __pthread_get_minstack@GLIBC_PRIVATE
-+     which returns a larger size that includes the required TLS variable
-+     space which has been determined at startup.  For sysconf here we are
-+     conservative and don't include the space required for TLS access.
-+     Eventually the TLS variable space will not be part of the stack
-+     (Bug 11787).  */
-+  return pthread_stack_min;
-+}
--- 
-2.33.1
-

+ 14 - 14
recipes-core/glibc/glibc/0005-nativesdk-glibc-Raise-the-size-of-arrays-containing-.patch

@@ -1,4 +1,4 @@
-From 6af8ce8eceed86addbc188f773a2d36d83ee4042 Mon Sep 17 00:00:00 2001
+From 2d41508ed1059df2df9994d35d870be2005f575f Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Wed, 18 Mar 2015 01:51:38 +0000
 Subject: [PATCH] nativesdk-glibc: Raise the size of arrays containing dl paths
@@ -26,10 +26,10 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
  8 files changed, 16 insertions(+), 10 deletions(-)
 
 diff --git a/elf/dl-cache.c b/elf/dl-cache.c
-index 2b8da8650d..3d9787bda4 100644
+index 8bbf110d02..c02a95d9b5 100644
 --- a/elf/dl-cache.c
 +++ b/elf/dl-cache.c
-@@ -355,6 +355,10 @@ search_cache (const char *string_table, uint32_t string_table_size,
+@@ -352,6 +352,10 @@ search_cache (const char *string_table, uint32_t string_table_size,
    return best;
  }
  
@@ -41,10 +41,10 @@ index 2b8da8650d..3d9787bda4 100644
  _dl_cache_libcmp (const char *p1, const char *p2)
  {
 diff --git a/elf/dl-load.c b/elf/dl-load.c
-index 2c6270e2a7..23018d2f7e 100644
+index ce3cbfa3c4..e116db24a1 100644
 --- a/elf/dl-load.c
 +++ b/elf/dl-load.c
-@@ -115,8 +115,8 @@ enum { ncapstr = 1, max_capstrlen = 0 };
+@@ -117,8 +117,8 @@ enum { ncapstr = 1, max_capstrlen = 0 };
     gen-trusted-dirs.awk.  */
  #include "trusted-dirs.h"
  
@@ -56,7 +56,7 @@ index 2c6270e2a7..23018d2f7e 100644
    SYSTEM_DIRS_LEN
  };
 diff --git a/elf/dl-usage.c b/elf/dl-usage.c
-index 5ad3a72559..88f26d3692 100644
+index 98d8c98948..77ca98cbf9 100644
 --- a/elf/dl-usage.c
 +++ b/elf/dl-usage.c
 @@ -25,6 +25,8 @@
@@ -87,7 +87,7 @@ index 5ad3a72559..88f26d3692 100644
    print_hwcaps_subdirectories (state);
    print_legacy_hwcap_directories ();
 diff --git a/elf/interp.c b/elf/interp.c
-index 91966702ca..dc86c20e83 100644
+index d82af036d1..9d282b2769 100644
 --- a/elf/interp.c
 +++ b/elf/interp.c
 @@ -18,5 +18,5 @@
@@ -98,10 +98,10 @@ index 91966702ca..dc86c20e83 100644
 +const char __invoke_dynamic_linker__[4096] __attribute__ ((section (".interp")))
    = RUNTIME_LINKER;
 diff --git a/elf/ldconfig.c b/elf/ldconfig.c
-index 1037e8d0cf..ffdac84952 100644
+index 9394ac6438..7f66b1a460 100644
 --- a/elf/ldconfig.c
 +++ b/elf/ldconfig.c
-@@ -177,6 +177,9 @@ static struct argp argp =
+@@ -176,6 +176,9 @@ static struct argp argp =
    options, parse_opt, NULL, doc, NULL, more_help, NULL
  };
  
@@ -112,10 +112,10 @@ index 1037e8d0cf..ffdac84952 100644
     a platform.  */
  static int
 diff --git a/elf/rtld.c b/elf/rtld.c
-index fbbd60b446..fce9940f80 100644
+index cbbaf4a331..d2d27a0127 100644
 --- a/elf/rtld.c
 +++ b/elf/rtld.c
-@@ -185,6 +185,7 @@ dso_name_valid_for_suid (const char *p)
+@@ -189,6 +189,7 @@ dso_name_valid_for_suid (const char *p)
      }
    return *p != '\0';
  }
@@ -124,10 +124,10 @@ index fbbd60b446..fce9940f80 100644
  static void
  audit_list_init (struct audit_list *list)
 diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
-index 62bee28769..67b60dc88c 100644
+index f069e28323..6288f715ba 100644
 --- a/iconv/gconv_conf.c
 +++ b/iconv/gconv_conf.c
-@@ -36,7 +36,7 @@
+@@ -35,7 +35,7 @@
  #include <gconv_parseconfdir.h>
  
  /* This is the default path where we look for module lists.  */
@@ -137,7 +137,7 @@ index 62bee28769..67b60dc88c 100644
  /* Type to represent search path.  */
  struct path_elem
 diff --git a/sysdeps/generic/dl-cache.h b/sysdeps/generic/dl-cache.h
-index 964d50a486..94bf68ca9d 100644
+index 93d4bea930..5249176441 100644
 --- a/sysdeps/generic/dl-cache.h
 +++ b/sysdeps/generic/dl-cache.h
 @@ -34,10 +34,6 @@

+ 7 - 7
recipes-core/glibc/glibc/0011-riscv-Resolve-symbols-directly-for-symbols-with-STO_.patch → recipes-core/glibc/glibc/0005-riscv-Resolve-symbols-directly-for-symbols-with-STO_.patch

@@ -1,7 +1,7 @@
-From fac8b2beac5d568ca0ed7f5e04a347befda44f58 Mon Sep 17 00:00:00 2001
+From 66e355177a3c5f637852e47290878e06a7f95c32 Mon Sep 17 00:00:00 2001
 From: Hsiangkai Wang <kai.wang@sifive.com>
 Date: Tue, 18 Jan 2022 12:31:59 +0800
-Subject: [PATCH 11/12] riscv: Resolve symbols directly for symbols with
+Subject: [PATCH 05/19] riscv: Resolve symbols directly for symbols with
  STO_RISCV_VARIANT_CC.
 
 In some cases, we do not want to go through the resolver for function
@@ -27,10 +27,10 @@ Signed-off-by: Vincent Chen <vincent.chen@sifive.com>
  create mode 100644 sysdeps/riscv/dl-dtprocnum.h
 
 diff --git a/elf/elf.h b/elf/elf.h
-index 27f46afa27..cc62deca0d 100644
+index 7d1571043d..27009bdbc0 100644
 --- a/elf/elf.h
 +++ b/elf/elf.h
-@@ -3907,6 +3907,13 @@ enum
+@@ -3925,6 +3925,13 @@ enum
  
  #define R_TILEGX_NUM		130
  
@@ -89,7 +89,7 @@ index 0000000000..f189fd700a
 +   default there are none.  */
 +#define DT_THISPROCNUM	DT_RISCV_NUM
 diff --git a/sysdeps/riscv/dl-machine.h b/sysdeps/riscv/dl-machine.h
-index ce2b3c3875..22e3c81706 100644
+index dfedc9801d..11523ae627 100644
 --- a/sysdeps/riscv/dl-machine.h
 +++ b/sysdeps/riscv/dl-machine.h
 @@ -53,6 +53,9 @@
@@ -102,7 +102,7 @@ index ce2b3c3875..22e3c81706 100644
  /* Return nonzero iff ELF header is compatible with the running host.  */
  static inline int __attribute_used__
  elf_machine_matches_host (const ElfW(Ehdr) *ehdr)
-@@ -299,6 +302,29 @@ elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
+@@ -281,6 +284,29 @@ elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
    /* Check for unexpected PLT reloc type.  */
    if (__glibc_likely (r_type == R_RISCV_JUMP_SLOT))
      {
@@ -133,5 +133,5 @@ index ce2b3c3875..22e3c81706 100644
  	{
  	  if (l_addr)
 -- 
-2.33.1
+2.25.1
 

+ 3 - 3
recipes-core/glibc/glibc/0013-change-memcpy_vector-LMUL-to-m8.patch → recipes-core/glibc/glibc/0006-change-memcpy_vector-LMUL-to-m8.patch

@@ -1,7 +1,7 @@
-From 5ba1268621eb208a5ed4a8ce2bbb6ae3392046a7 Mon Sep 17 00:00:00 2001
+From 8c1459b734f8cfe1562d72ad302d3dfa55fa85e7 Mon Sep 17 00:00:00 2001
 From: "max.ma" <max.ma@starfivetech.com>
 Date: Mon, 28 Feb 2022 18:49:58 -0800
-Subject: [PATCH 13/13] change memcpy_vector LMUL to m8
+Subject: [PATCH 06/19] change memcpy_vector LMUL to m8
 
 ---
  sysdeps/riscv/rv64/multiarch/memcpy_vector.S | 4 ++--
@@ -29,5 +29,5 @@ index 2319647de8..bae330f6e0 100644
  	add	a1, a1, t0
  	sub	a2, a2, t0
 -- 
-2.33.1
+2.25.1
 

+ 9 - 5
recipes-core/glibc/glibc/0006-nativesdk-glibc-Allow-64-bit-atomics-for-x86.patch

@@ -1,4 +1,4 @@
-From b30f380cd88ae181a4a6a3a4784206ffe3ccd19b Mon Sep 17 00:00:00 2001
+From 946d1cadf0bb54216409e8e0eb09be3e96044dbf Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Thu, 31 Dec 2015 14:35:35 -0800
 Subject: [PATCH] nativesdk-glibc: Allow 64 bit atomics for x86
@@ -13,14 +13,14 @@ Signed-off-by: Juro Bystricky <juro.bystricky@intel.com>
 Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
 Signed-off-by: Khem Raj <raj.khem@gmail.com>
 ---
- sysdeps/x86/atomic-machine.h | 3 +--
- 1 file changed, 1 insertion(+), 2 deletions(-)
+ sysdeps/x86/atomic-machine.h | 7 +------
+ 1 file changed, 1 insertion(+), 6 deletions(-)
 
 diff --git a/sysdeps/x86/atomic-machine.h b/sysdeps/x86/atomic-machine.h
-index 695222e4fa..9d39bfdbd5 100644
+index f24f1c71ed..574487ca54 100644
 --- a/sysdeps/x86/atomic-machine.h
 +++ b/sysdeps/x86/atomic-machine.h
-@@ -52,15 +52,14 @@ typedef uintmax_t uatomic_max_t;
+@@ -26,19 +26,14 @@
  #define LOCK_PREFIX "lock;"
  
  #define USE_ATOMIC_COMPILER_BUILTINS	1
@@ -33,6 +33,10 @@ index 695222e4fa..9d39bfdbd5 100644
  # define BR_CONSTRAINT			"q"
  # define IBR_CONSTRAINT			"iq"
  #else
+-/* Since the Pentium, i386 CPUs have supported 64-bit atomics, but the
+-   i386 psABI supplement provides only 4-byte alignment for uint64_t
+-   inside structs, so it is currently not possible to use 64-bit
+-   atomics on this platform.  */
 -# define __HAVE_64B_ATOMICS		0
  # define SP_REG				"esp"
  # define SEG_REG			"gs"

+ 182 - 0
recipes-core/glibc/glibc/0007-add-header-files-for-vector-support.patch

@@ -0,0 +1,182 @@
+From 850779729c6da29f45bc10b2fa4f500c9edfd19b Mon Sep 17 00:00:00 2001
+From: "max.ma" <max.ma@starfivetech.com>
+Date: Tue, 6 Sep 2022 02:21:53 -0700
+Subject: [PATCH 07/19] add header files for vector support
+
+cx
+---
+ sysdeps/riscv/rtld-global-offsets.sym         |  7 ++++
+ sysdeps/unix/sysv/linux/riscv/bits/hwcap.h    | 31 +++++++++++++++
+ .../sysv/linux/riscv/bits/pthread_stack_min.h | 21 ++++++++++
+ sysdeps/unix/sysv/linux/riscv/bits/sigstack.h | 32 +++++++++++++++
+ .../linux/riscv/sysconf-pthread_stack_min.h   | 39 +++++++++++++++++++
+ 5 files changed, 130 insertions(+)
+ create mode 100644 sysdeps/riscv/rtld-global-offsets.sym
+ create mode 100644 sysdeps/unix/sysv/linux/riscv/bits/hwcap.h
+ create mode 100644 sysdeps/unix/sysv/linux/riscv/bits/pthread_stack_min.h
+ create mode 100644 sysdeps/unix/sysv/linux/riscv/bits/sigstack.h
+ create mode 100644 sysdeps/unix/sysv/linux/riscv/sysconf-pthread_stack_min.h
+
+diff --git a/sysdeps/riscv/rtld-global-offsets.sym b/sysdeps/riscv/rtld-global-offsets.sym
+new file mode 100644
+index 0000000000..ff4e97f2a6
+--- /dev/null
++++ b/sysdeps/riscv/rtld-global-offsets.sym
+@@ -0,0 +1,7 @@
++#define SHARED 1
++
++#include <ldsodefs.h>
++
++#define rtld_global_ro_offsetof(mem) offsetof (struct rtld_global_ro, mem)
++
++RTLD_GLOBAL_RO_DL_HWCAP_OFFSET	rtld_global_ro_offsetof (_dl_hwcap)
+diff --git a/sysdeps/unix/sysv/linux/riscv/bits/hwcap.h b/sysdeps/unix/sysv/linux/riscv/bits/hwcap.h
+new file mode 100644
+index 0000000000..dbd101fa2e
+--- /dev/null
++++ b/sysdeps/unix/sysv/linux/riscv/bits/hwcap.h
+@@ -0,0 +1,31 @@
++/* Defines for bits in AT_HWCAP.  RISC-V Linux version.
++   Copyright (C) 2022 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, see
++   <http://www.gnu.org/licenses/>.  */
++
++#if !defined (_SYS_AUXV_H) && !defined (_LINUX_RISCV_SYSDEP_H)
++# error "Never include <bits/hwcap.h> directly; use <sys/auxv.h> instead."
++#endif
++
++/* The following must match the kernel's <asm/hwcap.h>.  */
++#define HWCAP_ISA_I      0x100		//(1 << ('I' - 'A'))
++#define HWCAP_ISA_M      0x1000 	//(1 << ('M' - 'A'))
++#define HWCAP_ISA_A      0x1		//(1 << ('A' - 'A'))
++#define HWCAP_ISA_F      0x20		//(1 << ('F' - 'A'))
++#define HWCAP_ISA_D      0x8		//(1 << ('D' - 'A'))
++#define HWCAP_ISA_C      0x4		//(1 << ('C' - 'A'))
++#define HWCAP_ISA_V      0x200000	//(1 << ('V' - 'A'))
++
+diff --git a/sysdeps/unix/sysv/linux/riscv/bits/pthread_stack_min.h b/sysdeps/unix/sysv/linux/riscv/bits/pthread_stack_min.h
+new file mode 100644
+index 0000000000..0ab7feb4a7
+--- /dev/null
++++ b/sysdeps/unix/sysv/linux/riscv/bits/pthread_stack_min.h
+@@ -0,0 +1,21 @@
++/* Definition of PTHREAD_STACK_MIN.  Linux/riscv version.
++   Copyright (C) 2022 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, see
++   <https://www.gnu.org/licenses/>.  */
++
++/* Minimum size for a thread.  We are free to choose a reasonable value.  */
++#define PTHREAD_STACK_MIN	20480
+diff --git a/sysdeps/unix/sysv/linux/riscv/bits/sigstack.h b/sysdeps/unix/sysv/linux/riscv/bits/sigstack.h
+new file mode 100644
+index 0000000000..c75ddc03b0
+--- /dev/null
++++ b/sysdeps/unix/sysv/linux/riscv/bits/sigstack.h
+@@ -0,0 +1,32 @@
++/* sigstack, sigaltstack definitions.
++   Copyright (C) 2022 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, see
++   <https://www.gnu.org/licenses/>.  */
++
++#ifndef _BITS_SIGSTACK_H
++#define _BITS_SIGSTACK_H 1
++
++#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H
++# error "Never include this file directly.  Use <signal.h> instead"
++#endif
++
++/* Minimum stack size (5k+256 bytes) for a signal handler.  */
++#define MINSIGSTKSZ	5376
++
++/* System default stack size.  */
++#define SIGSTKSZ	16384
++
++#endif /* bits/sigstack.h */
+diff --git a/sysdeps/unix/sysv/linux/riscv/sysconf-pthread_stack_min.h b/sysdeps/unix/sysv/linux/riscv/sysconf-pthread_stack_min.h
+new file mode 100644
+index 0000000000..53ba6a1142
+--- /dev/null
++++ b/sysdeps/unix/sysv/linux/riscv/sysconf-pthread_stack_min.h
+@@ -0,0 +1,39 @@
++/* __get_pthread_stack_min ().  Linux version.
++   Copyright (C) 2021 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, see
++   <https://www.gnu.org/licenses/>.  */
++
++/* Return sysconf (_SC_THREAD_STACK_MIN).  */
++
++static inline long int
++__get_pthread_stack_min (void)
++{
++  /* sysconf (_SC_THREAD_STACK_MIN) >= sysconf (_SC_MINSIGSTKSZ).  */
++  long int pthread_stack_min = GLRO(dl_minsigstacksize) * 4;
++  assert (pthread_stack_min != 0);
++  _Static_assert (__builtin_constant_p (PTHREAD_STACK_MIN),
++		  "PTHREAD_STACK_MIN is constant");
++  /* Return MAX (PTHREAD_STACK_MIN, pthread_stack_min).  */
++  if (pthread_stack_min < PTHREAD_STACK_MIN)
++    pthread_stack_min = PTHREAD_STACK_MIN;
++  /* We have a private interface, __pthread_get_minstack@GLIBC_PRIVATE
++     which returns a larger size that includes the required TLS variable
++     space which has been determined at startup.  For sysconf here we are
++     conservative and don't include the space required for TLS access.
++     Eventually the TLS variable space will not be part of the stack
++     (Bug 11787).  */
++  return pthread_stack_min;
++}
+-- 
+2.25.1
+

+ 11 - 11
recipes-core/glibc/glibc/0007-nativesdk-glibc-Make-relocatable-install-for-locales.patch

@@ -1,4 +1,4 @@
-From 24bffe9c2645cd6542e29cb57786dc703cced07b Mon Sep 17 00:00:00 2001
+From ce4e796fa8bd2df962cf7a0e4bc69ab6181e4ebf Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Fri, 3 Aug 2018 09:55:12 -0700
 Subject: [PATCH] nativesdk-glibc: Make relocatable install for locales
@@ -19,10 +19,10 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
  4 files changed, 8 insertions(+), 7 deletions(-)
 
 diff --git a/locale/findlocale.c b/locale/findlocale.c
-index ab09122b0c..f42cc75780 100644
+index fc433b61d8..d6f030f13c 100644
 --- a/locale/findlocale.c
 +++ b/locale/findlocale.c
-@@ -56,7 +56,7 @@ struct __locale_data *const _nl_C[] attribute_hidden =
+@@ -55,7 +55,7 @@ struct __locale_data *const _nl_C[] attribute_hidden =
     which are somehow addressed.  */
  struct loaded_l10nfile *_nl_locale_file_list[__LC_LAST];
  
@@ -31,7 +31,7 @@ index ab09122b0c..f42cc75780 100644
  
  /* 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,
+@@ -165,7 +165,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;
@@ -41,7 +41,7 @@ index ab09122b0c..f42cc75780 100644
    else
      /* We really have to load some data.  First see whether the name is
 diff --git a/locale/loadarchive.c b/locale/loadarchive.c
-index 512769eaec..436619091b 100644
+index fcc4913319..62cae8c6c0 100644
 --- a/locale/loadarchive.c
 +++ b/locale/loadarchive.c
 @@ -42,7 +42,7 @@
@@ -54,10 +54,10 @@ index 512769eaec..436619091b 100644
  /* Size of initial mapping window, optimal if large enough to
     cover the header plus the initial locale.  */
 diff --git a/locale/localeinfo.h b/locale/localeinfo.h
-index b3d4da0185..22f9dc1140 100644
+index fd43033a19..3dc26272a0 100644
 --- a/locale/localeinfo.h
 +++ b/locale/localeinfo.h
-@@ -331,7 +331,7 @@ _nl_lookup_word (locale_t l, int category, int item)
+@@ -347,7 +347,7 @@ _nl_lookup_word (locale_t l, int category, int item)
  }
  
  /* Default search path if no LOCPATH environment variable.  */
@@ -67,10 +67,10 @@ index b3d4da0185..22f9dc1140 100644
  /* 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/locale/programs/locale.c b/locale/programs/locale.c
-index ca0a95be99..6b98895203 100644
+index 1b51b50d68..87c9049444 100644
 --- a/locale/programs/locale.c
 +++ b/locale/programs/locale.c
-@@ -632,6 +632,7 @@ nameentcmp (const void *a, const void *b)
+@@ -631,6 +631,7 @@ nameentcmp (const void *a, const void *b)
  		  ((const struct nameent *) b)->name);
  }
  
@@ -78,7 +78,7 @@ index ca0a95be99..6b98895203 100644
  
  static int
  write_archive_locales (void **all_datap, char *linebuf)
-@@ -645,7 +646,7 @@ write_archive_locales (void **all_datap, char *linebuf)
+@@ -644,7 +645,7 @@ write_archive_locales (void **all_datap, char *linebuf)
    int fd, ret = 0;
    uint32_t cnt;
  
@@ -87,7 +87,7 @@ index ca0a95be99..6b98895203 100644
    if (fd < 0)
      return 0;
  
-@@ -700,8 +701,8 @@ write_archive_locales (void **all_datap, char *linebuf)
+@@ -699,8 +700,8 @@ write_archive_locales (void **all_datap, char *linebuf)
  	  if (cnt)
  	    putchar_unlocked ('\n');
  

+ 2 - 2
recipes-core/glibc/glibc/0008-nativesdk-glibc-Fall-back-to-faccessat-on-faccess2-r.patch

@@ -1,4 +1,4 @@
-From 2761400989bcbf11e10bc85f90c3a2ba1305c4ae Mon Sep 17 00:00:00 2001
+From 95508f06f13604ed96f28d18eb1670ea1ed02063 Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Sat, 6 Mar 2021 14:48:56 -0800
 Subject: [PATCH] nativesdk-glibc: Fall back to faccessat on faccess2 returns
@@ -14,7 +14,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
  1 file changed, 5 insertions(+), 1 deletion(-)
 
 diff --git a/sysdeps/unix/sysv/linux/faccessat.c b/sysdeps/unix/sysv/linux/faccessat.c
-index 13160d3249..ee3ddc9b79 100644
+index 1378bb2db8..19f2044172 100644
 --- a/sysdeps/unix/sysv/linux/faccessat.c
 +++ b/sysdeps/unix/sysv/linux/faccessat.c
 @@ -30,7 +30,11 @@ __faccessat (int fd, const char *file, int mode, int flag)

+ 598 - 0
recipes-core/glibc/glibc/0008-prohibit-from-generating-plt-table-when-static-linki.patch

@@ -0,0 +1,598 @@
+From 3549fcbe22dab50b01361db0d8e5542879ccdfc2 Mon Sep 17 00:00:00 2001
+From: "max.ma" <max.ma@starfivetech.com>
+Date: Wed, 15 Jun 2022 00:10:33 -0700
+Subject: [PATCH 08/19] prohibit from generating plt table when static linking
+
+---
+ sysdeps/riscv/rv64/multiarch/ifunc-impl-list.c |  4 ++--
+ sysdeps/riscv/rv64/multiarch/memchr.c          |  5 ++++-
+ sysdeps/riscv/rv64/multiarch/memchr_as.S       |  2 ++
+ sysdeps/riscv/rv64/multiarch/memchr_riscv.S    | 10 +++++++++-
+ sysdeps/riscv/rv64/multiarch/memchr_vector.S   |  6 ++++--
+ sysdeps/riscv/rv64/multiarch/memcmp.c          |  6 +++++-
+ sysdeps/riscv/rv64/multiarch/memcmp_riscv.c    |  9 +++++++--
+ sysdeps/riscv/rv64/multiarch/memcmp_vector.S   |  7 +++++--
+ sysdeps/riscv/rv64/multiarch/memcpy.c          |  5 ++++-
+ sysdeps/riscv/rv64/multiarch/memcpy_riscv.S    | 11 ++++++++++-
+ sysdeps/riscv/rv64/multiarch/memcpy_vector.S   |  6 ++++--
+ sysdeps/riscv/rv64/multiarch/memmove.c         |  5 ++++-
+ sysdeps/riscv/rv64/multiarch/memmove_riscv.c   |  6 ++++--
+ sysdeps/riscv/rv64/multiarch/memmove_vector.S  |  8 +++++---
+ sysdeps/riscv/rv64/multiarch/memset.c          |  5 ++++-
+ sysdeps/riscv/rv64/multiarch/memset_riscv.c    |  6 ++++--
+ sysdeps/riscv/rv64/multiarch/memset_vector.S   |  7 ++++---
+ sysdeps/riscv/rv64/multiarch/rtld-memcmp.c     |  2 +-
+ sysdeps/riscv/rv64/multiarch/rtld-memmove.c    |  2 +-
+ sysdeps/riscv/rv64/multiarch/rtld-memset.c     |  2 +-
+ sysdeps/riscv/rv64/multiarch/rtld-strlen.c     |  2 +-
+ sysdeps/riscv/rv64/multiarch/strcmp.c          |  5 ++++-
+ sysdeps/riscv/rv64/multiarch/strcmp_riscv.S    | 12 ++++++++----
+ sysdeps/riscv/rv64/multiarch/strcmp_vector.S   |  7 ++++---
+ sysdeps/riscv/rv64/multiarch/strlen.c          |  5 ++++-
+ sysdeps/riscv/rv64/multiarch/strlen_riscv.c    |  7 +++++--
+ sysdeps/riscv/rv64/multiarch/strlen_vector.S   |  6 ++++--
+ 27 files changed, 114 insertions(+), 44 deletions(-)
+
+diff --git a/sysdeps/riscv/rv64/multiarch/ifunc-impl-list.c b/sysdeps/riscv/rv64/multiarch/ifunc-impl-list.c
+index 28c6e123f0..1a6611ab88 100644
+--- a/sysdeps/riscv/rv64/multiarch/ifunc-impl-list.c
++++ b/sysdeps/riscv/rv64/multiarch/ifunc-impl-list.c
+@@ -30,7 +30,7 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
+ 			size_t max)
+ {
+   size_t i = 0;
+-
++#if defined SHARED && defined __riscv_vector
+   bool use_rvv = (GLRO(dl_hwcap) & HWCAP_ISA_V) != 0;
+ 
+   IFUNC_IMPL (i, name, memcpy,
+@@ -60,6 +60,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
+   IFUNC_IMPL (i, name, memset,
+ 	      IFUNC_IMPL_ADD (array, i, memset, use_rvv, __memset_vector)
+ 	      IFUNC_IMPL_ADD (array, i, memset, 1, __memset_riscv));
+-
++#endif
+   return i;
+ }
+diff --git a/sysdeps/riscv/rv64/multiarch/memchr.c b/sysdeps/riscv/rv64/multiarch/memchr.c
+index 1544bc3d01..0a059b2977 100644
+--- a/sysdeps/riscv/rv64/multiarch/memchr.c
++++ b/sysdeps/riscv/rv64/multiarch/memchr.c
+@@ -17,7 +17,8 @@
+    License along with the GNU C Library; if not, see
+    <https://www.gnu.org/licenses/>.  */
+ 
+-#if IS_IN (libc)
++#if IS_IN (libc) && defined SHARED && defined __riscv_vector  
++
+ # define memchr __redirect_memchr
+ # include <string.h>
+ # undef memchr
+@@ -29,4 +30,6 @@
+ 
+ riscv_libc_ifunc_redirected (__redirect_memchr, memchr, IFUNC_SELECTOR);
+ riscv_libc_ifunc_hidden_def (__redirect_memchr, memchr);
++#else 
++# include <string.h>
+ #endif
+diff --git a/sysdeps/riscv/rv64/multiarch/memchr_as.S b/sysdeps/riscv/rv64/multiarch/memchr_as.S
+index 557098afda..b8691744f3 100644
+--- a/sysdeps/riscv/rv64/multiarch/memchr_as.S
++++ b/sysdeps/riscv/rv64/multiarch/memchr_as.S
+@@ -19,6 +19,8 @@
+ 
+ #include <sysdep.h>
+ 
++	.p2align 6
++
+ ENTRY (memchr)
+    zext.b	a3,a1
+    beqz	a2, .L_not_found
+diff --git a/sysdeps/riscv/rv64/multiarch/memchr_riscv.S b/sysdeps/riscv/rv64/multiarch/memchr_riscv.S
+index ce7b64bbe0..ee4394fef9 100644
+--- a/sysdeps/riscv/rv64/multiarch/memchr_riscv.S
++++ b/sysdeps/riscv/rv64/multiarch/memchr_riscv.S
+@@ -18,8 +18,16 @@
+ 
+ #include <sysdep.h>
+ 
++#if IS_IN (libc) && defined SHARED && defined __riscv_vector
++
+ #define memchr __memchr_riscv
+ #undef libc_hidden_builtin_def
+ #define libc_hidden_builtin_def(name)
++#include "memchr_as.S"
++
++
++#elif !defined __riscv_vector
++
++#include "memchr_as.S"
+ 
+-#include "memchr_as.S"
+\ No newline at end of file
++#endif
+\ No newline at end of file
+diff --git a/sysdeps/riscv/rv64/multiarch/memchr_vector.S b/sysdeps/riscv/rv64/multiarch/memchr_vector.S
+index 77693d716d..9441ddb489 100644
+--- a/sysdeps/riscv/rv64/multiarch/memchr_vector.S
++++ b/sysdeps/riscv/rv64/multiarch/memchr_vector.S
+@@ -19,11 +19,12 @@
+ #include <sysdep.h>
+ 
+ /* For __riscv_vector this file defines memchr.  */
+-/* #ifndef __riscv_vector */
++#ifdef __riscv_vector 
++#ifdef SHARED
+ # define memchr __memchr_vector
+ # undef libc_hidden_builtin_def
+ # define libc_hidden_builtin_def(a)
+-/* #endif */
++#endif
+ 
+ 	.p2align 6
+ ENTRY (memchr)
+@@ -51,3 +52,4 @@ ENTRY (memchr)
+    ret
+ END (memchr)
+ libc_hidden_builtin_def (memchr)
++#endif
+\ No newline at end of file
+diff --git a/sysdeps/riscv/rv64/multiarch/memcmp.c b/sysdeps/riscv/rv64/multiarch/memcmp.c
+index 29730c6ed1..3dab42ea74 100644
+--- a/sysdeps/riscv/rv64/multiarch/memcmp.c
++++ b/sysdeps/riscv/rv64/multiarch/memcmp.c
+@@ -17,7 +17,8 @@
+    License along with the GNU C Library; if not, see
+    <https://www.gnu.org/licenses/>.  */
+ 
+-#if IS_IN (libc)
++#if IS_IN (libc) && defined SHARED && defined __riscv_vector
++
+ # define memcmp __redirect_memcmp
+ # include <string.h>
+ # undef memcmp
+@@ -29,4 +30,7 @@
+ 
+ riscv_libc_ifunc_redirected (__redirect_memcmp, memcmp, IFUNC_SELECTOR);
+ riscv_libc_ifunc_hidden_def (__redirect_memcmp, memcmp);
++
++#else 
++# include <string.h>
+ #endif
+diff --git a/sysdeps/riscv/rv64/multiarch/memcmp_riscv.c b/sysdeps/riscv/rv64/multiarch/memcmp_riscv.c
+index dda15d7d35..076431132b 100644
+--- a/sysdeps/riscv/rv64/multiarch/memcmp_riscv.c
++++ b/sysdeps/riscv/rv64/multiarch/memcmp_riscv.c
+@@ -16,14 +16,19 @@
+    License along with the GNU C Library; if not, see
+    <https://www.gnu.org/licenses/>.  */
+ 
+-#if IS_IN (libc)
++#if IS_IN (libc) && defined SHARED && defined __riscv_vector
++
+ #undef libc_hidden_builtin_def
+ #define libc_hidden_builtin_def(name)
+ 
+ #undef weak_alias
+ #  define MEMCMP __memcmp_riscv
+ # include <string/memcmp.c>
+-#else
+ 
++#elif !defined __riscv_vector
+ # include <string/memcmp.c>
++
+ #endif
++
++
++
+diff --git a/sysdeps/riscv/rv64/multiarch/memcmp_vector.S b/sysdeps/riscv/rv64/multiarch/memcmp_vector.S
+index fe89f92268..4810af026a 100644
+--- a/sysdeps/riscv/rv64/multiarch/memcmp_vector.S
++++ b/sysdeps/riscv/rv64/multiarch/memcmp_vector.S
+@@ -20,10 +20,13 @@
+ 
+ /* For __riscv_vector this file defines strcmp.  */
+ /* #ifndef __riscv_vector */
++
++#ifdef __riscv_vector 
++#ifdef SHARED
+ # define memcmp __memcmp_vector
+ # undef libc_hidden_builtin_def
+ # define libc_hidden_builtin_def(a)
+-/* #endif */
++#endif 
+ 
+ 	.p2align 6
+ ENTRY (memcmp)
+@@ -54,4 +57,4 @@ ENTRY (memcmp)
+ END (memcmp)
+ weak_alias (memcmp, bcmp)
+ libc_hidden_builtin_def (memcmp)
+-
++#endif
+diff --git a/sysdeps/riscv/rv64/multiarch/memcpy.c b/sysdeps/riscv/rv64/multiarch/memcpy.c
+index 0f20b7fd44..45cf14f52a 100644
+--- a/sysdeps/riscv/rv64/multiarch/memcpy.c
++++ b/sysdeps/riscv/rv64/multiarch/memcpy.c
+@@ -17,7 +17,8 @@
+    License along with the GNU C Library; if not, see
+    <https://www.gnu.org/licenses/>.  */
+ 
+-#if IS_IN (libc)
++#if IS_IN (libc) && defined SHARED && defined __riscv_vector
++
+ # define memcpy __redirect_memcpy
+ # include <string.h>
+ # undef memcpy
+@@ -30,4 +31,6 @@
+ riscv_libc_ifunc_redirected (__redirect_memcpy, memcpy, IFUNC_SELECTOR);
+ 
+ riscv_libc_ifunc_hidden_def (__redirect_memcpy, memcpy);
++#else 
++# include <string.h>
+ #endif
+diff --git a/sysdeps/riscv/rv64/multiarch/memcpy_riscv.S b/sysdeps/riscv/rv64/multiarch/memcpy_riscv.S
+index a0ba2150fc..249d4f6067 100644
+--- a/sysdeps/riscv/rv64/multiarch/memcpy_riscv.S
++++ b/sysdeps/riscv/rv64/multiarch/memcpy_riscv.S
+@@ -18,8 +18,17 @@
+ 
+ #include <sysdep.h>
+ 
++#if IS_IN (libc)  && defined SHARED && defined __riscv_vector
++
+ #define memcpy __memcpy_riscv
+ #undef libc_hidden_builtin_def
+ #define libc_hidden_builtin_def(name)
+ 
+-#include "memcpy_as.S"
+\ No newline at end of file
++#include "memcpy_as.S"
++
++#elif !defined __riscv_vector
++#include "memcpy_as.S"
++
++#endif
++
++
+diff --git a/sysdeps/riscv/rv64/multiarch/memcpy_vector.S b/sysdeps/riscv/rv64/multiarch/memcpy_vector.S
+index bae330f6e0..d15f4c3954 100644
+--- a/sysdeps/riscv/rv64/multiarch/memcpy_vector.S
++++ b/sysdeps/riscv/rv64/multiarch/memcpy_vector.S
+@@ -19,11 +19,12 @@
+ #include <sysdep.h>
+ 
+ /* For __riscv_vector this file defines memcpy.  */
+-/* #ifndef __riscv_vector */
++#ifdef __riscv_vector 
++#ifdef SHARED
+ # define memcpy __memcpy_vector
+ # undef libc_hidden_builtin_def
+ # define libc_hidden_builtin_def(a)
+-/* #endif */
++#endif
+ 
+ 	.p2align 6
+ ENTRY (memcpy)
+@@ -52,3 +53,4 @@ ENTRY (memcpy)
+ END (memcpy)
+ 
+ libc_hidden_builtin_def (memcpy)
++#endif
+\ No newline at end of file
+diff --git a/sysdeps/riscv/rv64/multiarch/memmove.c b/sysdeps/riscv/rv64/multiarch/memmove.c
+index 8d33da166d..3fc276e943 100644
+--- a/sysdeps/riscv/rv64/multiarch/memmove.c
++++ b/sysdeps/riscv/rv64/multiarch/memmove.c
+@@ -17,7 +17,7 @@
+    License along with the GNU C Library; if not, see
+    <https://www.gnu.org/licenses/>.  */
+ 
+-#if IS_IN (libc)
++#if IS_IN (libc) && defined SHARED && defined __riscv_vector
+ # define memmove __redirect_memmove
+ # include <string.h>
+ # undef memmove
+@@ -29,4 +29,7 @@
+ 
+ riscv_libc_ifunc_redirected (__redirect_memmove, memmove, IFUNC_SELECTOR);
+ riscv_libc_ifunc_hidden_def (__redirect_memmove, memmove);
++
++#else 
++# include <string.h>
+ #endif
+diff --git a/sysdeps/riscv/rv64/multiarch/memmove_riscv.c b/sysdeps/riscv/rv64/multiarch/memmove_riscv.c
+index e11a9d1a43..03708e0deb 100644
+--- a/sysdeps/riscv/rv64/multiarch/memmove_riscv.c
++++ b/sysdeps/riscv/rv64/multiarch/memmove_riscv.c
+@@ -16,14 +16,16 @@
+    License along with the GNU C Library; if not, see
+    <https://www.gnu.org/licenses/>.  */
+ 
+-#if IS_IN (libc)
++#if IS_IN (libc) && defined SHARED && defined __riscv_vector
++
+ #undef libc_hidden_builtin_def
+ #define libc_hidden_builtin_def(name)
+ 
+ #undef weak_alias
+ #  define MEMMOVE __memmove_riscv
+ # include <string/memmove.c>
+-#else
++#elif !defined __riscv_vector
+ 
+ # include <string/memmove.c>
+ #endif
++
+diff --git a/sysdeps/riscv/rv64/multiarch/memmove_vector.S b/sysdeps/riscv/rv64/multiarch/memmove_vector.S
+index 7bf89e6cf6..af748be5b2 100644
+--- a/sysdeps/riscv/rv64/multiarch/memmove_vector.S
++++ b/sysdeps/riscv/rv64/multiarch/memmove_vector.S
+@@ -19,11 +19,12 @@
+ #include <sysdep.h>
+ 
+ /* For __riscv_vector this file defines memmov.  */
+-/* #ifndef __riscv_vector */
++#ifdef __riscv_vector 
++#ifdef SHARED
+ # define memmove __memmove_vector
+ # undef libc_hidden_builtin_def
+ # define libc_hidden_builtin_def(a)
+-/* #endif */
++#endif
+ 
+ 	.p2align 6
+ ENTRY (memmove)
+@@ -53,4 +54,5 @@ ENTRY (memmove)
+ 	bltu	zero,a2,.L_backward_copy_loop
+ 	ret
+ END (memmove)
+-libc_hidden_builtin_def (memmove)
+\ No newline at end of file
++libc_hidden_builtin_def (memmove)
++#endif
+\ No newline at end of file
+diff --git a/sysdeps/riscv/rv64/multiarch/memset.c b/sysdeps/riscv/rv64/multiarch/memset.c
+index 0d3582e49f..56d7169ad1 100644
+--- a/sysdeps/riscv/rv64/multiarch/memset.c
++++ b/sysdeps/riscv/rv64/multiarch/memset.c
+@@ -17,7 +17,7 @@
+    License along with the GNU C Library; if not, see
+    <https://www.gnu.org/licenses/>.  */
+ 
+-#if IS_IN (libc)
++#if IS_IN (libc) && defined SHARED && defined __riscv_vector
+ # define memset __redirect_memset
+ # include <string.h>
+ # undef memset
+@@ -30,4 +30,7 @@
+ riscv_libc_ifunc_redirected (__redirect_memset, memset, IFUNC_SELECTOR);
+ 
+ riscv_libc_ifunc_hidden_def (__redirect_memset, memset);
++#else 
++# include <string.h>
++
+ #endif
+diff --git a/sysdeps/riscv/rv64/multiarch/memset_riscv.c b/sysdeps/riscv/rv64/multiarch/memset_riscv.c
+index 1101c10f96..de631eb187 100644
+--- a/sysdeps/riscv/rv64/multiarch/memset_riscv.c
++++ b/sysdeps/riscv/rv64/multiarch/memset_riscv.c
+@@ -16,14 +16,16 @@
+    License along with the GNU C Library; if not, see
+    <https://www.gnu.org/licenses/>.  */
+ 
+-#if IS_IN (libc)
++#if IS_IN (libc) && defined SHARED && defined __riscv_vector
+ #undef libc_hidden_builtin_def
+ #define libc_hidden_builtin_def(name)
+ 
+ #undef weak_alias
+ #  define MEMSET __memset_riscv
+ # include <string/memset.c>
+-#else
++#elif !defined __riscv_vector
+ 
+ # include <string/memset.c>
+ #endif
++
++
+diff --git a/sysdeps/riscv/rv64/multiarch/memset_vector.S b/sysdeps/riscv/rv64/multiarch/memset_vector.S
+index 54d04238d3..dc407630a6 100644
+--- a/sysdeps/riscv/rv64/multiarch/memset_vector.S
++++ b/sysdeps/riscv/rv64/multiarch/memset_vector.S
+@@ -19,12 +19,12 @@
+ 
+ #include <sysdep.h>
+ 
+-/* For __riscv_vector this file defines memcpy.  */
+-/* #ifndef __riscv_vector */
++#ifdef __riscv_vector 
++#ifdef SHARED
+ # define memset __memset_vector
+ # undef libc_hidden_builtin_def
+ # define libc_hidden_builtin_def(a)
+-/* #endif */
++#endif
+ 
+ 	.p2align 6
+ ENTRY (memset)
+@@ -43,3 +43,4 @@ ENTRY (memset)
+ 
+ END (memset)
+ libc_hidden_builtin_def (memset)
++#endif
+\ No newline at end of file
+diff --git a/sysdeps/riscv/rv64/multiarch/rtld-memcmp.c b/sysdeps/riscv/rv64/multiarch/rtld-memcmp.c
+index 25faa66478..36a22eee60 100644
+--- a/sysdeps/riscv/rv64/multiarch/rtld-memcmp.c
++++ b/sysdeps/riscv/rv64/multiarch/rtld-memcmp.c
+@@ -1 +1 @@
+-#include "memcmp_riscv.c"
++# include <string/memcmp.c>
+diff --git a/sysdeps/riscv/rv64/multiarch/rtld-memmove.c b/sysdeps/riscv/rv64/multiarch/rtld-memmove.c
+index 435c059184..90e37dbd8b 100644
+--- a/sysdeps/riscv/rv64/multiarch/rtld-memmove.c
++++ b/sysdeps/riscv/rv64/multiarch/rtld-memmove.c
+@@ -16,4 +16,4 @@
+    License along with the GNU C Library; if not, see
+    <https://www.gnu.org/licenses/>.  */
+ 
+-#include "memmove_riscv.c"
++# include <string/memmove.c>
+diff --git a/sysdeps/riscv/rv64/multiarch/rtld-memset.c b/sysdeps/riscv/rv64/multiarch/rtld-memset.c
+index eff6790df5..fa3c6f4104 100644
+--- a/sysdeps/riscv/rv64/multiarch/rtld-memset.c
++++ b/sysdeps/riscv/rv64/multiarch/rtld-memset.c
+@@ -1 +1 @@
+-#include "memset_riscv.c"
+\ No newline at end of file
++# include <string/memset.c>
+diff --git a/sysdeps/riscv/rv64/multiarch/rtld-strlen.c b/sysdeps/riscv/rv64/multiarch/rtld-strlen.c
+index 73308eb0fa..d3f1dd4a23 100644
+--- a/sysdeps/riscv/rv64/multiarch/rtld-strlen.c
++++ b/sysdeps/riscv/rv64/multiarch/rtld-strlen.c
+@@ -1 +1 @@
+-#include "strlen_riscv.c"
++# include <string/strlen.c>
+diff --git a/sysdeps/riscv/rv64/multiarch/strcmp.c b/sysdeps/riscv/rv64/multiarch/strcmp.c
+index 56969c77e8..3b65aaf55d 100644
+--- a/sysdeps/riscv/rv64/multiarch/strcmp.c
++++ b/sysdeps/riscv/rv64/multiarch/strcmp.c
+@@ -17,7 +17,7 @@
+    License along with the GNU C Library; if not, see
+    <https://www.gnu.org/licenses/>.  */
+ 
+-#if IS_IN (libc)
++#if IS_IN (libc) && defined SHARED && defined __riscv_vector
+ # define strcmp __redirect_strcmp
+ # include <string.h>
+ # undef strcmp
+@@ -30,4 +30,7 @@
+ riscv_libc_ifunc_redirected (__redirect_strcmp, strcmp, IFUNC_SELECTOR);
+ 
+ riscv_libc_ifunc_hidden_def (__redirect_strcmp, strcmp);
++#else 
++# include <string.h>
++
+ #endif
+diff --git a/sysdeps/riscv/rv64/multiarch/strcmp_riscv.S b/sysdeps/riscv/rv64/multiarch/strcmp_riscv.S
+index 93e598f0c5..f5be83d5b7 100644
+--- a/sysdeps/riscv/rv64/multiarch/strcmp_riscv.S
++++ b/sysdeps/riscv/rv64/multiarch/strcmp_riscv.S
+@@ -1,9 +1,13 @@
+ 
+-/* For __riscv_vector this file defines strcmp.  */
+-/* #ifndef __riscv_vector */
++#include <sysdep.h>
++
++#if IS_IN (libc) && defined SHARED && defined __riscv_vector
+ # define strcmp __strcmp_riscv
+ # undef libc_hidden_builtin_def
+ # define libc_hidden_builtin_def(a)
+-/* #endif */
+ 
+-#include "strcmp_.S"
+\ No newline at end of file
++#include "strcmp_.S"
++#elif !defined __riscv_vector
++
++#include "strcmp_.S"
++#endif
+diff --git a/sysdeps/riscv/rv64/multiarch/strcmp_vector.S b/sysdeps/riscv/rv64/multiarch/strcmp_vector.S
+index 41d653748a..d0b8e316f9 100644
+--- a/sysdeps/riscv/rv64/multiarch/strcmp_vector.S
++++ b/sysdeps/riscv/rv64/multiarch/strcmp_vector.S
+@@ -19,11 +19,12 @@
+ #include <sysdep.h>
+ 
+ /* For __riscv_vector this file defines strcmp.  */
+-/* #ifndef __riscv_vector */
++#ifdef __riscv_vector 
++#ifdef SHARED
+ # define strcmp __strcmp_vector
+ # undef libc_hidden_builtin_def
+ # define libc_hidden_builtin_def(a)
+-/* #endif */
++#endif 
+ 
+ 	.p2align 6
+ ENTRY (strcmp)
+@@ -51,4 +52,4 @@ ENTRY (strcmp)
+ 
+ END (strcmp)
+ libc_hidden_builtin_def (strcmp)
+-
++#endif
+diff --git a/sysdeps/riscv/rv64/multiarch/strlen.c b/sysdeps/riscv/rv64/multiarch/strlen.c
+index 292c9103fa..8fab570609 100644
+--- a/sysdeps/riscv/rv64/multiarch/strlen.c
++++ b/sysdeps/riscv/rv64/multiarch/strlen.c
+@@ -17,7 +17,7 @@
+    License along with the GNU C Library; if not, see
+    <https://www.gnu.org/licenses/>.  */
+ 
+-#if IS_IN (libc)
++#if IS_IN (libc) && defined SHARED && defined __riscv_vector
+ # define strlen __redirect_strlen
+ # include <string.h>
+ # undef strlen
+@@ -29,4 +29,7 @@
+ 
+ riscv_libc_ifunc_redirected (__redirect_strlen, strlen, IFUNC_SELECTOR);
+ riscv_libc_ifunc_hidden_def (__redirect_strlen, strlen);
++#else 
++# include <string.h>
++
+ #endif
+diff --git a/sysdeps/riscv/rv64/multiarch/strlen_riscv.c b/sysdeps/riscv/rv64/multiarch/strlen_riscv.c
+index e17a5dde31..d605941766 100644
+--- a/sysdeps/riscv/rv64/multiarch/strlen_riscv.c
++++ b/sysdeps/riscv/rv64/multiarch/strlen_riscv.c
+@@ -16,14 +16,17 @@
+    License along with the GNU C Library; if not, see
+    <https://www.gnu.org/licenses/>.  */
+ 
+-#if IS_IN (libc)
++
++#if IS_IN (libc) && defined SHARED && defined __riscv_vector
+ #undef libc_hidden_builtin_def
+ #define libc_hidden_builtin_def(name)
+ 
+ #undef weak_alias
+ #  define STRLEN __strlen_riscv
+ # include <string/strlen.c>
+-#else
++#elif !defined __riscv_vector
+ 
+ # include <string/strlen.c>
+ #endif
++
++
+diff --git a/sysdeps/riscv/rv64/multiarch/strlen_vector.S b/sysdeps/riscv/rv64/multiarch/strlen_vector.S
+index dd080e3a2f..f674de3a26 100644
+--- a/sysdeps/riscv/rv64/multiarch/strlen_vector.S
++++ b/sysdeps/riscv/rv64/multiarch/strlen_vector.S
+@@ -19,11 +19,12 @@
+ #include <sysdep.h>
+ 
+ /* For __riscv_vector this file defines strlen.  */
+-/* #ifndef __riscv_vector */
++#ifdef __riscv_vector 
++#ifdef SHARED
+ # define strlen __strlen_vector
+ # undef libc_hidden_builtin_def
+ # define libc_hidden_builtin_def(a)
+-/* #endif */
++#endif
+ 
+ 	.p2align 6
+ ENTRY (strlen)
+@@ -44,3 +45,4 @@ ENTRY (strlen)
+ 
+ END (strlen)
+ libc_hidden_builtin_def (strlen)
++#endif
+\ No newline at end of file
+-- 
+2.25.1
+

+ 0 - 27
recipes-core/glibc/glibc/0009-Revert-RISC-V-Reserve-about-5K-space-in-mcontext_t-t.patch

@@ -1,27 +0,0 @@
-From 0e504f890152ef8c96f4a5913dddd8179dbc1f71 Mon Sep 17 00:00:00 2001
-From: "max.ma" <max.ma@starfivetech.com>
-Date: Wed, 9 Feb 2022 23:04:46 -0800
-Subject: [PATCH 09/12] Revert "RISC-V: Reserve about 5K space in mcontext_t to
- support future ISA expansion."
-
-This reverts commit bcface37cf6df3f3b0800f79e4282a690122b0c8.
----
- sysdeps/unix/sysv/linux/riscv/sys/ucontext.h | 2 --
- 1 file changed, 2 deletions(-)
-
-diff --git a/sysdeps/unix/sysv/linux/riscv/sys/ucontext.h b/sysdeps/unix/sysv/linux/riscv/sys/ucontext.h
-index 80caf078fc..cfafa44f99 100644
---- a/sysdeps/unix/sysv/linux/riscv/sys/ucontext.h
-+++ b/sysdeps/unix/sysv/linux/riscv/sys/ucontext.h
-@@ -82,8 +82,6 @@ typedef struct mcontext_t
-   {
-     __riscv_mc_gp_state __gregs;
-     union  __riscv_mc_fp_state __fpregs;
--    /* 5K + 256 reserved for vector state and future expansion.  */
--    unsigned char __reserved[5376] __attribute__ ((__aligned__ (16)));
-   } mcontext_t;
- 
- /* Userlevel context.  */
--- 
-2.33.1
-

+ 0 - 1581
recipes-core/glibc/glibc/0009-fsl-e500-e5500-e6500-603e-fsqrt-implementation.patch

@@ -1,1581 +0,0 @@
-From 74923ca4b1ae0ed5a2478e7d265b37534f6815d7 Mon Sep 17 00:00:00 2001
-From: Khem Raj <raj.khem@gmail.com>
-Date: Wed, 18 Mar 2015 00:01:50 +0000
-Subject: [PATCH] fsl e500/e5500/e6500/603e fsqrt implementation
-
-Upstream-Status: Pending
-Signed-off-by: Edmar Wienskoski <edmar@freescale.com>
-Signed-off-by: Khem Raj <raj.khem@gmail.com>
----
- 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 <math.h>
-+#include <math_private.h>
-+#include <fenv_libc.h>
-+#include <inttypes.h>
-+
-+#include <sysdep.h>
-+#include <ldsodefs.h>
-+
-+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 <math.h>
-+#include <math_private.h>
-+#include <fenv_libc.h>
-+#include <inttypes.h>
-+
-+#include <sysdep.h>
-+#include <ldsodefs.h>
-+
-+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 <math.h>
-+#include <math_private.h>
-+#include <fenv_libc.h>
-+#include <inttypes.h>
-+
-+#include <sysdep.h>
-+#include <ldsodefs.h>
-+
-+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 <math.h>
-+#include <math_private.h>
-+#include <fenv_libc.h>
-+#include <inttypes.h>
-+
-+#include <sysdep.h>
-+#include <ldsodefs.h>
-+
-+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 <math.h>
-+#include <math_private.h>
-+#include <fenv_libc.h>
-+#include <inttypes.h>
-+
-+#include <sysdep.h>
-+#include <ldsodefs.h>
-+
-+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 <math.h>
-+#include <math_private.h>
-+#include <fenv_libc.h>
-+#include <inttypes.h>
-+
-+#include <sysdep.h>
-+#include <ldsodefs.h>
-+
-+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 <math.h>
-+#include <math_private.h>
-+#include <fenv_libc.h>
-+#include <inttypes.h>
-+
-+#include <sysdep.h>
-+#include <ldsodefs.h>
-+
-+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 <math.h>
-+#include <math_private.h>
-+#include <fenv_libc.h>
-+#include <inttypes.h>
-+
-+#include <sysdep.h>
-+#include <ldsodefs.h>
-+
-+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 <math.h>
-+#include <math_private.h>
-+#include <fenv_libc.h>
-+#include <inttypes.h>
-+
-+#include <sysdep.h>
-+#include <ldsodefs.h>
-+
-+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 <math.h>
-+#include <math_private.h>
-+#include <fenv_libc.h>
-+#include <inttypes.h>
-+
-+#include <sysdep.h>
-+#include <ldsodefs.h>
-+
-+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 <math.h>
-+#include <math_private.h>
-+#include <fenv_libc.h>
-+#include <inttypes.h>
-+
-+#include <sysdep.h>
-+#include <ldsodefs.h>
-+
-+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 <math.h>
-+#include <math_private.h>
-+#include <fenv_libc.h>
-+#include <inttypes.h>
-+
-+#include <sysdep.h>
-+#include <ldsodefs.h>
-+
-+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

+ 25 - 0
recipes-core/glibc/glibc/0009-resolve-__memcmpeq-aliased-to-undefined-symbol-memcm.patch

@@ -0,0 +1,25 @@
+From 5d6ab9fef7281483da3e9c306b56413c40165ef1 Mon Sep 17 00:00:00 2001
+From: "max.ma" <max.ma@starfivetech.com>
+Date: Tue, 6 Sep 2022 20:01:36 -0700
+Subject: [PATCH 09/19] resolve '__memcmpeq' aliased to undefined symbol
+ 'memcmp' issue
+
+cx
+---
+ string/memcmp.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/string/memcmp.c b/string/memcmp.c
+index 40029474e6..b275e5fbff 100644
+--- a/string/memcmp.c
++++ b/string/memcmp.c
+@@ -361,5 +361,5 @@ weak_alias (memcmp, bcmp)
+ #endif
+ 
+ #undef __memcmpeq
+-strong_alias (memcmp, __memcmpeq)
++strong_alias (MEMCMP, __memcmpeq)
+ libc_hidden_def(__memcmpeq)
+-- 
+2.25.1
+

+ 15 - 15
recipes-core/glibc/glibc/0016-yes-within-the-path-sets-wrong-config-variables.patch → recipes-core/glibc/glibc/0009-yes-within-the-path-sets-wrong-config-variables.patch

@@ -1,4 +1,4 @@
-From 7be3e82b66394a7b242e56c6fc609e858b8e2436 Mon Sep 17 00:00:00 2001
+From 07655aaa14f9d1f3a521caadde2936067ce84b07 Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Wed, 18 Mar 2015 00:31:06 +0000
 Subject: [PATCH] 'yes' within the path sets wrong config variables
@@ -29,10 +29,10 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
  12 files changed, 28 insertions(+), 28 deletions(-)
 
 diff --git a/sysdeps/aarch64/configure b/sysdeps/aarch64/configure
-index 4c1fac49f3..597314f476 100644
+index bf972122b1..f9397b8d6e 100644
 --- a/sysdeps/aarch64/configure
 +++ b/sysdeps/aarch64/configure
-@@ -157,12 +157,12 @@ else
+@@ -152,12 +152,12 @@ else
    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
  /* end confdefs.h.  */
  #ifdef __AARCH64EB__
@@ -48,10 +48,10 @@ index 4c1fac49f3..597314f476 100644
  else
    libc_cv_aarch64_be=no
 diff --git a/sysdeps/aarch64/configure.ac b/sysdeps/aarch64/configure.ac
-index 3347c13fa1..4af163c0b6 100644
+index 51253d9802..ba36a0e8b4 100644
 --- a/sysdeps/aarch64/configure.ac
 +++ b/sysdeps/aarch64/configure.ac
-@@ -17,8 +17,8 @@ AC_DEFINE(SUPPORT_STATIC_PIE)
+@@ -13,8 +13,8 @@ AC_DEFINE(SUPPORT_STATIC_PIE)
  # the dynamic linker via %ifdef.
  AC_CACHE_CHECK([for big endian],
    [libc_cv_aarch64_be],
@@ -63,10 +63,10 @@ index 3347c13fa1..4af163c0b6 100644
    ], 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
+index 5b0237e521..969fc9fe95 100644
 --- a/sysdeps/arm/configure
 +++ b/sysdeps/arm/configure
-@@ -151,12 +151,12 @@ else
+@@ -148,12 +148,12 @@ else
    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
  /* end confdefs.h.  */
  #ifdef __ARM_PCS_VFP
@@ -82,10 +82,10 @@ index 431e843b2b..e152461138 100644
  else
    libc_cv_arm_pcs_vfp=no
 diff --git a/sysdeps/arm/configure.ac b/sysdeps/arm/configure.ac
-index 90cdd69c75..05a262ba00 100644
+index 5172e30bbe..f06dedd7c5 100644
 --- a/sysdeps/arm/configure.ac
 +++ b/sysdeps/arm/configure.ac
-@@ -15,8 +15,8 @@ AC_DEFINE(PI_STATIC_AND_HIDDEN)
+@@ -10,8 +10,8 @@ GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
  # the dynamic linker via %ifdef.
  AC_CACHE_CHECK([whether the compiler is using the ARM hard-float ABI],
    [libc_cv_arm_pcs_vfp],
@@ -97,10 +97,10 @@ index 90cdd69c75..05a262ba00 100644
    ], 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
+index 3f4d9e9759..888453c70b 100644
 --- a/sysdeps/mips/configure
 +++ b/sysdeps/mips/configure
-@@ -143,11 +143,11 @@ else
+@@ -145,11 +145,11 @@ else
  /* end confdefs.h.  */
  dnl
  #ifdef __mips_nan2008
@@ -115,11 +115,11 @@ index 4e13248c03..f14af952d0 100644
  else
    libc_cv_mips_nan2008=no
 diff --git a/sysdeps/mips/configure.ac b/sysdeps/mips/configure.ac
-index bcbdaffd9f..ad3057f4cc 100644
+index d3cd780d78..250223d206 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_DEFINE(HIDDEN_VAR_NEEDS_DYNAMIC_RELOC)
  
  AC_CACHE_CHECK([whether the compiler is using the 2008 NaN encoding],
 -  libc_cv_mips_nan2008, [AC_EGREP_CPP(yes, [dnl
@@ -131,7 +131,7 @@ index bcbdaffd9f..ad3057f4cc 100644
  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
+index b3cd28349e..f47e5a5adc 100644
 --- a/sysdeps/nios2/configure
 +++ b/sysdeps/nios2/configure
 @@ -142,12 +142,12 @@ else
@@ -150,7 +150,7 @@ index 14c8a3a014..dde3814ef2 100644
  else
    libc_cv_nios2_be=no
 diff --git a/sysdeps/nios2/configure.ac b/sysdeps/nios2/configure.ac
-index f05f43802b..dc8639902d 100644
+index f738e9a7ed..4085851cbc 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.

+ 1 - 1
recipes-core/glibc/glibc/0019-eglibc-Cross-building-and-testing-instructions.patch → recipes-core/glibc/glibc/0010-eglibc-Cross-building-and-testing-instructions.patch

@@ -1,4 +1,4 @@
-From db9674ffc6583a508da1a3cb044c3ccf3febaea1 Mon Sep 17 00:00:00 2001
+From 9373891f13f3550f9b3f896c34ac152efd369ca9 Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Wed, 18 Mar 2015 00:42:58 +0000
 Subject: [PATCH] eglibc: Cross building and testing instructions

+ 1382 - 0
recipes-core/glibc/glibc/0010-merge-demin-s-mem_xxx-optimization.patch

@@ -0,0 +1,1382 @@
+From 87fc954b961c326c9630df55201320b0d32f66f9 Mon Sep 17 00:00:00 2001
+From: "max.ma" <max.ma@starfivetech.com>
+Date: Tue, 13 Sep 2022 01:06:07 -0700
+Subject: [PATCH 10/19] merge demin's mem_xxx optimization
+
+---
+ sysdeps/riscv/rv64/multiarch/Makefile         |   2 +-
+ sysdeps/riscv/rv64/multiarch/memchr_as.S      | 150 ++++++++------
+ sysdeps/riscv/rv64/multiarch/memchr_riscv.S   |   6 +-
+ sysdeps/riscv/rv64/multiarch/memchr_vector.S  |   6 +-
+ sysdeps/riscv/rv64/multiarch/memcmp.c         |   2 +
+ sysdeps/riscv/rv64/multiarch/memcmp_as.S      | 150 ++++++++++++++
+ .../{memcmp_riscv.c => memcmp_riscv.S}        |   8 +-
+ sysdeps/riscv/rv64/multiarch/memcmp_vector.S  |   7 +-
+ sysdeps/riscv/rv64/multiarch/memcpy.c         |   1 +
+ sysdeps/riscv/rv64/multiarch/memcpy_as.S      | 196 ++++++++++--------
+ sysdeps/riscv/rv64/multiarch/memcpy_riscv.S   |   2 +-
+ sysdeps/riscv/rv64/multiarch/memcpy_vector.S  |   5 +-
+ sysdeps/riscv/rv64/multiarch/memmove_as.S     | 168 +++++++++++++++
+ .../{memmove_riscv.c => memmove_riscv.S}      |   9 +-
+ sysdeps/riscv/rv64/multiarch/memmove_vector.S |   6 +-
+ sysdeps/riscv/rv64/multiarch/memrchr.S        | 123 +++++++++++
+ sysdeps/riscv/rv64/multiarch/memset_as.S      | 123 +++++++++++
+ .../{memset_riscv.c => memset_riscv.S}        |   8 +-
+ sysdeps/riscv/rv64/multiarch/memset_vector.S  |   6 +-
+ .../{rtld-memmove.c => rtld-memmove.S}        |   3 +-
+ sysdeps/riscv/rv64/multiarch/rtld-memrchr.S   |   1 +
+ sysdeps/riscv/rv64/multiarch/rtld-strcmp.S    |   2 +-
+ .../rv64/multiarch/{strcmp_.S => strcmp_as.S} |   0
+ sysdeps/riscv/rv64/multiarch/strcmp_riscv.S   |   6 +-
+ sysdeps/riscv/rv64/multiarch/strcmp_vector.S  |   6 +-
+ sysdeps/riscv/rv64/multiarch/strlen_riscv.c   |   2 +-
+ sysdeps/riscv/rv64/multiarch/strlen_vector.S  |   6 +-
+ 27 files changed, 799 insertions(+), 205 deletions(-)
+ create mode 100644 sysdeps/riscv/rv64/multiarch/memcmp_as.S
+ rename sysdeps/riscv/rv64/multiarch/{memcmp_riscv.c => memcmp_riscv.S} (89%)
+ create mode 100644 sysdeps/riscv/rv64/multiarch/memmove_as.S
+ rename sysdeps/riscv/rv64/multiarch/{memmove_riscv.c => memmove_riscv.S} (88%)
+ create mode 100644 sysdeps/riscv/rv64/multiarch/memrchr.S
+ create mode 100644 sysdeps/riscv/rv64/multiarch/memset_as.S
+ rename sysdeps/riscv/rv64/multiarch/{memset_riscv.c => memset_riscv.S} (89%)
+ rename sysdeps/riscv/rv64/multiarch/{rtld-memmove.c => rtld-memmove.S} (93%)
+ create mode 100644 sysdeps/riscv/rv64/multiarch/rtld-memrchr.S
+ rename sysdeps/riscv/rv64/multiarch/{strcmp_.S => strcmp_as.S} (100%)
+
+diff --git a/sysdeps/riscv/rv64/multiarch/Makefile b/sysdeps/riscv/rv64/multiarch/Makefile
+index 3349bf4888..7e8bfde544 100644
+--- a/sysdeps/riscv/rv64/multiarch/Makefile
++++ b/sysdeps/riscv/rv64/multiarch/Makefile
+@@ -1,5 +1,5 @@
+ ifeq ($(subdir),string)
+ sysdep_routines += memcpy_vector memcpy_riscv memchr_riscv memchr_vector memcmp_riscv \
+                  memcmp_vector strcmp_riscv strcmp_vector strlen_riscv strlen_vector \
+-                 memmove_vector memmove_riscv memset_vector memset_riscv
++                 memmove_vector memmove_riscv memset_vector memset_riscv memrchr
+ endif
+diff --git a/sysdeps/riscv/rv64/multiarch/memchr_as.S b/sysdeps/riscv/rv64/multiarch/memchr_as.S
+index b8691744f3..e614630a4d 100644
+--- a/sysdeps/riscv/rv64/multiarch/memchr_as.S
++++ b/sysdeps/riscv/rv64/multiarch/memchr_as.S
+@@ -19,72 +19,90 @@
+ 
+ #include <sysdep.h>
+ 
+-	.p2align 6
+-
+-ENTRY (memchr)
+-   zext.b	a3,a1
+-   beqz	a2, .L_not_found
+-   andi	a5,a0,7
+-.L_not_aligned:      
+-   beqz	a5,.L_aligned_8byte
+-   lbu	a5,0(a0)
+-   addi	a2,a2,-1
+-   beq	a5,a3,.L_found
+-   addi	a0,a0,1
+-   andi	a5,a0,7
+-   bnez	a2,.L_not_aligned
+-
+-.L_not_found:
+-   li	a0,0
+-.L_found:   
+-   ret
++.macro chr_8B
++    ld      a4, 0(a0)
++    xor     a4, a4, a1
++    sub     a3, a4, t1
++    andn    a3, a3, a4
++    and     a3, a3, a5
++    bnez    a3, .L_find
++.endm
++.macro gen_pat
++    slli    a3, a1, 8
++    or      a1, a1, a3
++    slli    a3, a1, 16
++    or      a1, a1, a3
++    slli    a3, a1, 32
++    or      a1, a1, a3
+ 
+-.L_aligned_8byte:
+-   zext.b	a1,a1
+-   slli	a5,a1,0x8
+-   or	a1,a1,a5
+-   slli	a5,a1,0x10
+-   or	a5,a5,a1
+-   slli	a1,a5,0x20
+-   li	a4,7
+-   or	a1,a1,a5
+-   bgeu	a4,a2,.L_less_8bytes
++    li      a5, 0x80
++    slli    a3, a5, 8
++    or      a5, a5, a3
++    slli    a3, a5, 16
++    or      a5, a5, a3
++    slli    a3, a5, 32
++    or      a5, a5, a3  # 0x8080808080808080
++    srli    t1, a5, 7   # 0x0101010101010101
++.endm
+ 
+-   ld    a7, mask1   
+-   ld    a6, mask2
+-   
+-   li	t1,7
+-   j	.L_8byte_compare_loop
+-.L_8byte_compare:
+-   addi	a2,a2,-8
+-   addi	a0,a0,8
+-   bgeu	t1,a2,.L_8byte_compare_exit
+-.L_8byte_compare_loop:   
+-   ld	a5,0(a0)
+-   xor	a5,a5,a1
+-   add	a4,a5,a7
+-   not	a5,a5
+-   and	a5,a5,a4
+-   and	a5,a5,a6
+-   beqz	a5,.L_8byte_compare
+-
+-.L_less_8bytes:
+-   add	a2,a2,a0
+-   j	.L_less_8bytes_compare
+-.L_less_8bytes_loop:   
+-   addi	a0,a0,1
+-   beq	a2,a0,.L_not_found
+-.L_less_8bytes_compare:   
+-   lbu	a5,0(a0)
+-   bne	a5,a3,.L_less_8bytes_loop
+-   ret
+-.L_8byte_compare_exit:
+-   bnez	a2,.L_less_8bytes
+-   j	.L_not_found
+-  .align 3
+-mask1:
+-  .dword 0xfefefefefefefeff
+-mask2:
+-  .dword 0x8080808080808080
++	.p2align 6
++ENTRY (memchr)
++    li      a3, 7
++    bgtu    a2, a3, .L_8_to_16
++.L_0_to_7:
++    beqz    a2, 1f
++0:
++    lbu     a4, 0(a0)
++    beq     a1, a4, 2f
++    addi    a2, a2, -1
++    addi    a0, a0, 1
++    bnez    a2, 0b
++1:
++    li      a0, 0
++    ret
++2:
++    ret
++.L_8_to_16:
++    gen_pat
++    li      a3, 16
++    bgtu    a2, a3, .L_over_16
++    addi    a2, a2, -8
++    chr_8B
++    add     a0, a0, a2
++    chr_8B
++    j       .L_not_find
++.L_over_16:
++    neg     t4, a0
++    andi    t4, t4, 0x7
++    beqz    t4, .L_dst_aligned
++    chr_8B
++    sub     a2, a2, t4
++    add     a0, a0, t4
++.L_dst_aligned:
++    andi    t0, a2, (16-1)
++    srli    a2, a2, 4
++    beqz    a2, .L_tail
++.L_loop:
++    chr_8B
++    add     a0, a0, 8
++    chr_8B
++    addi    a2, a2, -1
++    add     a0, a0, 8
++    bnez    a2, .L_loop
++    beqz    t0, .L_not_find
++.L_tail:
++    add     a0, a0, t0
++    addi    a0, a0, -16
++    chr_8B
++    add     a0, a0, 8
++    chr_8B
++.L_not_find:
++    li      a0, 0
++    ret
++.L_find:
++    ctz     a3, a3
++    srli    a3, a3, 3
++    add     a0, a0, a3
++    ret
+ END (memchr)
+-libc_hidden_builtin_def (memchr)
++libc_hidden_builtin_def (memchr)
+\ No newline at end of file
+diff --git a/sysdeps/riscv/rv64/multiarch/memchr_riscv.S b/sysdeps/riscv/rv64/multiarch/memchr_riscv.S
+index ee4394fef9..84b3375f31 100644
+--- a/sysdeps/riscv/rv64/multiarch/memchr_riscv.S
++++ b/sysdeps/riscv/rv64/multiarch/memchr_riscv.S
+@@ -26,8 +26,10 @@
+ #include "memchr_as.S"
+ 
+ 
+-#elif !defined __riscv_vector
++#else
+ 
+ #include "memchr_as.S"
+ 
+-#endif
+\ No newline at end of file
++#endif
++
++
+diff --git a/sysdeps/riscv/rv64/multiarch/memchr_vector.S b/sysdeps/riscv/rv64/multiarch/memchr_vector.S
+index 9441ddb489..87a464f38f 100644
+--- a/sysdeps/riscv/rv64/multiarch/memchr_vector.S
++++ b/sysdeps/riscv/rv64/multiarch/memchr_vector.S
+@@ -19,12 +19,10 @@
+ #include <sysdep.h>
+ 
+ /* For __riscv_vector this file defines memchr.  */
+-#ifdef __riscv_vector 
+-#ifdef SHARED
++#if IS_IN (libc) && defined SHARED && defined __riscv_vector
+ # define memchr __memchr_vector
+ # undef libc_hidden_builtin_def
+ # define libc_hidden_builtin_def(a)
+-#endif
+ 
+ 	.p2align 6
+ ENTRY (memchr)
+@@ -51,5 +49,5 @@ ENTRY (memchr)
+    add	a0,zero,zero
+    ret
+ END (memchr)
+-libc_hidden_builtin_def (memchr)
++
+ #endif
+\ No newline at end of file
+diff --git a/sysdeps/riscv/rv64/multiarch/memcmp.c b/sysdeps/riscv/rv64/multiarch/memcmp.c
+index 3dab42ea74..a67159346a 100644
+--- a/sysdeps/riscv/rv64/multiarch/memcmp.c
++++ b/sysdeps/riscv/rv64/multiarch/memcmp.c
+@@ -34,3 +34,5 @@ riscv_libc_ifunc_hidden_def (__redirect_memcmp, memcmp);
+ #else 
+ # include <string.h>
+ #endif
++
++
+diff --git a/sysdeps/riscv/rv64/multiarch/memcmp_as.S b/sysdeps/riscv/rv64/multiarch/memcmp_as.S
+new file mode 100644
+index 0000000000..a737172980
+--- /dev/null
++++ b/sysdeps/riscv/rv64/multiarch/memcmp_as.S
+@@ -0,0 +1,150 @@
++/* The assembly function for memcmp.  RISC-V version.
++   Copyright (C) 2018 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, see
++   <http://www.gnu.org/licenses/>.  */
++
++#include <sysdep.h>
++
++	.p2align 6
++ENTRY (memcmp)
++    li      a3, 32
++    mv      a5, a0
++    bgtu    a2, a3, .L_over_32
++    li      a3, 3
++    bgtu    a2, a3, .L_4_to_8
++.L_0_to_3:
++    beqz    a2, 2f
++0:
++    lbu     a3, 0(a1)
++    lbu     a4, 0(a5)
++    bne     a3, a4, 1f
++    addi    a2, a2, -1
++    addi    a1, a1, 1
++    addi    a5, a5, 1
++    bnez    a2, 0b
++1:
++    sub     a0, a4, a3
++    ret
++2:
++    li      a0, 0
++    ret
++.L_4_to_8:
++    li      a3, 8
++    bgtu    a2, a3, .L_9_to_16
++    lwu     a3, 0(a1)
++    lwu     a0, 0(a5)
++    bne     a3, a0, .L_end
++    add     a1, a1, a2
++    add     a5, a5, a2
++    lwu     a3, -4(a1)
++    lwu     a0, -4(a5)
++    j       .L_end
++.L_9_to_16:
++    li      a3, 16
++    bgtu    a2, a3, .L_17_to_32
++    addi    a2, a2, -8
++    ld      a3, 0(a1)
++    ld      a0, 0(a5)
++    bne     a3, a0, .L_end
++    add     a1, a1, a2
++    add     a5, a5, a2
++    ld      a3, 0(a1)
++    ld      a0, 0(a5)
++    j       .L_end
++.L_17_to_32:
++    addi    a2, a2, -16
++    ld      a3, 0(a1)
++    ld      a0, 0(a5)
++    bne     a3, a0, .L_end
++    ld      a3, 8(a1)
++    ld      a0, 8(a5)
++    bne     a3, a0, .L_end
++    add     a1, a1, a2
++    add     a5, a5, a2
++    ld      a3, 0(a1)
++    ld      a0, 0(a5)
++    bne     a3, a0, .L_end
++    ld      a3, 8(a1)
++    ld      a0, 8(a5)
++    j       .L_end
++.L_over_32:
++    neg     a4, a5
++    andi    a4, a4, 0x7
++    beqz    a4, .L_dst_aligned
++    ld      a3, 0(a1)
++    ld      a0, 0(a5)
++    bne     a3, a0, .L_end
++    sub     a2, a2, a4
++    add     a5, a5, a4
++    add     a1, a1, a4
++.L_dst_aligned:
++    andi    a4, a2, -32
++    andi    a2, a2, (32-1)
++    beqz    a4, .L_tail
++    add     a4, a4, a5
++.L_loop:
++    ld      a3, 0(a1)
++    ld      a0, 0(a5)
++    bne     a3, a0, .L_end
++    ld      a3, 8(a1)
++    ld      a0, 8(a5)
++    bne     a3, a0, .L_end
++    ld      a3, 16(a1)
++    ld      a0, 16(a5)
++    bne     a3, a0, .L_end
++    ld      a3, 24(a1)
++    ld      a0, 24(a5)
++    bne     a3, a0, .L_end
++    addi    a5, a5, 32
++    addi    a1, a1, 32
++    bltu    a5, a4, .L_loop
++    beqz    a2, .L_end
++.L_tail:
++    andi    a4, a2, -1
++.L_pc:
++    auipc   a3, 0
++    andi    a4, a4, -8
++    sub     a3, a3, a4
++    .equ    offset, .L_jmp_end - .L_pc
++    jalr    x0, a3, %lo(offset)
++    ld      a3, 16(a1)
++    ld      a0, 16(a5)
++    bne     a3, a0, .L_end
++    ld      a3, 8(a1)
++    ld      a0, 8(a5)
++    bne     a3, a0, .L_end
++    ld      a3, 0(a1)
++    ld      a0, 0(a5)
++    bne     a3, a0, .L_end
++.L_jmp_end:
++    add     a1, a1, a2
++    add     a5, a5, a2
++    ld      a3, -8(a1)
++    ld      a0, -8(a5)
++.L_end:
++    bltu    a0, a3, 2f
++    beq     a0, a3, 3f
++    li      a0, 1
++    ret
++2:
++    li      a0, -1
++    ret
++3:
++    li      a0, 0
++    ret
++END (memcmp)
++
++libc_hidden_builtin_def (memcmp)
+diff --git a/sysdeps/riscv/rv64/multiarch/memcmp_riscv.c b/sysdeps/riscv/rv64/multiarch/memcmp_riscv.S
+similarity index 89%
+rename from sysdeps/riscv/rv64/multiarch/memcmp_riscv.c
+rename to sysdeps/riscv/rv64/multiarch/memcmp_riscv.S
+index 076431132b..32df79f769 100644
+--- a/sysdeps/riscv/rv64/multiarch/memcmp_riscv.c
++++ b/sysdeps/riscv/rv64/multiarch/memcmp_riscv.S
+@@ -22,11 +22,11 @@
+ #define libc_hidden_builtin_def(name)
+ 
+ #undef weak_alias
+-#  define MEMCMP __memcmp_riscv
+-# include <string/memcmp.c>
++#  define memcmp __memcmp_riscv
++# include "memcmp_as.S"
+ 
+-#elif !defined __riscv_vector
+-# include <string/memcmp.c>
++#else
++# include "memcmp_as.S"
+ 
+ #endif
+ 
+diff --git a/sysdeps/riscv/rv64/multiarch/memcmp_vector.S b/sysdeps/riscv/rv64/multiarch/memcmp_vector.S
+index 4810af026a..89d8a7e08f 100644
+--- a/sysdeps/riscv/rv64/multiarch/memcmp_vector.S
++++ b/sysdeps/riscv/rv64/multiarch/memcmp_vector.S
+@@ -21,12 +21,10 @@
+ /* For __riscv_vector this file defines strcmp.  */
+ /* #ifndef __riscv_vector */
+ 
+-#ifdef __riscv_vector 
+-#ifdef SHARED
++#if IS_IN (libc) && defined SHARED && defined __riscv_vector
+ # define memcmp __memcmp_vector
+ # undef libc_hidden_builtin_def
+ # define libc_hidden_builtin_def(a)
+-#endif 
+ 
+ 	.p2align 6
+ ENTRY (memcmp)
+@@ -55,6 +53,5 @@ ENTRY (memcmp)
+    add	a0,zero,zero
+    ret
+ END (memcmp)
+-weak_alias (memcmp, bcmp)
+-libc_hidden_builtin_def (memcmp)
++
+ #endif
+diff --git a/sysdeps/riscv/rv64/multiarch/memcpy.c b/sysdeps/riscv/rv64/multiarch/memcpy.c
+index 45cf14f52a..4fa4cccd9d 100644
+--- a/sysdeps/riscv/rv64/multiarch/memcpy.c
++++ b/sysdeps/riscv/rv64/multiarch/memcpy.c
+@@ -34,3 +34,4 @@ riscv_libc_ifunc_hidden_def (__redirect_memcpy, memcpy);
+ #else 
+ # include <string.h>
+ #endif
++
+diff --git a/sysdeps/riscv/rv64/multiarch/memcpy_as.S b/sysdeps/riscv/rv64/multiarch/memcpy_as.S
+index f0a074df13..4a97d75545 100644
+--- a/sysdeps/riscv/rv64/multiarch/memcpy_as.S
++++ b/sysdeps/riscv/rv64/multiarch/memcpy_as.S
+@@ -19,96 +19,116 @@
+ #include <sysdep.h>
+ 
+ 
+-#  define LABLE_ALIGN   \
+-        .balignl 16, 0x00000013
++.macro copy_32B d, s
++    ld      a3, 0(\s)
++    sd      a3, 0(\d)
++    ld      a3, 8(\s)
++    sd      a3, 8(\d)
++    ld      a3, 16(\s)
++    sd      a3, 16(\d)
++    ld      a3, 24(\s)
++    sd      a3, 24(\d)
++.endm
+ 
++    .p2align 6
+ ENTRY (memcpy)
+-
+-        /* Test if len less than 8 bytes.  */
+-        mv      t6, a0
+-        sltiu   a3, a2, 8
+-        li     t3, 1
+-        bnez    a3, .L_copy_by_byte
+-
+-        andi    a3, a0, 7
+-        li     t5, 8
+-	/* Test if dest is not 8 bytes aligned.  */
+-        bnez    a3, .L_dest_not_aligned
+-.L_dest_aligned:
+-        /* If dest is aligned, then copy.  */
+-        srli    t4, a2, 6
+-        /* Test if len less than 32 bytes.  */
+-        beqz     t4, .L_len_less_16bytes
+-	andi    a2, a2, 63
+-
+-.L_len_larger_16bytes:
+-        ld      a4, 0(a1)
+-        sd      a4, 0(a0)
+-        ld      a5, 8(a1)
+-        sd      a5, 8(a0)
+-        ld      a6, 16(a1)
+-        sd      a6, 16(a0)
+-        ld      a7, 24(a1)
+-        sd      a7, 24(a0)
+-        ld      a4, 32(a1)
+-        sd      a4, 32(a0)
+-        ld      a5, 40(a1)
+-        sd      a5, 40(a0)
+-        ld      a6, 48(a1)
+-        sd      a6, 48(a0)
+-        ld      a7, 56(a1)
+-        sub     t4, t4, t3
+-        addi    a1, a1, 64
+-        sd      a7, 56(a0)
+-        addi    a0, a0, 64
+-	bnez	t4, .L_len_larger_16bytes
+-
+-.L_len_less_16bytes:
+-	srli    t4, a2, 2
+-        beqz     t4, .L_copy_by_byte
+-        andi    a2, a2, 3
+-.L_len_less_16bytes_loop:
+-        lw      a4, 0(a1)
+-	sub	t4, t4, t3
+-        addi    a1, a1, 4
+-        sw      a4, 0(a0)
+-        addi    a0, a0, 4
+-	bnez    t4, .L_len_less_16bytes_loop
+-
+-        /* Copy tail.  */
+-.L_copy_by_byte:
+-        andi    t4, a2, 7
+-        beqz     t4, .L_return
+-.L_copy_by_byte_loop:
+-        lb     a4, 0(a1)
+-	sub	t4, t4, t3
+-        addi    a1, a1, 1
+-        sb     a4, 0(a0)
+-        addi    a0, a0, 1
+-	bnez	t4, .L_copy_by_byte_loop
+-
+-.L_return:
+-        mv      a0, t6
+-        ret
+-
+-        /* If dest is not aligned, just copying some bytes makes the dest
+-           align.  */
+-.L_dest_not_aligned:
+-        sub     a3, t5, a3
+-        mv      t5, a3
+-.L_dest_not_aligned_loop:
+-        /* Makes the dest align.  */
+-        lb     a4, 0(a1)
+-	sub	a3, a3, t3
+-        addi    a1, a1, 1
+-        sb     a4, 0(a0)
+-        addi    a0, a0, 1
+-	bnez	a3, .L_dest_not_aligned_loop
+-        sub     a2, a2, t5
+-	sltiu	a3, a2, 4
+-        bnez    a3, .L_copy_by_byte
+-        /* Check whether the src is aligned.  */
+-        j		.L_dest_aligned
++    li      a3, 32
++    mv      a5, a0
++    bgtu    a2, a3, .L_over_32
++    li      a3, 4
++    bgtu    a2, a3, .L_5_to_8
++.L_0_to_4:
++    beqz    a2, 1f
++    lb      a4, 0(a1)
++    sb      a4, 0(a5)
++    /* process [n-1] */
++    add     t1, a1, a2
++    lb      a4, -1(t1)
++    add     t0, a5, a2
++    sb      a4, -1(t0)
++    li      a3, 2
++    bleu    a2, a3, 1f
++    lb      a4, 2(a1)
++    sb      a4, 2(a5)
++    lb      a4, 1(a1)
++    sb      a4, 1(a5)
++1:
++    ret
++.L_5_to_8:
++    li      a3, 8
++    bgtu    a2, a3, .L_9_to_16
++    lw      a3, 0(a1)
++    sw      a3, 0(a5)
++    add     a1, a1, a2
++    add     a5, a5, a2
++    lw      a3, -4(a1)
++    sw      a3, -4(a5)
++    ret
++.L_9_to_16:
++    li      a3, 16
++    bgtu    a2, a3, .L_17_to_32
++    ld      a3, 0(a1)
++    sd      a3, 0(a5)
++    add     a1, a1, a2
++    add     a5, a5, a2
++    ld      a3, -8(a1)
++    sd      a3, -8(a5)
++    ret
++.L_17_to_32:
++    addi    a2, a2, -16
++    ld      a3, 0(a1)
++    sd      a3, 0(a5)
++    ld      a3, 8(a1)
++    sd      a3, 8(a5)
++    add     a1, a1, a2
++    add     a5, a5, a2
++    ld      a3, 0(a1)
++    sd      a3, 0(a5)
++    ld      a3, 8(a1)
++    sd      a3, 8(a5)
++    ret
++.L_over_32:
++    neg     a4, a5
++    andi    a4, a4, 0x7
++    beqz    a4, .L_dst_aligned
++    ld      a3, 0(a1)
++    sd      a3, 0(a5)
++    sub     a2, a2, a4
++    add     a5, a5, a4
++    add     a1, a1, a4
++.L_dst_aligned:
++    andi    a4, a2, -32
++    andi    a2, a2, (32-1)
++    beqz    a4, .L_tail
++    add     a4, a4, a5
++.L_loop:
++    copy_32B a5, a1
++    addi    a5, a5, 32
++    addi    a1, a1, 32
++    bltu    a5, a4, .L_loop
++    beqz    a2, .L_ret
++.L_tail:
++    andi    a4, a2, -1
++.L_pc:
++    auipc   a3, 0
++    andi    a4, a4, -8
++    srli    a4, a4, 1
++    sub     a3, a3, a4
++    .equ    offset, .L_jmp_end - .L_pc
++    jalr    x0, a3, %lo(offset)
++    ld      a3, 16(a1) # offset-12
++    sd      a3, 16(a5)
++    ld      a3, 8(a1)  # offset-8
++    sd      a3, 8(a5)
++    ld      a3, 0(a1)  # offset-4
++    sd      a3, 0(a5)
++.L_jmp_end:
++    add     a1, a1, a2
++    add     a5, a5, a2
++    ld      a3, -8(a1)
++    sd      a3, -8(a5)
++.L_ret:
++    ret
+ END (memcpy)
+ 
+ libc_hidden_builtin_def (memcpy)
+diff --git a/sysdeps/riscv/rv64/multiarch/memcpy_riscv.S b/sysdeps/riscv/rv64/multiarch/memcpy_riscv.S
+index 249d4f6067..34b4e981c1 100644
+--- a/sysdeps/riscv/rv64/multiarch/memcpy_riscv.S
++++ b/sysdeps/riscv/rv64/multiarch/memcpy_riscv.S
+@@ -26,7 +26,7 @@
+ 
+ #include "memcpy_as.S"
+ 
+-#elif !defined __riscv_vector
++#else
+ #include "memcpy_as.S"
+ 
+ #endif
+diff --git a/sysdeps/riscv/rv64/multiarch/memcpy_vector.S b/sysdeps/riscv/rv64/multiarch/memcpy_vector.S
+index d15f4c3954..cba5e00f19 100644
+--- a/sysdeps/riscv/rv64/multiarch/memcpy_vector.S
++++ b/sysdeps/riscv/rv64/multiarch/memcpy_vector.S
+@@ -19,12 +19,10 @@
+ #include <sysdep.h>
+ 
+ /* For __riscv_vector this file defines memcpy.  */
+-#ifdef __riscv_vector 
+-#ifdef SHARED
++#if IS_IN (libc) && defined SHARED && defined __riscv_vector
+ # define memcpy __memcpy_vector
+ # undef libc_hidden_builtin_def
+ # define libc_hidden_builtin_def(a)
+-#endif
+ 
+ 	.p2align 6
+ ENTRY (memcpy)
+@@ -52,5 +50,4 @@ ENTRY (memcpy)
+ 	ret
+ END (memcpy)
+ 
+-libc_hidden_builtin_def (memcpy)
+ #endif
+\ No newline at end of file
+diff --git a/sysdeps/riscv/rv64/multiarch/memmove_as.S b/sysdeps/riscv/rv64/multiarch/memmove_as.S
+new file mode 100644
+index 0000000000..222b87b9c8
+--- /dev/null
++++ b/sysdeps/riscv/rv64/multiarch/memmove_as.S
+@@ -0,0 +1,168 @@
++/* The assembly function for memmove.  RISC-V version.
++   Copyright (C) 2018 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, see
++   <http://www.gnu.org/licenses/>.  */
++
++#include <sysdep.h>
++
++#define memcpy memcpy_internal 
++#include "memcpy_as.S"
++
++
++	.p2align 6
++    
++ENTRY (memmove)
++    beq     a0, a1, .L_ret_fwd
++    /* abs(dst - src) */
++    sub     a3, a0, a1
++    srai    a4, a3, 63
++    xor     a3, a3, a4
++    subw    a3, a3, a4
++
++    bltu    a3, a2, .L_overlap
++    j       memcpy
++.L_overlap:
++    li      a4, 8
++    bltu    a1, a0, .L_backward
++    mv      a5, a0
++    bltu    a2, a4, .L_byte_fwd
++    neg     a4, a0
++    andi    a4, a4, 0x7
++    beqz    a4, .L_32B_fwd
++.L_byte_head_fwd:
++    sub     a2, a2, a4
++    add     a4, a5, a4
++0:
++    lb      a3, 0(a1)
++    sb      a3, 0(a5)
++    addi    a5, a5, 1
++    addi    a1, a1, 1
++    bltu    a5, a4, 0b
++.L_32B_fwd:
++    andi    a4, a2, -32
++    andi    a2, a2, (32 - 1)
++    beqz    a4, .L_8B_fwd
++    add     a4, a4, a5
++0:
++    ld      a3, 0(a1)
++    sd      a3, 0(a5)
++    ld      a3, 8(a1)
++    sd      a3, 8(a5)
++    ld      a3, 16(a1)
++    sd      a3, 16(a5)
++    ld      a3, 24(a1)
++    sd      a3, 24(a5)
++    addi    a5, a5, 32
++    addi    a1, a1, 32
++    bltu    a5, a4, 0b
++    beqz    a2, .L_ret_fwd
++.L_8B_fwd:
++    andi    a4, a2, -8
++    beqz    a4, .L_byte_tail_fwd
++.L_pc_fwd:
++    auipc   a3, 0
++    add     a1, a1, a4
++    add     a5, a5, a4
++    sub     a3, a3, a4
++    .equ    offset_fwd, .L_jmp_end_fwd - .L_pc_fwd
++    jalr    x0, a3, %lo(offset_fwd)
++    ld      a3, -24(a1)
++    sd      a3, -24(a5)
++    ld      a3, -16(a1)
++    sd      a3, -16(a5)
++    ld      a3, -8(a1)
++    sd      a3, -8(a5)
++.L_jmp_end_fwd:
++.L_byte_tail_fwd:
++    andi    a2, a2, (8 - 1)
++.L_byte_fwd:
++    beqz    a2, .L_ret_fwd
++    add     a2, a2, a5
++0:
++    lb      a3, 0(a1)
++    sb      a3, 0(a5)
++    addi    a5, a5, 1
++    addi    a1, a1, 1
++    bltu    a5, a2, 0b
++.L_ret_fwd:
++    ret
++
++.L_backward:
++    add     a1, a1, a2
++    add     a5, a0, a2
++    bltu    a2, a4, .L_byte_bwd
++    andi    a4, a5, 0x7
++    beqz    a4, .L_32B_bwd
++.L_byte_head_bwd:
++    sub     a2, a2, a4
++    sub     a4, a5, a4
++0:
++    addi    a5, a5, -1
++    addi    a1, a1, -1
++    lb      a3, 0(a1)
++    sb      a3, 0(a5)
++    bltu    a4, a5, 0b
++.L_32B_bwd:
++    andi    a4, a2, -32
++    andi    a2, a2, (32 - 1)
++    beqz    a4, .L_8B_bwd
++    sub     a4, a5, a4
++0:
++    addi    a5, a5, -32
++    addi    a1, a1, -32
++    ld      a3, 24(a1)
++    sd      a3, 24(a5)
++    ld      a3, 16(a1)
++    sd      a3, 16(a5)
++    ld      a3, 8(a1)
++    sd      a3, 8(a5)
++    ld      a3, 0(a1)
++    sd      a3, 0(a5)
++    bltu    a4, a5, 0b
++    beqz    a2, .L_ret_bwd
++.L_8B_bwd:
++    andi    a4, a2, -8
++    beqz    a4, .L_byte_tail_bwd
++.L_pc_bwd:
++    auipc   a3, 0
++    sub     a1, a1, a4
++    sub     a5, a5, a4
++    srli    a4, a4, 1
++    sub     a3, a3, a4
++    .equ    offset_bwd, .L_jmp_end_bwd - .L_pc_bwd
++    jalr    x0, a3, %lo(offset_bwd)
++    ld      a3, 16(a1)
++    sd      a3, 16(a5)
++    ld      a3, 8(a1)
++    sd      a3, 8(a5)
++    ld      a3, 0(a1)
++    sd      a3, 0(a5)
++.L_jmp_end_bwd:
++.L_byte_tail_bwd:
++    andi    a2, a2, (8 - 1)
++.L_byte_bwd:
++    beqz    a2, .L_ret_bwd
++0:
++    addi    a5, a5, -1
++    addi    a1, a1, -1
++    lb      a3, 0(a1)
++    sb      a3, 0(a5)
++    bltu    a0, a5, 0b
++.L_ret_bwd:
++    ret
++END (memmove)
++
++libc_hidden_builtin_def (memmove)
+diff --git a/sysdeps/riscv/rv64/multiarch/memmove_riscv.c b/sysdeps/riscv/rv64/multiarch/memmove_riscv.S
+similarity index 88%
+rename from sysdeps/riscv/rv64/multiarch/memmove_riscv.c
+rename to sysdeps/riscv/rv64/multiarch/memmove_riscv.S
+index 03708e0deb..14f154e226 100644
+--- a/sysdeps/riscv/rv64/multiarch/memmove_riscv.c
++++ b/sysdeps/riscv/rv64/multiarch/memmove_riscv.S
+@@ -22,10 +22,11 @@
+ #define libc_hidden_builtin_def(name)
+ 
+ #undef weak_alias
+-#  define MEMMOVE __memmove_riscv
+-# include <string/memmove.c>
+-#elif !defined __riscv_vector
++#  define memmove __memmove_riscv
++# include "memmove_as.S"
+ 
+-# include <string/memmove.c>
++#else
++
++# include "memmove_as.S"
+ #endif
+ 
+diff --git a/sysdeps/riscv/rv64/multiarch/memmove_vector.S b/sysdeps/riscv/rv64/multiarch/memmove_vector.S
+index af748be5b2..e45137298e 100644
+--- a/sysdeps/riscv/rv64/multiarch/memmove_vector.S
++++ b/sysdeps/riscv/rv64/multiarch/memmove_vector.S
+@@ -19,12 +19,10 @@
+ #include <sysdep.h>
+ 
+ /* For __riscv_vector this file defines memmov.  */
+-#ifdef __riscv_vector 
+-#ifdef SHARED
++#if IS_IN (libc) && defined SHARED && defined __riscv_vector
+ # define memmove __memmove_vector
+ # undef libc_hidden_builtin_def
+ # define libc_hidden_builtin_def(a)
+-#endif
+ 
+ 	.p2align 6
+ ENTRY (memmove)
+@@ -54,5 +52,5 @@ ENTRY (memmove)
+ 	bltu	zero,a2,.L_backward_copy_loop
+ 	ret
+ END (memmove)
+-libc_hidden_builtin_def (memmove)
++
+ #endif
+\ No newline at end of file
+diff --git a/sysdeps/riscv/rv64/multiarch/memrchr.S b/sysdeps/riscv/rv64/multiarch/memrchr.S
+new file mode 100644
+index 0000000000..c6db183163
+--- /dev/null
++++ b/sysdeps/riscv/rv64/multiarch/memrchr.S
+@@ -0,0 +1,123 @@
++
++/* The assembly function for memrchr.  RISC-V version.
++   Copyright (C) 2018 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, see
++   <http://www.gnu.org/licenses/>.  */
++
++#include <sysdep.h>
++
++.macro chr_8B
++    ld      a4, -8(a0)
++    xor     a4, a4, a1
++    sub     a3, a4, t1
++    andn    a3, a3, a4
++    and     a3, a3, a5
++    bnez    a3, .L_find
++.endm
++.macro gen_pat
++    slli    a3, a1, 8
++    or      a1, a1, a3
++    slli    a3, a1, 16
++    or      a1, a1, a3
++    slli    a3, a1, 32
++    or      a1, a1, a3
++
++    li      a5, 0x80
++    slli    a3, a5, 8
++    or      a5, a5, a3
++    slli    a3, a5, 16
++    or      a5, a5, a3
++    slli    a3, a5, 32
++    or      a5, a5, a3  # 0x8080808080808080
++    srli    t1, a5, 7   # 0x0101010101010101
++.endm
++
++    .p2align 6
++#ifndef MEMRCHR
++ENTRY (__memrchr)
++#else
++ENTRY (MEMRCHR)
++#endif
++    li      a3, 7
++    add     a0, a0, a2
++    bgtu    a2, a3, .L_8_to_16
++.L_0_to_7:
++    beqz    a2, 1f
++0:
++    lbu     a4, -1(a0)
++    beq     a1, a4, 2f
++    addi    a2, a2, -1
++    addi    a0, a0, -1
++    bnez    a2, 0b
++1:
++    li      a0, 0
++    ret
++2:
++    addi    a0, a0, -1
++    ret
++.L_8_to_16:
++    gen_pat
++    li      a3, 16
++    bgtu    a2, a3, .L_over_16
++    addi    a2, a2, -8
++    chr_8B
++    sub     a0, a0, a2
++    chr_8B
++    j       .L_not_find
++.L_over_16:
++    and     t4, a0, 0x7
++    beqz    t4, .L_dst_aligned
++    chr_8B
++    sub     a2, a2, t4
++    sub     a0, a0, t4
++.L_dst_aligned:
++    andi    t0, a2, (16-1)
++    srli    a2, a2, 4
++    beqz    a2, .L_tail
++.L_loop:
++    chr_8B
++    addi    a0, a0, -8
++    chr_8B
++    addi    a2, a2, -1
++    addi    a0, a0, -8
++    bnez    a2, .L_loop
++    beqz    t0, .L_not_find
++.L_tail:
++    sub     a0, a0, t0
++    addi    a0, a0, 16
++    chr_8B
++    addi    a0, a0, -8
++    chr_8B
++.L_not_find:
++    li      a0, 0
++    ret
++.L_find:
++    clz     a3, a3
++    addi    a0, a0, -1
++    srli    a3, a3, 3
++    sub     a0, a0, a3
++    ret
++#ifndef MEMRCHR
++END (__memrchr)
++#else
++END (MEMRCHR)
++#endif
++
++#ifndef MEMRCHR
++# ifdef weak_alias
++weak_alias (__memrchr, memrchr)
++# endif
++#endif
+diff --git a/sysdeps/riscv/rv64/multiarch/memset_as.S b/sysdeps/riscv/rv64/multiarch/memset_as.S
+new file mode 100644
+index 0000000000..7f67c79215
+--- /dev/null
++++ b/sysdeps/riscv/rv64/multiarch/memset_as.S
+@@ -0,0 +1,123 @@
++
++/* The assembly function for memset.  RISC-V version.
++   Copyright (C) 2018 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, see
++   <http://www.gnu.org/licenses/>.  */
++
++#include <sysdep.h>
++
++    .p2align 6
++ENTRY (memset)
++    li      a3, 32
++    andi    a1, a1, 0xff
++    mv      a5, a0
++    bgtu    a2, a3, .L_over_32
++    li      a3, 4
++    bgtu    a2, a3, .L_5_to_8
++.L_0_to_4:
++    beqz    a2, 1f
++    sb      a1, 0(a5)
++    add     t0, a5, a2
++    sb      a1, -1(t0)
++    li      a3, 2
++    bleu    a2, a3, 1f
++    sb      a1, 1(a5)
++    sb      a1, 2(a5)
++1:
++    ret
++.L_5_to_8:
++    slli    a3, a1, 8
++    or      a1, a1, a3
++    slli    a3, a1, 16
++    or      a1, a1, a3
++    li      a3, 8
++    bgtu    a2, a3, .L_9_to_16
++    sw      a1, 0(a5)
++    add     a5, a5, a2
++    sw      a1, -4(a5)
++    ret
++.L_9_to_16:
++    li      a3, 16
++    bgtu    a2, a3, .L_17_to_32
++    sw      a1, 0(a5)
++    sw      a1, 4(a5)
++    add     a5, a5, a2
++    sw      a1, -8(a5)
++    sw      a1, -4(a5)
++    ret
++.L_17_to_32:
++    slli    a3, a1, 32
++    or      a1, a1, a3
++    sd      a1, 0(a5)
++    sd      a1, 8(a5)
++    add     a5, a5, a2
++    sd      a1, -16(a5)
++    sd      a1, -8(a5)
++    ret
++.L_over_32:
++    slli    a3, a1, 8
++    or      a1, a1, a3
++    slli    a3, a1, 16
++    or      a1, a1, a3
++    slli    a3, a1, 32
++    or      a1, a1, a3
++
++    neg     a4, a5
++    andi    a4, a4, 0x7
++    beqz    a4, .L_dst_aligned
++    sd      a1, 0(a5)
++    sub     a2, a2, a4
++    add     a5, a5, a4
++.L_dst_aligned:
++    andi    a4, a2, -64
++    andi    a2, a2, (64-1)
++    beqz    a4, .L_tail
++    add     a4, a4, a5
++.L_loop:
++    sd      a1, 0(a5)
++    sd      a1, 8(a5)
++    sd      a1, 16(a5)
++    sd      a1, 24(a5)
++    sd      a1, 32(a5)
++    sd      a1, 40(a5)
++    sd      a1, 48(a5)
++    sd      a1, 56(a5)
++    addi    a5, a5, 64
++    bltu    a5, a4, .L_loop
++    beqz    a2, .L_ret
++.L_tail:
++    andi    a4, a2, -1
++.L_pc:
++    auipc   a3, 0
++    andi    a4, a4, -8
++    srli    a4, a4, 2
++    sub     a3, a3, a4
++    .equ    offset, .L_jmp_end - .L_pc
++    jalr    x0, a3, %lo(offset)
++    sd      a1, 48(a5)
++    sd      a1, 40(a5)
++    sd      a1, 32(a5)
++    sd      a1, 24(a5)
++    sd      a1, 16(a5)
++    sd      a1, 8(a5)
++    sd      a1, 0(a5)
++.L_jmp_end:
++    add     a5, a5, a2
++    sd      a1, -8(a5)
++ .L_ret:
++    ret
++END (memset)
++libc_hidden_builtin_def (memset)
+diff --git a/sysdeps/riscv/rv64/multiarch/memset_riscv.c b/sysdeps/riscv/rv64/multiarch/memset_riscv.S
+similarity index 89%
+rename from sysdeps/riscv/rv64/multiarch/memset_riscv.c
+rename to sysdeps/riscv/rv64/multiarch/memset_riscv.S
+index de631eb187..8585db0228 100644
+--- a/sysdeps/riscv/rv64/multiarch/memset_riscv.c
++++ b/sysdeps/riscv/rv64/multiarch/memset_riscv.S
+@@ -21,11 +21,11 @@
+ #define libc_hidden_builtin_def(name)
+ 
+ #undef weak_alias
+-#  define MEMSET __memset_riscv
+-# include <string/memset.c>
+-#elif !defined __riscv_vector
++#  define memset __memset_riscv
++# include "memset_as.S"
++#else
+ 
+-# include <string/memset.c>
++# include "memset_as.S"
+ #endif
+ 
+ 
+diff --git a/sysdeps/riscv/rv64/multiarch/memset_vector.S b/sysdeps/riscv/rv64/multiarch/memset_vector.S
+index dc407630a6..1271b04ba1 100644
+--- a/sysdeps/riscv/rv64/multiarch/memset_vector.S
++++ b/sysdeps/riscv/rv64/multiarch/memset_vector.S
+@@ -19,12 +19,11 @@
+ 
+ #include <sysdep.h>
+ 
+-#ifdef __riscv_vector 
+-#ifdef SHARED
++#if IS_IN (libc) && defined SHARED && defined __riscv_vector
++
+ # define memset __memset_vector
+ # undef libc_hidden_builtin_def
+ # define libc_hidden_builtin_def(a)
+-#endif
+ 
+ 	.p2align 6
+ ENTRY (memset)
+@@ -42,5 +41,4 @@ ENTRY (memset)
+   ret
+ 
+ END (memset)
+-libc_hidden_builtin_def (memset)
+ #endif
+\ No newline at end of file
+diff --git a/sysdeps/riscv/rv64/multiarch/rtld-memmove.c b/sysdeps/riscv/rv64/multiarch/rtld-memmove.S
+similarity index 93%
+rename from sysdeps/riscv/rv64/multiarch/rtld-memmove.c
+rename to sysdeps/riscv/rv64/multiarch/rtld-memmove.S
+index 90e37dbd8b..fb6c2c3748 100644
+--- a/sysdeps/riscv/rv64/multiarch/rtld-memmove.c
++++ b/sysdeps/riscv/rv64/multiarch/rtld-memmove.S
+@@ -16,4 +16,5 @@
+    License along with the GNU C Library; if not, see
+    <https://www.gnu.org/licenses/>.  */
+ 
+-# include <string/memmove.c>
++//# include <string/memmove.c>
++#include "memmove_as.S"
+\ No newline at end of file
+diff --git a/sysdeps/riscv/rv64/multiarch/rtld-memrchr.S b/sysdeps/riscv/rv64/multiarch/rtld-memrchr.S
+new file mode 100644
+index 0000000000..b1154d0f2a
+--- /dev/null
++++ b/sysdeps/riscv/rv64/multiarch/rtld-memrchr.S
+@@ -0,0 +1 @@
++#include "memrchr_as.S"
+\ No newline at end of file
+diff --git a/sysdeps/riscv/rv64/multiarch/rtld-strcmp.S b/sysdeps/riscv/rv64/multiarch/rtld-strcmp.S
+index eb6ff5f8d3..e59c57f738 100644
+--- a/sysdeps/riscv/rv64/multiarch/rtld-strcmp.S
++++ b/sysdeps/riscv/rv64/multiarch/rtld-strcmp.S
+@@ -1 +1 @@
+-#include "strcmp_.S"
+\ No newline at end of file
++#include "strcmp_as.S"
+\ No newline at end of file
+diff --git a/sysdeps/riscv/rv64/multiarch/strcmp_.S b/sysdeps/riscv/rv64/multiarch/strcmp_as.S
+similarity index 100%
+rename from sysdeps/riscv/rv64/multiarch/strcmp_.S
+rename to sysdeps/riscv/rv64/multiarch/strcmp_as.S
+diff --git a/sysdeps/riscv/rv64/multiarch/strcmp_riscv.S b/sysdeps/riscv/rv64/multiarch/strcmp_riscv.S
+index f5be83d5b7..abf2984230 100644
+--- a/sysdeps/riscv/rv64/multiarch/strcmp_riscv.S
++++ b/sysdeps/riscv/rv64/multiarch/strcmp_riscv.S
+@@ -6,8 +6,8 @@
+ # undef libc_hidden_builtin_def
+ # define libc_hidden_builtin_def(a)
+ 
+-#include "strcmp_.S"
+-#elif !defined __riscv_vector
++#include "strcmp_as.S"
++#else
+ 
+-#include "strcmp_.S"
++#include "strcmp_as.S"
+ #endif
+diff --git a/sysdeps/riscv/rv64/multiarch/strcmp_vector.S b/sysdeps/riscv/rv64/multiarch/strcmp_vector.S
+index d0b8e316f9..40fc474695 100644
+--- a/sysdeps/riscv/rv64/multiarch/strcmp_vector.S
++++ b/sysdeps/riscv/rv64/multiarch/strcmp_vector.S
+@@ -19,12 +19,10 @@
+ #include <sysdep.h>
+ 
+ /* For __riscv_vector this file defines strcmp.  */
+-#ifdef __riscv_vector 
+-#ifdef SHARED
++#if IS_IN (libc) && defined SHARED && defined __riscv_vector
+ # define strcmp __strcmp_vector
+ # undef libc_hidden_builtin_def
+ # define libc_hidden_builtin_def(a)
+-#endif 
+ 
+ 	.p2align 6
+ ENTRY (strcmp)
+@@ -51,5 +49,5 @@ ENTRY (strcmp)
+    ret
+ 
+ END (strcmp)
+-libc_hidden_builtin_def (strcmp)
++
+ #endif
+diff --git a/sysdeps/riscv/rv64/multiarch/strlen_riscv.c b/sysdeps/riscv/rv64/multiarch/strlen_riscv.c
+index d605941766..d3bae0fc43 100644
+--- a/sysdeps/riscv/rv64/multiarch/strlen_riscv.c
++++ b/sysdeps/riscv/rv64/multiarch/strlen_riscv.c
+@@ -24,7 +24,7 @@
+ #undef weak_alias
+ #  define STRLEN __strlen_riscv
+ # include <string/strlen.c>
+-#elif !defined __riscv_vector
++#else
+ 
+ # include <string/strlen.c>
+ #endif
+diff --git a/sysdeps/riscv/rv64/multiarch/strlen_vector.S b/sysdeps/riscv/rv64/multiarch/strlen_vector.S
+index f674de3a26..0b4ae7ba90 100644
+--- a/sysdeps/riscv/rv64/multiarch/strlen_vector.S
++++ b/sysdeps/riscv/rv64/multiarch/strlen_vector.S
+@@ -19,12 +19,10 @@
+ #include <sysdep.h>
+ 
+ /* For __riscv_vector this file defines strlen.  */
+-#ifdef __riscv_vector 
+-#ifdef SHARED
++#if IS_IN (libc) && defined SHARED && defined __riscv_vector
+ # define strlen __strlen_vector
+ # undef libc_hidden_builtin_def
+ # define libc_hidden_builtin_def(a)
+-#endif
+ 
+ 	.p2align 6
+ ENTRY (strlen)
+@@ -44,5 +42,5 @@ ENTRY (strlen)
+    ret
+ 
+ END (strlen)
+-libc_hidden_builtin_def (strlen)
++
+ #endif
+\ No newline at end of file
+-- 
+2.25.1
+

+ 0 - 205
recipes-core/glibc/glibc/0010-ppc-sqrt-Fix-undefined-reference-to-__sqrt_finite.patch

@@ -1,205 +0,0 @@
-From 5da3da7f2d276c2a6ae1b04419b28e96953803ec Mon Sep 17 00:00:00 2001
-From: Khem Raj <raj.khem@gmail.com>
-Date: Wed, 18 Mar 2015 00:15:07 +0000
-Subject: [PATCH] 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  <raj.khem@gmail.com>
-
-        * 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 <raj.khem@gmail.com>
----
- 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)

+ 0 - 384
recipes-core/glibc/glibc/0011-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch

@@ -1,384 +0,0 @@
-From 77f1c90d67a2f8852184fb8fd95cb0ed63065dc7 Mon Sep 17 00:00:00 2001
-From: Khem Raj <raj.khem@gmail.com>
-Date: Wed, 18 Mar 2015 00:16:38 +0000
-Subject: [PATCH] __ieee754_sqrt{,f} are now inline functions and call out
- __slow versions
-
-Upstream-Status: Pending
-
-Signed-off-by: Khem Raj <raj.khem@gmail.com>
----
- 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)

+ 32 - 0
recipes-core/glibc/glibc/0011-add-alias-to-bcmp.patch

@@ -0,0 +1,32 @@
+From c598ae46e8159326563883b6243de8ac8391dc45 Mon Sep 17 00:00:00 2001
+From: "max.ma" <max.ma@starfivetech.com>
+Date: Tue, 13 Sep 2022 18:33:27 -0700
+Subject: [PATCH 11/19] add alias to bcmp
+
+---
+ sysdeps/riscv/rv64/multiarch/memcmp_as.S | 11 ++++++++++-
+ 1 file changed, 10 insertions(+), 1 deletion(-)
+
+diff --git a/sysdeps/riscv/rv64/multiarch/memcmp_as.S b/sysdeps/riscv/rv64/multiarch/memcmp_as.S
+index a737172980..c9c6b3e909 100644
+--- a/sysdeps/riscv/rv64/multiarch/memcmp_as.S
++++ b/sysdeps/riscv/rv64/multiarch/memcmp_as.S
+@@ -146,5 +146,14 @@ ENTRY (memcmp)
+     li      a0, 0
+     ret
+ END (memcmp)
+-
+ libc_hidden_builtin_def (memcmp)
++
++#ifdef weak_alias
++# undef bcmp
++weak_alias (memcmp, bcmp)
++#endif
++
++#undef __memcmpeq
++strong_alias (memcmp, __memcmpeq)
++libc_hidden_def(__memcmpeq)
++
+-- 
+2.25.1
+

+ 4 - 4
recipes-core/glibc/glibc/0020-eglibc-Help-bootstrap-cross-toolchain.patch → recipes-core/glibc/glibc/0011-eglibc-Help-bootstrap-cross-toolchain.patch

@@ -1,4 +1,4 @@
-From 7856684f76c100155cad11b5b236fb31234b6e28 Mon Sep 17 00:00:00 2001
+From 7f2fd574646cb5ecbbc09372a2d8580ab72ec158 Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Wed, 18 Mar 2015 00:49:28 +0000
 Subject: [PATCH] eglibc: Help bootstrap cross toolchain
@@ -29,7 +29,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
  create mode 100644 include/stubs-bootstrap.h
 
 diff --git a/Makefile b/Makefile
-index f98d5a9e67..c36d04da0f 100644
+index 179dd478ff..55cfb740bf 100644
 --- a/Makefile
 +++ b/Makefile
 @@ -79,9 +79,18 @@ subdir-dirs = include
@@ -52,7 +52,7 @@ index f98d5a9e67..c36d04da0f 100644
  ifeq (yes,$(build-shared))
  headers += gnu/lib-names.h
  endif
-@@ -415,6 +424,16 @@ others: $(common-objpfx)testrun.sh $(common-objpfx)debugglibc.sh
+@@ -421,6 +430,16 @@ others: $(common-objpfx)testrun.sh $(common-objpfx)debugglibc.sh
  
  subdir-stubs := $(foreach dir,$(subdirs),$(common-objpfx)$(dir)/stubs)
  
@@ -69,7 +69,7 @@ index f98d5a9e67..c36d04da0f 100644
  ifndef abi-variants
  installed-stubs = $(inst_includedir)/gnu/stubs.h
  else
-@@ -441,6 +460,7 @@ $(inst_includedir)/gnu/stubs.h: $(+force)
+@@ -447,6 +466,7 @@ $(inst_includedir)/gnu/stubs.h: $(+force)
  
  install-others-nosubdir: $(installed-stubs)
  endif

+ 0 - 58
recipes-core/glibc/glibc/0012-Quote-from-bug-1443-which-explains-what-the-patch-do.patch

@@ -1,58 +0,0 @@
-From add514edf4299d1bf540d85d0aa0bd5fe0d46b78 Mon Sep 17 00:00:00 2001
-From: Khem Raj <raj.khem@gmail.com>
-Date: Wed, 18 Mar 2015 00:20:09 +0000
-Subject: [PATCH] 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 <andrei.adrianx.dinu@intel.com>
-Signed-off-by: Khem Raj <raj.khem@gmail.com>
----
- 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 ff5e09e207..d68bfe5cbe 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:

+ 0 - 49
recipes-core/glibc/glibc/0012-add-hwcap.h-header-file.patch

@@ -1,49 +0,0 @@
-From b20b70ad45a75c817b2320bed6c8f463e230c20e Mon Sep 17 00:00:00 2001
-From: "max.ma" <max.ma@starfivetech.com>
-Date: Mon, 14 Feb 2022 15:40:51 -0800
-Subject: [PATCH 12/12] add hwcap.h header file
-
----
- sysdeps/unix/sysv/linux/riscv/bits/hwcap.h | 30 ++++++++++++++++++++++
- 1 file changed, 30 insertions(+)
- create mode 100644 sysdeps/unix/sysv/linux/riscv/bits/hwcap.h
-
-diff --git a/sysdeps/unix/sysv/linux/riscv/bits/hwcap.h b/sysdeps/unix/sysv/linux/riscv/bits/hwcap.h
-new file mode 100644
-index 0000000000..a90e7bb070
---- /dev/null
-+++ b/sysdeps/unix/sysv/linux/riscv/bits/hwcap.h
-@@ -0,0 +1,30 @@
-+/* Defines for bits in AT_HWCAP.  RISC-V Linux version.
-+   Copyright (C) 2021 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, see
-+   <http://www.gnu.org/licenses/>.  */
-+
-+#if !defined (_SYS_AUXV_H) && !defined (_LINUX_RISCV_SYSDEP_H)
-+# error "Never include <bits/hwcap.h> directly; use <sys/auxv.h> instead."
-+#endif
-+
-+/* The following must match the kernel's <asm/hwcap.h>.  */
-+#define HWCAP_ISA_I      0x100		//(1 << ('I' - 'A'))
-+#define HWCAP_ISA_M      0x1000 	//(1 << ('M' - 'A'))
-+#define HWCAP_ISA_A      0x1		//(1 << ('A' - 'A'))
-+#define HWCAP_ISA_F      0x20		//(1 << ('F' - 'A'))
-+#define HWCAP_ISA_D      0x8		//(1 << ('D' - 'A'))
-+#define HWCAP_ISA_C      0x4		//(1 << ('C' - 'A'))
-+#define HWCAP_ISA_V      0x200000	//(1 << ('V' - 'A'))
--- 
-2.33.1
-

+ 2 - 2
recipes-core/glibc/glibc/0021-eglibc-Resolve-__fpscr_values-on-SH4.patch → recipes-core/glibc/glibc/0012-eglibc-Resolve-__fpscr_values-on-SH4.patch

@@ -1,4 +1,4 @@
-From 111ab95a85314d1e70fb159a14250354cc69d899 Mon Sep 17 00:00:00 2001
+From 9f1803a2f91d59a9478ca4d8d93e1de5c62671e5 Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Wed, 18 Mar 2015 00:55:53 +0000
 Subject: [PATCH] eglibc: Resolve __fpscr_values on SH4
@@ -33,7 +33,7 @@ index 9c734ff755..974e33b4b1 100644
      # a*
      alphasort64;
 diff --git a/sysdeps/unix/sysv/linux/sh/sysdep.S b/sysdeps/unix/sysv/linux/sh/sysdep.S
-index a18fbb2e8b..59421bfbb0 100644
+index c5e3a7a365..35120031c4 100644
 --- a/sysdeps/unix/sysv/linux/sh/sysdep.S
 +++ b/sysdeps/unix/sysv/linux/sh/sysdep.S
 @@ -30,3 +30,14 @@ ENTRY (__syscall_error)

+ 30 - 56
recipes-core/glibc/glibc/0010-Revert-RISC-V-Save-and-restore-VCSR-when-doing-user-.patch → recipes-core/glibc/glibc/0012-remove-unnecessary-changes-to-support-v.patch

@@ -1,24 +1,21 @@
-From edd15521391233dec3a1538c1e091881395b277b Mon Sep 17 00:00:00 2001
+From 0df4da2c05981efe9aab12570b68106fca1e801d Mon Sep 17 00:00:00 2001
 From: "max.ma" <max.ma@starfivetech.com>
-Date: Wed, 9 Feb 2022 23:12:18 -0800
-Subject: [PATCH 10/12] Revert "RISC-V: Save and restore VCSR when doing user
- context switch"
+Date: Fri, 7 Oct 2022 22:45:48 -0700
+Subject: [PATCH 12/19] remove unnecessary changes to support v
 
-This reverts commit 1c08ed548a24c41542bdb7309e05c1aef70f135d.
 ---
  sysdeps/riscv/Makefile                       |  5 ---
  sysdeps/riscv/rtld-global-offsets.sym        |  7 ----
- sysdeps/unix/sysv/linux/riscv/bits/hwcap.h   | 31 ---------------
- sysdeps/unix/sysv/linux/riscv/getcontext.S   | 22 +----------
+ sysdeps/unix/sysv/linux/riscv/getcontext.S   | 24 +-----------
  sysdeps/unix/sysv/linux/riscv/setcontext.S   | 22 -----------
  sysdeps/unix/sysv/linux/riscv/swapcontext.S  | 41 --------------------
- sysdeps/unix/sysv/linux/riscv/ucontext_i.sym |  6 ---
- 7 files changed, 1 insertion(+), 133 deletions(-)
+ sysdeps/unix/sysv/linux/riscv/sys/ucontext.h |  2 -
+ sysdeps/unix/sysv/linux/riscv/ucontext_i.sym |  5 ---
+ 7 files changed, 2 insertions(+), 104 deletions(-)
  delete mode 100644 sysdeps/riscv/rtld-global-offsets.sym
- delete mode 100644 sysdeps/unix/sysv/linux/riscv/bits/hwcap.h
 
 diff --git a/sysdeps/riscv/Makefile b/sysdeps/riscv/Makefile
-index a5c2106a09..20a9968106 100644
+index e2d84640d4..8fb10b164f 100644
 --- a/sysdeps/riscv/Makefile
 +++ b/sysdeps/riscv/Makefile
 @@ -2,11 +2,6 @@ ifeq ($(subdir),misc)
@@ -46,45 +43,8 @@ index ff4e97f2a6..0000000000
 -#define rtld_global_ro_offsetof(mem) offsetof (struct rtld_global_ro, mem)
 -
 -RTLD_GLOBAL_RO_DL_HWCAP_OFFSET	rtld_global_ro_offsetof (_dl_hwcap)
-diff --git a/sysdeps/unix/sysv/linux/riscv/bits/hwcap.h b/sysdeps/unix/sysv/linux/riscv/bits/hwcap.h
-deleted file mode 100644
-index e6c5ef5740..0000000000
---- a/sysdeps/unix/sysv/linux/riscv/bits/hwcap.h
-+++ /dev/null
-@@ -1,31 +0,0 @@
--/* Defines for bits in AT_HWCAP.  RISC-V Linux version.
--   Copyright (C) 2021 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, see
--   <http://www.gnu.org/licenses/>.  */
--
--#if !defined (_SYS_AUXV_H) && !defined (_LINUX_RISCV_SYSDEP_H)
--# error "Never include <bits/hwcap.h> directly; use <sys/auxv.h> instead."
--#endif
--
--/* The following must match the kernel's <asm/hwcap.h>.  */
--#define HWCAP_ISA_I      0x100		//(1 << ('I' - 'A'))
--#define HWCAP_ISA_M      0x1000 	//(1 << ('M' - 'A'))
--#define HWCAP_ISA_A      0x1		//(1 << ('A' - 'A'))
--#define HWCAP_ISA_F      0x20		//(1 << ('F' - 'A'))
--#define HWCAP_ISA_D      0x8		//(1 << ('D' - 'A'))
--#define HWCAP_ISA_C      0x4		//(1 << ('C' - 'A'))
--#define HWCAP_ISA_V      0x200000	//(1 << ('V' - 'A'))
--
 diff --git a/sysdeps/unix/sysv/linux/riscv/getcontext.S b/sysdeps/unix/sysv/linux/riscv/getcontext.S
-index 840d8feca4..d6a9bbca60 100644
+index 371ebd52a7..499f70b65d 100644
 --- a/sysdeps/unix/sysv/linux/riscv/getcontext.S
 +++ b/sysdeps/unix/sysv/linux/riscv/getcontext.S
 @@ -16,8 +16,6 @@
@@ -126,10 +86,12 @@ index 840d8feca4..d6a9bbca60 100644
  99:	j	__syscall_error
  
  PSEUDO_END (__getcontext)
+-weak_alias (__getcontext, getcontext)
+\ No newline at end of file
 +
- weak_alias (__getcontext, getcontext)
++weak_alias (__getcontext, getcontext)
 diff --git a/sysdeps/unix/sysv/linux/riscv/setcontext.S b/sysdeps/unix/sysv/linux/riscv/setcontext.S
-index d2404fbe9c..9510518750 100644
+index 423d94df27..e3bc84a2e6 100644
 --- a/sysdeps/unix/sysv/linux/riscv/setcontext.S
 +++ b/sysdeps/unix/sysv/linux/riscv/setcontext.S
 @@ -16,8 +16,6 @@
@@ -169,7 +131,7 @@ index d2404fbe9c..9510518750 100644
  	   unless makecontext() has been called.  */
  	RESTORE_INT_REG     (t1,   0, t0)
 diff --git a/sysdeps/unix/sysv/linux/riscv/swapcontext.S b/sysdeps/unix/sysv/linux/riscv/swapcontext.S
-index 94ae8e4bdc..df0f69969c 100644
+index 16600f78df..4da615f6d4 100644
 --- a/sysdeps/unix/sysv/linux/riscv/swapcontext.S
 +++ b/sysdeps/unix/sysv/linux/riscv/swapcontext.S
 @@ -16,8 +16,6 @@
@@ -234,8 +196,21 @@ index 94ae8e4bdc..df0f69969c 100644
  	/* Note the contents of argument registers will be random
  	   unless makecontext() has been called.  */
  	RESTORE_INT_REG (t1,   0, t0)
+diff --git a/sysdeps/unix/sysv/linux/riscv/sys/ucontext.h b/sysdeps/unix/sysv/linux/riscv/sys/ucontext.h
+index 1b370f0f45..e226ee85ee 100644
+--- a/sysdeps/unix/sysv/linux/riscv/sys/ucontext.h
++++ b/sysdeps/unix/sysv/linux/riscv/sys/ucontext.h
+@@ -82,8 +82,6 @@ typedef struct mcontext_t
+   {
+     __riscv_mc_gp_state __gregs;
+     union  __riscv_mc_fp_state __fpregs;
+-    /* 5K + 256 reserved for vector state and future expansion.  */
+-    unsigned char __reserved[5376] __attribute__ ((__aligned__ (16)));
+   } mcontext_t;
+ 
+ /* Userlevel context.  */
 diff --git a/sysdeps/unix/sysv/linux/riscv/ucontext_i.sym b/sysdeps/unix/sysv/linux/riscv/ucontext_i.sym
-index 4037473c9a..be55b26310 100644
+index b91945a080..be55b26310 100644
 --- a/sysdeps/unix/sysv/linux/riscv/ucontext_i.sym
 +++ b/sysdeps/unix/sysv/linux/riscv/ucontext_i.sym
 @@ -2,7 +2,6 @@
@@ -246,17 +221,16 @@ index 4037473c9a..be55b26310 100644
  
  -- Constants used by the rt_sigprocmask call.
  
-@@ -28,10 +27,5 @@ STACK_FLAGS			stack (ss_flags)
+@@ -28,9 +27,5 @@ STACK_FLAGS			stack (ss_flags)
  
  MCONTEXT_GREGS			mcontext (__gregs)
  MCONTEXT_FPREGS			mcontext (__fpregs)
 -MCONTEXT_EXTENSION 		mcontext (__reserved)
  
  UCONTEXT_SIZE			sizeof (ucontext_t)
--
 -VCSR_OFFSET			offsetof (struct __riscv_v_state, vcsr)
 -
 -RVV_MAGIC
 -- 
-2.33.1
+2.25.1
 

+ 41 - 41
recipes-core/glibc/glibc/0022-eglibc-Forward-port-cross-locale-generation-support.patch → recipes-core/glibc/glibc/0013-eglibc-Forward-port-cross-locale-generation-support.patch

@@ -1,4 +1,4 @@
-From 4e5de801a39d66b8bd93d09f5912dcbe5db4ef04 Mon Sep 17 00:00:00 2001
+From 2c6449014151a4bcd4b253b2acc920f0b3d6b13f Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Wed, 18 Mar 2015 01:33:49 +0000
 Subject: [PATCH] eglibc: Forward port cross locale generation support
@@ -23,7 +23,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
  create mode 100644 locale/catnames.c
 
 diff --git a/locale/Makefile b/locale/Makefile
-index b7c60681fa..07c606cde3 100644
+index eb55750496..b0461ac4b9 100644
 --- a/locale/Makefile
 +++ b/locale/Makefile
 @@ -26,7 +26,8 @@ headers		= langinfo.h locale.h bits/locale.h \
@@ -89,10 +89,10 @@ index 0000000000..538f3f5edb
 +    [LC_ALL] = sizeof ("LC_ALL") - 1
 +  };
 diff --git a/locale/localeinfo.h b/locale/localeinfo.h
-index 22f9dc1140..fa31b3c5ea 100644
+index 3dc26272a0..b667d32c23 100644
 --- a/locale/localeinfo.h
 +++ b/locale/localeinfo.h
-@@ -230,7 +230,7 @@ __libc_tsd_define (extern, locale_t, LOCALE)
+@@ -246,7 +246,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.  */
@@ -102,7 +102,7 @@ index 22f9dc1140..fa31b3c5ea 100644
  # define NL_CURRENT_INDIRECT	1
  #endif
 diff --git a/locale/programs/charmap-dir.c b/locale/programs/charmap-dir.c
-index 4841bfd05d..ffcba1fd79 100644
+index 396a0d76c0..91f4a765ee 100644
 --- a/locale/programs/charmap-dir.c
 +++ b/locale/programs/charmap-dir.c
 @@ -18,7 +18,9 @@
@@ -148,10 +148,10 @@ index 4841bfd05d..ffcba1fd79 100644
    return NULL;
  }
 diff --git a/locale/programs/ld-collate.c b/locale/programs/ld-collate.c
-index b6406b775d..bfa4adba9c 100644
+index 992814491d..da4dde4663 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,
+@@ -352,7 +352,7 @@ new_element (struct locale_collate_t *collate, const char *mbs, size_t mbslen,
      }
    if (wcs != NULL)
      {
@@ -160,7 +160,7 @@ index b6406b775d..bfa4adba9c 100644
        uint32_t zero = 0;
        /* Handle <U0000> as a single character.  */
        if (nwcs == 0)
-@@ -1775,8 +1775,7 @@ symbol `%s' has the same encoding as"), (*eptr)->name);
+@@ -1776,8 +1776,7 @@ symbol `%s' has the same encoding as"), (*eptr)->name);
  
  	      if ((*eptr)->nwcs == runp->nwcs)
  		{
@@ -170,7 +170,7 @@ index b6406b775d..bfa4adba9c 100644
  
  		  if (c == 0)
  		    {
-@@ -2003,9 +2002,9 @@ add_to_tablewc (uint32_t ch, struct element_t *runp)
+@@ -2004,9 +2003,9 @@ add_to_tablewc (uint32_t ch, struct element_t *runp)
  	     one consecutive entry.  */
  	  if (runp->wcnext != NULL
  	      && runp->nwcs == runp->wcnext->nwcs
@@ -183,7 +183,7 @@ index b6406b775d..bfa4adba9c 100644
  	      && (runp->wcs[runp->nwcs - 1]
  		  == runp->wcnext->wcs[runp->nwcs - 1] + 1))
  	    {
-@@ -2029,9 +2028,9 @@ add_to_tablewc (uint32_t ch, struct element_t *runp)
+@@ -2030,9 +2029,9 @@ add_to_tablewc (uint32_t ch, struct element_t *runp)
  		runp = runp->wcnext;
  	      while (runp->wcnext != NULL
  		     && runp->nwcs == runp->wcnext->nwcs
@@ -197,10 +197,10 @@ index b6406b775d..bfa4adba9c 100644
  			 == runp->wcnext->wcs[runp->nwcs - 1] + 1));
  
 diff --git a/locale/programs/ld-ctype.c b/locale/programs/ld-ctype.c
-index 2fb579bbbf..d0be99581c 100644
+index c6749dbd82..ac99777925 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,
+@@ -914,7 +914,7 @@ ctype_output (struct localedef_t *locale, const struct charmap_t *charmap,
    allocate_arrays (ctype, charmap, ctype->repertoire);
  
    default_missing_len = (ctype->default_missing
@@ -209,7 +209,7 @@ index 2fb579bbbf..d0be99581c 100644
  			 : 0);
  
    init_locale_data (&file, nelems);
-@@ -1927,7 +1927,7 @@ read_translit_entry (struct linereader *ldfile, struct locale_ctype_t *ctype,
+@@ -1926,7 +1926,7 @@ read_translit_entry (struct linereader *ldfile, struct locale_ctype_t *ctype,
  	    ignore = 1;
  	  else
  	    /* This value is usable.  */
@@ -218,7 +218,7 @@ index 2fb579bbbf..d0be99581c 100644
  
  	  first = 0;
  	}
-@@ -2461,8 +2461,8 @@ with character code range values one must use the absolute ellipsis `...'"));
+@@ -2460,8 +2460,8 @@ with character code range values one must use the absolute ellipsis `...'"));
  	    }
  
  	handle_tok_digit:
@@ -229,7 +229,7 @@ index 2fb579bbbf..d0be99581c 100644
  	  handle_digits = 1;
  	  goto read_charclass;
  
-@@ -3904,8 +3904,7 @@ allocate_arrays (struct locale_ctype_t *ctype, const struct charmap_t *charmap,
+@@ -3876,8 +3876,7 @@ allocate_arrays (struct locale_ctype_t *ctype, const struct charmap_t *charmap,
  
  	  while (idx < number)
  	    {
@@ -239,7 +239,7 @@ index 2fb579bbbf..d0be99581c 100644
  	      if (res == 0)
  		{
  		  replace = 1;
-@@ -3942,11 +3941,11 @@ allocate_arrays (struct locale_ctype_t *ctype, const struct charmap_t *charmap,
+@@ -3914,11 +3913,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;
@@ -253,7 +253,7 @@ index 2fb579bbbf..d0be99581c 100644
  	      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,
+@@ -3942,18 +3941,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;
  
@@ -279,10 +279,10 @@ index 2fb579bbbf..d0be99581c 100644
  	      srunp = srunp->next;
  	    }
 diff --git a/locale/programs/ld-time.c b/locale/programs/ld-time.c
-index dcd2a2386d..6814740325 100644
+index b58fecfcee..a4d70e0780 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");
+@@ -219,8 +219,10 @@ No definition for %s category found"), "LC_TIME");
  	}
        else
  	{
@@ -294,7 +294,7 @@ index dcd2a2386d..6814740325 100644
  	}
      }
  
-@@ -231,7 +233,7 @@ No definition for %s category found"), "LC_TIME");
+@@ -230,7 +232,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;
@@ -303,7 +303,7 @@ index dcd2a2386d..6814740325 100644
  
        time->era_entries =
  	(struct era_data *) xmalloc (time->num_era
-@@ -457,18 +459,18 @@ No definition for %s category found"), "LC_TIME");
+@@ -456,18 +458,18 @@ No definition for %s category found"), "LC_TIME");
  	    }
  
  	  /* Now generate the wide character name and format.  */
@@ -329,7 +329,7 @@ index dcd2a2386d..6814740325 100644
  		}
  	      else
  		time->era_entries[idx].wname =
-@@ -527,7 +529,16 @@ No definition for %s category found"), "LC_TIME");
+@@ -526,7 +528,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)
@@ -348,23 +348,23 @@ index dcd2a2386d..6814740325 100644
  
  
 diff --git a/locale/programs/linereader.c b/locale/programs/linereader.c
-index 96d3ab66db..3af379d2c3 100644
+index 0460074a0c..31a7151f66 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,
+@@ -776,7 +776,7 @@ get_string (struct linereader *lr, const struct charmap_t *charmap,
  {
    int return_widestr = lr->return_widestr;
-   char *buf;
+   struct lr_buffer lrb;
 -  wchar_t *buf2 = NULL;
 +  uint32_t *buf2 = NULL;
-   size_t bufact;
-   size_t bufmax = 56;
+ 
+   lr_buffer_init (&lrb);
  
 diff --git a/locale/programs/localedef.c b/locale/programs/localedef.c
-index 832c8fd1fc..fe689b3ae1 100644
+index 35a092a111..94712bf114 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;
+@@ -108,6 +108,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
@@ -372,7 +372,7 @@ index 832c8fd1fc..fe689b3ae1 100644
  
  /* Definitions of arguments for argp functions.  */
  static const struct argp_option options[] =
-@@ -153,6 +154,8 @@ static const struct argp_option options[] =
+@@ -152,6 +153,8 @@ static const struct argp_option options[] =
      N_("Generate little-endian output") },
    { "big-endian", OPT_BIG_ENDIAN, NULL, 0,
      N_("Generate big-endian output") },
@@ -381,7 +381,7 @@ index 832c8fd1fc..fe689b3ae1 100644
    { NULL, 0, NULL, 0, NULL }
  };
  
-@@ -243,12 +246,14 @@ main (int argc, char *argv[])
+@@ -242,12 +245,14 @@ main (int argc, char *argv[])
       ctype locale.  (P1003.2 4.35.5.2)  */
    setlocale (LC_CTYPE, "POSIX");
  
@@ -396,7 +396,7 @@ index 832c8fd1fc..fe689b3ae1 100644
  
    /* Process charmap file.  */
    charmap = charmap_read (charmap_file, verbose, 1, be_quiet, 1);
-@@ -400,6 +405,9 @@ parse_opt (int key, char *arg, struct argp_state *state)
+@@ -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;
@@ -407,10 +407,10 @@ index 832c8fd1fc..fe689b3ae1 100644
        force_output = 1;
        break;
 diff --git a/locale/programs/locfile.c b/locale/programs/locfile.c
-index 0f1affa1d4..7d86fae801 100644
+index 8fa74dce60..8d5aca6d9e 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,
+@@ -543,6 +543,9 @@ compare_files (const char *filename1, const char *filename2, size_t size,
     machine running localedef.  */
  bool swap_endianness_p;
  
@@ -420,7 +420,7 @@ index 0f1affa1d4..7d86fae801 100644
  /* 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)
+@@ -620,7 +623,7 @@ add_locale_string (struct locale_file *file, const char *string)
  void
  add_locale_wstring (struct locale_file *file, const uint32_t *string)
  {
@@ -430,10 +430,10 @@ index 0f1affa1d4..7d86fae801 100644
  
  /* Record that FILE's next element is the 32-bit integer VALUE.  */
 diff --git a/locale/programs/locfile.h b/locale/programs/locfile.h
-index c986d599ec..222a779176 100644
+index 57b2211e2f..e9498c6c7e 100644
 --- a/locale/programs/locfile.h
 +++ b/locale/programs/locfile.h
-@@ -71,6 +71,8 @@ extern void write_all_categories (struct localedef_t *definitions,
+@@ -70,6 +70,8 @@ extern void write_all_categories (struct localedef_t *definitions,
  
  extern bool swap_endianness_p;
  
@@ -442,7 +442,7 @@ index c986d599ec..222a779176 100644
  /* 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)
+@@ -88,7 +90,8 @@ maybe_swap_uint32 (uint32_t value)
  }
  
  /* Likewise, but munge an array of N uint32_ts starting at ARRAY.  */
@@ -452,7 +452,7 @@ index c986d599ec..222a779176 100644
  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)
+@@ -98,7 +101,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.  */
@@ -462,7 +462,7 @@ index c986d599ec..222a779176 100644
  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,
+@@ -275,4 +279,55 @@ extern void identification_output (struct localedef_t *locale,
  				   const struct charmap_t *charmap,
  				   const char *output_path);
  
@@ -519,7 +519,7 @@ index c986d599ec..222a779176 100644
 +
  #endif /* locfile.h */
 diff --git a/locale/setlocale.c b/locale/setlocale.c
-index 19ed85ae8e..f28ca11446 100644
+index 56c14d8533..6aac00503e 100644
 --- a/locale/setlocale.c
 +++ b/locale/setlocale.c
 @@ -63,35 +63,6 @@ static char *const _nl_current_used[] =

+ 0 - 33
recipes-core/glibc/glibc/0013-eglibc-run-libm-err-tab.pl-with-specific-dirs-in-S.patch

@@ -1,33 +0,0 @@
-From c5047b8f7d1a17324cfa02b99f07a70ebcec2cf2 Mon Sep 17 00:00:00 2001
-From: Ting Liu <b28495@freescale.com>
-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 <b28495@freescale.com>
----
- manual/Makefile | 3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
-
-diff --git a/manual/Makefile b/manual/Makefile
-index e83444341e..aa2645bc55 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 $@
- 

+ 46 - 0
recipes-core/glibc/glibc/0013-fix-compiling-error-when-march-not-include-b-ext.patch

@@ -0,0 +1,46 @@
+From 66b5c3e50b1acf0a4cb7cdaf7ddad7c7f8e2c3b8 Mon Sep 17 00:00:00 2001
+From: "demin.han" <demin.han@starfivetech.com>
+Date: Mon, 31 Oct 2022 11:20:22 +0800
+Subject: [PATCH 13/19] fix compiling error when -march not include b ext
+
+---
+ sysdeps/riscv/rv64/multiarch/memchr_as.S | 4 +++-
+ sysdeps/riscv/rv64/multiarch/memrchr.S   | 2 ++
+ 2 files changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/sysdeps/riscv/rv64/multiarch/memchr_as.S b/sysdeps/riscv/rv64/multiarch/memchr_as.S
+index e614630a4d..aa6c22a3d0 100644
+--- a/sysdeps/riscv/rv64/multiarch/memchr_as.S
++++ b/sysdeps/riscv/rv64/multiarch/memchr_as.S
+@@ -19,6 +19,8 @@
+ 
+ #include <sysdep.h>
+ 
++.option arch, +zbb
++
+ .macro chr_8B
+     ld      a4, 0(a0)
+     xor     a4, a4, a1
+@@ -105,4 +107,4 @@ ENTRY (memchr)
+     add     a0, a0, a3
+     ret
+ END (memchr)
+-libc_hidden_builtin_def (memchr)
+\ No newline at end of file
++libc_hidden_builtin_def (memchr)
+diff --git a/sysdeps/riscv/rv64/multiarch/memrchr.S b/sysdeps/riscv/rv64/multiarch/memrchr.S
+index c6db183163..01c2d949de 100644
+--- a/sysdeps/riscv/rv64/multiarch/memrchr.S
++++ b/sysdeps/riscv/rv64/multiarch/memrchr.S
+@@ -19,6 +19,8 @@
+ 
+ #include <sysdep.h>
+ 
++.option arch, +zbb
++
+ .macro chr_8B
+     ld      a4, -8(a0)
+     xor     a4, a4, a1
+-- 
+2.25.1
+

+ 0 - 58
recipes-core/glibc/glibc/0014-__ieee754_sqrt-f-are-now-inline-functions-and-call-o.patch

@@ -1,58 +0,0 @@
-From 133870f12ba36686dd8df1311fac32a4c5b28579 Mon Sep 17 00:00:00 2001
-From: Khem Raj <raj.khem@gmail.com>
-Date: Wed, 18 Mar 2015 00:24:46 +0000
-Subject: [PATCH] __ieee754_sqrt{,f} are now inline functions and call out
- __slow versions
-
-Upstream-Status: Pending
-
-Signed-off-by: chunrong guo <B40290@freescale.com>
-Signed-off-by: Khem Raj <raj.khem@gmail.com>
----
- 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
- {

+ 53 - 0
recipes-core/glibc/glibc/0014-fix-memcmp-bug-relate-to-use-jmp-table.patch

@@ -0,0 +1,53 @@
+From c3dd8b0c45f338b0f5bca70871ea08322fe499d0 Mon Sep 17 00:00:00 2001
+From: "demin.han" <demin.han@starfivetech.com>
+Date: Fri, 11 Nov 2022 14:29:51 +0800
+Subject: [PATCH 14/19] fix memcmp bug relate to use jmp table
+
+jump table tech is not suitable for memcmp
+memcmp has order requirement, but jmp table has reverse order feature
+---
+ sysdeps/riscv/rv64/multiarch/memcmp_as.S | 25 +++++++++++-------------
+ 1 file changed, 11 insertions(+), 14 deletions(-)
+
+diff --git a/sysdeps/riscv/rv64/multiarch/memcmp_as.S b/sysdeps/riscv/rv64/multiarch/memcmp_as.S
+index c9c6b3e909..984aeb7645 100644
+--- a/sysdeps/riscv/rv64/multiarch/memcmp_as.S
++++ b/sysdeps/riscv/rv64/multiarch/memcmp_as.S
+@@ -113,23 +113,20 @@ ENTRY (memcmp)
+     bltu    a5, a4, .L_loop
+     beqz    a2, .L_end
+ .L_tail:
+-    andi    a4, a2, -1
+-.L_pc:
+-    auipc   a3, 0
+-    andi    a4, a4, -8
+-    sub     a3, a3, a4
+-    .equ    offset, .L_jmp_end - .L_pc
+-    jalr    x0, a3, %lo(offset)
+-    ld      a3, 16(a1)
+-    ld      a0, 16(a5)
+-    bne     a3, a0, .L_end
+-    ld      a3, 8(a1)
+-    ld      a0, 8(a5)
+-    bne     a3, a0, .L_end
++    andi    a4, a2, -8
++    beqz    a4, .L_last
++    add     a4, a4, a5
++0:
+     ld      a3, 0(a1)
+     ld      a0, 0(a5)
+     bne     a3, a0, .L_end
+-.L_jmp_end:
++    add     a5, a5, 8
++    add     a1, a1, 8
++    bltu    a5, a4, 0b
++
++.L_last:
++    andi    a2, a2, (8-1)
++    beqz    a2, 3f
+     add     a1, a1, a2
+     add     a5, a5, a2
+     ld      a3, -8(a1)
+-- 
+2.25.1
+

+ 5 - 5
recipes-core/glibc/glibc/0024-localedef-add-to-archive-uses-a-hard-coded-locale-pa.patch → recipes-core/glibc/glibc/0014-localedef-add-to-archive-uses-a-hard-coded-locale-pa.patch

@@ -1,4 +1,4 @@
-From 13bc0e53cc91e102472d532f28b3d44c30d291fc Mon Sep 17 00:00:00 2001
+From 8ebf6708ba54147b44f5638b93f123fd55d4c37e Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Fri, 3 Aug 2018 09:42:06 -0700
 Subject: [PATCH] localedef --add-to-archive uses a hard-coded locale path
@@ -18,10 +18,10 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
  1 file changed, 25 insertions(+), 10 deletions(-)
 
 diff --git a/locale/programs/locarchive.c b/locale/programs/locarchive.c
-index f38e835c52..8d8f8699b2 100644
+index eeb2fa6ffe..15274b0191 100644
 --- a/locale/programs/locarchive.c
 +++ b/locale/programs/locarchive.c
-@@ -340,12 +340,24 @@ enlarge_archive (struct locarhandle *ah, const struct locarhead *head)
+@@ -339,12 +339,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;
@@ -51,7 +51,7 @@ index f38e835c52..8d8f8699b2 100644
    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)
+@@ -568,10 +580,13 @@ open_archive (struct locarhandle *ah, bool readonly)
    /* If ah has a non-NULL fname open that otherwise open the default.  */
    if (archivefname == NULL)
      {
@@ -69,7 +69,7 @@ index f38e835c52..8d8f8699b2 100644
      }
  
    while (1)
-@@ -585,7 +600,7 @@ open_archive (struct locarhandle *ah, bool readonly)
+@@ -584,7 +599,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.  */

+ 4 - 4
recipes-core/glibc/glibc/0027-locale-prevent-maybe-uninitialized-errors-with-Os-BZ.patch → recipes-core/glibc/glibc/0015-locale-prevent-maybe-uninitialized-errors-with-Os-BZ.patch

@@ -1,4 +1,4 @@
-From 3190ada9ecaec915794886a608221655c120f90c Mon Sep 17 00:00:00 2001
+From bd2b87eaa2e99310f5439df95bea12a48dc978bf Mon Sep 17 00:00:00 2001
 From: Martin Jansa <martin.jansa@gmail.com>
 Date: Mon, 17 Dec 2018 21:36:18 +0000
 Subject: [PATCH] locale: prevent maybe-uninitialized errors with -Os [BZ
@@ -33,10 +33,10 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
  1 file changed, 7 insertions(+)
 
 diff --git a/locale/weight.h b/locale/weight.h
-index 723e1fefda..f5798d379a 100644
+index 8be2d220f8..4a4d5aa6b2 100644
 --- a/locale/weight.h
 +++ b/locale/weight.h
-@@ -28,7 +28,14 @@ findidx (const int32_t *table,
+@@ -27,7 +27,14 @@ findidx (const int32_t *table,
  	 const unsigned char *extra,
  	 const unsigned char **cpp, size_t len)
  {
@@ -46,7 +46,7 @@ index 723e1fefda..f5798d379a 100644
 +     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)++];
+   int32_t i = table[*(*cpp)++];
 +  DIAG_POP_NEEDS_COMMENT;
    const unsigned char *cp;
    const unsigned char *usrc;

+ 980 - 0
recipes-core/glibc/glibc/0015-memxxx-align-version-with-merge-tech-or-B-ext.patch

@@ -0,0 +1,980 @@
+From 58e09fded3cf5222461c2a0198b47368bb69d3d6 Mon Sep 17 00:00:00 2001
+From: "demin.han" <demin.han@starfivetech.com>
+Date: Fri, 2 Dec 2022 15:06:20 +0800
+Subject: [PATCH 15/19] memxxx align version with merge tech or B ext
+
+---
+ sysdeps/riscv/rv64/multiarch/memchr_as.S  | 115 +++++++--------
+ sysdeps/riscv/rv64/multiarch/memcmp_as.S  | 171 ++++++++++------------
+ sysdeps/riscv/rv64/multiarch/memcpy_as.S  | 145 +++++++++---------
+ sysdeps/riscv/rv64/multiarch/memmove_as.S |  62 +++++++-
+ sysdeps/riscv/rv64/multiarch/memrchr.S    | 114 +++++++--------
+ sysdeps/riscv/rv64/multiarch/memset_as.S  | 129 ++++++++--------
+ 6 files changed, 374 insertions(+), 362 deletions(-)
+
+diff --git a/sysdeps/riscv/rv64/multiarch/memchr_as.S b/sysdeps/riscv/rv64/multiarch/memchr_as.S
+index aa6c22a3d0..ad559e6a11 100644
+--- a/sysdeps/riscv/rv64/multiarch/memchr_as.S
++++ b/sysdeps/riscv/rv64/multiarch/memchr_as.S
+@@ -21,90 +21,75 @@
+ 
+ .option arch, +zbb
+ 
+-.macro chr_8B
+-    ld      a4, 0(a0)
+-    xor     a4, a4, a1
+-    sub     a3, a4, t1
+-    andn    a3, a3, a4
+-    and     a3, a3, a5
+-    bnez    a3, .L_find
+-.endm
+-.macro gen_pat
+-    slli    a3, a1, 8
+-    or      a1, a1, a3
+-    slli    a3, a1, 16
+-    or      a1, a1, a3
+-    slli    a3, a1, 32
+-    or      a1, a1, a3
+-
+-    li      a5, 0x80
+-    slli    a3, a5, 8
+-    or      a5, a5, a3
+-    slli    a3, a5, 16
+-    or      a5, a5, a3
+-    slli    a3, a5, 32
+-    or      a5, a5, a3  # 0x8080808080808080
+-    srli    t1, a5, 7   # 0x0101010101010101
+-.endm
+-
+ 	.p2align 6
+ ENTRY (memchr)
+-    li      a3, 7
+-    bgtu    a2, a3, .L_8_to_16
+-.L_0_to_7:
+-    beqz    a2, 1f
++    beqz    a2, .L_not_find
++    li      a4, 9
++    bltu    a2, a4, .L_0_to_8 
++    
++    neg     a4, a0
++    andi    a4, a4, 0x7
++    beqz    a4, .L_dst_aligned
++
++.L_0_to_8:
++    min     a4, a4, a2
++.L_head:
++    sub     a2, a2, a4
+ 0:
+-    lbu     a4, 0(a0)
+-    beq     a1, a4, 2f
+-    addi    a2, a2, -1
++    lbu     a3, 0(a0)
++    beq     a1, a3, .L_find_byte
++    addi    a4, a4, -1
+     addi    a0, a0, 1
+-    bnez    a2, 0b
+-1:
+-    li      a0, 0
+-    ret
+-2:
+-    ret
+-.L_8_to_16:
+-    gen_pat
+-    li      a3, 16
+-    bgtu    a2, a3, .L_over_16
+-    addi    a2, a2, -8
+-    chr_8B
+-    add     a0, a0, a2
+-    chr_8B
+-    j       .L_not_find
+-.L_over_16:
+-    neg     t4, a0
+-    andi    t4, t4, 0x7
+-    beqz    t4, .L_dst_aligned
+-    chr_8B
+-    sub     a2, a2, t4
+-    add     a0, a0, t4
++    bnez    a4, 0b
++    beqz    a2, .L_not_find
++
+ .L_dst_aligned:
+-    andi    t0, a2, (16-1)
++    andi    a4, a2, (16-1)
+     srli    a2, a2, 4
+     beqz    a2, .L_tail
++    
++    slli    a3, a1, 8
++    or      a1, a1, a3
++    slli    a3, a1, 16
++    or      a1, a1, a3
++    slli    a3, a1, 32
++    or      a1, a1, a3
++    li      a5, -1
+ .L_loop:
+-    chr_8B
+-    add     a0, a0, 8
+-    chr_8B
++    ld      a3, 0(a0)
++    xor     a3, a3, a1
++    orc.b   a3, a3
++    bne     a3, a5, .L_find
++    addi    a0, a0, 8
++    
++    ld      a3, 0(a0)
++    xor     a3, a3, a1
++    orc.b   a3, a3
++    bne     a3, a5, .L_find
++    
+     addi    a2, a2, -1
+     add     a0, a0, 8
+     bnez    a2, .L_loop
+-    beqz    t0, .L_not_find
++    beqz    a4, .L_not_find
++
+ .L_tail:
+-    add     a0, a0, t0
+-    addi    a0, a0, -16
+-    chr_8B
+-    add     a0, a0, 8
+-    chr_8B
++    andi    a1, a1, 0xff
++0:
++    lbu     a3, 0(a0)
++    beq     a1, a3, .L_find_byte
++    addi    a4, a4, -1
++    addi    a0, a0, 1
++    bnez    a4, 0b
++
+ .L_not_find:
+     li      a0, 0
+     ret
+ .L_find:
++    not     a3, a3
+     ctz     a3, a3
+     srli    a3, a3, 3
+     add     a0, a0, a3
++.L_find_byte:
+     ret
+ END (memchr)
+ libc_hidden_builtin_def (memchr)
+diff --git a/sysdeps/riscv/rv64/multiarch/memcmp_as.S b/sysdeps/riscv/rv64/multiarch/memcmp_as.S
+index 984aeb7645..972f6cb5fd 100644
+--- a/sysdeps/riscv/rv64/multiarch/memcmp_as.S
++++ b/sysdeps/riscv/rv64/multiarch/memcmp_as.S
+@@ -17,84 +17,46 @@
+    <http://www.gnu.org/licenses/>.  */
+ 
+ #include <sysdep.h>
++.option arch, +zbb
+ 
+ 	.p2align 6
+ ENTRY (memcmp)
+-    li      a3, 32
+     mv      a5, a0
+-    bgtu    a2, a3, .L_over_32
+-    li      a3, 3
+-    bgtu    a2, a3, .L_4_to_8
+-.L_0_to_3:
+-    beqz    a2, 2f
++    li      a4, 9
++    bltu    a2, a4, .L_0_to_8
++
++    neg     a4, a5
++    andi    a4, a4, 0x7
++    beqz    a4, .L_8B_aligned
++
++.L_0_to_8:
++    min     a4, a4, a2
++.L_head:
++    beqz    a4, 2f
++    sub     a2, a2, a4
++    add     a4, a4, a5
+ 0:
+     lbu     a3, 0(a1)
+-    lbu     a4, 0(a5)
+-    bne     a3, a4, 1f
+-    addi    a2, a2, -1
++    lbu     a0, 0(a5)
++    bne     a3, a0, 1f
+     addi    a1, a1, 1
+     addi    a5, a5, 1
+-    bnez    a2, 0b
++    bltu    a5, a4, 0b
++    beqz    a2, 2f
++    j       .L_8B_aligned
+ 1:
+-    sub     a0, a4, a3
++    sub     a0, a0, a3
+     ret
+ 2:
+     li      a0, 0
+     ret
+-.L_4_to_8:
+-    li      a3, 8
+-    bgtu    a2, a3, .L_9_to_16
+-    lwu     a3, 0(a1)
+-    lwu     a0, 0(a5)
+-    bne     a3, a0, .L_end
+-    add     a1, a1, a2
+-    add     a5, a5, a2
+-    lwu     a3, -4(a1)
+-    lwu     a0, -4(a5)
+-    j       .L_end
+-.L_9_to_16:
+-    li      a3, 16
+-    bgtu    a2, a3, .L_17_to_32
+-    addi    a2, a2, -8
+-    ld      a3, 0(a1)
+-    ld      a0, 0(a5)
+-    bne     a3, a0, .L_end
+-    add     a1, a1, a2
+-    add     a5, a5, a2
+-    ld      a3, 0(a1)
+-    ld      a0, 0(a5)
+-    j       .L_end
+-.L_17_to_32:
+-    addi    a2, a2, -16
+-    ld      a3, 0(a1)
+-    ld      a0, 0(a5)
+-    bne     a3, a0, .L_end
+-    ld      a3, 8(a1)
+-    ld      a0, 8(a5)
+-    bne     a3, a0, .L_end
+-    add     a1, a1, a2
+-    add     a5, a5, a2
+-    ld      a3, 0(a1)
+-    ld      a0, 0(a5)
+-    bne     a3, a0, .L_end
+-    ld      a3, 8(a1)
+-    ld      a0, 8(a5)
+-    j       .L_end
+-.L_over_32:
+-    neg     a4, a5
+-    andi    a4, a4, 0x7
+-    beqz    a4, .L_dst_aligned
+-    ld      a3, 0(a1)
+-    ld      a0, 0(a5)
+-    bne     a3, a0, .L_end
+-    sub     a2, a2, a4
+-    add     a5, a5, a4
+-    add     a1, a1, a4
+-.L_dst_aligned:
+-    andi    a4, a2, -32
+-    andi    a2, a2, (32-1)
+-    beqz    a4, .L_tail
++.L_8B_aligned:
++    andi    a4, a2, -16
++    beqz    a4, .L_byte
+     add     a4, a4, a5
++    andi    t5, a1, 0x7
++    andi    a2, a2, (16-1)
++    bnez    t5, .L_merge
+ .L_loop:
+     ld      a3, 0(a1)
+     ld      a0, 0(a5)
+@@ -102,36 +64,14 @@ ENTRY (memcmp)
+     ld      a3, 8(a1)
+     ld      a0, 8(a5)
+     bne     a3, a0, .L_end
+-    ld      a3, 16(a1)
+-    ld      a0, 16(a5)
+-    bne     a3, a0, .L_end
+-    ld      a3, 24(a1)
+-    ld      a0, 24(a5)
+-    bne     a3, a0, .L_end
+-    addi    a5, a5, 32
+-    addi    a1, a1, 32
++    addi    a5, a5, 16
++    addi    a1, a1, 16
+     bltu    a5, a4, .L_loop
+-    beqz    a2, .L_end
+-.L_tail:
+-    andi    a4, a2, -8
+-    beqz    a4, .L_last
+-    add     a4, a4, a5
+-0:
+-    ld      a3, 0(a1)
+-    ld      a0, 0(a5)
+-    bne     a3, a0, .L_end
+-    add     a5, a5, 8
+-    add     a1, a1, 8
+-    bltu    a5, a4, 0b
++    bnez    a2, .L_byte
+ 
+-.L_last:
+-    andi    a2, a2, (8-1)
+-    beqz    a2, 3f
+-    add     a1, a1, a2
+-    add     a5, a5, a2
+-    ld      a3, -8(a1)
+-    ld      a0, -8(a5)
+ .L_end:
++    rev8    a0, a0
++    rev8    a3, a3
+     bltu    a0, a3, 2f
+     beq     a0, a3, 3f
+     li      a0, 1
+@@ -142,6 +82,55 @@ ENTRY (memcmp)
+ 3:
+     li      a0, 0
+     ret
++
++.L_byte:
++    add     a2, a2, a5
++0:
++    lbu     a3, 0(a1)
++    lbu     a4, 0(a5)
++    bne     a3, a4, 1f
++    addi    a5, a5, 1
++    addi    a1, a1, 1
++    bltu    a5, a2, 0b
++1:
++    sub     a0, a4, a3
++    ret
++2:
++    li      a0, 0
++    ret
++
++    .balign 4
++    .option push
++    .option norvc
++.L_merge:
++    andi    a1, a1, -8
++    ld      t2, 0(a1)
++    slli    t3, t5, 3
++    neg     t4, t3
++    andi    t4, t4, (64 - 1)
++    srl     t1, t2, t3
++1:
++    ld      t2, 8(a1)
++    sll     a3, t2, t4
++    or      a3, a3, t1
++    ld      a0, 0(a5)
++    bne     a3, a0, .L_end
++    srl     t1, t2, t3
++
++    ld      t2, 16(a1)
++    sll     a3, t2, t4
++    or      a3, a3, t1
++    ld      a0, 8(a5)
++    bne     a3, a0, .L_end
++    srl     t1, t2, t3
++    .option pop
++
++    addi    a5, a5, 16
++    addi    a1, a1, 16
++    bltu    a5, a4, 1b
++    beqz    a2, .L_end
++    add     a1, a1, t5
++    j       .L_byte
+ END (memcmp)
+ libc_hidden_builtin_def (memcmp)
+ 
+diff --git a/sysdeps/riscv/rv64/multiarch/memcpy_as.S b/sysdeps/riscv/rv64/multiarch/memcpy_as.S
+index 4a97d75545..fae522684c 100644
+--- a/sysdeps/riscv/rv64/multiarch/memcpy_as.S
++++ b/sysdeps/riscv/rv64/multiarch/memcpy_as.S
+@@ -32,73 +32,50 @@
+ 
+     .p2align 6
+ ENTRY (memcpy)
+-    li      a3, 32
+     mv      a5, a0
+-    bgtu    a2, a3, .L_over_32
+-    li      a3, 4
+-    bgtu    a2, a3, .L_5_to_8
+-.L_0_to_4:
+-    beqz    a2, 1f
+-    lb      a4, 0(a1)
+-    sb      a4, 0(a5)
+-    /* process [n-1] */
+-    add     t1, a1, a2
+-    lb      a4, -1(t1)
+-    add     t0, a5, a2
+-    sb      a4, -1(t0)
+-    li      a3, 2
+-    bleu    a2, a3, 1f
+-    lb      a4, 2(a1)
+-    sb      a4, 2(a5)
+-    lb      a4, 1(a1)
+-    sb      a4, 1(a5)
+-1:
+-    ret
+-.L_5_to_8:
+-    li      a3, 8
+-    bgtu    a2, a3, .L_9_to_16
+-    lw      a3, 0(a1)
+-    sw      a3, 0(a5)
+-    add     a1, a1, a2
+-    add     a5, a5, a2
+-    lw      a3, -4(a1)
+-    sw      a3, -4(a5)
+-    ret
+-.L_9_to_16:
+-    li      a3, 16
+-    bgtu    a2, a3, .L_17_to_32
+-    ld      a3, 0(a1)
+-    sd      a3, 0(a5)
+-    add     a1, a1, a2
+-    add     a5, a5, a2
+-    ld      a3, -8(a1)
+-    sd      a3, -8(a5)
+-    ret
+-.L_17_to_32:
+-    addi    a2, a2, -16
+-    ld      a3, 0(a1)
+-    sd      a3, 0(a5)
+-    ld      a3, 8(a1)
+-    sd      a3, 8(a5)
+-    add     a1, a1, a2
+-    add     a5, a5, a2
+-    ld      a3, 0(a1)
+-    sd      a3, 0(a5)
+-    ld      a3, 8(a1)
+-    sd      a3, 8(a5)
+-    ret
+-.L_over_32:
++    li      a4, 9
++    bltu    a2, a4, .L_byte
++
+     neg     a4, a5
+     andi    a4, a4, 0x7
+     beqz    a4, .L_dst_aligned
+-    ld      a3, 0(a1)
+-    sd      a3, 0(a5)
+-    sub     a2, a2, a4
++    j       .L_pc_0
++
++.L_byte:
++    mv      a4, a2
++
++.L_pc_0:
++    auipc   a3, 0
++    slli    t0, a4, 3
++    sub     a3, a3, t0
++    .equ    offset_0, .L_jmp_end_0 - .L_pc_0
++    jalr    x0, a3, %lo(offset_0)
++    lb      a3, 7(a1)
++    sb      a3, 7(a5)
++    lb      a3, 6(a1)
++    sb      a3, 6(a5)
++    lb      a3, 5(a1)
++    sb      a3, 5(a5)
++    lb      a3, 4(a1)
++    sb      a3, 4(a5)
++    lb      a3, 3(a1)
++    sb      a3, 3(a5)
++    lb      a3, 2(a1)
++    sb      a3, 2(a5)
++    lb      a3, 1(a1)
++    sb      a3, 1(a5)
++    lb      a3, 0(a1)
++    sb      a3, 0(a5)
++.L_jmp_end_0:
++    sub     a2, a2, a4          /* update cnt */
++    beqz    a2, .L_ret
+     add     a5, a5, a4
+     add     a1, a1, a4
++
+ .L_dst_aligned:
++    andi    t5, a1, 0x7
++    bnez    t5, .L_merge
+     andi    a4, a2, -32
+-    andi    a2, a2, (32-1)
+     beqz    a4, .L_tail
+     add     a4, a4, a5
+ .L_loop:
+@@ -106,29 +83,57 @@ ENTRY (memcpy)
+     addi    a5, a5, 32
+     addi    a1, a1, 32
+     bltu    a5, a4, .L_loop
++    andi    a2, a2, (32-1)
+     beqz    a2, .L_ret
++
+ .L_tail:
+-    andi    a4, a2, -1
++    andi    a4, a2, -8
+ .L_pc:
+     auipc   a3, 0
+-    andi    a4, a4, -8
+-    srli    a4, a4, 1
+-    sub     a3, a3, a4
++    srli    t0, a4, 1
++    sub     a3, a3, t0
+     .equ    offset, .L_jmp_end - .L_pc
+     jalr    x0, a3, %lo(offset)
+-    ld      a3, 16(a1) # offset-12
++    ld      a3, 16(a1)
+     sd      a3, 16(a5)
+-    ld      a3, 8(a1)  # offset-8
++    ld      a3, 8(a1)
+     sd      a3, 8(a5)
+-    ld      a3, 0(a1)  # offset-4
++    ld      a3, 0(a1)
+     sd      a3, 0(a5)
+ .L_jmp_end:
+-    add     a1, a1, a2
+-    add     a5, a5, a2
+-    ld      a3, -8(a1)
+-    sd      a3, -8(a5)
++    add     a1, a1, a4
++    add     a5, a5, a4
++    andi    a2, a2, (8 - 1)     /* update cnt */
++    j       .L_byte
++
+ .L_ret:
+     ret
++
++    .balign 4
++.L_merge:
++    andi    a4, a2, -8
++    andi    a2, a2, (8 - 1)     /* update cnt */
++    beqz    a4, .L_byte
++    add     a4, a4, a5
++    andi    a1, a1, -8
++    ld      t2, 0(a1)
++    slli    t3, t5, 3
++    neg     t4, t3
++    andi    t4, t4, (64 - 1)
++    srl     t1, t2, t3
++1:
++    ld      t2, 8(a1)
++    sll     a3, t2, t4
++    or      a3, a3, t1
++    sd      a3, 0(a5)
++    srl     t1, t2, t3
++
++    addi    a5, a5, 8
++    addi    a1, a1, 8
++    bltu    a5, a4, 1b
++    beqz    a2, .L_ret
++    add     a1, a1, t5
++    j       .L_byte
+ END (memcpy)
+ 
+ libc_hidden_builtin_def (memcpy)
+diff --git a/sysdeps/riscv/rv64/multiarch/memmove_as.S b/sysdeps/riscv/rv64/multiarch/memmove_as.S
+index 222b87b9c8..b8275b6dd7 100644
+--- a/sysdeps/riscv/rv64/multiarch/memmove_as.S
++++ b/sysdeps/riscv/rv64/multiarch/memmove_as.S
+@@ -35,10 +35,10 @@ ENTRY (memmove)
+     bltu    a3, a2, .L_overlap
+     j       memcpy
+ .L_overlap:
+-    li      a4, 8
+     bltu    a1, a0, .L_backward
+     mv      a5, a0
+-    bltu    a2, a4, .L_byte_fwd
++    li      a3, 8
++    bltu    a2, a3, .L_byte_fwd
+     neg     a4, a0
+     andi    a4, a4, 0x7
+     beqz    a4, .L_32B_fwd
+@@ -52,6 +52,8 @@ ENTRY (memmove)
+     addi    a1, a1, 1
+     bltu    a5, a4, 0b
+ .L_32B_fwd:
++    andi    t5, a1, 0x7
++    bnez    t5, .L_merge_fwd
+     andi    a4, a2, -32
+     andi    a2, a2, (32 - 1)
+     beqz    a4, .L_8B_fwd
+@@ -100,11 +102,36 @@ ENTRY (memmove)
+ .L_ret_fwd:
+     ret
+ 
++    .balign 4
++.L_merge_fwd:
++    andi    a4, a2, -8
++    beqz    a4, .L_byte_tail_fwd
++    add     a4, a4, a5
++    andi    a1, a1, -8
++    ld      t2, 0(a1)
++    slli    t3, t5, 3
++    neg     t4, t3
++    andi    t4, t4, (64 - 1)
++    srl     t1, t2, t3
++1:
++    ld      t2, 8(a1)
++    sll     a3, t2, t4
++    or      a3, a3, t1
++    sd      a3, 0(a5)
++    srl     t1, t2, t3
++
++    addi    a5, a5, 8
++    addi    a1, a1, 8
++    bltu    a5, a4, 1b
++    add     a1, a1, t5
++    j       .L_byte_tail_fwd
++
+ .L_backward:
+     add     a1, a1, a2
+     add     a5, a0, a2
+-    bltu    a2, a4, .L_byte_bwd
+-    andi    a4, a5, 0x7
++    li      a3, 8
++    bltu    a2, a3, .L_byte_bwd
++    andi    a4, a0, 0x7
+     beqz    a4, .L_32B_bwd
+ .L_byte_head_bwd:
+     sub     a2, a2, a4
+@@ -116,6 +143,8 @@ ENTRY (memmove)
+     sb      a3, 0(a5)
+     bltu    a4, a5, 0b
+ .L_32B_bwd:
++    andi    t5, a1, 0x7
++    bnez    t5, .L_merge_bwd
+     andi    a4, a2, -32
+     andi    a2, a2, (32 - 1)
+     beqz    a4, .L_8B_bwd
+@@ -163,6 +192,31 @@ ENTRY (memmove)
+     bltu    a0, a5, 0b
+ .L_ret_bwd:
+     ret
++
++    .balign 4
++.L_merge_bwd:
++    andi    a4, a2, -8
++    beqz    a4, .L_byte_tail_bwd
++    sub     a4, a5, a4
++    andi    a1, a1, -8
++    ld      t2, 0(a1)   
++    slli    t3, t5, 3
++    neg     t4, t3
++    andi    t4, t4, (64 - 1)
++    sll     t1, t2, t4
++1:
++    ld      t2, -8(a1)
++    srl     a3, t2, t3
++    or      a3, a3, t1
++    sd      a3, -8(a5)
++    sll     t1, t2, t4
++    
++    addi    a5, a5, -8
++    addi    a1, a1, -8
++    bltu    a4, a5, 1b
++    add     a1, a1, t5 
++    j       .L_byte_tail_bwd
++
+ END (memmove)
+ 
+ libc_hidden_builtin_def (memmove)
+diff --git a/sysdeps/riscv/rv64/multiarch/memrchr.S b/sysdeps/riscv/rv64/multiarch/memrchr.S
+index 01c2d949de..b72a13e62a 100644
+--- a/sysdeps/riscv/rv64/multiarch/memrchr.S
++++ b/sysdeps/riscv/rv64/multiarch/memrchr.S
+@@ -21,96 +21,80 @@
+ 
+ .option arch, +zbb
+ 
+-.macro chr_8B
+-    ld      a4, -8(a0)
+-    xor     a4, a4, a1
+-    sub     a3, a4, t1
+-    andn    a3, a3, a4
+-    and     a3, a3, a5
+-    bnez    a3, .L_find
+-.endm
+-.macro gen_pat
+-    slli    a3, a1, 8
+-    or      a1, a1, a3
+-    slli    a3, a1, 16
+-    or      a1, a1, a3
+-    slli    a3, a1, 32
+-    or      a1, a1, a3
+-
+-    li      a5, 0x80
+-    slli    a3, a5, 8
+-    or      a5, a5, a3
+-    slli    a3, a5, 16
+-    or      a5, a5, a3
+-    slli    a3, a5, 32
+-    or      a5, a5, a3  # 0x8080808080808080
+-    srli    t1, a5, 7   # 0x0101010101010101
+-.endm
+-
+     .p2align 6
+ #ifndef MEMRCHR
+ ENTRY (__memrchr)
+ #else
+ ENTRY (MEMRCHR)
+ #endif
+-    li      a3, 7
++    beqz    a2, .L_not_find
+     add     a0, a0, a2
+-    bgtu    a2, a3, .L_8_to_16
+-.L_0_to_7:
+-    beqz    a2, 1f
++    li      a4, 9
++    bltu    a2, a4, .L_0_to_8 
++    
++    andi    a4, a0, 0x7
++    beqz    a4, .L_dst_aligned
++
++.L_0_to_8:
++    min     a4, a4, a2
++.L_head:
++    sub     a2, a2, a4
+ 0:
+-    lbu     a4, -1(a0)
+-    beq     a1, a4, 2f
+-    addi    a2, a2, -1
++    lbu     a3, -1(a0)
++    beq     a1, a3, .L_find_byte
++    addi    a4, a4, -1
+     addi    a0, a0, -1
+-    bnez    a2, 0b
+-1:
+-    li      a0, 0
+-    ret
+-2:
+-    addi    a0, a0, -1
+-    ret
+-.L_8_to_16:
+-    gen_pat
+-    li      a3, 16
+-    bgtu    a2, a3, .L_over_16
+-    addi    a2, a2, -8
+-    chr_8B
+-    sub     a0, a0, a2
+-    chr_8B
+-    j       .L_not_find
+-.L_over_16:
+-    and     t4, a0, 0x7
+-    beqz    t4, .L_dst_aligned
+-    chr_8B
+-    sub     a2, a2, t4
+-    sub     a0, a0, t4
++    bnez    a4, 0b
++    beqz    a2, .L_not_find
++
+ .L_dst_aligned:
+-    andi    t0, a2, (16-1)
++    andi    a4, a2, (16-1)
+     srli    a2, a2, 4
+     beqz    a2, .L_tail
++    
++    slli    a3, a1, 8
++    or      a1, a1, a3
++    slli    a3, a1, 16
++    or      a1, a1, a3
++    slli    a3, a1, 32
++    or      a1, a1, a3
++    li      a5, -1
+ .L_loop:
+-    chr_8B
++    ld      a3, -8(a0)
++    xor     a3, a3, a1
++    orc.b   a3, a3
++    bne     a3, a5, .L_find 
+     addi    a0, a0, -8
+-    chr_8B
++
++    ld      a3, -8(a0)
++    xor     a3, a3, a1
++    orc.b   a3, a3
++    bne     a3, a5, .L_find
++
+     addi    a2, a2, -1
+     addi    a0, a0, -8
+     bnez    a2, .L_loop
+-    beqz    t0, .L_not_find
++    beqz    a4, .L_not_find
++
+ .L_tail:
+-    sub     a0, a0, t0
+-    addi    a0, a0, 16
+-    chr_8B
+-    addi    a0, a0, -8
+-    chr_8B
++    andi    a1, a1, 0xff
++0:
++    lbu     a3, -1(a0)
++    beq     a1, a3, .L_find_byte
++    addi    a4, a4, -1
++    addi    a0, a0, -1
++    bnez    a4, 0b
++
+ .L_not_find:
+     li      a0, 0
+     ret
+ .L_find:
++    not     a3, a3
+     clz     a3, a3
+-    addi    a0, a0, -1
+     srli    a3, a3, 3
+     sub     a0, a0, a3
++.L_find_byte:
++    addi    a0, a0, -1
+     ret
+ #ifndef MEMRCHR
+ END (__memrchr)
+diff --git a/sysdeps/riscv/rv64/multiarch/memset_as.S b/sysdeps/riscv/rv64/multiarch/memset_as.S
+index 7f67c79215..455033adf0 100644
+--- a/sysdeps/riscv/rv64/multiarch/memset_as.S
++++ b/sysdeps/riscv/rv64/multiarch/memset_as.S
+@@ -21,53 +21,38 @@
+ 
+     .p2align 6
+ ENTRY (memset)
+-    li      a3, 32
+-    andi    a1, a1, 0xff
+     mv      a5, a0
+-    bgtu    a2, a3, .L_over_32
+-    li      a3, 4
+-    bgtu    a2, a3, .L_5_to_8
+-.L_0_to_4:
+-    beqz    a2, 1f
+-    sb      a1, 0(a5)
+-    add     t0, a5, a2
+-    sb      a1, -1(t0)
+-    li      a3, 2
+-    bleu    a2, a3, 1f
+-    sb      a1, 1(a5)
++    andi    a1, a1, 0xff
++    li      a4, 9
++    bltu    a2, a4, .L_0_to_8 
++    
++    neg     a4, a5
++    andi    a4, a4, 0x7
++    beqz    a4, .L_dst_aligned
++    j       .L_pc_0
++.L_0_to_8:
++    mv      a4, a2
++
++.L_pc_0:
++    auipc   a3, 0
++    slli    t0, a4, 2
++    sub     a3, a3, t0
++    .equ    offset_0, .L_jmp_end_0 - .L_pc_0
++    jalr    x0, a3, %lo(offset_0)
++    sb      a1, 7(a5)
++    sb      a1, 6(a5)
++    sb      a1, 5(a5)
++    sb      a1, 4(a5)
++    sb      a1, 3(a5)
+     sb      a1, 2(a5)
+-1:
+-    ret
+-.L_5_to_8:
+-    slli    a3, a1, 8
+-    or      a1, a1, a3
+-    slli    a3, a1, 16
+-    or      a1, a1, a3
+-    li      a3, 8
+-    bgtu    a2, a3, .L_9_to_16
+-    sw      a1, 0(a5)
+-    add     a5, a5, a2
+-    sw      a1, -4(a5)
+-    ret
+-.L_9_to_16:
+-    li      a3, 16
+-    bgtu    a2, a3, .L_17_to_32
+-    sw      a1, 0(a5)
+-    sw      a1, 4(a5)
+-    add     a5, a5, a2
+-    sw      a1, -8(a5)
+-    sw      a1, -4(a5)
+-    ret
+-.L_17_to_32:
+-    slli    a3, a1, 32
+-    or      a1, a1, a3
+-    sd      a1, 0(a5)
+-    sd      a1, 8(a5)
+-    add     a5, a5, a2
+-    sd      a1, -16(a5)
+-    sd      a1, -8(a5)
+-    ret
+-.L_over_32:
++    sb      a1, 1(a5)
++    sb      a1, 0(a5)
++.L_jmp_end_0:
++    sub     a2, a2, a4          /* update cnt */
++    beqz    a2, .L_ret
++    add     a5, a5, a4
++
++.L_dst_aligned:
+     slli    a3, a1, 8
+     or      a1, a1, a3
+     slli    a3, a1, 16
+@@ -75,17 +60,10 @@ ENTRY (memset)
+     slli    a3, a1, 32
+     or      a1, a1, a3
+ 
+-    neg     a4, a5
+-    andi    a4, a4, 0x7
+-    beqz    a4, .L_dst_aligned
+-    sd      a1, 0(a5)
+-    sub     a2, a2, a4
+-    add     a5, a5, a4
+-.L_dst_aligned:
+     andi    a4, a2, -64
+-    andi    a2, a2, (64-1)
+     beqz    a4, .L_tail
+     add     a4, a4, a5
++
+ .L_loop:
+     sd      a1, 0(a5)
+     sd      a1, 8(a5)
+@@ -97,27 +75,44 @@ ENTRY (memset)
+     sd      a1, 56(a5)
+     addi    a5, a5, 64
+     bltu    a5, a4, .L_loop
++    andi    a2, a2, (64-1)      /* update cnt */
+     beqz    a2, .L_ret
++
+ .L_tail:
+-    andi    a4, a2, -1
++    andi    a4, a2, -8
+ .L_pc:
+     auipc   a3, 0
+-    andi    a4, a4, -8
+-    srli    a4, a4, 2
+-    sub     a3, a3, a4
++    srli    t0, a4, 2
++    sub     a3, a3, t0
+     .equ    offset, .L_jmp_end - .L_pc
+     jalr    x0, a3, %lo(offset)
+-    sd      a1, 48(a5)
+-    sd      a1, 40(a5)
+-    sd      a1, 32(a5)
+-    sd      a1, 24(a5)
+-    sd      a1, 16(a5)
+-    sd      a1, 8(a5)
+-    sd      a1, 0(a5)
++    sd      a1, 6*8(a5)
++    sd      a1, 5*8(a5)
++    sd      a1, 4*8(a5)
++    sd      a1, 3*8(a5)
++    sd      a1, 2*8(a5)
++    sd      a1, 1*8(a5)
++    sd      a1, 0*8(a5)
+ .L_jmp_end:
+-    add     a5, a5, a2
+-    sd      a1, -8(a5)
+- .L_ret:
++    add     a5, a5, a4
++    andi    a4, a2, (8 - 1)     /* update cnt */
++
++.L_tail_byte:
++.L_pc_2:
++    auipc   a3, 0
++    slli    a4, a4, 2
++    sub     a3, a3, a4
++    .equ    offset_2, .L_jmp_end_2 - .L_pc_2
++    jalr    x0, a3, %lo(offset_2)
++    sb      a1, 6(a5)
++    sb      a1, 5(a5)
++    sb      a1, 4(a5)
++    sb      a1, 3(a5)
++    sb      a1, 2(a5)
++    sb      a1, 1(a5)
++    sb      a1, 0(a5)
++.L_jmp_end_2:
++.L_ret:
+     ret
+ END (memset)
+ libc_hidden_builtin_def (memset)
+-- 
+2.25.1
+

+ 3 - 3
recipes-core/glibc/glibc/0028-readlib-Add-OECORE_KNOWN_INTERPRETER_NAMES-to-known-.patch → recipes-core/glibc/glibc/0016-readlib-Add-OECORE_KNOWN_INTERPRETER_NAMES-to-known-.patch

@@ -1,4 +1,4 @@
-From 5d201a75918a0e181ee6206f701901fdb91baf81 Mon Sep 17 00:00:00 2001
+From 58dd1336c1c32716f4f0938bf18f2ddfbe9305ca Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Wed, 18 Mar 2015 00:11:22 +0000
 Subject: [PATCH] readlib: Add OECORE_KNOWN_INTERPRETER_NAMES to known names
@@ -16,10 +16,10 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
  1 file changed, 1 insertion(+)
 
 diff --git a/elf/readlib.c b/elf/readlib.c
-index 7383c23249..e97ea9449d 100644
+index ed42fbd48e..777f6c80be 100644
 --- a/elf/readlib.c
 +++ b/elf/readlib.c
-@@ -51,6 +51,7 @@ static struct known_names interpreters[] =
+@@ -49,6 +49,7 @@ static struct known_names interpreters[] =
  #ifdef SYSDEP_KNOWN_INTERPRETER_NAMES
    SYSDEP_KNOWN_INTERPRETER_NAMES
  #endif

+ 675 - 0
recipes-core/glibc/glibc/0016-strxxx-B-ext-opt-version.patch

@@ -0,0 +1,675 @@
+From cb7b9da1f6e784440bbebc2377acc0e6d888e1a4 Mon Sep 17 00:00:00 2001
+From: "yilun.xie" <yilun.xie@starfivetech.com>
+Date: Wed, 10 Aug 2022 00:16:46 -0700
+Subject: [PATCH 16/19] strxxx B ext opt version
+
+---
+ sysdeps/riscv/rv64/multiarch/Makefile         |  3 +-
+ .../riscv/rv64/multiarch/ifunc-impl-list.c    | 12 +++
+ sysdeps/riscv/rv64/multiarch/rtld-strchr.S    |  1 +
+ sysdeps/riscv/rv64/multiarch/rtld-strchrnul.S |  1 +
+ sysdeps/riscv/rv64/multiarch/rtld-strlen.S    |  1 +
+ sysdeps/riscv/rv64/multiarch/rtld-strlen.c    |  1 -
+ sysdeps/riscv/rv64/multiarch/rtld-strncmp.S   |  1 +
+ sysdeps/riscv/rv64/multiarch/strcmp.c         |  1 -
+ sysdeps/riscv/rv64/multiarch/strcmp_as.S      | 85 ++++++++++++++++---
+ sysdeps/riscv/rv64/multiarch/strcmp_riscv.S   | 17 ++++
+ sysdeps/riscv/rv64/multiarch/strlen_as.S      | 56 ++++++++++++
+ .../{strlen_riscv.c => strlen_riscv.S}        | 23 ++---
+ sysdeps/riscv/rv64/strchr.S                   | 81 ++++++++++++++++++
+ sysdeps/riscv/rv64/strchrnul.S                | 79 +++++++++++++++++
+ sysdeps/riscv/rv64/strncmp.S                  | 73 ++++++++++++++++
+ sysdeps/riscv/rv64/strnlen.S                  | 62 ++++++++++++++
+ 16 files changed, 471 insertions(+), 26 deletions(-)
+ create mode 100644 sysdeps/riscv/rv64/multiarch/rtld-strchr.S
+ create mode 100644 sysdeps/riscv/rv64/multiarch/rtld-strchrnul.S
+ create mode 100644 sysdeps/riscv/rv64/multiarch/rtld-strlen.S
+ delete mode 100644 sysdeps/riscv/rv64/multiarch/rtld-strlen.c
+ create mode 100644 sysdeps/riscv/rv64/multiarch/rtld-strncmp.S
+ create mode 100644 sysdeps/riscv/rv64/multiarch/strlen_as.S
+ rename sysdeps/riscv/rv64/multiarch/{strlen_riscv.c => strlen_riscv.S} (60%)
+ create mode 100644 sysdeps/riscv/rv64/strchr.S
+ create mode 100644 sysdeps/riscv/rv64/strchrnul.S
+ create mode 100644 sysdeps/riscv/rv64/strncmp.S
+ create mode 100644 sysdeps/riscv/rv64/strnlen.S
+
+diff --git a/sysdeps/riscv/rv64/multiarch/Makefile b/sysdeps/riscv/rv64/multiarch/Makefile
+index 7e8bfde544..3123ced35d 100644
+--- a/sysdeps/riscv/rv64/multiarch/Makefile
++++ b/sysdeps/riscv/rv64/multiarch/Makefile
+@@ -1,5 +1,6 @@
+ ifeq ($(subdir),string)
+ sysdep_routines += memcpy_vector memcpy_riscv memchr_riscv memchr_vector memcmp_riscv \
+                  memcmp_vector strcmp_riscv strcmp_vector strlen_riscv strlen_vector \
+-                 memmove_vector memmove_riscv memset_vector memset_riscv memrchr
++                 memmove_vector memmove_riscv memset_vector memset_riscv memrchr \
++                  
+ endif
+diff --git a/sysdeps/riscv/rv64/multiarch/ifunc-impl-list.c b/sysdeps/riscv/rv64/multiarch/ifunc-impl-list.c
+index 1a6611ab88..7bba6fa30c 100644
+--- a/sysdeps/riscv/rv64/multiarch/ifunc-impl-list.c
++++ b/sysdeps/riscv/rv64/multiarch/ifunc-impl-list.c
+@@ -60,6 +60,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
+   IFUNC_IMPL (i, name, memset,
+ 	      IFUNC_IMPL_ADD (array, i, memset, use_rvv, __memset_vector)
+ 	      IFUNC_IMPL_ADD (array, i, memset, 1, __memset_riscv));
++
++  IFUNC_IMPL (i, name, strchr,
++	      IFUNC_IMPL_ADD (array, i, strchr, use_rvv, __strchr_riscv)
++	      IFUNC_IMPL_ADD (array, i, strchr, 1, __strchr_riscv));
++
++  IFUNC_IMPL (i, name, strchrnul,
++	      IFUNC_IMPL_ADD (array, i, strchrnul, use_rvv, __strchrnul_riscv)
++	      IFUNC_IMPL_ADD (array, i, strchrnul, 1, __strchrnul_riscv));
++
++  IFUNC_IMPL (i, name, strncmp,
++	      IFUNC_IMPL_ADD (array, i, strncmp, use_rvv, __strncmp_riscv)
++	      IFUNC_IMPL_ADD (array, i, strncmp, 1, __strncmp_riscv));
+ #endif
+   return i;
+ }
+diff --git a/sysdeps/riscv/rv64/multiarch/rtld-strchr.S b/sysdeps/riscv/rv64/multiarch/rtld-strchr.S
+new file mode 100644
+index 0000000000..d969c0ab57
+--- /dev/null
++++ b/sysdeps/riscv/rv64/multiarch/rtld-strchr.S
+@@ -0,0 +1 @@
++#include "../strchr.S"
+diff --git a/sysdeps/riscv/rv64/multiarch/rtld-strchrnul.S b/sysdeps/riscv/rv64/multiarch/rtld-strchrnul.S
+new file mode 100644
+index 0000000000..5799994393
+--- /dev/null
++++ b/sysdeps/riscv/rv64/multiarch/rtld-strchrnul.S
+@@ -0,0 +1 @@
++#include "../strchrnul.S"
+diff --git a/sysdeps/riscv/rv64/multiarch/rtld-strlen.S b/sysdeps/riscv/rv64/multiarch/rtld-strlen.S
+new file mode 100644
+index 0000000000..801def494d
+--- /dev/null
++++ b/sysdeps/riscv/rv64/multiarch/rtld-strlen.S
+@@ -0,0 +1 @@
++#include "strlen_as.S"
+diff --git a/sysdeps/riscv/rv64/multiarch/rtld-strlen.c b/sysdeps/riscv/rv64/multiarch/rtld-strlen.c
+deleted file mode 100644
+index d3f1dd4a23..0000000000
+--- a/sysdeps/riscv/rv64/multiarch/rtld-strlen.c
++++ /dev/null
+@@ -1 +0,0 @@
+-# include <string/strlen.c>
+diff --git a/sysdeps/riscv/rv64/multiarch/rtld-strncmp.S b/sysdeps/riscv/rv64/multiarch/rtld-strncmp.S
+new file mode 100644
+index 0000000000..c5a02a137c
+--- /dev/null
++++ b/sysdeps/riscv/rv64/multiarch/rtld-strncmp.S
+@@ -0,0 +1 @@
++#include "../strncmp.S"
+diff --git a/sysdeps/riscv/rv64/multiarch/strcmp.c b/sysdeps/riscv/rv64/multiarch/strcmp.c
+index 3b65aaf55d..d18ae03246 100644
+--- a/sysdeps/riscv/rv64/multiarch/strcmp.c
++++ b/sysdeps/riscv/rv64/multiarch/strcmp.c
+@@ -28,7 +28,6 @@
+ # include "ifunc-common.h"
+ 
+ riscv_libc_ifunc_redirected (__redirect_strcmp, strcmp, IFUNC_SELECTOR);
+-
+ riscv_libc_ifunc_hidden_def (__redirect_strcmp, strcmp);
+ #else 
+ # include <string.h>
+diff --git a/sysdeps/riscv/rv64/multiarch/strcmp_as.S b/sysdeps/riscv/rv64/multiarch/strcmp_as.S
+index db5a6346b8..40bdbfef08 100644
+--- a/sysdeps/riscv/rv64/multiarch/strcmp_as.S
++++ b/sysdeps/riscv/rv64/multiarch/strcmp_as.S
+@@ -19,21 +19,82 @@
+    <http://www.gnu.org/licenses/>.  */
+ 
+ #include <sysdep.h>
++#define N 3
+ 
+ 	.p2align 6
+ ENTRY (strcmp)
+-.L_strcmp_by_byte:
+-   lbu	a5,0(a0)
+-   addi	a1,a1,1
+-   addi	a0,a0,1
+-   lbu	a4,-1(a1)
+-   beqz	a5,.L_strcmp_by_byte_exit
+-   beq	a5,a4,.L_strcmp_by_byte
+-   subw	a0,a5,a4
+-   ret
+-.L_strcmp_by_byte_exit:
+-   negw	a0,a4
+-   ret
++  or    a4, a0, a1
++  li    t2, -1
++  and   a4, a4, 7
++  beqz  a4, .Lenter
++  j .Lmisaligned
++
++  .macro check_one_word i n
++    ld a2, \i*8(a0)
++    ld a3, \i*8(a1)
++
++    orc.b t0, a2
++
++    bne   t0, t2, .Lnull\i
++    .if \i+1-\n
++      bne   a2, a3, .Lmismatch
++    .else
++      beq   a2, a3, .Lloop
++      # fall through to .Lmismatch
++    .endif
++  .endm
++
++  .macro foundnull i n
++    .ifne \i
++      .Lnull\i:
++      add   a0, a0, \i*8
++      add   a1, a1, \i*8
++      .ifeq \i-1
++        .Lnull0:
++      .endif
++      bne   a2, a3, .Lmisaligned
++      li    a0, 0
++      ret
++    .endif
++  .endm
++
++.Lloop:
++  add   a0, a0, N*8
++  add   a1, a1, N*8
++
++.Lenter:
++  # examine full words at a time, favoring strings of a couple dozen chars
++  check_one_word 0 N
++  check_one_word 1 N
++  check_one_word 2 N
++  # backwards branch to .Lloop contained above
++
++.Lmismatch:
++  rev8 a4, a2
++  rev8 a5, a3
++  bgeu a4, a5, 1f
++  li a0, -1
++  ret
++1:
++  li a0, 1
++  ret
++
++.Lmisaligned:
++  # misaligned
++  lbu   a2, 0(a0)
++  lbu   a3, 0(a1)
++  add   a0, a0, 1
++  add   a1, a1, 1
++  bne   a2, a3, 1f
++  bnez  a2, .Lmisaligned
++1:
++  sub   a0, a2, a3
++  ret
++
++  # cases in which a null byte was detected
++  foundnull 0 N
++  foundnull 1 N
++  foundnull 2 N
+ 
+ END (strcmp)
+ libc_hidden_builtin_def (strcmp)
+diff --git a/sysdeps/riscv/rv64/multiarch/strcmp_riscv.S b/sysdeps/riscv/rv64/multiarch/strcmp_riscv.S
+index abf2984230..8a2bfa9629 100644
+--- a/sysdeps/riscv/rv64/multiarch/strcmp_riscv.S
++++ b/sysdeps/riscv/rv64/multiarch/strcmp_riscv.S
+@@ -1,3 +1,20 @@
++/* The assembly function for strcmp.  RISC-V version.
++   Copyright (C) 2018 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, see
++   <http://www.gnu.org/licenses/>.  */
+ 
+ #include <sysdep.h>
+ 
+diff --git a/sysdeps/riscv/rv64/multiarch/strlen_as.S b/sysdeps/riscv/rv64/multiarch/strlen_as.S
+new file mode 100644
+index 0000000000..862f5ebb72
+--- /dev/null
++++ b/sysdeps/riscv/rv64/multiarch/strlen_as.S
+@@ -0,0 +1,56 @@
++/* The assembly function for strlen.  RISC-V version.
++   Copyright (C) 2018 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, see
++   <http://www.gnu.org/licenses/>.  */
++
++#include <sysdep.h>
++
++	.p2align 6
++ENTRY (strlen)
++  andi  a3, a0, 7
++  andi  a1, a0, -8
++.Lprologue:
++  li    a4, 8
++  sub   a4, a4, a3
++  slli  a3, a3, 3
++  ld    a2, 0(a1)
++  srl   a2, a2, a3
++  orc.b a2, a2
++  not   a2, a2
++  ctz   a2, a2
++  srli  a0, a2, 3
++  bgtu  a4, a0, .Ldone
++  addi  a3, a1, 8
++  li    a4, -1
++
++  .align 2
++.Lloop:
++  ld    a2, 8(a1)
++  addi  a1, a1, 8
++  orc.b a2, a2
++  beq   a2, a4, .Lloop
++.Lepilogue:
++  not   a2, a2
++  ctz   a2, a2
++  sub   a1, a1, a3
++  add   a0, a0, a1
++  srli  a2, a2, 3
++  add   a0, a0, a2
++.Ldone:
++  ret
++
++END (strlen)
++libc_hidden_builtin_def (strlen)
+\ No newline at end of file
+diff --git a/sysdeps/riscv/rv64/multiarch/strlen_riscv.c b/sysdeps/riscv/rv64/multiarch/strlen_riscv.S
+similarity index 60%
+rename from sysdeps/riscv/rv64/multiarch/strlen_riscv.c
+rename to sysdeps/riscv/rv64/multiarch/strlen_riscv.S
+index d3bae0fc43..d6fd969afb 100644
+--- a/sysdeps/riscv/rv64/multiarch/strlen_riscv.c
++++ b/sysdeps/riscv/rv64/multiarch/strlen_riscv.S
+@@ -1,5 +1,5 @@
+-/* RISCV C version strlen.
+-   Copyright (C) 2018-2021 Free Software Foundation, Inc.
++/* The assembly function for strlen.  RISC-V version.
++   Copyright (C) 2018 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
+@@ -13,20 +13,21 @@
+    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, see
+-   <https://www.gnu.org/licenses/>.  */
++   License along with the GNU C Library.  If not, see
++   <http://www.gnu.org/licenses/>.  */
+ 
++#include <sysdep.h>
+ 
+-#if IS_IN (libc) && defined SHARED && defined __riscv_vector
+-#undef libc_hidden_builtin_def
+-#define libc_hidden_builtin_def(name)
++#if IS_IN (libc)  && defined SHARED && defined __riscv_vector
++# define strlen __strlen_riscv
++# undef libc_hidden_builtin_def
++# define libc_hidden_builtin_def(name)
++
++# include "strlen_as.S"
+ 
+-#undef weak_alias
+-#  define STRLEN __strlen_riscv
+-# include <string/strlen.c>
+ #else
++# include "strlen_as.S"
+ 
+-# include <string/strlen.c>
+ #endif
+ 
+ 
+diff --git a/sysdeps/riscv/rv64/strchr.S b/sysdeps/riscv/rv64/strchr.S
+new file mode 100644
+index 0000000000..a9059c19ca
+--- /dev/null
++++ b/sysdeps/riscv/rv64/strchr.S
+@@ -0,0 +1,81 @@
++/* The assembly function for strchr.  RISC-V version.
++   Copyright (C) 2018 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, see
++   <http://www.gnu.org/licenses/>.  */
++
++#include <sysdep.h>
++
++	.p2align 6
++ENTRY (strchr)
++  andi  a1, a1, 0xff
++
++.Lmisaligned:
++  andi  a5, a0, 7
++  beqz  a5, .Laligned
++  lbu   a5, 0(a0)
++  beq   a5, a1, .Ldone
++  beqz  a5, .Lnofind
++  addi  a0, a0, 1
++  j .Lmisaligned
++
++.Laligned:
++  slli  a5, a1, 0x8
++  or    a5, a5, a1
++  slli  t0, a5, 0x10
++  or    t0, t0, a5
++  slli  a5, t0, 0x20
++  or    t0, t0, a5
++
++  li    a5, -1
++  addi  a0, a0, -8
++.Lloop:
++  addi  a0, a0, 8
++  ld    a2, 0(a0)
++  orc.b t1, a2
++  bne   t1, a5, .Lnull
++  xor   a3, a2, t0
++  orc.b a3, a3
++  bne   a3, a5, .Lfind
++  orc.b a2, a2
++  beq   a2, a5, .Lloop
++
++.Lnofind:
++  li    a0, 0
++.Ldone:
++  ret
++
++.Lfind:
++  not   a3, a3
++  ctz   a3, a3
++  srli  a3, a3, 3
++  add   a0, a0, a3
++  ret
++
++# cases in which a null byte was detected
++.Lnull:
++  bne   a2, t0, .Lend
++  j .Lfind
++
++.Lend:
++  lbu   a5, 0(a0)
++  beq   a5, a1, .Ldone
++  beqz  a5, .Lnofind
++  addi  a0, a0, 1
++  j .Lend
++     
++
++END (strchr)
++libc_hidden_builtin_def (strchr)
+\ No newline at end of file
+diff --git a/sysdeps/riscv/rv64/strchrnul.S b/sysdeps/riscv/rv64/strchrnul.S
+new file mode 100644
+index 0000000000..3e48445f11
+--- /dev/null
++++ b/sysdeps/riscv/rv64/strchrnul.S
+@@ -0,0 +1,79 @@
++/* The assembly function for strchrnul.  RISC-V version.
++   Copyright (C) 2018 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, see
++   <http://www.gnu.org/licenses/>.  */
++
++#include <sysdep.h>
++
++	.p2align 6
++ENTRY (__strchrnul)
++  andi  a1, a1, 0xff
++
++.Lmisaligned:
++  andi  a5, a0, 7
++  beqz  a5, .Laligned
++  lbu   a5, 0(a0)
++  beq   a5, a1, .Ldone
++  beqz  a5, .Ldone
++  addi  a0, a0, 1
++  j .Lmisaligned
++
++.Laligned:
++  slli  a5, a1, 0x8
++  or    a5, a5, a1
++  slli  t0, a5, 0x10
++  or    t0, t0, a5
++  slli  a5, t0, 0x20
++  or    t0, t0, a5
++
++  li    a5, -1
++  addi  a0, a0, -8
++.Lloop:
++  addi  a0, a0, 8
++  ld    a2, 0(a0)
++  orc.b t1, a2
++  bne   t1, a5, .Lnull
++  xor   a3, a2, t0
++  orc.b a3, a3
++  bne   a3, a5, .Lfind
++  orc.b a2, a2
++  beq   a2, a5, .Lloop
++
++.Ldone:
++  ret
++
++.Lfind:
++  not   a3, a3
++  ctz   a3, a3
++  srli  a3, a3, 3
++  add   a0, a0, a3
++  ret
++
++# cases in which a null byte was detected
++.Lnull:
++  bne   a2, t0, .Lend
++  j .Lfind
++
++.Lend:
++  lbu   a5, 0(a0)
++  beq   a5, a1, .Ldone
++  beqz  a5, .Ldone
++  addi  a0, a0, 1
++  j .Lend
++
++END (__strchrnul)
++weak_alias (__strchrnul,strchrnul)
++libc_hidden_builtin_def (__strchrnul)
+\ No newline at end of file
+diff --git a/sysdeps/riscv/rv64/strncmp.S b/sysdeps/riscv/rv64/strncmp.S
+new file mode 100644
+index 0000000000..85245df98d
+--- /dev/null
++++ b/sysdeps/riscv/rv64/strncmp.S
+@@ -0,0 +1,73 @@
++/* The assembly function for strncmp.  RISC-V version.
++   Copyright (C) 2018 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, see
++   <http://www.gnu.org/licenses/>.  */
++
++#include <sysdep.h>
++
++	.p2align 6
++ENTRY (strncmp)
++  beqz  a2, .Lequal
++  or    a4, a0, a1
++  li    t2, -1
++  and   a4, a4, 7
++  beqz  a4, .Lenter
++  j     .Lmisaligned
++
++.Lloop:
++  addi  a0, a0, 8
++  addi  a1, a1, 8
++  addi  a2, a2, -8
++
++.Lenter:
++  addi  a5, a2, -8
++  blez  a5, .Lmisaligned
++  ld    a3, 0(a0)
++  ld    a4, 0(a1)
++  orc.b t0, a3
++  bne   t0, t2, .Lnull
++  beq   a3, a4, .Lloop
++  rev8  a6, a3
++  rev8  a7, a4
++  bgeu  a6, a7, 1f
++  li    a0, -1
++  ret
++1:
++  li    a0, 1
++  ret
++
++.Lmisaligned:
++  blez  a2, .Ldone
++  lbu   a3, 0(a0)
++  lbu   a4, 0(a1)
++  addi  a0, a0, 1
++  addi  a1, a1, 1
++  addi  a2, a2, -1
++  bne   a3, a4, .Ldone
++  bnez  a3, .Lmisaligned
++.Ldone:
++  sub   a0, a3, a4
++  ret
++
++# cases in which a null byte was detected
++.Lnull:
++  bne   a3, a4, .Lmisaligned
++.Lequal:
++  li    a0, 0
++  ret
++
++END (strncmp)
++libc_hidden_builtin_def (strncmp)
+\ No newline at end of file
+diff --git a/sysdeps/riscv/rv64/strnlen.S b/sysdeps/riscv/rv64/strnlen.S
+new file mode 100644
+index 0000000000..33b140a0ac
+--- /dev/null
++++ b/sysdeps/riscv/rv64/strnlen.S
+@@ -0,0 +1,62 @@
++/* The assembly function for strnlen.  RISC-V version.
++   Copyright (C) 2018 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, see
++   <http://www.gnu.org/licenses/>.  */
++
++#include <sysdep.h>
++
++	.p2align 6
++ENTRY (strnlen)
++  mv    a2, a0
++  mv    a0, a1
++  li    a3, -1
++  beqz  a1, .Ldone
++  add   a0, a2, a1
++  bleu  a2, a0, 1f
++  li    a0, -1
++1:
++  mv    a5, a2
++
++.Lmisaligned:
++  andi  a4, a5, 7
++  beqz  a4, .Lloop
++  lbu   a4, 0(a5)
++  beqz  a4, .Llenth
++  addi  a5, a5, 1
++  j     .Lmisaligned  
++
++.Laligned:
++  addi  a5, a5, 8
++  addi  a1, a1, -8
++.Lloop:
++  bleu  a1, x0, .Llenth
++  ld    a4, 0(a5)
++  orc.b a4, a4
++  beq   a4, a3, .Laligned
++  not   a4, a4
++  ctz   a4, a4
++  srli  a4, a4, 3
++  add   a5, a5, a4
++.Llenth:
++  minu  a5, a5, a0
++  sub   a0, a5, a2
++.Ldone:
++  ret
++
++END (strnlen)
++weak_alias (strnlen, __strnlen)
++libc_hidden_builtin_def (strnlen)
++libc_hidden_builtin_def (__strnlen)
+-- 
+2.25.1
+

+ 28 - 0
recipes-core/glibc/glibc/0017-fix-strchr-missing-index-weak-alias.patch

@@ -0,0 +1,28 @@
+From 3ecd64e60697cf19c98a2afb5e6f51f5f9c8fe63 Mon Sep 17 00:00:00 2001
+From: "demin.han" <demin.han@starfivetech.com>
+Date: Thu, 8 Dec 2022 15:18:15 +0800
+Subject: [PATCH 17/19] fix strchr missing 'index' weak alias
+
+---
+ sysdeps/riscv/rv64/strchr.S | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/sysdeps/riscv/rv64/strchr.S b/sysdeps/riscv/rv64/strchr.S
+index a9059c19ca..2d108800c1 100644
+--- a/sysdeps/riscv/rv64/strchr.S
++++ b/sysdeps/riscv/rv64/strchr.S
+@@ -78,4 +78,9 @@ ENTRY (strchr)
+      
+ 
+ END (strchr)
+-libc_hidden_builtin_def (strchr)
+\ No newline at end of file
++
++#ifdef weak_alias
++# undef index
++weak_alias (strchr, index)
++#endif
++libc_hidden_builtin_def (strchr)
+-- 
+2.25.1
+

+ 1 - 1
recipes-core/glibc/glibc/0030-powerpc-Do-not-ask-compiler-for-finding-arch.patch → recipes-core/glibc/glibc/0017-powerpc-Do-not-ask-compiler-for-finding-arch.patch

@@ -1,4 +1,4 @@
-From 60aa53f547911163b42a1c436d695a15c87f34ee Mon Sep 17 00:00:00 2001
+From 93c5b86fae5e42e148e5182466eb0ac26298159c Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Fri, 7 Aug 2020 14:31:16 -0700
 Subject: [PATCH] powerpc: Do not ask compiler for finding arch

+ 0 - 34
recipes-core/glibc/glibc/0017-timezone-re-written-tzselect-as-posix-sh.patch

@@ -1,34 +0,0 @@
-From 2731fa0c7463cd160361a8ac92f3bd7f984d953d Mon Sep 17 00:00:00 2001
-From: Khem Raj <raj.khem@gmail.com>
-Date: Wed, 18 Mar 2015 00:33:03 +0000
-Subject: [PATCH] timezone: re-written tzselect as posix sh
-
-To avoid the bash dependency.
-
-Upstream-Status: Pending
-
-Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
-Signed-off-by: Khem Raj <raj.khem@gmail.com>
----
- timezone/tzselect.ksh | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/timezone/tzselect.ksh b/timezone/tzselect.ksh
-index 18fce27e24..7705df83d7 100755
---- a/timezone/tzselect.ksh
-+++ b/timezone/tzselect.ksh
-@@ -1,4 +1,4 @@
--#!/bin/bash
-+#!/bin/sh
- # Ask the user about the time zone, and output the resulting TZ value to stdout.
- # Interact with the user via stderr and stdin.
- 
-@@ -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 '-'.

+ 25 - 0
recipes-core/glibc/glibc/0018-fix-memmove-align-fail-because-of-typo.patch

@@ -0,0 +1,25 @@
+From 8461fb86ab5ac8b38bdc3114c09654362d7e9ecf Mon Sep 17 00:00:00 2001
+From: "demin.han" <demin.han@starfivetech.com>
+Date: Mon, 12 Dec 2022 15:38:27 +0800
+Subject: [PATCH 18/19] fix memmove align fail because of typo
+
+---
+ sysdeps/riscv/rv64/multiarch/memmove_as.S | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/sysdeps/riscv/rv64/multiarch/memmove_as.S b/sysdeps/riscv/rv64/multiarch/memmove_as.S
+index b8275b6dd7..35d0905186 100644
+--- a/sysdeps/riscv/rv64/multiarch/memmove_as.S
++++ b/sysdeps/riscv/rv64/multiarch/memmove_as.S
+@@ -131,7 +131,7 @@ ENTRY (memmove)
+     add     a5, a0, a2
+     li      a3, 8
+     bltu    a2, a3, .L_byte_bwd
+-    andi    a4, a0, 0x7
++    andi    a4, a5, 0x7
+     beqz    a4, .L_32B_bwd
+ .L_byte_head_bwd:
+     sub     a2, a2, a4
+-- 
+2.25.1
+

+ 8 - 8
recipes-core/glibc/glibc/0029-wordsize.h-Unify-the-header-between-arm-and-aarch64.patch → recipes-core/glibc/glibc/0018-wordsize.h-Unify-the-header-between-arm-and-aarch64.patch

@@ -1,4 +1,4 @@
-From baba3c6021340a9070b734f931a15cea4cfe6c31 Mon Sep 17 00:00:00 2001
+From e2dba281429384cc22a73a58eaf79459e64be266 Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Fri, 15 May 2020 17:05:45 -0700
 Subject: [PATCH] wordsize.h: Unify the header between arm and aarch64
@@ -11,13 +11,13 @@ Upstream-Status: Inappropriate [ OE-Specific ]
 
 Signed-off-by: Khem Raj <raj.khem@gmail.com>
 ---
- sysdeps/aarch64/bits/wordsize.h          |  8 ++++++--
- sysdeps/{aarch64 => arm}/bits/wordsize.h | 10 +++++++---
- 2 files changed, 13 insertions(+), 5 deletions(-)
- copy sysdeps/{aarch64 => arm}/bits/wordsize.h (80%)
+ sysdeps/aarch64/bits/wordsize.h          | 8 ++++++--
+ sysdeps/{aarch64 => arm}/bits/wordsize.h | 8 ++++++--
+ 2 files changed, 12 insertions(+), 4 deletions(-)
+ copy sysdeps/{aarch64 => arm}/bits/wordsize.h (85%)
 
 diff --git a/sysdeps/aarch64/bits/wordsize.h b/sysdeps/aarch64/bits/wordsize.h
-index 91da566b74..9a754514b3 100644
+index 4635431f0e..5ef0ed21f3 100644
 --- a/sysdeps/aarch64/bits/wordsize.h
 +++ b/sysdeps/aarch64/bits/wordsize.h
 @@ -17,12 +17,16 @@
@@ -40,10 +40,10 @@ index 91da566b74..9a754514b3 100644
  
  #define __WORDSIZE_TIME64_COMPAT32	0
 diff --git a/sysdeps/aarch64/bits/wordsize.h b/sysdeps/arm/bits/wordsize.h
-similarity index 80%
+similarity index 85%
 copy from sysdeps/aarch64/bits/wordsize.h
 copy to sysdeps/arm/bits/wordsize.h
-index 91da566b74..34fcdef1f1 100644
+index 4635431f0e..5ef0ed21f3 100644
 --- a/sysdeps/aarch64/bits/wordsize.h
 +++ b/sysdeps/arm/bits/wordsize.h
 @@ -17,12 +17,16 @@

+ 26 - 19
recipes-core/glibc/glibc/0018-Remove-bash-dependency-for-nscd-init-script.patch → recipes-core/glibc/glibc/0019-Replace-echo-with-printf-builtin-in-nscd-init-script.patch

@@ -1,21 +1,22 @@
-From 412d33bbfe42a10a9b1f62afcc73fe121a0363b0 Mon Sep 17 00:00:00 2001
+From 97a71e1dd07ba6721464150b03fd67823b6271e2 Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Thu, 31 Dec 2015 14:33:02 -0800
-Subject: [PATCH] Remove bash dependency for nscd init script
+Subject: [PATCH] Replace echo with printf builtin in 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.
+The nscd init script calls for #! /bin/bash interpreter
+since it uses bash specific extentions namely (translated strings)
+and echo -n command, replace echo with printf and
+switch the shell interpreter to #!/bin/sh.
 
 Upstream-Status: Pending
-
-Signed-off-by: Ross Burton <ross.burton@intel.com>
+Signed-off-by: Ross Burton <ross.burton@arm.com>
 Signed-off-by: Khem Raj <raj.khem@gmail.com>
 ---
- nscd/nscd.init | 14 +++++++-------
- 1 file changed, 7 insertions(+), 7 deletions(-)
+ nscd/nscd.init | 20 ++++++++++----------
+ 1 file changed, 10 insertions(+), 10 deletions(-)
 
 diff --git a/nscd/nscd.init b/nscd/nscd.init
-index a882da7d8b..b02986ec15 100644
+index a882da7d8b..857b541381 100644
 --- a/nscd/nscd.init
 +++ b/nscd/nscd.init
 @@ -1,4 +1,4 @@
@@ -24,25 +25,27 @@ index a882da7d8b..b02986ec15 100644
  #
  # nscd:		Starts the Name Switch Cache Daemon
  #
-@@ -49,7 +49,7 @@ prog=nscd
+@@ -49,16 +49,16 @@ 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: "
++    printf "Starting $prog: "
      daemon /usr/sbin/nscd
      RETVAL=$?
-     echo
-@@ -58,7 +58,7 @@ start () {
+-    echo
++    printf "\n"
+     [ $RETVAL -eq 0 ] && touch /var/lock/subsys/nscd
+     return $RETVAL
  }
  
  stop () {
 -    echo -n $"Stopping $prog: "
-+    echo -n "Stopping $prog: "
++    printf "Stopping $prog: "
      /usr/sbin/nscd -K
      RETVAL=$?
      if [ $RETVAL -eq 0 ]; then
-@@ -67,9 +67,9 @@ stop () {
+@@ -67,11 +67,11 @@ stop () {
  	# a non-privileged user
  	rm -f /var/run/nscd/nscd.pid
  	rm -f /var/run/nscd/socket
@@ -52,21 +55,25 @@ index a882da7d8b..b02986ec15 100644
 -       	failure $"$prog shutdown"
 +	failure "$prog shutdown"
      fi
-     echo
+-    echo
++    printf "\n"
      return $RETVAL
+ }
+ 
 @@ -103,13 +103,13 @@ case "$1" in
  	RETVAL=$?
  	;;
      force-reload | reload)
 -    	echo -n $"Reloading $prog: "
-+	echo -n "Reloading $prog: "
++	printf "Reloading $prog: "
  	killproc /usr/sbin/nscd -HUP
  	RETVAL=$?
- 	echo
+-	echo
++	printf "\n"
  	;;
      *)
 -	echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
-+	echo "Usage: $0 {start|stop|status|restart|reload|condrestart}"
++	printf "Usage: $0 {start|stop|status|restart|reload|condrestart}\n"
  	RETVAL=1
  	;;
  esac

+ 123 - 0
recipes-core/glibc/glibc/0019-fix-missing-alias-functions.patch

@@ -0,0 +1,123 @@
+From 6de07625ef56d37f9804ef4ffc7fe568954cb689 Mon Sep 17 00:00:00 2001
+From: "max.ma" <max.ma@starfivetech.com>
+Date: Wed, 14 Dec 2022 16:55:05 -0800
+Subject: [PATCH 19/19] fix missing alias functions
+
+---
+ sysdeps/riscv/rv64/multiarch/memchr_as.S     |  8 ++++++--
+ sysdeps/riscv/rv64/multiarch/memchr_riscv.S  |  3 +--
+ sysdeps/riscv/rv64/multiarch/memcmp_riscv.S  |  1 -
+ sysdeps/riscv/rv64/multiarch/memmove_riscv.S |  1 -
+ sysdeps/riscv/rv64/multiarch/memset_riscv.S  |  1 -
+ sysdeps/riscv/rv64/strnlen.S                 | 13 ++++++++-----
+ 6 files changed, 15 insertions(+), 12 deletions(-)
+
+diff --git a/sysdeps/riscv/rv64/multiarch/memchr_as.S b/sysdeps/riscv/rv64/multiarch/memchr_as.S
+index ad559e6a11..4d3221c60e 100644
+--- a/sysdeps/riscv/rv64/multiarch/memchr_as.S
++++ b/sysdeps/riscv/rv64/multiarch/memchr_as.S
+@@ -22,7 +22,7 @@
+ .option arch, +zbb
+ 
+ 	.p2align 6
+-ENTRY (memchr)
++ENTRY (__memchr)
+     beqz    a2, .L_not_find
+     li      a4, 9
+     bltu    a2, a4, .L_0_to_8 
+@@ -91,5 +91,9 @@ ENTRY (memchr)
+     add     a0, a0, a3
+ .L_find_byte:
+     ret
+-END (memchr)
++END (__memchr)
++#ifdef weak_alias
++weak_alias (__memchr, memchr)
++#endif
++
+ libc_hidden_builtin_def (memchr)
+diff --git a/sysdeps/riscv/rv64/multiarch/memchr_riscv.S b/sysdeps/riscv/rv64/multiarch/memchr_riscv.S
+index 84b3375f31..829f57e7e5 100644
+--- a/sysdeps/riscv/rv64/multiarch/memchr_riscv.S
++++ b/sysdeps/riscv/rv64/multiarch/memchr_riscv.S
+@@ -20,12 +20,11 @@
+ 
+ #if IS_IN (libc) && defined SHARED && defined __riscv_vector
+ 
+-#define memchr __memchr_riscv
++#define __memchr __memchr_riscv
+ #undef libc_hidden_builtin_def
+ #define libc_hidden_builtin_def(name)
+ #include "memchr_as.S"
+ 
+-
+ #else
+ 
+ #include "memchr_as.S"
+diff --git a/sysdeps/riscv/rv64/multiarch/memcmp_riscv.S b/sysdeps/riscv/rv64/multiarch/memcmp_riscv.S
+index 32df79f769..f9ba9da081 100644
+--- a/sysdeps/riscv/rv64/multiarch/memcmp_riscv.S
++++ b/sysdeps/riscv/rv64/multiarch/memcmp_riscv.S
+@@ -21,7 +21,6 @@
+ #undef libc_hidden_builtin_def
+ #define libc_hidden_builtin_def(name)
+ 
+-#undef weak_alias
+ #  define memcmp __memcmp_riscv
+ # include "memcmp_as.S"
+ 
+diff --git a/sysdeps/riscv/rv64/multiarch/memmove_riscv.S b/sysdeps/riscv/rv64/multiarch/memmove_riscv.S
+index 14f154e226..f829e0d5c3 100644
+--- a/sysdeps/riscv/rv64/multiarch/memmove_riscv.S
++++ b/sysdeps/riscv/rv64/multiarch/memmove_riscv.S
+@@ -21,7 +21,6 @@
+ #undef libc_hidden_builtin_def
+ #define libc_hidden_builtin_def(name)
+ 
+-#undef weak_alias
+ #  define memmove __memmove_riscv
+ # include "memmove_as.S"
+ 
+diff --git a/sysdeps/riscv/rv64/multiarch/memset_riscv.S b/sysdeps/riscv/rv64/multiarch/memset_riscv.S
+index 8585db0228..6540639296 100644
+--- a/sysdeps/riscv/rv64/multiarch/memset_riscv.S
++++ b/sysdeps/riscv/rv64/multiarch/memset_riscv.S
+@@ -20,7 +20,6 @@
+ #undef libc_hidden_builtin_def
+ #define libc_hidden_builtin_def(name)
+ 
+-#undef weak_alias
+ #  define memset __memset_riscv
+ # include "memset_as.S"
+ #else
+diff --git a/sysdeps/riscv/rv64/strnlen.S b/sysdeps/riscv/rv64/strnlen.S
+index 33b140a0ac..73757b69f2 100644
+--- a/sysdeps/riscv/rv64/strnlen.S
++++ b/sysdeps/riscv/rv64/strnlen.S
+@@ -19,7 +19,7 @@
+ #include <sysdep.h>
+ 
+ 	.p2align 6
+-ENTRY (strnlen)
++ENTRY (__strnlen)
+   mv    a2, a0
+   mv    a0, a1
+   li    a3, -1
+@@ -56,7 +56,10 @@ ENTRY (strnlen)
+ .Ldone:
+   ret
+ 
+-END (strnlen)
+-weak_alias (strnlen, __strnlen)
+-libc_hidden_builtin_def (strnlen)
+-libc_hidden_builtin_def (__strnlen)
++END (__strnlen)
++
++#ifndef STRNLEN
++libc_hidden_def (__strnlen)
++weak_alias (__strnlen, strnlen)
++#endif
++libc_hidden_def (strnlen)
+-- 
+2.25.1
+

+ 9 - 8
recipes-core/glibc/glibc/0015-sysdeps-gnu-configure.ac-handle-correctly-libc_cv_ro.patch → recipes-core/glibc/glibc/0020-sysdeps-gnu-configure.ac-Set-libc_cv_rootsbindir-onl.patch

@@ -1,11 +1,12 @@
-From b4613f814ba7ba5db95d18116172f81a83ac8f5b Mon Sep 17 00:00:00 2001
+From 3b5b6079512af8af50d0a43d4c1c218f5ba1b302 Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Wed, 18 Mar 2015 00:27:10 +0000
-Subject: [PATCH] sysdeps/gnu/configure.ac: handle correctly
- $libc_cv_rootsbindir
+Subject: [PATCH] sysdeps/gnu/configure.ac: Set libc_cv_rootsbindir only if its
+ empty
 
-Upstream-Status:Pending
+This ensures that it can be set in build environment
 
+Upstream-Status: Pending
 Signed-off-by: Matthieu Crapet <Matthieu.Crapet@ingenico.com>
 Signed-off-by: Khem Raj <raj.khem@gmail.com>
 ---
@@ -14,7 +15,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
  2 files changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/sysdeps/gnu/configure b/sysdeps/gnu/configure
-index c15d1087e8..37cc983f2a 100644
+index c15d1087e8..d30d6e37ae 100644
 --- a/sysdeps/gnu/configure
 +++ b/sysdeps/gnu/configure
 @@ -32,6 +32,6 @@ case "$prefix" in
@@ -22,11 +23,11 @@ index c15d1087e8..37cc983f2a 100644
      libc_cv_localstatedir=$localstatedir
     fi
 -  libc_cv_rootsbindir=/sbin
-+  test -n "$libc_cv_rootsbindir" || libc_cv_rootsbindir=/sbin
++  libc_cv_rootsbindir=${libc_cv_rootsbindir:=/sbin}
    ;;
  esac
 diff --git a/sysdeps/gnu/configure.ac b/sysdeps/gnu/configure.ac
-index 634fe4de2a..3db1697f4f 100644
+index 634fe4de2a..492112e0fd 100644
 --- a/sysdeps/gnu/configure.ac
 +++ b/sysdeps/gnu/configure.ac
 @@ -21,6 +21,6 @@ case "$prefix" in
@@ -34,6 +35,6 @@ index 634fe4de2a..3db1697f4f 100644
      libc_cv_localstatedir=$localstatedir
     fi
 -  libc_cv_rootsbindir=/sbin
-+  test -n "$libc_cv_rootsbindir" || libc_cv_rootsbindir=/sbin
++  libc_cv_rootsbindir=${libc_cv_rootsbindir:=/sbin}
    ;;
  esac

+ 47 - 0
recipes-core/glibc/glibc/0021-timezone-Make-shell-interpreter-overridable-in-tzsel.patch

@@ -0,0 +1,47 @@
+From 8d5ff7357354394b958321204b75e3855781aefe Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Thu, 9 Dec 2021 15:14:42 -0800
+Subject: [PATCH] timezone: Make shell interpreter overridable in tzselect.ksh
+
+define new macro called KSHELL which can be used to define default shell
+use Bash by default
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ Makeconfig        | 9 +++++++++
+ timezone/Makefile | 1 +
+ 2 files changed, 10 insertions(+)
+
+diff --git a/Makeconfig b/Makeconfig
+index ba70321af1..4b643768d9 100644
+--- a/Makeconfig
++++ b/Makeconfig
+@@ -293,6 +293,15 @@ ifndef sysincludedir
+ sysincludedir = /usr/include
+ endif
+ 
++# The full path name of a Posix-compliant shell, preferably one that supports
++# the Korn shell's 'select' statement as an extension.
++# These days, Bash is the most popular.
++# It should be OK to set this to /bin/sh, on platforms where /bin/sh
++# lacks 'select' or doesn't completely conform to Posix, but /bin/bash
++# is typically nicer if it works.
++ifndef KSHELL
++KSHELL = /bin/bash
++endif
+ 
+ # Commands to install files.
+ ifndef INSTALL_DATA
+diff --git a/timezone/Makefile b/timezone/Makefile
+index a789c22d26..3e69409a94 100644
+--- a/timezone/Makefile
++++ b/timezone/Makefile
+@@ -134,6 +134,7 @@ $(objpfx)tzselect: tzselect.ksh $(common-objpfx)config.make
+ 	    -e '/TZVERSION=/s|see_Makefile|"$(version)"|' \
+ 	    -e '/PKGVERSION=/s|=.*|="$(PKGVERSION)"|' \
+ 	    -e '/REPORT_BUGS_TO=/s|=.*|="$(REPORT_BUGS_TO)"|' \
++	    -e 's|#!/bin/bash|#!$(KSHELL)|g' \
+ 	    < $< > $@.new
+ 	chmod 555 $@.new
+ 	mv -f $@.new $@

+ 27 - 0
recipes-core/glibc/glibc/0022-tzselect.ksh-Use-bin-sh-default-shell-interpreter.patch

@@ -0,0 +1,27 @@
+From ba1365f19ccc8378f2fcff892721187537479884 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Wed, 15 Dec 2021 21:47:53 -0800
+Subject: [PATCH] tzselect.ksh: Use /bin/sh default shell interpreter
+
+checkbashism reports no issues with tzselect.ksh, therefore using
+/bin/sh instead of /bin/bash should be safe and portable across systems
+which don't ship bash ( embedded systems )
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+Cc: Adhemerval Zanella <adhemerval.zanella@linaro.org>
+Cc: Paul Eggert <eggert@cs.ucla.edu>
+---
+ timezone/tzselect.ksh | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/timezone/tzselect.ksh b/timezone/tzselect.ksh
+index 18fce27e24..cc08efb0fb 100755
+--- a/timezone/tzselect.ksh
++++ b/timezone/tzselect.ksh
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!/bin/sh
+ # Ask the user about the time zone, and output the resulting TZ value to stdout.
+ # Interact with the user via stderr and stdin.
+ 

+ 13 - 6
recipes-core/glibc/glibc/0001-fix-create-thread-failed-in-unprivileged-process-BZ-.patch → recipes-core/glibc/glibc/0023-fix-create-thread-failed-in-unprivileged-process-BZ-.patch

@@ -1,4 +1,4 @@
-From a8bc44936202692edcd82a48c07d7cf27d6ed8ee Mon Sep 17 00:00:00 2001
+From ffbb37732807e180b14a21d1bf79ad5038252c02 Mon Sep 17 00:00:00 2001
 From: Hongxu Jia <hongxu.jia@windriver.com>
 Date: Sun, 29 Aug 2021 20:49:16 +0800
 Subject: [PATCH] fix create thread failed in unprivileged process [BZ #28287]
@@ -54,15 +54,25 @@ $ ./conftest
 start thread: check_me 42
 check_me 42, p 0x7ffe253c6f20
 
-Upstream-Status: Submitted [libc-alpha@sourceware.org]
+Upstream-Status: Inappropriate [Rejected by upstream]
+
+Upstream glibc rejected it because the latest docker has resolved the issue [1],
+and upstream glibc does not backward compatibility with old docker[2]
+
+In order to build Yocto with uninative in old docker, we need this local
+patch
+
+[1] https://github.com/moby/moby/commit/9f6b562dd12ef7b1f9e2f8e6f2ab6477790a6594
+[2] https://sourceware.org/pipermail/libc-alpha/2021-August/130590.html
 
 Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
 ---
  sysdeps/unix/sysv/linux/clone-internal.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/sysdeps/unix/sysv/linux/clone-internal.c b/sysdeps/unix/sysv/linux/clone-internal.c
-index 979f7880be..97101994e8 100644
+index a71effcbd3..a0569113aa 100644
 --- a/sysdeps/unix/sysv/linux/clone-internal.c
 +++ b/sysdeps/unix/sysv/linux/clone-internal.c
 @@ -52,7 +52,7 @@ __clone_internal (struct clone_args *cl_args,
@@ -74,6 +84,3 @@ index 979f7880be..97101994e8 100644
      return ret;
  
    /* NB: Restore errno since errno may be checked against non-zero
--- 
-2.30.2
-

+ 32 - 0
recipes-core/glibc/glibc/0024-Avoid-hardcoded-build-time-paths-in-the-output-binar.patch

@@ -0,0 +1,32 @@
+From f873e25e29684cbbf7b141d9c6ee725268505c29 Mon Sep 17 00:00:00 2001
+From: Richard Purdie <richard.purdie@linuxfoundation.org>
+Date: Sun, 24 Jul 2022 07:07:29 -0700
+Subject: [PATCH] Avoid hardcoded build time paths in the output binaries
+
+replace the compile definitions with the output locations.
+
+Upstream-Status: Inappropriate [would need reworking somehow to be acceptable upstream]
+
+Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ support/Makefile | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/support/Makefile b/support/Makefile
+index 9b50eac117..4c24d9f61a 100644
+--- a/support/Makefile
++++ b/support/Makefile
+@@ -218,9 +218,9 @@ libsupport-inhibit-o += .o
+ endif
+ 
+ CFLAGS-support_paths.c = \
+-		-DSRCDIR_PATH=\"`cd .. ; pwd`\" \
+-		-DOBJDIR_PATH=\"`cd $(objpfx)/..; pwd`\" \
+-		-DOBJDIR_ELF_LDSO_PATH=\"`cd $(objpfx)/..; pwd`/elf/$(rtld-installed-name)\" \
++		-DSRCDIR_PATH=\"$(oe_srcdir)\" \
++		-DOBJDIR_PATH=\"$(libdir)/glibc-tests/ptest/tests/glibc-ptest\" \
++		-DOBJDIR_ELF_LDSO_PATH=\"$(slibdir)/$(rtld-installed-name)\" \
+ 		-DINSTDIR_PATH=\"$(prefix)\" \
+ 		-DLIBDIR_PATH=\"$(libdir)\" \
+ 		-DBINDIR_PATH=\"$(bindir)\" \

+ 0 - 53
recipes-core/glibc/glibc/0025-elf-dl-deps.c-Make-_dl_build_local_scope-breadth-fir.patch

@@ -1,53 +0,0 @@
-From 50b605dece16606dd9d1c737e579c13725eab11d Mon Sep 17 00:00:00 2001
-From: Mark Hatle <mark.hatle@windriver.com>
-Date: Thu, 18 Aug 2016 14:07:58 -0500
-Subject: [PATCH] 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 <mark.hatle@windriver.com>
----
- 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 087a49b212..c09f9334f2 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;
- }
- 

+ 28 - 0
recipes-core/glibc/glibc/0025-startup-Force-O2.patch

@@ -0,0 +1,28 @@
+From 5e635e5dc7d1b21a78f38109d4f43a03bec865c8 Mon Sep 17 00:00:00 2001
+From: "H.J. Lu" <hjl.tools@gmail.com>
+Date: Sun, 7 Aug 2022 12:51:48 +0200
+Subject: [PATCH] startup: Force -O2
+
+Upstream-Status: Submitted [https://sourceware.org/bugzilla/show_bug.cgi?id=29249]
+
+Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
+---
+ sysdeps/unix/sysv/linux/startup.h | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/sysdeps/unix/sysv/linux/startup.h b/sysdeps/unix/sysv/linux/startup.h
+index 39859b404a..e1fc1b682d 100644
+--- a/sysdeps/unix/sysv/linux/startup.h
++++ b/sysdeps/unix/sysv/linux/startup.h
+@@ -21,6 +21,11 @@
+ #else
+ # include <sysdep.h>
+ 
++# if !defined __OPTIMIZE__ || __OPTIMIZE__ < 2
++/* Force to fold strlen.  */
++#  pragma GCC optimize(2)
++# endif
++
+ /* Avoid a run-time invocation of strlen.  */
+ #define _startup_fatal(message)                                         \
+   do                                                                    \

+ 0 - 31
recipes-core/glibc/glibc/0026-intl-Emit-no-lines-in-bison-generated-files.patch

@@ -1,31 +0,0 @@
-From 99ab34278a6ebec134267412b4f619f43e278dea Mon Sep 17 00:00:00 2001
-From: Khem Raj <raj.khem@gmail.com>
-Date: Fri, 3 Aug 2018 09:44:00 -0700
-Subject: [PATCH] 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 <juro.bystricky@intel.com>
-Signed-off-by: Khem Raj <raj.khem@gmail.com>
----
- intl/Makefile | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/intl/Makefile b/intl/Makefile
-index 93478d87e8..b27a7935eb 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)

+ 490 - 0
recipes-core/glibc/glibc/1f34a2328890aa192141f96449d25b77f666bf47.patch

@@ -0,0 +1,490 @@
+From 1f34a2328890aa192141f96449d25b77f666bf47 Mon Sep 17 00:00:00 2001
+From: Florian Weimer <fweimer@redhat.com>
+Date: Thu, 3 Nov 2022 17:28:03 +0100
+Subject: [PATCH] elf: Introduce <dl-call_tls_init_tp.h> and call_tls_init_tp
+ (bug 29249)
+
+This makes it more likely that the compiler can compute the strlen
+argument in _startup_fatal at compile time, which is required to
+avoid a dependency on strlen this early during process startup.
+
+Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
+---
+ csu/libc-tls.c                        | 14 ++++-------
+ elf/rtld.c                            | 14 +++--------
+ sysdeps/aarch64/nptl/tls.h            |  2 +-
+ sysdeps/alpha/nptl/tls.h              |  2 +-
+ sysdeps/arc/nptl/tls.h                |  3 +--
+ sysdeps/csky/nptl/tls.h               |  3 +--
+ sysdeps/generic/dl-call_tls_init_tp.h | 34 +++++++++++++++++++++++++++
+ sysdeps/generic/startup.h             |  2 +-
+ sysdeps/hppa/nptl/tls.h               |  2 +-
+ sysdeps/i386/nptl/tls.h               |  3 +--
+ sysdeps/ia64/nptl/tls.h               |  2 +-
+ sysdeps/loongarch/nptl/tls.h          |  2 +-
+ sysdeps/m68k/nptl/tls.h               |  2 +-
+ sysdeps/mach/hurd/i386/tls.h          | 10 ++++----
+ sysdeps/microblaze/nptl/tls.h         |  2 +-
+ sysdeps/mips/nptl/tls.h               |  3 +--
+ sysdeps/nios2/nptl/tls.h              |  2 +-
+ sysdeps/or1k/nptl/tls.h               |  2 +-
+ sysdeps/powerpc/nptl/tls.h            |  2 +-
+ sysdeps/riscv/nptl/tls.h              |  2 +-
+ sysdeps/s390/nptl/tls.h               |  2 +-
+ sysdeps/sh/nptl/tls.h                 |  2 +-
+ sysdeps/sparc/nptl/tls.h              |  2 +-
+ sysdeps/unix/sysv/linux/arm/tls.h     |  3 +--
+ sysdeps/x86_64/nptl/tls.h             |  2 +-
+ 25 files changed, 68 insertions(+), 51 deletions(-)
+ create mode 100644 sysdeps/generic/dl-call_tls_init_tp.h
+
+diff --git a/csu/libc-tls.c b/csu/libc-tls.c
+index 0a216c55028..ca4def26133 100644
+--- a/csu/libc-tls.c
++++ b/csu/libc-tls.c
+@@ -25,6 +25,7 @@
+ #include <sys/param.h>
+ #include <array_length.h>
+ #include <pthreadP.h>
++#include <dl-call_tls_init_tp.h>
+ 
+ #ifdef SHARED
+  #error makefile bug, this file is for static only
+@@ -147,14 +148,14 @@ __libc_setup_tls (void)
+   tcb_offset = roundup (memsz + GLRO(dl_tls_static_surplus), max_align);
+   tlsblock = _dl_early_allocate (tcb_offset + TLS_INIT_TCB_SIZE + max_align);
+   if (tlsblock == NULL)
+-    _startup_fatal ("Fatal glibc error: Cannot allocate TLS block\n");
++    _startup_fatal_tls_error ();
+ #elif TLS_DTV_AT_TP
+   tcb_offset = roundup (TLS_INIT_TCB_SIZE, align ?: 1);
+   tlsblock = _dl_early_allocate (tcb_offset + memsz + max_align
+ 				 + TLS_PRE_TCB_SIZE
+ 				 + GLRO(dl_tls_static_surplus));
+   if (tlsblock == NULL)
+-    _startup_fatal ("Fatal glibc error: Cannot allocate TLS block\n");
++    _startup_fatal_tls_error ();
+   tlsblock += TLS_PRE_TCB_SIZE;
+ #else
+   /* In case a model with a different layout for the TCB and DTV
+@@ -191,16 +192,11 @@ __libc_setup_tls (void)
+ #if TLS_TCB_AT_TP
+   INSTALL_DTV ((char *) tlsblock + tcb_offset, _dl_static_dtv);
+ 
+-  const char *lossage = TLS_INIT_TP ((char *) tlsblock + tcb_offset);
++  call_tls_init_tp ((char *) tlsblock + tcb_offset);
+ #elif TLS_DTV_AT_TP
+   INSTALL_DTV (tlsblock, _dl_static_dtv);
+-  const char *lossage = TLS_INIT_TP (tlsblock);
+-#else
+-# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
++  call_tls_init_tp (tlsblock);
+ #endif
+-  if (__builtin_expect (lossage != NULL, 0))
+-    _startup_fatal (lossage);
+-  __tls_init_tp ();
+ 
+   /* Update the executable's link map with enough information to make
+      the TLS routines happy.  */
+diff --git a/elf/rtld.c b/elf/rtld.c
+index 8671594f1f5..70ad1acc43e 100644
+--- a/elf/rtld.c
++++ b/elf/rtld.c
+@@ -52,6 +52,7 @@
+ #include <dl-execve.h>
+ #include <dl-find_object.h>
+ #include <dl-audit-check.h>
++#include <dl-call_tls_init_tp.h>
+ 
+ #include <assert.h>
+ 
+@@ -796,10 +797,7 @@ cannot allocate TLS data structures for initial thread\n");
+   GL(dl_initial_dtv) = GET_DTV (tcbp);
+ 
+   /* And finally install it for the main thread.  */
+-  const char *lossage = TLS_INIT_TP (tcbp);
+-  if (__glibc_unlikely (lossage != NULL))
+-    _dl_fatal_printf ("cannot set up thread-local storage: %s\n", lossage);
+-  __tls_init_tp ();
++  call_tls_init_tp (tcbp);
+   tls_init_tp_called = true;
+ 
+   return tcbp;
+@@ -2348,13 +2346,7 @@ dl_main (const ElfW(Phdr) *phdr,
+ 
+   /* And finally install it for the main thread.  */
+   if (! tls_init_tp_called)
+-    {
+-      const char *lossage = TLS_INIT_TP (tcbp);
+-      if (__glibc_unlikely (lossage != NULL))
+-	_dl_fatal_printf ("cannot set up thread-local storage: %s\n",
+-			  lossage);
+-      __tls_init_tp ();
+-    }
++    call_tls_init_tp (tcbp);
+ 
+   /* Make sure no new search directories have been added.  */
+   assert (GLRO(dl_init_all_dirs) == GL(dl_all_dirs));
+diff --git a/sysdeps/aarch64/nptl/tls.h b/sysdeps/aarch64/nptl/tls.h
+index 08aa2eff891..6fe084c1ef9 100644
+--- a/sysdeps/aarch64/nptl/tls.h
++++ b/sysdeps/aarch64/nptl/tls.h
+@@ -72,7 +72,7 @@ typedef struct
+    special attention since 'errno' is not yet available and if the
+    operation can cause a failure 'errno' must not be touched.  */
+ # define TLS_INIT_TP(tcbp) \
+-  ({ __asm __volatile ("msr tpidr_el0, %0" : : "r" (tcbp)); NULL; })
++  ({ __asm __volatile ("msr tpidr_el0, %0" : : "r" (tcbp)); true; })
+ 
+ /* Value passed to 'clone' for initialization of the thread register.  */
+ # define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd) + 1
+diff --git a/sysdeps/alpha/nptl/tls.h b/sysdeps/alpha/nptl/tls.h
+index 8f5b69ad3b1..48dc1369fc1 100644
+--- a/sysdeps/alpha/nptl/tls.h
++++ b/sysdeps/alpha/nptl/tls.h
+@@ -69,7 +69,7 @@ typedef struct
+    special attention since 'errno' is not yet available and if the
+    operation can cause a failure 'errno' must not be touched.  */
+ # define TLS_INIT_TP(tcbp) \
+-  (__builtin_set_thread_pointer ((void *)(tcbp)), NULL)
++  (__builtin_set_thread_pointer ((void *)(tcbp)), true)
+ 
+ /* Value passed to 'clone' for initialization of the thread register.  */
+ # define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd) + 1
+diff --git a/sysdeps/arc/nptl/tls.h b/sysdeps/arc/nptl/tls.h
+index 7fc6602b236..948e618a3aa 100644
+--- a/sysdeps/arc/nptl/tls.h
++++ b/sysdeps/arc/nptl/tls.h
+@@ -75,8 +75,7 @@ typedef struct
+ 	long result_var;					\
+ 	__builtin_set_thread_pointer (tcbp);     		\
+ 	result_var = INTERNAL_SYSCALL_CALL (arc_settls, (tcbp));\
+-	INTERNAL_SYSCALL_ERROR_P (result_var)			\
+-	  ? "settls syscall error" : NULL;			\
++	!INTERNAL_SYSCALL_ERROR_P (result_var);			\
+    })
+ 
+ /* Value passed to 'clone' for initialization of the thread register.  */
+diff --git a/sysdeps/csky/nptl/tls.h b/sysdeps/csky/nptl/tls.h
+index 58d6ab0fb2a..3f7afc93391 100644
+--- a/sysdeps/csky/nptl/tls.h
++++ b/sysdeps/csky/nptl/tls.h
+@@ -92,8 +92,7 @@ typedef struct
+   ({ long int result_var;						\
+      result_var = INTERNAL_SYSCALL_CALL (set_thread_area, 		\
+                     (char *) (tcbp) + TLS_TCB_OFFSET);			\
+-     INTERNAL_SYSCALL_ERROR_P (result_var)				\
+-       ? "unknown error" : NULL; })
++     !INTERNAL_SYSCALL_ERROR_P (result_var); })
+ 
+ /* Return the address of the dtv for the current thread.  */
+ # define THREAD_DTV() \
+diff --git a/sysdeps/generic/dl-call_tls_init_tp.h b/sysdeps/generic/dl-call_tls_init_tp.h
+new file mode 100644
+index 00000000000..411feda3fc0
+--- /dev/null
++++ b/sysdeps/generic/dl-call_tls_init_tp.h
+@@ -0,0 +1,34 @@
++/* Invoke TLS_INIT_TP and __tls_init_tp with error handling.
++   Copyright (C) 2022 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, see
++   <https://www.gnu.org/licenses/>.  */
++
++#include <startup.h>
++#include <tls.h>
++
++static inline void
++_startup_fatal_tls_error (void)
++{
++  _startup_fatal ("Fatal glibc error: Cannot allocate TLS block\n");
++}
++
++static inline void
++call_tls_init_tp (void *addr)
++{
++  if (!TLS_INIT_TP (addr))
++    _startup_fatal_tls_error ();
++  __tls_init_tp ();
++}
+diff --git a/sysdeps/generic/startup.h b/sysdeps/generic/startup.h
+index 45979ab2319..4b444511b4f 100644
+--- a/sysdeps/generic/startup.h
++++ b/sysdeps/generic/startup.h
+@@ -19,7 +19,7 @@
+ /* Targets should override this file if the default definitions below
+    will not work correctly very early before TLS is initialized.  */
+ 
+-#include <unistd.h>
++#include <stdio.h>
+ 
+ /* Use macro instead of inline function to avoid including <stdio.h>.  */
+ #define _startup_fatal(message) __libc_fatal ((message))
+diff --git a/sysdeps/hppa/nptl/tls.h b/sysdeps/hppa/nptl/tls.h
+index e6b0bd5c718..6af22cdc004 100644
+--- a/sysdeps/hppa/nptl/tls.h
++++ b/sysdeps/hppa/nptl/tls.h
+@@ -74,7 +74,7 @@ typedef struct
+    special attention since 'errno' is not yet available and if the
+    operation can cause a failure 'errno' must not be touched.  */
+ # define TLS_INIT_TP(tcbp) \
+-  ({ __set_cr27(tcbp); NULL; })
++  ({ __set_cr27(tcbp); true; })
+ 
+ /* Value passed to 'clone' for initialization of the thread register.  */
+ # define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd) + 1
+diff --git a/sysdeps/i386/nptl/tls.h b/sysdeps/i386/nptl/tls.h
+index 91090bf2877..553b55b3f2d 100644
+--- a/sysdeps/i386/nptl/tls.h
++++ b/sysdeps/i386/nptl/tls.h
+@@ -203,8 +203,7 @@ tls_fill_user_desc (union user_desc_init *desc,
+ 	  which is necessary since we have changed it.   */		      \
+        TLS_SET_GS (_segdescr.desc.entry_number * 8 + 3);		      \
+ 									      \
+-     _result == 0 ? NULL						      \
+-     : "set_thread_area failed when setting up thread-local storage\n"; })
++     _result == 0; })
+ 
+ # define TLS_DEFINE_INIT_TP(tp, pd)					      \
+   union user_desc_init _segdescr;					      \
+diff --git a/sysdeps/ia64/nptl/tls.h b/sysdeps/ia64/nptl/tls.h
+index d2411b3c1ac..4085c568326 100644
+--- a/sysdeps/ia64/nptl/tls.h
++++ b/sysdeps/ia64/nptl/tls.h
+@@ -105,7 +105,7 @@ register struct pthread *__thread_self __asm__("r13");
+    special attention since 'errno' is not yet available and if the
+    operation can cause a failure 'errno' must not be touched.  */
+ # define TLS_INIT_TP(thrdescr) \
+-  (__thread_self = (thrdescr), INIT_SYSINFO, NULL)
++  (__thread_self = (thrdescr), INIT_SYSINFO, true)
+ 
+ /* Value passed to 'clone2' for initialization of the thread register.  */
+ # define TLS_DEFINE_INIT_TP(tp, pd) \
+diff --git a/sysdeps/loongarch/nptl/tls.h b/sysdeps/loongarch/nptl/tls.h
+index 24bffe3a0ad..e8b616854f7 100644
+--- a/sysdeps/loongarch/nptl/tls.h
++++ b/sysdeps/loongarch/nptl/tls.h
+@@ -83,7 +83,7 @@ typedef struct
+ #define TLS_INIT_TP(tcbp) \
+   ({ \
+     __thread_self = (char *) tcbp + TLS_TCB_OFFSET; \
+-    NULL; \
++    true; \
+   })
+ 
+ /* Return the address of the dtv for the current thread.  */
+diff --git a/sysdeps/m68k/nptl/tls.h b/sysdeps/m68k/nptl/tls.h
+index 742e1b6767d..ebcc118bbe2 100644
+--- a/sysdeps/m68k/nptl/tls.h
++++ b/sysdeps/m68k/nptl/tls.h
+@@ -90,7 +90,7 @@ typedef struct
+ 									\
+     _sys_result = INTERNAL_SYSCALL_CALL (set_thread_area, 		\
+ 				    ((void *) (tcbp)) + TLS_TCB_OFFSET); \
+-    INTERNAL_SYSCALL_ERROR_P (_sys_result) ? "unknown error" : NULL; })
++    !INTERNAL_SYSCALL_ERROR_P (_sys_result); })
+ 
+ # define TLS_DEFINE_INIT_TP(tp, pd) \
+   void *tp = (void *) (pd) + TLS_TCB_OFFSET + TLS_PRE_TCB_SIZE
+diff --git a/sysdeps/mach/hurd/i386/tls.h b/sysdeps/mach/hurd/i386/tls.h
+index 602bacc0de0..2847e3ee61c 100644
+--- a/sysdeps/mach/hurd/i386/tls.h
++++ b/sysdeps/mach/hurd/i386/tls.h
+@@ -117,12 +117,12 @@ extern unsigned short __init1_desc;
+ 
+ # define HURD_SEL_LDT(sel) (__builtin_expect ((sel) & 4, 0))
+ 
+-static inline const char * __attribute__ ((unused))
++static inline bool __attribute__ ((unused))
+ _hurd_tls_init (tcbhead_t *tcb)
+ {
+   HURD_TLS_DESC_DECL (desc, tcb);
+   thread_t self = __mach_thread_self ();
+-  const char *msg = NULL;
++  bool success = true;
+ 
+   /* This field is used by TLS accesses to get our "thread pointer"
+      from the TLS point of view.  */
+@@ -141,14 +141,14 @@ _hurd_tls_init (tcbhead_t *tcb)
+       assert_perror (err);
+       if (err)
+       {
+-	msg = "i386_set_ldt failed";
++	success = false;
+ 	goto out;
+       }
+     }
+   else if (err)
+     {
+       assert_perror (err); /* Separate from above with different line #. */
+-      msg = "i386_set_gdt failed";
++      success = false;
+       goto out;
+     }
+ 
+@@ -157,7 +157,7 @@ _hurd_tls_init (tcbhead_t *tcb)
+ 
+ out:
+   __mach_port_deallocate (__mach_task_self (), self);
+-  return msg;
++  return success;
+ }
+ 
+ /* Code to initially initialize the thread pointer.  This might need
+diff --git a/sysdeps/microblaze/nptl/tls.h b/sysdeps/microblaze/nptl/tls.h
+index 588fd1c5d63..d8be1932b9b 100644
+--- a/sysdeps/microblaze/nptl/tls.h
++++ b/sysdeps/microblaze/nptl/tls.h
+@@ -75,7 +75,7 @@ typedef struct
+ /* Code to initially initialize the thread pointer.
+    r21 is reserved for thread pointer.  */
+ # define TLS_INIT_TP(tcbp) \
+-  ({ __asm __volatile ("or r21,r0,%0" : : "r" ((void *)tcbp)); NULL; })
++  ({ __asm __volatile ("or r21,r0,%0" : : "r" ((void *)tcbp)); true; })
+ 
+ # define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd) + 1
+ 
+diff --git a/sysdeps/mips/nptl/tls.h b/sysdeps/mips/nptl/tls.h
+index 2aa7cb4bb8d..bac6e8771cd 100644
+--- a/sysdeps/mips/nptl/tls.h
++++ b/sysdeps/mips/nptl/tls.h
+@@ -116,8 +116,7 @@ typedef struct
+   ({ long int result_var;						\
+      result_var = INTERNAL_SYSCALL_CALL (set_thread_area, 		\
+ 				    (char *) (tcbp) + TLS_TCB_OFFSET);	\
+-     INTERNAL_SYSCALL_ERROR_P (result_var)				\
+-       ? "unknown error" : NULL; })
++     !INTERNAL_SYSCALL_ERROR_P (result_var); })
+ 
+ /* Value passed to 'clone' for initialization of the thread register.  */
+ # define TLS_DEFINE_INIT_TP(tp, pd) \
+diff --git a/sysdeps/nios2/nptl/tls.h b/sysdeps/nios2/nptl/tls.h
+index cb231e2a4bb..f5a9713f93f 100644
+--- a/sysdeps/nios2/nptl/tls.h
++++ b/sysdeps/nios2/nptl/tls.h
+@@ -88,7 +88,7 @@ register struct pthread *__thread_self __asm__("r23");
+ 
+ /* Code to initially initialize the thread pointer.  */
+ # define TLS_INIT_TP(tcbp) \
+-  (__thread_self = (struct pthread *) ((char *) tcbp + TLS_TCB_OFFSET), NULL)
++  (__thread_self = (struct pthread *) ((char *) tcbp + TLS_TCB_OFFSET), true)
+ 
+ /* Value passed to 'clone' for initialization of the thread register.  */
+ # define TLS_DEFINE_INIT_TP(tp, pd) \
+diff --git a/sysdeps/or1k/nptl/tls.h b/sysdeps/or1k/nptl/tls.h
+index e82f444738d..eda0e893aea 100644
+--- a/sysdeps/or1k/nptl/tls.h
++++ b/sysdeps/or1k/nptl/tls.h
+@@ -112,7 +112,7 @@ register tcbhead_t *__thread_self __asm__("r10");
+    It's hard to fail this, so return NULL always.  */
+ 
+ # define TLS_INIT_TP(tcbp) \
+-  ({__thread_self = ((tcbhead_t *)tcbp + 1); NULL;})
++  ({__thread_self = ((tcbhead_t *)tcbp + 1); true;})
+ 
+ /* Value passed to 'clone' for initialization of the thread register.  */
+ # define TLS_DEFINE_INIT_TP(tp, pd) \
+diff --git a/sysdeps/powerpc/nptl/tls.h b/sysdeps/powerpc/nptl/tls.h
+index e62a96238aa..68a1d8b546b 100644
+--- a/sysdeps/powerpc/nptl/tls.h
++++ b/sysdeps/powerpc/nptl/tls.h
+@@ -139,7 +139,7 @@ typedef struct
+     __thread_register = (void *) (tcbp) + TLS_TCB_OFFSET;		      \
+     THREAD_SET_HWCAP (__tcb.hwcap);					      \
+     THREAD_SET_AT_PLATFORM (__tcb.at_platform);				      \
+-    NULL;								      \
++    true;								      \
+   })
+ 
+ /* Value passed to 'clone' for initialization of the thread register.  */
+diff --git a/sysdeps/riscv/nptl/tls.h b/sysdeps/riscv/nptl/tls.h
+index 700c2f51899..b221980399b 100644
+--- a/sysdeps/riscv/nptl/tls.h
++++ b/sysdeps/riscv/nptl/tls.h
+@@ -79,7 +79,7 @@ typedef struct
+ 
+ /* Code to initially initialize the thread pointer.  */
+ # define TLS_INIT_TP(tcbp) \
+-  ({ __thread_self = (char*)tcbp + TLS_TCB_OFFSET; NULL; })
++  ({ __thread_self = (char*)tcbp + TLS_TCB_OFFSET; true; })
+ 
+ /* Return the address of the dtv for the current thread.  */
+ # define THREAD_DTV() \
+diff --git a/sysdeps/s390/nptl/tls.h b/sysdeps/s390/nptl/tls.h
+index 98d7870148c..937c49dda68 100644
+--- a/sysdeps/s390/nptl/tls.h
++++ b/sysdeps/s390/nptl/tls.h
+@@ -112,7 +112,7 @@ typedef struct
+      INIT_SYSINFO;							      \
+ 									      \
+     __builtin_set_thread_pointer (_thrdescr);				      \
+-    NULL;								      \
++    true;								      \
+   })
+ 
+ /* Value passed to 'clone' for initialization of the thread register.  */
+diff --git a/sysdeps/sh/nptl/tls.h b/sysdeps/sh/nptl/tls.h
+index 1530489a6ce..3882114f5c8 100644
+--- a/sysdeps/sh/nptl/tls.h
++++ b/sysdeps/sh/nptl/tls.h
+@@ -83,7 +83,7 @@ typedef struct
+    special attention since 'errno' is not yet available and if the
+    operation can cause a failure 'errno' must not be touched.  */
+ # define TLS_INIT_TP(tcbp) \
+-  ({ __asm __volatile ("ldc %0,gbr" : : "r" (tcbp)); NULL; })
++  ({ __asm __volatile ("ldc %0,gbr" : : "r" (tcbp)); true; })
+ 
+ # define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd) + 1
+ 
+diff --git a/sysdeps/sparc/nptl/tls.h b/sysdeps/sparc/nptl/tls.h
+index 95a69cb8249..e8fbe40e7bb 100644
+--- a/sysdeps/sparc/nptl/tls.h
++++ b/sysdeps/sparc/nptl/tls.h
+@@ -89,7 +89,7 @@ register struct pthread *__thread_self __asm__("%g7");
+ 
+ /* Code to initially initialize the thread pointer.  */
+ # define TLS_INIT_TP(descr) \
+-  (__thread_self = (__typeof (__thread_self)) (descr), NULL)
++  (__thread_self = (__typeof (__thread_self)) (descr), true)
+ 
+ /* Value passed to 'clone' for initialization of the thread register.  */
+ # define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd)
+diff --git a/sysdeps/unix/sysv/linux/arm/tls.h b/sysdeps/unix/sysv/linux/arm/tls.h
+index 9d1601af44c..045fad22751 100644
+--- a/sysdeps/unix/sysv/linux/arm/tls.h
++++ b/sysdeps/unix/sysv/linux/arm/tls.h
+@@ -33,8 +33,7 @@
+ # define TLS_INIT_TP(tcbp) \
+   ({ long int result_var;						\
+      result_var = INTERNAL_SYSCALL_CALL (set_tls, (tcbp));		\
+-     INTERNAL_SYSCALL_ERROR_P (result_var)				\
+-       ? "unknown error" : NULL; })
++     !INTERNAL_SYSCALL_ERROR_P (result_var); })
+ 
+ #endif /* __ASSEMBLER__ */
+ 
+diff --git a/sysdeps/x86_64/nptl/tls.h b/sysdeps/x86_64/nptl/tls.h
+index 75f80209758..63744f63845 100644
+--- a/sysdeps/x86_64/nptl/tls.h
++++ b/sysdeps/x86_64/nptl/tls.h
+@@ -156,7 +156,7 @@ _Static_assert (offsetof (tcbhead_t, __glibc_unused2) == 0x80,
+ 		     "S" (_thrdescr)					      \
+ 		   : "memory", "cc", "r11", "cx");			      \
+ 									      \
+-    _result ? "cannot set %fs base address for thread-local storage" : 0;     \
++    _result == 0;							      \
+   })
+ 
+ # define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd)

+ 0 - 184
recipes-core/glibc/glibc/CVE-2021-43396.patch

@@ -1,184 +0,0 @@
-From ff012870b2c02a62598c04daa1e54632e020fd7d Mon Sep 17 00:00:00 2001
-From: Nikita Popov <npv1310@gmail.com>
-Date: Tue, 2 Nov 2021 13:21:42 +0500
-Subject: [PATCH] gconv: Do not emit spurious NUL character in ISO-2022-JP-3
- (bug 28524)
-
-Bugfix 27256 has introduced another issue:
-In conversion from ISO-2022-JP-3 encoding, it is possible
-to force iconv to emit extra NUL character on internal state reset.
-To do this, it is sufficient to feed iconv with escape sequence
-which switches active character set.
-The simplified check 'data->__statep->__count != ASCII_set'
-introduced by the aforementioned bugfix picks that case and
-behaves as if '\0' character has been queued thus emitting it.
-
-To eliminate this issue, these steps are taken:
-* Restore original condition
-'(data->__statep->__count & ~7) != ASCII_set'.
-It is necessary since bits 0-2 may contain
-number of buffered input characters.
-* Check that queued character is not NUL.
-Similar step is taken for main conversion loop.
-
-Bundled test case follows following logic:
-* Try to convert ISO-2022-JP-3 escape sequence
-switching active character set
-* Reset internal state by providing NULL as input buffer
-* Ensure that nothing has been converted.
-
-Signed-off-by: Nikita Popov <npv1310@gmail.com>
-
-CVE: CVE-2021-43396
-Upstream-Status: Backport [ff012870b2c02a62598c04daa1e54632e020fd7d]
----
- iconvdata/Makefile        |  5 +++-
- iconvdata/bug-iconv15.c   | 60 +++++++++++++++++++++++++++++++++++++++
- iconvdata/iso-2022-jp-3.c | 28 ++++++++++++------
- 3 files changed, 84 insertions(+), 9 deletions(-)
- create mode 100644 iconvdata/bug-iconv15.c
-
-Index: git/iconvdata/Makefile
-===================================================================
---- git.orig/iconvdata/Makefile
-+++ git/iconvdata/Makefile
-@@ -1,4 +1,5 @@
- # Copyright (C) 1997-2021 Free Software Foundation, Inc.
-+# Copyright (C) The GNU Toolchain Authors.
- # This file is part of the GNU C Library.
- 
- # The GNU C Library is free software; you can redistribute it and/or
-@@ -74,7 +75,7 @@ ifeq (yes,$(build-shared))
- tests = bug-iconv1 bug-iconv2 tst-loading tst-e2big tst-iconv4 bug-iconv4 \
- 	tst-iconv6 bug-iconv5 bug-iconv6 tst-iconv7 bug-iconv8 bug-iconv9 \
- 	bug-iconv10 bug-iconv11 bug-iconv12 tst-iconv-big5-hkscs-to-2ucs4 \
--	bug-iconv13 bug-iconv14
-+	bug-iconv13 bug-iconv14 bug-iconv15
- ifeq ($(have-thread-library),yes)
- tests += bug-iconv3
- endif
-@@ -327,6 +328,8 @@ $(objpfx)bug-iconv12.out: $(addprefix $(
- 			  $(addprefix $(objpfx),$(modules.so))
- $(objpfx)bug-iconv14.out: $(addprefix $(objpfx), $(gconv-modules)) \
- 			  $(addprefix $(objpfx),$(modules.so))
-+$(objpfx)bug-iconv15.out: $(addprefix $(objpfx), $(gconv-modules)) \
-+			  $(addprefix $(objpfx),$(modules.so))
- 
- $(objpfx)iconv-test.out: run-iconv-test.sh \
- 			 $(addprefix $(objpfx), $(gconv-modules)) \
-Index: git/iconvdata/bug-iconv15.c
-===================================================================
---- /dev/null
-+++ git/iconvdata/bug-iconv15.c
-@@ -0,0 +1,60 @@
-+/* Bug 28524: Conversion from ISO-2022-JP-3 with iconv
-+   may emit spurious NUL character on state reset.
-+   Copyright (C) The GNU Toolchain Authors.
-+   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, see
-+   <https://www.gnu.org/licenses/>.  */
-+
-+#include <stddef.h>
-+#include <iconv.h>
-+#include <support/check.h>
-+
-+static int
-+do_test (void)
-+{
-+  char in[] = "\x1b(I";
-+  char *inbuf = in;
-+  size_t inleft = sizeof (in) - 1;
-+  char out[1];
-+  char *outbuf = out;
-+  size_t outleft = sizeof (out);
-+  iconv_t cd;
-+
-+  cd = iconv_open ("UTF8", "ISO-2022-JP-3");
-+  TEST_VERIFY_EXIT (cd != (iconv_t) -1);
-+
-+  /* First call to iconv should alter internal state.
-+     Now, JISX0201_Kana_set is selected and
-+     state value != ASCII_set.  */
-+  TEST_VERIFY (iconv (cd, &inbuf, &inleft, &outbuf, &outleft) != (size_t) -1);
-+
-+  /* No bytes should have been added to
-+     the output buffer at this point.  */
-+  TEST_VERIFY (outbuf == out);
-+  TEST_VERIFY (outleft == sizeof (out));
-+
-+  /* Second call shall emit spurious NUL character in unpatched glibc.  */
-+  TEST_VERIFY (iconv (cd, NULL, NULL, &outbuf, &outleft) != (size_t) -1);
-+
-+  /* No characters are expected to be produced.  */
-+  TEST_VERIFY (outbuf == out);
-+  TEST_VERIFY (outleft == sizeof (out));
-+
-+  TEST_VERIFY_EXIT (iconv_close (cd) != -1);
-+
-+  return 0;
-+}
-+
-+#include <support/test-driver.c>
-Index: git/iconvdata/iso-2022-jp-3.c
-===================================================================
---- git.orig/iconvdata/iso-2022-jp-3.c
-+++ git/iconvdata/iso-2022-jp-3.c
-@@ -1,5 +1,6 @@
- /* Conversion module for ISO-2022-JP-3.
-    Copyright (C) 1998-2021 Free Software Foundation, Inc.
-+   Copyright (C) The GNU Toolchain Authors.
-    This file is part of the GNU C Library.
-    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998,
-    and Bruno Haible <bruno@clisp.org>, 2002.
-@@ -81,20 +82,31 @@ enum
-    the output state to the initial state.  This has to be done during the
-    flushing.  */
- #define EMIT_SHIFT_TO_INIT \
--  if (data->__statep->__count != ASCII_set)			      \
-+  if ((data->__statep->__count & ~7) != ASCII_set)			      \
-     {									      \
-       if (FROM_DIRECTION)						      \
- 	{								      \
--	  if (__glibc_likely (outbuf + 4 <= outend))			      \
-+	  uint32_t ch = data->__statep->__count >> 6;			      \
-+									      \
-+	  if (__glibc_unlikely (ch != 0))				      \
- 	    {								      \
--	      /* Write out the last character.  */			      \
--	      *((uint32_t *) outbuf) = data->__statep->__count >> 6;	      \
--	      outbuf += sizeof (uint32_t);				      \
--	      data->__statep->__count = ASCII_set;			\
-+	      if (__glibc_likely (outbuf + 4 <= outend))		      \
-+		{							      \
-+		  /* Write out the last character.  */			      \
-+		  put32u (outbuf, ch);					      \
-+		  outbuf += 4;						      \
-+		  data->__statep->__count &= 7;				      \
-+		  data->__statep->__count |= ASCII_set;			      \
-+		}							      \
-+	      else							      \
-+		/* We don't have enough room in the output buffer.  */	      \
-+		status = __GCONV_FULL_OUTPUT;				      \
- 	    }								      \
- 	  else								      \
--	    /* We don't have enough room in the output buffer.  */	      \
--	    status = __GCONV_FULL_OUTPUT;				      \
-+	    {								      \
-+	      data->__statep->__count &= 7;				      \
-+	      data->__statep->__count |= ASCII_set;			      \
-+	    }								      \
- 	}								      \
-       else								      \
- 	{								      \

+ 37 - 0
recipes-core/glibc/glibc/run-ptest

@@ -0,0 +1,37 @@
+#!/bin/sh
+# ptest script for glibc - to run time related tests to
+# facilitate Y2038 validation
+# Run with 'ptest-runner glibc-tests'
+
+output() {
+  retcode=$?
+  if [ $retcode -eq 0 ]
+    then echo "PASS: $i"
+  elif [ $retcode -eq 77 ]
+    then echo "SKIP: $i"
+  else echo "FAIL: $i"
+  fi
+}
+
+# Allow altering time on the target
+export GLIBC_TEST_ALLOW_TIME_SETTING="1"
+
+tst_time64=$(ls -r ${PWD}/tests/glibc-ptest/*-time64)
+
+# Remove '-time64' suffix - those tests are also time
+# related
+tst_time_tmp=$(sed -e "s/-time64$//" <<< ${tst_time64})
+
+# Run tests supporting only 32 bit time
+for i in ${tst_time_tmp}
+do
+	$i >/dev/null 2>&1
+	output
+done
+
+# Run tests supporting only 64 bit time
+for i in ${tst_time64}
+do
+	$i >/dev/null 2>&1
+	output
+done

+ 44 - 39
recipes-core/glibc/glibc_2.35.bb → recipes-core/glibc/glibc_2.36.bb

@@ -16,7 +16,10 @@ CVE_CHECK_IGNORE += "CVE-2019-1010022 CVE-2019-1010023 CVE-2019-1010024"
 # Potential patch at https://sourceware.org/bugzilla/show_bug.cgi?id=22853
 CVE_CHECK_IGNORE += "CVE-2019-1010025"
 
-DEPENDS += "gperf-native bison-native make-native"
+# This has been integrated into the 2.36 branch as of c399271 so is now fixed
+CVE_CHECK_IGNORE += "CVE-2022-39046"
+
+DEPENDS += "gperf-native bison-native"
 
 NATIVESDKFIXES ?= ""
 NATIVESDKFIXES:class-nativesdk = "\
@@ -26,50 +29,52 @@ NATIVESDKFIXES:class-nativesdk = "\
            file://0006-nativesdk-glibc-Allow-64-bit-atomics-for-x86.patch \
            file://0007-nativesdk-glibc-Make-relocatable-install-for-locales.patch \
            file://0008-nativesdk-glibc-Fall-back-to-faccessat-on-faccess2-r.patch \
+	   file://1f34a2328890aa192141f96449d25b77f666bf47.patch \
 "
 
 SRC_URI =  "${GLIBC_GIT_URI};branch=${SRCBRANCH};name=glibc \
            file://etc/ld.so.conf \
            file://generate-supported.mk \
            file://makedbs.sh \
-           \
            ${NATIVESDKFIXES} \
-           file://0009-fsl-e500-e5500-e6500-603e-fsqrt-implementation.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-yes-within-the-path-sets-wrong-config-variables.patch \
-           file://0017-timezone-re-written-tzselect-as-posix-sh.patch \
-           file://0018-Remove-bash-dependency-for-nscd-init-script.patch \
-           file://0019-eglibc-Cross-building-and-testing-instructions.patch \
-           file://0020-eglibc-Help-bootstrap-cross-toolchain.patch \
-           file://0021-eglibc-Resolve-__fpscr_values-on-SH4.patch \
-           file://0022-eglibc-Forward-port-cross-locale-generation-support.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-locale-prevent-maybe-uninitialized-errors-with-Os-BZ.patch \
-           file://0028-readlib-Add-OECORE_KNOWN_INTERPRETER_NAMES-to-known-.patch \
-           file://0029-wordsize.h-Unify-the-header-between-arm-and-aarch64.patch \
-           file://0030-powerpc-Do-not-ask-compiler-for-finding-arch.patch \
-           file://0001-fix-create-thread-failed-in-unprivileged-process-BZ-.patch \
-           file://0001-RISC-V-Remove-riscv-specific-sigcontext.h.patch \
-           file://0002-RISC-V-Reserve-about-5K-space-in-mcontext_t-to-suppo.patch \
-           file://0003-RISC-V-Save-and-restore-VCSR-when-doing-user-context.patch \
-           file://0004-RISC-V-Extend-MINSIGSTKSZ-and-SIGSTKSZ-to-backup-RVV.patch \
-           file://0005-RISC-V-Expand-PTHREAD_STACK_MIN-to-support-RVV-envir.patch \
-           file://0006-add-vector-support-for-memset-memcmp-memmove-memcpy-.patch \
-           file://0007-add-NT_RISCV_VECTOR-macro-definition-to-align-with-l.patch \
-           file://0008-fix-the-bcmp-unrecognized-issue.patch \
-           file://0009-Revert-RISC-V-Reserve-about-5K-space-in-mcontext_t-t.patch  \
-           file://0010-Revert-RISC-V-Save-and-restore-VCSR-when-doing-user-.patch  \
-           file://0011-riscv-Resolve-symbols-directly-for-symbols-with-STO_.patch  \
-           file://0012-add-hwcap.h-header-file.patch  \
-           file://0013-change-memcpy_vector-LMUL-to-m8.patch \
-           "
+           file://0009-yes-within-the-path-sets-wrong-config-variables.patch \
+           file://0010-eglibc-Cross-building-and-testing-instructions.patch \
+           file://0011-eglibc-Help-bootstrap-cross-toolchain.patch \
+           file://0012-eglibc-Resolve-__fpscr_values-on-SH4.patch \
+           file://0013-eglibc-Forward-port-cross-locale-generation-support.patch \
+           file://0014-localedef-add-to-archive-uses-a-hard-coded-locale-pa.patch \
+           file://0015-locale-prevent-maybe-uninitialized-errors-with-Os-BZ.patch \
+           file://0016-readlib-Add-OECORE_KNOWN_INTERPRETER_NAMES-to-known-.patch \
+           file://0017-powerpc-Do-not-ask-compiler-for-finding-arch.patch \
+           file://0018-wordsize.h-Unify-the-header-between-arm-and-aarch64.patch \
+           file://0019-Replace-echo-with-printf-builtin-in-nscd-init-script.patch \
+           file://0020-sysdeps-gnu-configure.ac-Set-libc_cv_rootsbindir-onl.patch \
+           file://0021-timezone-Make-shell-interpreter-overridable-in-tzsel.patch \
+           file://0022-tzselect.ksh-Use-bin-sh-default-shell-interpreter.patch \
+           file://0023-fix-create-thread-failed-in-unprivileged-process-BZ-.patch \
+           file://0024-Avoid-hardcoded-build-time-paths-in-the-output-binar.patch \
+           file://0025-startup-Force-O2.patch \
+           file://0001-Linux-Add-ppoll-fortify-symbol-for-64-bit-time_t-BZ-.patch \
+	   file://0001-modify-and-merge-sifive-patches-to-support-V.patch \
+           file://0002-add-vector-support-for-memset-memcmp-memmove-memcpy-.patch \
+           file://0003-add-NT_RISCV_VECTOR-macro-definition-to-align-with-l.patch \
+           file://0004-fix-the-bcmp-unrecognized-issue.patch \
+           file://0005-riscv-Resolve-symbols-directly-for-symbols-with-STO_.patch \
+           file://0006-change-memcpy_vector-LMUL-to-m8.patch \
+           file://0007-add-header-files-for-vector-support.patch \
+           file://0008-prohibit-from-generating-plt-table-when-static-linki.patch \
+           file://0009-resolve-__memcmpeq-aliased-to-undefined-symbol-memcm.patch \
+           file://0010-merge-demin-s-mem_xxx-optimization.patch \
+           file://0011-add-alias-to-bcmp.patch \
+           file://0012-remove-unnecessary-changes-to-support-v.patch \
+           file://0013-fix-compiling-error-when-march-not-include-b-ext.patch \
+           file://0014-fix-memcmp-bug-relate-to-use-jmp-table.patch \
+           file://0015-memxxx-align-version-with-merge-tech-or-B-ext.patch \
+           file://0016-strxxx-B-ext-opt-version.patch \
+           file://0017-fix-strchr-missing-index-weak-alias.patch \
+           file://0018-fix-memmove-align-fail-because-of-typo.patch \
+           file://0019-fix-missing-alias-functions.patch \
+	   "
 S = "${WORKDIR}/git"
 B = "${WORKDIR}/build-${TARGET_SYS}"
 
@@ -100,7 +105,7 @@ EXTRA_OECONF = "--enable-kernel=${OLDEST_KERNEL} \
 
 EXTRA_OECONF += "${@get_libc_fpu_setting(bb, d)}"
 
-EXTRA_OECONF:append:x86 = " --enable-cet"
+EXTRA_OECONF:append:x86 = " ${@bb.utils.contains_any('TUNE_FEATURES', 'i586 c3', '--disable-cet', '--enable-cet', d)}"
 EXTRA_OECONF:append:x86-64 = " --enable-cet"
 
 PACKAGECONFIG ??= "nscd memory-tagging"

+ 1 - 1
recipes-core/glibc/ldconfig-native_2.12.1.bb

@@ -1,6 +1,6 @@
 SUMMARY = "A standalone native ldconfig build"
 
-LICENSE = "GPLv2+"
+LICENSE = "GPL-2.0-or-later"
 
 LIC_FILES_CHKSUM = "file://${S}/ldconfig.c;endline=17;md5=1d15f20937c055cb5de2329a4c054399"
 

+ 0 - 42
recipes-devtools/binutils/binutils-2.37.inc

@@ -1,42 +0,0 @@
-LIC_FILES_CHKSUM="\
-    file://COPYING;md5=59530bdf33659b29e73d4adb9f9f6552\
-    file://COPYING.LIB;md5=9f604d8a4f8e74f4f5140845a21b6674\
-    file://COPYING3;md5=d32239bcb673463ab874e80d47fae504\
-    file://COPYING3.LIB;md5=6a6a8e020838b23406c81b19c1d46df6\
-    file://gas/COPYING;md5=d32239bcb673463ab874e80d47fae504\
-    file://include/COPYING;md5=59530bdf33659b29e73d4adb9f9f6552\
-    file://include/COPYING3;md5=d32239bcb673463ab874e80d47fae504\
-    file://libiberty/COPYING.LIB;md5=a916467b91076e631dd8edb7424769c7\
-    file://bfd/COPYING;md5=d32239bcb673463ab874e80d47fae504\
-    "
-
-# When upgrading to 2.37, please make sure there is no trailing .0, so
-# that upstream version check can work correctly.
-PV = "2.37"
-CVE_VERSION = "2.37"
-SRCBRANCH ?= "binutils-2_37-branch"
-
-UPSTREAM_CHECK_GITTAGREGEX = "binutils-(?P<pver>\d+_(\d_?)*)"
-
-SRCREV ?= "87d4632d36323091e731eb07b8aa65f90293da66"
-BINUTILS_GIT_URI ?= "git://sourceware.org/git/binutils-gdb.git;branch=${SRCBRANCH};protocol=git"
-SRC_URI = "\
-     ${BINUTILS_GIT_URI} \
-     file://0004-configure-widen-the-regexp-for-SH-architectures.patch \
-     file://0005-Point-scripts-location-to-libdir.patch \
-     file://0006-Only-generate-an-RPATH-entry-if-LD_RUN_PATH-is-not-e.patch \
-     file://0007-don-t-let-the-distro-compiler-point-to-the-wrong-ins.patch \
-     file://0008-warn-for-uses-of-system-directories-when-cross-linki.patch \
-     file://0009-Change-default-emulation-for-mips64-linux.patch \
-     file://0010-Add-support-for-Netlogic-XLP.patch \
-     file://0011-fix-the-incorrect-assembling-for-ppc-wait-mnemonic.patch \
-     file://0012-Detect-64-bit-MIPS-targets.patch \
-     file://0013-Use-libtool-2.4.patch \
-     file://0014-Fix-rpath-in-libtool-when-sysroot-is-enabled.patch \
-     file://0015-sync-with-OE-libtool-changes.patch \
-     file://0016-Check-for-clang-before-checking-gcc-version.patch \
-     file://0017-bfd-Close-the-file-descriptor-if-there-is-no-archive.patch \
-     file://0001-CVE-2021-42574.patch \
-     file://161e87d12167b1e36193385485c1f6ce92f74f02.patch \
-"
-S  = "${WORKDIR}/git"

+ 63 - 0
recipes-devtools/binutils/binutils-2.39.inc

@@ -0,0 +1,63 @@
+LIC_FILES_CHKSUM="\
+    file://COPYING;md5=59530bdf33659b29e73d4adb9f9f6552\
+    file://COPYING.LIB;md5=9f604d8a4f8e74f4f5140845a21b6674\
+    file://COPYING3;md5=d32239bcb673463ab874e80d47fae504\
+    file://COPYING3.LIB;md5=6a6a8e020838b23406c81b19c1d46df6\
+    file://gas/COPYING;md5=d32239bcb673463ab874e80d47fae504\
+    file://include/COPYING;md5=59530bdf33659b29e73d4adb9f9f6552\
+    file://include/COPYING3;md5=d32239bcb673463ab874e80d47fae504\
+    file://libiberty/COPYING.LIB;md5=a916467b91076e631dd8edb7424769c7\
+    file://bfd/COPYING;md5=d32239bcb673463ab874e80d47fae504\
+    "
+
+# When upgrading to 2.39, please make sure there is no trailing .0, so
+# that upstream version check can work correctly.
+PV = "2.39"
+CVE_VERSION = "2.39"
+SRCBRANCH ?= "binutils-2_39-branch"
+
+UPSTREAM_CHECK_GITTAGREGEX = "binutils-(?P<pver>\d+_(\d_?)*)"
+
+SRCREV ?= "f89058434f13382c85b8729464192bc7763d88a4"
+BINUTILS_GIT_URI ?= "git://sourceware.org/git/binutils-gdb.git;branch=${SRCBRANCH};protocol=git"
+SRC_URI = "\
+     ${BINUTILS_GIT_URI} \
+     file://0004-Point-scripts-location-to-libdir.patch \
+     file://0005-don-t-let-the-distro-compiler-point-to-the-wrong-ins.patch \
+     file://0006-warn-for-uses-of-system-directories-when-cross-linki.patch \
+     file://0007-fix-the-incorrect-assembling-for-ppc-wait-mnemonic.patch \
+     file://0008-Use-libtool-2.4.patch \
+     file://0009-Fix-rpath-in-libtool-when-sysroot-is-enabled.patch \
+     file://0010-sync-with-OE-libtool-changes.patch \
+     file://0011-Check-for-clang-before-checking-gcc-version.patch \
+     file://0012-Only-generate-an-RPATH-entry-if-LD_RUN_PATH-is-not-e.patch \
+     file://0013-CVE-2022-38533.patch \
+     file://0014-CVE-2022-38128-1.patch \
+     file://0014-CVE-2022-38128-2.patch \
+     file://0014-CVE-2022-38128-3.patch \
+     file://0001-Automatic-date-update-in-version.in.patch \
+     file://0002-Automatic-date-update-in-version.in.patch \
+     file://0003-Automatic-date-update-in-version.in.patch \
+     file://0004-Automatic-date-update-in-version.in.patch \
+     file://0005-Automatic-date-update-in-version.in.patch \
+     file://0006-Automatic-date-update-in-version.in.patch \
+     file://0007-Automatic-date-update-in-version.in.patch \
+     file://0008-Automatic-date-update-in-version.in.patch \
+     file://0009-Automatic-date-update-in-version.in.patch \
+     file://0010-Automatic-date-update-in-version.in.patch \
+     file://0011-Automatic-date-update-in-version.in.patch \
+     file://0012-Automatic-date-update-in-version.in.patch \
+     file://0013-Automatic-date-update-in-version.in.patch \
+     file://0014-Automatic-date-update-in-version.in.patch \
+     file://0015-Automatic-date-update-in-version.in.patch \
+     file://0016-Automatic-date-update-in-version.in.patch \
+     file://0017-Automatic-date-update-in-version.in.patch \
+     file://0018-add-customer-pref-support.patch \
+     file://0019-add-four-instruction-for-custom-CSRs.patch \
+     file://0020-fix-a-merge-typo.patch \
+"
+S  = "${WORKDIR}/git"
+# Already in 2.39 branch
+# - https://sourceware.org/bugzilla/show_bug.cgi?id=29289
+# - https://sourceware.org/bugzilla/show_bug.cgi?id=29290
+CVE_CHECK_IGNORE += "CVE-2022-38126 CVE-2022-38127"

+ 3 - 3
recipes-devtools/binutils/binutils-cross-canadian.inc

@@ -13,8 +13,6 @@ EXTRA_OECONF += "--with-sysroot=${SDKPATH}/sysroots/${TUNE_PKGARCH}${TARGET_VEND
 # e.g. we switch between different machines with different tunes.
 EXTRA_OECONF[vardepsexclude] = "TUNE_PKGARCH"
 
-LDGOLD:sdkmingw32 = ""
-
 do_install () {
 	autotools_do_install
 
@@ -25,7 +23,9 @@ do_install () {
 	rm -f ${D}${libdir}/libiberty*
 	rm -f ${D}${libdir}/libopcodes*
 	rm -f ${D}${includedir}/*.h
-	
+	rm -f ${D}${sysconfdir}/gprofng.rc
+	rmdir ${D}${sysconfdir} || :
+
 	cross_canadian_bindirlinks
 }
 

+ 0 - 27
recipes-devtools/binutils/binutils-cross-canadian_2.37.bb

@@ -1,27 +0,0 @@
-require binutils.inc
-require binutils-${PV}.inc
-require binutils-cross-canadian.inc
-
-FILESEXTRAPATHS:prepend := "${THISDIR}/binutils:"
-
-SRCREV = "116a737f438d03a1bd6aa706b6ea0b4022f3b7e2"
-
-BINUTILS_GIT_URI = "git://sourceware.org/git/binutils-gdb.git;branch=${SRCBRANCH};protocol=git"
-
-SRC_URI += "\
-     file://0001-merge-from-dubhe-pr-06-30-to-support-b0.94.patch \
-     file://0002-merge-from-dubhe-pr-06-30-to-support-vector1.0.patch \
-     file://0003-fix-unrecoginized-b-ext-issue.patch \
-     file://0004-set-v-ext-version-to-1.0-draft.patch \
-     file://0005-fix-incorrect-RCLASS_MAX.patch \
-     file://0006-Merge-B-instruction-from-0p94-to-1.0.patch \
-     file://0007-merge-Add-four-new-instruction-of-custom-CSRs.patch \
-     file://0008-add-cache-prefetch-instruction.patch \
-     file://0009-Delete-redundant-b0.94-instructions.patch \
-     file://0010-change-vle1.v-vse1.v-to-vlm.v-vsm.v-according-rvv-1..patch \
-     file://0011-enable-l2-cache-prefetch.patch \
-     file://0012-RISC-V-Hypervisor-ext-drop-Privileged-Spec-1.9.1.patch \
-     file://0013-RISC-V-Hypervisor-ext-support-Privileged-Spec-1.12.patch \
-     file://0014-fixed-a-compiled-error-when-enable-gdb.patch \
-     file://0015-fix-incorrect-pref-address-range.patch \
-"

+ 3 - 0
recipes-devtools/binutils/binutils-cross-canadian_2.39.bb

@@ -0,0 +1,3 @@
+require binutils.inc
+require binutils-${PV}.inc
+require binutils-cross-canadian.inc

+ 0 - 24
recipes-devtools/binutils/binutils-cross-testsuite_2.37.bb → recipes-devtools/binutils/binutils-cross-testsuite_2.39.bb

@@ -79,27 +79,3 @@ do_check() {
     done
 }
 addtask check after do_configure
-
-FILESEXTRAPATHS:prepend := "${THISDIR}/binutils:"
-
-SRCREV = "116a737f438d03a1bd6aa706b6ea0b4022f3b7e2"
-
-BINUTILS_GIT_URI = "git://sourceware.org/git/binutils-gdb.git;branch=${SRCBRANCH};protocol=git"
-
-SRC_URI += "\
-     file://0001-merge-from-dubhe-pr-06-30-to-support-b0.94.patch \
-     file://0002-merge-from-dubhe-pr-06-30-to-support-vector1.0.patch \
-     file://0003-fix-unrecoginized-b-ext-issue.patch \
-     file://0004-set-v-ext-version-to-1.0-draft.patch \
-     file://0005-fix-incorrect-RCLASS_MAX.patch \
-     file://0006-Merge-B-instruction-from-0p94-to-1.0.patch \
-     file://0007-merge-Add-four-new-instruction-of-custom-CSRs.patch \
-     file://0008-add-cache-prefetch-instruction.patch \
-     file://0009-Delete-redundant-b0.94-instructions.patch \
-     file://0010-change-vle1.v-vse1.v-to-vlm.v-vsm.v-according-rvv-1..patch \
-     file://0011-enable-l2-cache-prefetch.patch \
-     file://0012-RISC-V-Hypervisor-ext-drop-Privileged-Spec-1.9.1.patch \
-     file://0013-RISC-V-Hypervisor-ext-support-Privileged-Spec-1.12.patch \
-     file://0014-fixed-a-compiled-error-when-enable-gdb.patch \
-     file://0015-fix-incorrect-pref-address-range.patch \
-"

+ 1 - 0
recipes-devtools/binutils/binutils-cross.inc

@@ -16,6 +16,7 @@ SRC_URI += "file://0002-binutils-cross-Do-not-generate-linker-script-directo.pat
 # and mean the linker scripts have to be relocated.
 EXTRA_OECONF += "--with-sysroot=${STAGING_DIR_TARGET} \
                 --disable-install-libbfd \
+                --disable-gprofng \
                 --enable-poison-system-directories \
                 --with-lib-path==${target_base_libdir}:=${target_libdir} \
                 "

+ 0 - 27
recipes-devtools/binutils/binutils-cross_2.37.bb

@@ -1,27 +0,0 @@
-require binutils.inc
-require binutils-${PV}.inc
-require binutils-cross.inc
-                                   
-FILESEXTRAPATHS:prepend := "${THISDIR}/binutils:"
-
-SRCREV = "116a737f438d03a1bd6aa706b6ea0b4022f3b7e2"
-
-BINUTILS_GIT_URI = "git://sourceware.org/git/binutils-gdb.git;branch=${SRCBRANCH};protocol=git"
-
-SRC_URI += "\
-     file://0001-merge-from-dubhe-pr-06-30-to-support-b0.94.patch \
-     file://0002-merge-from-dubhe-pr-06-30-to-support-vector1.0.patch \
-     file://0003-fix-unrecoginized-b-ext-issue.patch \
-     file://0004-set-v-ext-version-to-1.0-draft.patch \
-     file://0005-fix-incorrect-RCLASS_MAX.patch \
-     file://0006-Merge-B-instruction-from-0p94-to-1.0.patch \
-     file://0007-merge-Add-four-new-instruction-of-custom-CSRs.patch \
-     file://0008-add-cache-prefetch-instruction.patch \
-     file://0009-Delete-redundant-b0.94-instructions.patch \
-     file://0010-change-vle1.v-vse1.v-to-vlm.v-vsm.v-according-rvv-1..patch \
-     file://0011-enable-l2-cache-prefetch.patch \
-     file://0012-RISC-V-Hypervisor-ext-drop-Privileged-Spec-1.9.1.patch \
-     file://0013-RISC-V-Hypervisor-ext-support-Privileged-Spec-1.12.patch \
-     file://0014-fixed-a-compiled-error-when-enable-gdb.patch \
-     file://0015-fix-incorrect-pref-address-range.patch \
-"

+ 3 - 0
recipes-devtools/binutils/binutils-cross_2.39.bb

@@ -0,0 +1,3 @@
+require binutils.inc
+require binutils-${PV}.inc
+require binutils-cross.inc

+ 0 - 7
recipes-devtools/binutils/binutils-crosssdk_2.37.bb → recipes-devtools/binutils/binutils-crosssdk_2.39.bb

@@ -11,10 +11,3 @@ SRC_URI += "file://0001-binutils-crosssdk-Generate-relocatable-SDKs.patch"
 do_configure:prepend () {
 	sed -i 's#/usr/local/lib /lib /usr/lib#${SDKPATHNATIVE}/lib ${SDKPATHNATIVE}/usr/lib /usr/local/lib /lib /usr/lib#' ${S}/ld/configure.tgt
 }
-
-FILESEXTRAPATHS:prepend := "${THISDIR}/binutils:"
-
-SRCREV = "116a737f438d03a1bd6aa706b6ea0b4022f3b7e2"
-
-BINUTILS_GIT_URI = "git://sourceware.org/git/binutils-gdb.git;branch=${SRCBRANCH};protocol=git"
-

+ 20 - 1
recipes-devtools/binutils/binutils.inc

@@ -9,7 +9,7 @@ object information), and other tools and related libraries."
 HOMEPAGE = "http://www.gnu.org/software/binutils/"
 BUGTRACKER = "http://sourceware.org/bugzilla/"
 SECTION = "devel"
-LICENSE = "GPLv3"
+LICENSE = "GPL-3.0-only"
 
 DEPENDS = "flex-native bison-native zlib-native gnu-config-native autoconf-native"
 
@@ -36,6 +36,24 @@ FILES:${PN}-dev = " \
 # Rather than duplicating multiple entries for these, make one
 # list and reuse it.
 
+GPROFNGS = " \
+	gp-archive \
+	gp-collect-app \
+	gp-display-html \
+	gp-display-src \
+	gp-display-text \
+	gprofng \
+"
+
+# it disables gprofng for clang and musl in the bb file
+GPROFNGS:toolchain-clang = ""
+GPROFNGS:libc-musl = ""
+
+GPROFNG_ALTS ?= ""
+GPROFNG_ALTS:x86 = "${GPROFNGS}"
+GPROFNG_ALTS:x86-64 = "${GPROFNGS}"
+GPROFNG_ALTS:aarch64 = "${GPROFNGS}"
+
 LDGOLD_ALTS ?= "ld.gold dwp"
 LDGOLD_ALTS:riscv64 = ""
 LDGOLD_ALTS:riscv32 = ""
@@ -48,6 +66,7 @@ USE_ALTERNATIVES_FOR = " \
 	c++filt \
 	elfedit \
 	gprof \
+	${GPROFNG_ALTS} \
 	ld \
 	ld.bfd \
 	${LDGOLD_ALTS} \

+ 25 - 0
recipes-devtools/binutils/binutils/0001-Automatic-date-update-in-version.in.patch

@@ -0,0 +1,25 @@
+From 08aa4430eacd272a320067a23cffd81fac492bae Mon Sep 17 00:00:00 2001
+From: GDB Administrator <gdbadmin@sourceware.org>
+Date: Sat, 20 Aug 2022 00:00:44 +0000
+Subject: [PATCH 01/20] Automatic date update in version.in
+
+---
+ bfd/version.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/bfd/version.h b/bfd/version.h
+index 44451de6b7..c5c3ce4fd5 100644
+--- a/bfd/version.h
++++ b/bfd/version.h
+@@ -16,7 +16,7 @@
+ 
+    In releases, the date is not included in either version strings or
+    sonames.  */
+-#define BFD_VERSION_DATE 20220819
++#define BFD_VERSION_DATE 20220820
+ #define BFD_VERSION @bfd_version@
+ #define BFD_VERSION_STRING  @bfd_version_package@ @bfd_version_string@
+ #define REPORT_BUGS_TO @report_bugs_to@
+-- 
+2.25.1
+

+ 0 - 2001
recipes-devtools/binutils/binutils/0001-CVE-2021-42574.patch

@@ -1,2001 +0,0 @@
-From b3aa80b45c4f46029efeb204bb9f2d2c4278a0e5 Mon Sep 17 00:00:00 2001
-From: Nick Clifton <nickc@redhat.com>
-Date: Tue, 9 Nov 2021 13:25:42 +0000
-Subject: [PATCH] Add --unicode option to control how unicode characters are
- handled by display tools.
-
-	* nm.c: Add --unicode option to control how unicode characters are
-	handled.
-	* objdump.c: Likewise.
-	* readelf.c: Likewise.
-	* strings.c: Likewise.
-	* binutils.texi: Document the new feature.
-	* NEWS: Document the new feature.
-	* testsuite/binutils-all/unicode.exp: New file.
-	* testsuite/binutils-all/nm.hex.unicode
-	* testsuite/binutils-all/strings.escape.unicode
-	* testsuite/binutils-all/objdump.highlight.unicode
-	* testsuite/binutils-all/readelf.invalid.unicode
-
-CVE: CVE-2021-42574
-Upstream-Status: Backport [https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=b3aa80b45c4f46029efeb204bb9f2d2c4278a0e5]
-
-RP: Added tweak uint -> unsigned int partial backport of
-https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=795588aec4f894206863c938bd6d716895886009
-
-Signed-off-by: pgowda <pgowda.cve@gmail.com>
----
- binutils/ChangeLog         |  15 +
- binutils/NEWS              |   9 +
- binutils/doc/binutils.texi |  78 ++++
- binutils/nm.c              | 228 ++++++++++-
- binutils/objdump.c         | 235 ++++++++++--
- binutils/readelf.c         | 190 +++++++++-
- binutils/strings.c         | 757 ++++++++++++++++++++++++++++++++++---
- 7 files changed, 1409 insertions(+), 103 deletions(-)
-
-diff --git a/binutils/ChangeLog b/binutils/ChangeLog
---- a/binutils/ChangeLog	2021-12-19 19:00:27.038540406 -0800
-+++ b/binutils/ChangeLog	2021-12-19 19:28:42.733565078 -0800
-@@ -1,3 +1,18 @@
-+2021-11-09  Nick Clifton  <nickc@redhat.com>
-+
-+	* nm.c: Add --unicode option to control how unicode characters are
-+	handled.
-+	* objdump.c: Likewise.
-+	* readelf.c: Likewise.
-+	* strings.c: Likewise.
-+	* binutils.texi: Document the new feature.
-+	* NEWS: Document the new feature.
-+	* testsuite/binutils-all/unicode.exp: New file.
-+	* testsuite/binutils-all/nm.hex.unicode
-+	* testsuite/binutils-all/strings.escape.unicode
-+	* testsuite/binutils-all/objdump.highlight.unicode
-+	* testsuite/binutils-all/readelf.invalid.unicode
-+
- 2021-07-16  Nick Clifton  <nickc@redhat.com>
- 
- 	* po/sv.po: Updated Swedish translation.
-diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi
---- a/binutils/doc/binutils.texi	2021-12-19 19:00:27.042540338 -0800
-+++ b/binutils/doc/binutils.texi	2021-12-19 19:27:56.526354667 -0800
-@@ -812,6 +812,7 @@ nm [@option{-A}|@option{-o}|@option{--pr
-    [@option{-s}|@option{--print-armap}]
-    [@option{-t} @var{radix}|@option{--radix=}@var{radix}]
-    [@option{-u}|@option{--undefined-only}]
-+   [@option{-U} @var{method}] [@option{--unicode=}@var{method}]
-    [@option{-V}|@option{--version}]
-    [@option{-X 32_64}]
-    [@option{--defined-only}]
-@@ -1132,6 +1133,21 @@ Use @var{radix} as the radix for printin
- @cindex undefined symbols
- Display only undefined symbols (those external to each object file).
- 
-+@item -U @var{[d|i|l|e|x|h]}
-+@itemx --unicode=@var{[default|invalid|locale|escape|hex|highlight]}
-+Controls the display of UTF-8 encoded mulibyte characters in strings.
-+The default (@option{--unicode=default}) is to give them no special
-+treatment.  The @option{--unicode=locale} option displays the sequence
-+in the current locale, which may or may not support them.  The options
-+@option{--unicode=hex} and @option{--unicode=invalid} display them as
-+hex byte sequences enclosed by either angle brackets or curly braces.
-+
-+The @option{--unicode=escape} option displays them as escape sequences
-+(@var{\uxxxx}) and the @option{--unicode=highlight} option displays
-+them as escape sequences highlighted in red (if supported by the
-+output device).  The colouring is intended to draw attention to the
-+presence of unicode sequences where they might not be expected.
-+
- @item -V
- @itemx --version
- Show the version number of @command{nm} and exit.
-@@ -2247,6 +2263,7 @@ objdump [@option{-a}|@option{--archive-h
-         [@option{--prefix-strip=}@var{level}]
-         [@option{--insn-width=}@var{width}]
-         [@option{--visualize-jumps[=color|=extended-color|=off]}
-+        [@option{-U} @var{method}] [@option{--unicode=}@var{method}]
-         [@option{-V}|@option{--version}]
-         [@option{-H}|@option{--help}]
-         @var{objfile}@dots{}
-@@ -2921,6 +2938,21 @@ When displaying symbols include those wh
- special in some way and which would not normally be of interest to the
- user.
- 
-+@item -U @var{[d|i|l|e|x|h]}
-+@itemx --unicode=@var{[default|invalid|locale|escape|hex|highlight]}
-+Controls the display of UTF-8 encoded mulibyte characters in strings.
-+The default (@option{--unicode=default}) is to give them no special
-+treatment.  The @option{--unicode=locale} option displays the sequence
-+in the current locale, which may or may not support them.  The options
-+@option{--unicode=hex} and @option{--unicode=invalid} display them as
-+hex byte sequences enclosed by either angle brackets or curly braces.
-+
-+The @option{--unicode=escape} option displays them as escape sequences
-+(@var{\uxxxx}) and the @option{--unicode=highlight} option displays
-+them as escape sequences highlighted in red (if supported by the
-+output device).  The colouring is intended to draw attention to the
-+presence of unicode sequences where they might not be expected.
-+
- @item -V
- @itemx --version
- Print the version number of @command{objdump} and exit.
-@@ -3197,6 +3229,7 @@ strings [@option{-afovV}] [@option{-}@va
-         [@option{-n} @var{min-len}] [@option{--bytes=}@var{min-len}]
-         [@option{-t} @var{radix}] [@option{--radix=}@var{radix}]
-         [@option{-e} @var{encoding}] [@option{--encoding=}@var{encoding}]
-+        [@option{-U} @var{method}] [@option{--unicode=}@var{method}]
-         [@option{-}] [@option{--all}] [@option{--print-file-name}]
-         [@option{-T} @var{bfdname}] [@option{--target=}@var{bfdname}]
-         [@option{-w}] [@option{--include-all-whitespace}]
-@@ -3288,6 +3321,28 @@ single-8-bit-byte characters, @samp{b} =
- littleendian.  Useful for finding wide character strings. (@samp{l}
- and @samp{b} apply to, for example, Unicode UTF-16/UCS-2 encodings).
- 
-+@item -U @var{[d|i|l|e|x|h]}
-+@itemx --unicode=@var{[default|invalid|locale|escape|hex|highlight]}
-+Controls the display of UTF-8 encoded mulibyte characters in strings.
-+The default (@option{--unicode=default}) is to give them no special
-+treatment, and instead rely upon the setting of the
-+@option{--encoding} option.  The other values for this option
-+automatically enable @option{--encoding=S}.
-+
-+The @option{--unicode=invalid} option treats them as non-graphic
-+characters and hence not part of a valid string.  All the remaining
-+options treat them as valid string characters.
-+
-+The @option{--unicode=locale} option displays them in the current
-+locale, which may or may not support UTF-8 encoding.  The
-+@option{--unicode=hex} option displays them as hex byte sequences
-+enclosed between @var{<>} characters.  The @option{--unicode=escape}
-+option displays them as escape sequences (@var{\uxxxx}) and the
-+@option{--unicode=highlight} option displays them as escape sequences
-+highlighted in red (if supported by the output device).  The colouring
-+is intended to draw attention to the presence of unicode sequences
-+where they might not be expected.
-+
- @item -T @var{bfdname}
- @itemx --target=@var{bfdname}
- @cindex object code format
-@@ -4796,6 +4851,7 @@ readelf [@option{-a}|@option{--all}]
-         [@option{--demangle@var{=style}}|@option{--no-demangle}]
-         [@option{--quiet}]
-         [@option{--recurse-limit}|@option{--no-recurse-limit}]
-+        [@option{-U} @var{method}|@option{--unicode=}@var{method}]
-         [@option{-n}|@option{--notes}]
-         [@option{-r}|@option{--relocs}]
-         [@option{-u}|@option{--unwind}]
-@@ -4962,6 +5018,28 @@ necessary in order to demangle truly com
- that if the recursion limit is disabled then stack exhaustion is
- possible and any bug reports about such an event will be rejected.
- 
-+@item -U @var{[d|i|l|e|x|h]}
-+@itemx --unicode=[default|invalid|locale|escape|hex|highlight]
-+Controls the display of non-ASCII characters in identifier names.
-+The default (@option{--unicode=locale} or @option{--unicode=default}) is
-+to treat them as multibyte characters and display them in the current
-+locale.  All other versions of this option treat the bytes as UTF-8
-+encoded values and attempt to interpret them.  If they cannot be
-+interpreted or if the @option{--unicode=invalid} option is used then
-+they are displayed as a sequence of hex bytes, encloses in curly
-+parethesis characters.
-+
-+Using the @option{--unicode=escape} option will display the characters
-+as as unicode escape sequences (@var{\uxxxx}).  Using the
-+@option{--unicode=hex} will display the characters as hex byte
-+sequences enclosed between angle brackets.
-+
-+Using the @option{--unicode=highlight} will display the characters as 
-+unicode escape sequences but it will also highlighted them in red,
-+assuming that colouring is supported by the output device.  The
-+colouring is intended to draw attention to the presence of unicode
-+sequences when they might not be expected.
-+
- @item -e
- @itemx --headers
- Display all the headers in the file.  Equivalent to @option{-h -l -S}.
-diff --git a/binutils/NEWS b/binutils/NEWS
---- a/binutils/NEWS	2021-12-19 19:00:27.038540406 -0800
-+++ b/binutils/NEWS	2021-12-19 19:30:04.764162972 -0800
-@@ -1,5 +1,14 @@
- -*- text -*-
- 
-+* Tools which display symbols or strings (readelf, strings, nm, objdump)
-+  have a new command line option which controls how unicode characters are
-+  handled.  By default they are treated as normal for the tool.  Using
-+  --unicode=locale will display them according to the current locale.
-+  Using --unicode=hex will display them as hex byte values, whilst
-+  --unicode=escape will display them as escape sequences.  In addition
-+  using --unicode=highlight will display them as unicode escape sequences
-+  highlighted in red (if supported by the output device).
-+
- Changes in 2.37:
- 
- * The readelf tool has a new command line option which can be used to specify
-diff --git a/binutils/nm.c b/binutils/nm.c
---- a/binutils/nm.c	2021-12-19 19:00:27.046540270 -0800
-+++ b/binutils/nm.c	2021-12-19 19:36:34.797491555 -0800
-@@ -38,6 +38,11 @@
- #include "bucomm.h"
- #include "plugin-api.h"
- #include "plugin.h"
-+#include "safe-ctype.h"
-+
-+#ifndef streq
-+#define streq(a,b) (strcmp ((a),(b)) == 0)
-+#endif
- 
- /* When sorting by size, we use this structure to hold the size and a
-    pointer to the minisymbol.  */
-@@ -216,6 +221,18 @@ static const char *plugin_target = NULL;
- static bfd *lineno_cache_bfd;
- static bfd *lineno_cache_rel_bfd;
- 
-+typedef enum unicode_display_type
-+{
-+  unicode_default = 0,
-+  unicode_locale,
-+  unicode_escape,
-+  unicode_hex,
-+  unicode_highlight,
-+  unicode_invalid
-+} unicode_display_type;
-+
-+static unicode_display_type unicode_display = unicode_default;
-+
- enum long_option_values
- {
-   OPTION_TARGET = 200,
-@@ -260,6 +277,7 @@ static struct option long_options[] =
-   {"target", required_argument, 0, OPTION_TARGET},
-   {"defined-only", no_argument, &defined_only, 1},
-   {"undefined-only", no_argument, &undefined_only, 1},
-+  {"unicode", required_argument, NULL, 'U'},
-   {"version", no_argument, &show_version, 1},
-   {"with-symbol-versions", no_argument, &with_symbol_versions, 1},
-   {"without-symbol-versions", no_argument, &with_symbol_versions, 0},
-@@ -313,6 +331,8 @@ usage (FILE *stream, int status)
-   -t, --radix=RADIX      Use RADIX for printing symbol values\n\
-       --target=BFDNAME   Specify the target object format as BFDNAME\n\
-   -u, --undefined-only   Display only undefined symbols\n\
-+  -U {d|s|i|x|e|h}       Specify how to treat UTF-8 encoded unicode characters\n\
-+      --unicode={default|show|invalid|hex|escape|highlight}\n\
-       --with-symbol-versions  Display version strings after symbol names\n\
-   -X 32_64               (ignored)\n\
-   @FILE                  Read options from FILE\n\
-@@ -432,6 +452,187 @@ get_coff_symbol_type (const struct inter
-   return bufp;
- }
- 
-+/* Convert a potential UTF-8 encoded sequence in IN into characters in OUT.
-+   The conversion format is controlled by the unicode_display variable.
-+   Returns the number of characters added to OUT.
-+   Returns the number of bytes consumed from IN in CONSUMED.
-+   Always consumes at least one byte and displays at least one character.  */
-+   
-+static unsigned int
-+display_utf8 (const unsigned char * in, char * out, unsigned int * consumed)
-+{
-+  char *        orig_out = out;
-+  unsigned int  nchars = 0;
-+  unsigned int j;
-+
-+  if (unicode_display == unicode_default)
-+    goto invalid;
-+
-+  if (in[0] < 0xc0)
-+    goto invalid;
-+
-+  if ((in[1] & 0xc0) != 0x80)
-+    goto invalid;
-+
-+  if ((in[0] & 0x20) == 0)
-+    {
-+      nchars = 2;
-+      goto valid;
-+    }
-+
-+  if ((in[2] & 0xc0) != 0x80)
-+    goto invalid;
-+
-+  if ((in[0] & 0x10) == 0)
-+    {
-+      nchars = 3;
-+      goto valid;
-+    }
-+
-+  if ((in[3] & 0xc0) != 0x80)
-+    goto invalid;
-+
-+  nchars = 4;
-+
-+ valid:
-+  switch (unicode_display)
-+    {
-+    case unicode_locale:
-+      /* Copy the bytes into the output buffer as is.  */
-+      memcpy (out, in, nchars);
-+      out += nchars;
-+      break;
-+
-+    case unicode_invalid:
-+    case unicode_hex:
-+      out += sprintf (out, "%c", unicode_display == unicode_hex ? '<' : '{');
-+      out += sprintf (out, "0x");
-+      for (j = 0; j < nchars; j++)
-+	out += sprintf (out, "%02x", in [j]);
-+      out += sprintf (out, "%c", unicode_display == unicode_hex ? '>' : '}');
-+      break;
-+      
-+    case unicode_highlight:
-+      if (isatty (1))
-+	out += sprintf (out, "\x1B[31;47m"); /* Red.  */
-+      /* Fall through.  */
-+    case unicode_escape:
-+      switch (nchars)
-+	{
-+	case 2:
-+	  out += sprintf (out, "\\u%02x%02x",
-+		  ((in[0] & 0x1c) >> 2), 
-+		  ((in[0] & 0x03) << 6) | (in[1] & 0x3f));
-+	  break;
-+
-+	case 3:
-+	  out += sprintf (out, "\\u%02x%02x",
-+		  ((in[0] & 0x0f) << 4) | ((in[1] & 0x3c) >> 2),
-+		  ((in[1] & 0x03) << 6) | ((in[2] & 0x3f)));
-+	  break;
-+
-+	case 4:
-+	  out += sprintf (out, "\\u%02x%02x%02x",
-+		  ((in[0] & 0x07) << 6) | ((in[1] & 0x3c) >> 2),
-+		  ((in[1] & 0x03) << 6) | ((in[2] & 0x3c) >> 2),
-+		  ((in[2] & 0x03) << 6) | ((in[3] & 0x3f)));
-+	  break;
-+	default:
-+	  /* URG.  */
-+	  break;
-+	}
-+
-+      if (unicode_display == unicode_highlight && isatty (1))
-+	out += sprintf (out, "\033[0m"); /* Default colour.  */
-+      break;
-+
-+    default:
-+      /* URG */
-+      break;
-+    }
-+
-+  * consumed = nchars;
-+  return out - orig_out;
-+
-+ invalid:
-+  /* Not a valid UTF-8 sequence.  */
-+  *out = *in;
-+  * consumed = 1;
-+  return 1;
-+}
-+
-+/* Convert any UTF-8 encoded characters in NAME into the form specified by
-+   unicode_display.  Also converts control characters.  Returns a static
-+   buffer if conversion was necessary.
-+   Code stolen from objdump.c:sanitize_string().  */
-+
-+static const char *
-+convert_utf8 (const char * in)
-+{
-+  static char *  buffer = NULL;
-+  static size_t  buffer_len = 0;
-+  const char *   original = in;
-+  char *         out;
-+
-+  /* Paranoia.  */
-+  if (in == NULL)
-+    return "";
-+
-+  /* See if any conversion is necessary.
-+     In the majority of cases it will not be needed.  */
-+  do
-+    {
-+      unsigned char c = *in++;
-+
-+      if (c == 0)
-+	return original;
-+
-+      if (ISCNTRL (c))
-+	break;
-+
-+      if (unicode_display != unicode_default && c >= 0xc0)
-+	break;
-+    }
-+  while (1);
-+
-+  /* Copy the input, translating as needed.  */
-+  in = original;
-+  if (buffer_len < (strlen (in) * 9))
-+    {
-+      free ((void *) buffer);
-+      buffer_len = strlen (in) * 9;
-+      buffer = xmalloc (buffer_len + 1);
-+    }
-+
-+  out = buffer;
-+  do
-+    {
-+      unsigned char c = *in++;
-+
-+      if (c == 0)
-+	break;
-+
-+      if (ISCNTRL (c))
-+	{
-+	  *out++ = '^';
-+	  *out++ = c + 0x40;
-+	}
-+      else if (unicode_display != unicode_default && c >= 0xc0)
-+	{
-+	  unsigned int num_consumed;
-+
-+	  out += display_utf8 ((const unsigned char *)(in - 1), out, & num_consumed);
-+	  in += num_consumed - 1;
-+	}
-+      else
-+	*out++ = c;
-+    }
-+  while (1);
-+
-+  *out = 0;
-+  return buffer;
-+}
-+
- /* Print symbol name NAME, read from ABFD, with printf format FORM,
-    demangling it if requested.  */
- 
-@@ -444,6 +645,7 @@ print_symname (const char *form, struct
- 
-   if (name == NULL)
-     name = info->sinfo->name;
-+
-   if (!with_symbol_versions
-       && bfd_get_flavour (abfd) == bfd_target_elf_flavour)
-     {
-@@ -451,6 +653,7 @@ print_symname (const char *form, struct
-       if (atver)
- 	*atver = 0;
-     }
-+
-   if (do_demangle && *name)
-     {
-       alloc = bfd_demangle (abfd, name, demangle_flags);
-@@ -458,6 +661,11 @@ print_symname (const char *form, struct
- 	name = alloc;
-     }
- 
-+  if (unicode_display != unicode_default)
-+    {
-+      name = convert_utf8 (name);
-+    }
-+
-   if (info != NULL && info->elfinfo && with_symbol_versions)
-     {
-       const char *version_string;
-@@ -1807,7 +2015,7 @@ main (int argc, char **argv)
-     fatal (_("fatal error: libbfd ABI mismatch"));
-   set_default_bfd_target ();
- 
--  while ((c = getopt_long (argc, argv, "aABCDef:gHhjJlnopPrSst:uvVvX:",
-+  while ((c = getopt_long (argc, argv, "aABCDef:gHhjJlnopPrSst:uU:vVvX:",
- 			   long_options, (int *) 0)) != EOF)
-     {
-       switch (c)
-@@ -1900,6 +2108,24 @@ main (int argc, char **argv)
- 	case 'u':
- 	  undefined_only = 1;
- 	  break;
-+
-+	case 'U':
-+	  if (streq (optarg, "default") || streq (optarg, "d"))
-+	    unicode_display = unicode_default;
-+	  else if (streq (optarg, "locale") || streq (optarg, "l"))
-+	    unicode_display = unicode_locale;
-+	  else if (streq (optarg, "escape") || streq (optarg, "e"))
-+	    unicode_display = unicode_escape;
-+	  else if (streq (optarg, "invalid") || streq (optarg, "i"))
-+	    unicode_display = unicode_invalid;
-+	  else if (streq (optarg, "hex") || streq (optarg, "x"))
-+	    unicode_display = unicode_hex;
-+	  else if (streq (optarg, "highlight") || streq (optarg, "h"))
-+	    unicode_display = unicode_highlight;
-+	  else
-+	    fatal (_("invalid argument to -U/--unicode: %s"), optarg);
-+	  break;
-+
- 	case 'V':
- 	  show_version = 1;
- 	  break;
-diff --git a/binutils/objdump.c b/binutils/objdump.c
---- a/binutils/objdump.c	2021-12-19 19:00:27.046540270 -0800
-+++ b/binutils/objdump.c	2021-12-19 19:43:09.438736729 -0800
-@@ -204,6 +204,18 @@ static const struct objdump_private_desc
- 
- /* The list of detected jumps inside a function.  */
- static struct jump_info *detected_jumps = NULL;
-+
-+typedef enum unicode_display_type
-+{
-+  unicode_default = 0,
-+  unicode_locale,
-+  unicode_escape,
-+  unicode_hex,
-+  unicode_highlight,
-+  unicode_invalid
-+} unicode_display_type;
-+
-+static unicode_display_type unicode_display = unicode_default;
- 
- static void usage (FILE *, int) ATTRIBUTE_NORETURN;
- static void
-@@ -330,6 +342,9 @@ usage (FILE *stream, int status)
-       fprintf (stream, _("\
-   -w, --wide                     Format output for more than 80 columns\n"));
-       fprintf (stream, _("\
-+  -U[d|l|i|x|e|h]                Controls the display of UTF-8 unicode characters\n\
-+  --unicode=[default|locale|invalid|hex|escape|highlight]\n"));
-+      fprintf (stream, _("\
-   -z, --disassemble-zeroes       Do not skip blocks of zeroes when disassembling\n"));
-       fprintf (stream, _("\
-       --start-address=ADDR       Only process data whose address is >= ADDR\n"));
-@@ -420,17 +435,23 @@ static struct option long_options[]=
- {
-   {"adjust-vma", required_argument, NULL, OPTION_ADJUST_VMA},
-   {"all-headers", no_argument, NULL, 'x'},
--  {"private-headers", no_argument, NULL, 'p'},
--  {"private", required_argument, NULL, 'P'},
-   {"architecture", required_argument, NULL, 'm'},
-   {"archive-headers", no_argument, NULL, 'a'},
-+#ifdef ENABLE_LIBCTF
-+  {"ctf", required_argument, NULL, OPTION_CTF},
-+  {"ctf-parent", required_argument, NULL, OPTION_CTF_PARENT},
-+#endif
-   {"debugging", no_argument, NULL, 'g'},
-   {"debugging-tags", no_argument, NULL, 'e'},
-   {"demangle", optional_argument, NULL, 'C'},
-   {"disassemble", optional_argument, NULL, 'd'},
-   {"disassemble-all", no_argument, NULL, 'D'},
--  {"disassembler-options", required_argument, NULL, 'M'},
-   {"disassemble-zeroes", no_argument, NULL, 'z'},
-+  {"disassembler-options", required_argument, NULL, 'M'},
-+  {"dwarf", optional_argument, NULL, OPTION_DWARF},
-+  {"dwarf-check", no_argument, 0, OPTION_DWARF_CHECK},
-+  {"dwarf-depth", required_argument, 0, OPTION_DWARF_DEPTH},
-+  {"dwarf-start", required_argument, 0, OPTION_DWARF_START},
-   {"dynamic-reloc", no_argument, NULL, 'R'},
-   {"dynamic-syms", no_argument, NULL, 'T'},
-   {"endian", required_argument, NULL, OPTION_ENDIAN},
-@@ -440,16 +461,23 @@ static struct option long_options[]=
-   {"full-contents", no_argument, NULL, 's'},
-   {"headers", no_argument, NULL, 'h'},
-   {"help", no_argument, NULL, 'H'},
-+  {"include", required_argument, NULL, 'I'},
-   {"info", no_argument, NULL, 'i'},
-+  {"inlines", no_argument, 0, OPTION_INLINES},
-+  {"insn-width", required_argument, NULL, OPTION_INSN_WIDTH},
-   {"line-numbers", no_argument, NULL, 'l'},
--  {"no-show-raw-insn", no_argument, &show_raw_insn, -1},
-   {"no-addresses", no_argument, &no_addresses, 1},
--  {"process-links", no_argument, &process_links, true},
-+  {"no-recurse-limit", no_argument, NULL, OPTION_NO_RECURSE_LIMIT},
-+  {"no-recursion-limit", no_argument, NULL, OPTION_NO_RECURSE_LIMIT},
-+  {"no-show-raw-insn", no_argument, &show_raw_insn, -1},
-+  {"prefix", required_argument, NULL, OPTION_PREFIX},
-   {"prefix-addresses", no_argument, &prefix_addresses, 1},
-+  {"prefix-strip", required_argument, NULL, OPTION_PREFIX_STRIP},
-+  {"private", required_argument, NULL, 'P'},
-+  {"private-headers", no_argument, NULL, 'p'},
-+  {"process-links", no_argument, &process_links, true},
-   {"recurse-limit", no_argument, NULL, OPTION_RECURSE_LIMIT},
-   {"recursion-limit", no_argument, NULL, OPTION_RECURSE_LIMIT},
--  {"no-recurse-limit", no_argument, NULL, OPTION_NO_RECURSE_LIMIT},
--  {"no-recursion-limit", no_argument, NULL, OPTION_NO_RECURSE_LIMIT},
-   {"reloc", no_argument, NULL, 'r'},
-   {"section", required_argument, NULL, 'j'},
-   {"section-headers", no_argument, NULL, 'h'},
-@@ -457,28 +485,16 @@ static struct option long_options[]=
-   {"source", no_argument, NULL, 'S'},
-   {"source-comment", optional_argument, NULL, OPTION_SOURCE_COMMENT},
-   {"special-syms", no_argument, &dump_special_syms, 1},
--  {"include", required_argument, NULL, 'I'},
--  {"dwarf", optional_argument, NULL, OPTION_DWARF},
--#ifdef ENABLE_LIBCTF
--  {"ctf", required_argument, NULL, OPTION_CTF},
--  {"ctf-parent", required_argument, NULL, OPTION_CTF_PARENT},
--#endif
-   {"stabs", no_argument, NULL, 'G'},
-   {"start-address", required_argument, NULL, OPTION_START_ADDRESS},
-   {"stop-address", required_argument, NULL, OPTION_STOP_ADDRESS},
-   {"syms", no_argument, NULL, 't'},
-   {"target", required_argument, NULL, 'b'},
-+  {"unicode", required_argument, NULL, 'U'},
-   {"version", no_argument, NULL, 'V'},
--  {"wide", no_argument, NULL, 'w'},
--  {"prefix", required_argument, NULL, OPTION_PREFIX},
--  {"prefix-strip", required_argument, NULL, OPTION_PREFIX_STRIP},
--  {"insn-width", required_argument, NULL, OPTION_INSN_WIDTH},
--  {"dwarf-depth", required_argument, 0, OPTION_DWARF_DEPTH},
--  {"dwarf-start", required_argument, 0, OPTION_DWARF_START},
--  {"dwarf-check", no_argument, 0, OPTION_DWARF_CHECK},
--  {"inlines", no_argument, 0, OPTION_INLINES},
-   {"visualize-jumps", optional_argument, 0, OPTION_VISUALIZE_JUMPS},
--  {0, no_argument, 0, 0}
-+  {"wide", no_argument, NULL, 'w'},
-+  {NULL, no_argument, NULL, 0}
- };
- 
- static void
-@@ -488,9 +504,121 @@ nonfatal (const char *msg)
-   exit_status = 1;
- }
- 
-+/* Convert a potential UTF-8 encoded sequence in IN into characters in OUT.
-+   The conversion format is controlled by the unicode_display variable.
-+   Returns the number of characters added to OUT.
-+   Returns the number of bytes consumed from IN in CONSUMED.
-+   Always consumes at least one byte and displays at least one character.  */
-+   
-+static unsigned int
-+display_utf8 (const unsigned char * in, char * out, unsigned int * consumed)
-+{
-+  char *        orig_out = out;
-+  unsigned int  nchars = 0;
-+  unsigned int j;
-+
-+  if (unicode_display == unicode_default)
-+    goto invalid;
-+
-+  if (in[0] < 0xc0)
-+    goto invalid;
-+
-+  if ((in[1] & 0xc0) != 0x80)
-+    goto invalid;
-+
-+  if ((in[0] & 0x20) == 0)
-+    {
-+      nchars = 2;
-+      goto valid;
-+    }
-+
-+  if ((in[2] & 0xc0) != 0x80)
-+    goto invalid;
-+
-+  if ((in[0] & 0x10) == 0)
-+    {
-+      nchars = 3;
-+      goto valid;
-+    }
-+
-+  if ((in[3] & 0xc0) != 0x80)
-+    goto invalid;
-+
-+  nchars = 4;
-+
-+ valid:
-+  switch (unicode_display)
-+    {
-+    case unicode_locale:
-+      /* Copy the bytes into the output buffer as is.  */
-+      memcpy (out, in, nchars);
-+      out += nchars;
-+      break;
-+
-+    case unicode_invalid:
-+    case unicode_hex:
-+      out += sprintf (out, "%c", unicode_display == unicode_hex ? '<' : '{');
-+      out += sprintf (out, "0x");
-+      for (j = 0; j < nchars; j++)
-+	out += sprintf (out, "%02x", in [j]);
-+      out += sprintf (out, "%c", unicode_display == unicode_hex ? '>' : '}');
-+      break;
-+      
-+    case unicode_highlight:
-+      if (isatty (1))
-+	out += sprintf (out, "\x1B[31;47m"); /* Red.  */
-+      /* Fall through.  */
-+    case unicode_escape:
-+      switch (nchars)
-+	{
-+	case 2:
-+	  out += sprintf (out, "\\u%02x%02x",
-+		  ((in[0] & 0x1c) >> 2), 
-+		  ((in[0] & 0x03) << 6) | (in[1] & 0x3f));
-+	  break;
-+
-+	case 3:
-+	  out += sprintf (out, "\\u%02x%02x",
-+		  ((in[0] & 0x0f) << 4) | ((in[1] & 0x3c) >> 2),
-+		  ((in[1] & 0x03) << 6) | ((in[2] & 0x3f)));
-+	  break;
-+
-+	case 4:
-+	  out += sprintf (out, "\\u%02x%02x%02x",
-+		  ((in[0] & 0x07) << 6) | ((in[1] & 0x3c) >> 2),
-+		  ((in[1] & 0x03) << 6) | ((in[2] & 0x3c) >> 2),
-+		  ((in[2] & 0x03) << 6) | ((in[3] & 0x3f)));
-+	  break;
-+	default:
-+	  /* URG.  */
-+	  break;
-+	}
-+
-+      if (unicode_display == unicode_highlight && isatty (1))
-+	out += sprintf (out, "\033[0m"); /* Default colour.  */
-+      break;
-+
-+    default:
-+      /* URG */
-+      break;
-+    }
-+
-+  * consumed = nchars;
-+  return out - orig_out;
-+
-+ invalid:
-+  /* Not a valid UTF-8 sequence.  */
-+  *out = *in;
-+  * consumed = 1;
-+  return 1;
-+}
-+
- /* Returns a version of IN with any control characters
-    replaced by escape sequences.  Uses a static buffer
--   if necessary.  */
-+   if necessary.
-+
-+   If unicode display is enabled, then also handles the
-+   conversion of unicode characters.  */
- 
- static const char *
- sanitize_string (const char * in)
-@@ -508,40 +636,50 @@ sanitize_string (const char * in)
-      of cases it will not be needed.  */
-   do
-     {
--      char c = *in++;
-+      unsigned char c = *in++;
- 
-       if (c == 0)
- 	return original;
- 
-       if (ISCNTRL (c))
- 	break;
-+
-+      if (unicode_display != unicode_default && c >= 0xc0)
-+	break;
-     }
-   while (1);
- 
-   /* Copy the input, translating as needed.  */
-   in = original;
--  if (buffer_len < (strlen (in) * 2))
-+  if (buffer_len < (strlen (in) * 9))
-     {
-       free ((void *) buffer);
--      buffer_len = strlen (in) * 2;
-+      buffer_len = strlen (in) * 9;
-       buffer = xmalloc (buffer_len + 1);
-     }
- 
-   out = buffer;
-   do
-     {
--      char c = *in++;
-+      unsigned char c = *in++;
- 
-       if (c == 0)
- 	break;
- 
--      if (!ISCNTRL (c))
--	*out++ = c;
--      else
-+      if (ISCNTRL (c))
- 	{
- 	  *out++ = '^';
- 	  *out++ = c + 0x40;
- 	}
-+      else if (unicode_display != unicode_default && c >= 0xc0)
-+	{
-+	  unsigned int num_consumed;
-+
-+	  out += display_utf8 ((const unsigned char *)(in - 1), out, & num_consumed);
-+	  in += num_consumed - 1;
-+	}
-+      else
-+	*out++ = c;
-     }
-   while (1);
- 
-@@ -4529,6 +4667,24 @@ dump_symbols (bfd *abfd ATTRIBUTE_UNUSED
- 		  free (alloc);
- 		}
- 	    }
-+	  else if (unicode_display != unicode_default
-+		   && name != NULL && *name != '\0')
-+	    {
-+	      const char * sanitized_name;
-+
-+	      /* If we want to sanitize the name, we do it here, and
-+		 temporarily clobber it while calling bfd_print_symbol.
-+		 FIXME: This is a gross hack.  */
-+	      sanitized_name = sanitize_string (name);
-+	      if (sanitized_name != name)
-+		(*current)->name = sanitized_name;
-+	      else
-+		sanitized_name = NULL;
-+	      bfd_print_symbol (cur_bfd, stdout, *current,
-+				bfd_print_symbol_all);
-+	      if (sanitized_name != NULL)
-+		(*current)->name = name;
-+	    }
- 	  else
- 	    bfd_print_symbol (cur_bfd, stdout, *current,
- 			      bfd_print_symbol_all);
-@@ -5212,7 +5368,7 @@ main (int argc, char **argv)
-   set_default_bfd_target ();
- 
-   while ((c = getopt_long (argc, argv,
--			   "pP:ib:m:M:VvCdDlfFaHhrRtTxsSI:j:wE:zgeGW::",
-+			   "CDE:FGHI:LM:P:RSTU:VW::ab:defghij:lm:prstvwxz",
- 			   long_options, (int *) 0))
- 	 != EOF)
-     {
-@@ -5495,6 +5651,23 @@ main (int argc, char **argv)
- 	  seenflag = true;
- 	  break;
- 
-+	case 'U':
-+	  if (streq (optarg, "default") || streq (optarg, "d"))
-+	    unicode_display = unicode_default;
-+	  else if (streq (optarg, "locale") || streq (optarg, "l"))
-+	    unicode_display = unicode_locale;
-+	  else if (streq (optarg, "escape") || streq (optarg, "e"))
-+	    unicode_display = unicode_escape;
-+	  else if (streq (optarg, "invalid") || streq (optarg, "i"))
-+	    unicode_display = unicode_invalid;
-+	  else if (streq (optarg, "hex") || streq (optarg, "x"))
-+	    unicode_display = unicode_hex;
-+	  else if (streq (optarg, "highlight") || streq (optarg, "h"))
-+	    unicode_display = unicode_highlight;
-+	  else
-+	    fatal (_("invalid argument to -U/--unicode: %s"), optarg);
-+	  break;
-+
- 	case 'H':
- 	  usage (stdout, 0);
- 	  /* No need to set seenflag or to break - usage() does not return.  */
-diff --git a/binutils/readelf.c b/binutils/readelf.c
---- a/binutils/readelf.c	2021-12-19 19:00:27.058540065 -0800
-+++ b/binutils/readelf.c	2021-12-19 19:27:56.538354462 -0800
-@@ -328,6 +328,19 @@ typedef enum print_mode
- }
- print_mode;
- 
-+typedef enum unicode_display_type
-+{
-+  unicode_default = 0,
-+  unicode_locale,
-+  unicode_escape,
-+  unicode_hex,
-+  unicode_highlight,
-+  unicode_invalid
-+} unicode_display_type;
-+
-+static unicode_display_type unicode_display = unicode_default;
-+
-+  
- /* Versioned symbol info.  */
- enum versioned_symbol_info
- {
-@@ -632,11 +645,18 @@ print_symbol (signed int width, const ch
-       if (c == 0)
- 	break;
- 
--      /* Do not print control characters directly as they can affect terminal
--	 settings.  Such characters usually appear in the names generated
--	 by the assembler for local labels.  */
--      if (ISCNTRL (c))
-+      if (ISPRINT (c))
-+	{
-+	  putchar (c);
-+	  width_remaining --;
-+	  num_printed ++;
-+	}
-+      else if (ISCNTRL (c))
- 	{
-+	  /* Do not print control characters directly as they can affect terminal
-+	     settings.  Such characters usually appear in the names generated
-+	     by the assembler for local labels.  */
-+
- 	  if (width_remaining < 2)
- 	    break;
- 
-@@ -644,11 +664,137 @@ print_symbol (signed int width, const ch
- 	  width_remaining -= 2;
- 	  num_printed += 2;
- 	}
--      else if (ISPRINT (c))
-+      else if (c == 0x7f)
- 	{
--	  putchar (c);
--	  width_remaining --;
--	  num_printed ++;
-+	  if (width_remaining < 5)
-+	    break;
-+	  printf ("<DEL>");
-+	  width_remaining -= 5;
-+	  num_printed += 5;
-+	}
-+      else if (unicode_display != unicode_locale
-+	       && unicode_display != unicode_default)
-+	{
-+	  /* Display unicode characters as something else.  */
-+	  unsigned char bytes[4];
-+	  bool          is_utf8;
-+	  unsigned int          nbytes;
-+
-+	  bytes[0] = c;
-+
-+	  if (bytes[0] < 0xc0)
-+	    {
-+	      nbytes = 1;
-+	      is_utf8 = false;
-+	    }
-+	  else
-+	    {
-+	      bytes[1] = *symbol++;
-+
-+	      if ((bytes[1] & 0xc0) != 0x80)
-+		{
-+		  is_utf8 = false;
-+		  /* Do not consume this character.  It may only
-+		     be the first byte in the sequence that was
-+		     corrupt.  */
-+		  --symbol;
-+		  nbytes = 1;
-+		}
-+	      else if ((bytes[0] & 0x20) == 0)
-+		{
-+		  is_utf8 = true;
-+		  nbytes = 2;
-+		}
-+	      else
-+		{
-+		  bytes[2] = *symbol++;
-+
-+		  if ((bytes[2] & 0xc0) != 0x80)
-+		    {
-+		      is_utf8 = false;
-+		      symbol -= 2;
-+		      nbytes = 1;
-+		    }
-+		  else if ((bytes[0] & 0x10) == 0)
-+		    {
-+		      is_utf8 = true;
-+		      nbytes = 3;
-+		    }
-+		  else
-+		    {
-+		      bytes[3] = *symbol++;
-+
-+		      nbytes = 4;
-+
-+		      if ((bytes[3] & 0xc0) != 0x80)
-+			{
-+			  is_utf8 = false;
-+			  symbol -= 3;
-+			  nbytes = 1;
-+			}
-+		      else
-+			is_utf8 = true;
-+		    }
-+		}
-+	    }
-+
-+	  if (unicode_display == unicode_invalid)
-+	    is_utf8 = false;
-+
-+	  if (unicode_display == unicode_hex || ! is_utf8)
-+	    {
-+	      unsigned int i;
-+
-+	      if (width_remaining < (nbytes * 2) + 2)
-+		break;
-+	  
-+	      putchar (is_utf8 ? '<' : '{');
-+	      printf ("0x");
-+	      for (i = 0; i < nbytes; i++)
-+		printf ("%02x", bytes[i]);
-+	      putchar (is_utf8 ? '>' : '}');
-+	    }
-+	  else
-+	    {
-+	      if (unicode_display == unicode_highlight && isatty (1))
-+		printf ("\x1B[31;47m"); /* Red.  */
-+	      
-+	      switch (nbytes)
-+		{
-+		case 2:
-+		  if (width_remaining < 6)
-+		    break;
-+		  printf ("\\u%02x%02x",
-+			  (bytes[0] & 0x1c) >> 2, 
-+			  ((bytes[0] & 0x03) << 6) | (bytes[1] & 0x3f));
-+		  break;
-+		case 3:
-+		  if (width_remaining < 6)
-+		    break;
-+		  printf ("\\u%02x%02x",
-+			  ((bytes[0] & 0x0f) << 4) | ((bytes[1] & 0x3c) >> 2),
-+			  ((bytes[1] & 0x03) << 6) | (bytes[2] & 0x3f));
-+		  break;
-+		case 4:
-+		  if (width_remaining < 8)
-+		    break;
-+		  printf ("\\u%02x%02x%02x",
-+			  ((bytes[0] & 0x07) << 6) | ((bytes[1] & 0x3c) >> 2),
-+			  ((bytes[1] & 0x03) << 6) | ((bytes[2] & 0x3c) >> 2),
-+			  ((bytes[2] & 0x03) << 6) | (bytes[3] & 0x3f));
-+		  
-+		  break;
-+		default:
-+		  /* URG.  */
-+		  break;
-+		}
-+
-+	      if (unicode_display == unicode_highlight && isatty (1))
-+		printf ("\033[0m"); /* Default colour.  */
-+	    }
-+	  
-+	  if (bytes[nbytes - 1] == 0)
-+	    break;
- 	}
-       else
- 	{
-@@ -4668,6 +4814,7 @@ static struct option options[] =
-   {"syms",	       no_argument, 0, 's'},
-   {"silent-truncation",no_argument, 0, 'T'},
-   {"section-details",  no_argument, 0, 't'},
-+  {"unicode",          required_argument, NULL, 'U'},
-   {"unwind",	       no_argument, 0, 'u'},
-   {"version-info",     no_argument, 0, 'V'},
-   {"version",	       no_argument, 0, 'v'},
-@@ -4744,6 +4891,12 @@ usage (FILE * stream)
-   fprintf (stream, _("\
-      --no-recurse-limit  Disable a demangling recursion limit\n"));
-   fprintf (stream, _("\
-+     -U[dlexhi] --unicode=[default|locale|escape|hex|highlight|invalid]\n\
-+                         Display unicode characters as determined by the current locale\n\
-+                          (default), escape sequences, \"<hex sequences>\", highlighted\n\
-+                          escape sequences, or treat them as invalid and display as\n\
-+                          \"{hex sequences}\"\n"));
-+  fprintf (stream, _("\
-   -n --notes             Display the core notes (if present)\n"));
-   fprintf (stream, _("\
-   -r --relocs            Display the relocations (if present)\n"));
-@@ -4928,7 +5081,7 @@ parse_args (struct dump_data *dumpdata,
-     usage (stderr);
- 
-   while ((c = getopt_long
--	  (argc, argv, "ACDHILNPR:STVWacdeghi:lnp:rstuvw::x:z", options, NULL)) != EOF)
-+	  (argc, argv, "ACDHILNPR:STU:VWacdeghi:lnp:rstuvw::x:z", options, NULL)) != EOF)
-     {
-       switch (c)
- 	{
-@@ -5130,6 +5283,25 @@ parse_args (struct dump_data *dumpdata,
- 	  /* Ignored for backward compatibility.  */
- 	  break;
- 
-+	case 'U':
-+	  if (optarg == NULL)
-+	    error (_("Missing arg to -U/--unicode")); /* Can this happen ?  */
-+	  else if (streq (optarg, "default") || streq (optarg, "d"))
-+	    unicode_display = unicode_default;
-+	  else if (streq (optarg, "locale") || streq (optarg, "l"))
-+	    unicode_display = unicode_locale;
-+	  else if (streq (optarg, "escape") || streq (optarg, "e"))
-+	    unicode_display = unicode_escape;
-+	  else if (streq (optarg, "invalid") || streq (optarg, "i"))
-+	    unicode_display = unicode_invalid;
-+	  else if (streq (optarg, "hex") || streq (optarg, "x"))
-+	    unicode_display = unicode_hex;
-+	  else if (streq (optarg, "highlight") || streq (optarg, "h"))
-+	    unicode_display = unicode_highlight;
-+	  else
-+	    error (_("invalid argument to -U/--unicode: %s"), optarg);
-+	  break;
-+
- 	case OPTION_SYM_BASE:
- 	  sym_base = 0;
- 	  if (optarg != NULL)
-diff --git a/binutils/strings.c b/binutils/strings.c
---- a/binutils/strings.c	2021-12-19 19:00:27.058540065 -0800
-+++ b/binutils/strings.c	2021-12-19 19:48:26.205313218 -0800
-@@ -55,6 +55,19 @@
-    -T {bfdname}
- 		Specify a non-default object file format.
- 
-+  --unicode={default|locale|invalid|hex|escape|highlight}
-+  -u {d|l|i|x|e|h}
-+                Determine how to handle UTF-8 unicode characters.  The default
-+		is no special treatment.  All other versions of this option
-+		only apply if the encoding is valid and enabling the option
-+		implies --encoding=S.
-+		The 'locale' option displays the characters according to the
-+		current locale.  The 'invalid' option treats them as
-+		non-string characters.  The 'hex' option displays them as hex
-+		byte sequences.  The 'escape' option displays them as escape
-+		sequences and the 'highlight' option displays them as
-+		coloured escape sequences.
-+
-   --output-separator=sep_string
-   -s sep_string	String used to separate parsed strings in output.
- 		Default is newline.
-@@ -76,6 +89,22 @@
- #include "safe-ctype.h"
- #include "bucomm.h"
- 
-+#ifndef streq
-+#define streq(a,b) (strcmp ((a),(b)) == 0)
-+#endif
-+
-+typedef enum unicode_display_type
-+{
-+  unicode_default = 0,
-+  unicode_locale,
-+  unicode_escape,
-+  unicode_hex,
-+  unicode_highlight,
-+  unicode_invalid
-+} unicode_display_type;
-+
-+static unicode_display_type unicode_display = unicode_default;
-+
- #define STRING_ISGRAPHIC(c) \
-       (   (c) >= 0 \
-        && (c) <= 255 \
-@@ -94,7 +123,7 @@ extern int errno;
- static int address_radix;
- 
- /* Minimum length of sequence of graphic chars to trigger output.  */
--static int string_min;
-+static unsigned int string_min;
- 
- /* Whether or not we include all whitespace as a graphic char.   */
- static bool include_all_whitespace;
-@@ -121,21 +150,22 @@ static char *output_separator;
- static struct option long_options[] =
- {
-   {"all", no_argument, NULL, 'a'},
-+  {"bytes", required_argument, NULL, 'n'},
-   {"data", no_argument, NULL, 'd'},
-+  {"encoding", required_argument, NULL, 'e'},
-+  {"help", no_argument, NULL, 'h'},
-+  {"include-all-whitespace", no_argument, NULL, 'w'},
-+  {"output-separator", required_argument, NULL, 's'},
-   {"print-file-name", no_argument, NULL, 'f'},
--  {"bytes", required_argument, NULL, 'n'},
-   {"radix", required_argument, NULL, 't'},
--  {"include-all-whitespace", no_argument, NULL, 'w'},
--  {"encoding", required_argument, NULL, 'e'},
-   {"target", required_argument, NULL, 'T'},
--  {"output-separator", required_argument, NULL, 's'},
--  {"help", no_argument, NULL, 'h'},
-+  {"unicode", required_argument, NULL, 'U'},
-   {"version", no_argument, NULL, 'v'},
-   {NULL, 0, NULL, 0}
- };
- 
- static bool strings_file (char *);
--static void print_strings (const char *, FILE *, file_ptr, int, int, char *);
-+static void print_strings (const char *, FILE *, file_ptr, int, char *);
- static void usage (FILE *, int) ATTRIBUTE_NORETURN;
- 
- int main (int, char **);
-@@ -171,7 +201,7 @@ main (int argc, char **argv)
-   encoding = 's';
-   output_separator = NULL;
- 
--  while ((optc = getopt_long (argc, argv, "adfhHn:wot:e:T:s:Vv0123456789",
-+  while ((optc = getopt_long (argc, argv, "adfhHn:wot:e:T:s:U:Vv0123456789",
- 			      long_options, (int *) 0)) != EOF)
-     {
-       switch (optc)
-@@ -244,6 +274,23 @@ main (int argc, char **argv)
- 	  output_separator = optarg;
-           break;
- 
-+	case 'U':
-+	  if (streq (optarg, "default") || streq (optarg, "d"))
-+	    unicode_display = unicode_default;
-+	  else if (streq (optarg, "locale") || streq (optarg, "l"))
-+	    unicode_display = unicode_locale;
-+	  else if (streq (optarg, "escape") || streq (optarg, "e"))
-+	    unicode_display = unicode_escape;
-+	  else if (streq (optarg, "invalid") || streq (optarg, "i"))
-+	    unicode_display = unicode_invalid;
-+	  else if (streq (optarg, "hex") || streq (optarg, "x"))
-+	    unicode_display = unicode_hex;
-+	  else if (streq (optarg, "highlight") || streq (optarg, "h"))
-+	    unicode_display = unicode_highlight;
-+	  else
-+	    fatal (_("invalid argument to -U/--unicode: %s"), optarg);
-+	  break;
-+
- 	case 'V':
- 	case 'v':
- 	  print_version ("strings");
-@@ -258,6 +305,9 @@ main (int argc, char **argv)
- 	}
-     }
- 
-+  if (unicode_display != unicode_default)
-+    encoding = 'S';
-+
-   if (numeric_opt != 0)
-     {
-       string_min = (int) strtoul (argv[numeric_opt - 1] + 1, &s, 0);
-@@ -293,14 +343,14 @@ main (int argc, char **argv)
-     {
-       datasection_only = false;
-       SET_BINARY (fileno (stdin));
--      print_strings ("{standard input}", stdin, 0, 0, 0, (char *) NULL);
-+      print_strings ("{standard input}", stdin, 0, 0, (char *) NULL);
-       files_given = true;
-     }
-   else
-     {
-       for (; optind < argc; ++optind)
- 	{
--	  if (strcmp (argv[optind], "-") == 0)
-+	  if (streq (argv[optind], "-"))
- 	    datasection_only = false;
- 	  else
- 	    {
-@@ -342,7 +392,7 @@ strings_a_section (bfd *abfd, asection *
-     }
- 
-   *got_a_section = true;
--  print_strings (filename, NULL, sect->filepos, 0, sectsize, (char *) mem);
-+  print_strings (filename, NULL, sect->filepos, sectsize, (char *) mem);
-   free (mem);
- }
- 
-@@ -427,7 +477,7 @@ strings_file (char *file)
- 	  return false;
- 	}
- 
--      print_strings (file, stream, (file_ptr) 0, 0, 0, (char *) 0);
-+      print_strings (file, stream, (file_ptr) 0, 0, (char *) NULL);
- 
-       if (fclose (stream) == EOF)
- 	{
-@@ -551,6 +601,626 @@ unget_part_char (long c, file_ptr *addre
- 	}
-     }
- }
-+
-+static void
-+print_filename_and_address (const char * filename, file_ptr address)
-+{
-+  if (print_filenames)
-+    printf ("%s: ", filename);
-+
-+  if (! print_addresses)
-+    return;
-+
-+  switch (address_radix)
-+    {
-+    case 8:
-+      if (sizeof (address) > sizeof (long))
-+	{
-+#ifndef __MSVCRT__
-+	  printf ("%7llo ", (unsigned long long) address);
-+#else
-+	  printf ("%7I64o ", (unsigned long long) address);
-+#endif
-+	}
-+      else
-+	printf ("%7lo ", (unsigned long) address);
-+      break;
-+
-+    case 10:
-+      if (sizeof (address) > sizeof (long))
-+	{
-+#ifndef __MSVCRT__
-+	  printf ("%7llu ", (unsigned long long) address);
-+#else
-+	  printf ("%7I64d ", (unsigned long long) address);
-+#endif
-+	}
-+      else
-+	printf ("%7ld ", (long) address);
-+      break;
-+
-+    case 16:
-+      if (sizeof (address) > sizeof (long))
-+	{
-+#ifndef __MSVCRT__
-+	  printf ("%7llx ", (unsigned long long) address);
-+#else
-+	  printf ("%7I64x ", (unsigned long long) address);
-+#endif
-+	}
-+      else
-+	printf ("%7lx ", (unsigned long) address);
-+      break;
-+    }
-+}
-+
-+/* Return non-zero if the bytes starting at BUFFER form a valid UTF-8 encoding.
-+   If the encoding is valid then returns the number of bytes it uses.  */
-+
-+static unsigned int
-+is_valid_utf8 (const unsigned char * buffer, unsigned long buflen)
-+{
-+  if (buffer[0] < 0xc0)
-+    return 0;
-+
-+  if (buflen < 2)
-+    return 0;
-+
-+  if ((buffer[1] & 0xc0) != 0x80)
-+    return 0;
-+
-+  if ((buffer[0] & 0x20) == 0)
-+    return 2;
-+
-+  if (buflen < 3)
-+    return 0;
-+
-+  if ((buffer[2] & 0xc0) != 0x80)
-+    return 0;
-+
-+  if ((buffer[0] & 0x10) == 0)
-+    return 3;
-+
-+  if (buflen < 4)
-+    return 0;
-+
-+  if ((buffer[3] & 0xc0) != 0x80)
-+    return 0;
-+
-+  return 4;
-+}
-+
-+/* Display a UTF-8 encoded character in BUFFER according to the setting
-+   of unicode_display.  The character is known to be valid.
-+   Returns the number of bytes consumed.  */
-+
-+static unsigned int
-+display_utf8_char (const unsigned char * buffer)
-+{
-+  unsigned int j;
-+  unsigned int utf8_len;
-+
-+  switch (buffer[0] & 0x30)
-+    {
-+    case 0x00:
-+    case 0x10:
-+      utf8_len = 2;
-+      break;
-+    case 0x20:
-+      utf8_len = 3;
-+      break;
-+    default:
-+      utf8_len = 4;
-+    }
-+
-+  switch (unicode_display)
-+    {
-+    default:
-+      fprintf (stderr, "ICE: unexpected unicode display type\n");
-+      break;
-+
-+    case unicode_escape:
-+    case unicode_highlight:
-+      if (unicode_display == unicode_highlight && isatty (1))
-+	printf ("\x1B[31;47m"); /* Red.  */
-+
-+      switch (utf8_len)
-+	{
-+	case 2:
-+	  printf ("\\u%02x%02x",
-+		  ((buffer[0] & 0x1c) >> 2),
-+		  ((buffer[0] & 0x03) << 6) | (buffer[1] & 0x3f));
-+	  break;
-+
-+	case 3:
-+	  printf ("\\u%02x%02x",
-+		  ((buffer[0] & 0x0f) << 4) | ((buffer[1] & 0x3c) >> 2),
-+		  ((buffer[1] & 0x03) << 6) | ((buffer[2] & 0x3f)));
-+	  break;
-+
-+	case 4:
-+	  printf ("\\u%02x%02x%02x",
-+		  ((buffer[0] & 0x07) << 6) | ((buffer[1] & 0x3c) >> 2),
-+		  ((buffer[1] & 0x03) << 6) | ((buffer[2] & 0x3c) >> 2),
-+		  ((buffer[2] & 0x03) << 6) | ((buffer[3] & 0x3f)));
-+	  break;
-+	default:
-+	  /* URG.  */
-+	  break;
-+	}
-+
-+      if (unicode_display == unicode_highlight && isatty (1))
-+	printf ("\033[0m"); /* Default colour.  */
-+      break;
-+
-+    case unicode_hex:
-+      putchar ('<');
-+      printf ("0x");
-+      for (j = 0; j < utf8_len; j++)
-+	printf ("%02x", buffer [j]);
-+      putchar ('>');
-+      break;
-+
-+    case unicode_locale:
-+      printf ("%.1s", buffer);
-+      break;
-+    }
-+
-+  return utf8_len;
-+}
-+
-+/* Display strings in BUFFER.  Treat any UTF-8 encoded characters encountered
-+   according to the setting of the unicode_display variable.  The buffer
-+   contains BUFLEN bytes.
-+
-+   Display the characters as if they started at ADDRESS and are contained in
-+   FILENAME.  */
-+
-+static void
-+print_unicode_buffer (const char *            filename,
-+		      file_ptr                address,
-+		      const unsigned char *   buffer,
-+		      unsigned long           buflen)
-+{
-+  /* Paranoia checks...  */
-+  if (filename == NULL
-+      || buffer == NULL
-+      || unicode_display == unicode_default
-+      || encoding != 'S'
-+      || encoding_bytes != 1)
-+    {
-+      fprintf (stderr, "ICE: bad arguments to print_unicode_buffer\n");
-+      return;
-+    }
-+
-+  if (buflen == 0)
-+    return;
-+
-+  /* We must only display strings that are at least string_min *characters*
-+     long.  So we scan the buffer in two stages.  First we locate the start
-+     of a potential string.  Then we walk along it until we have found
-+     string_min characters.  Then we go back to the start point and start
-+     displaying characters according to the unicode_display setting.  */
-+
-+  unsigned long start_point = 0;
-+  unsigned long i = 0;
-+  unsigned int char_len = 1;
-+  unsigned int num_found = 0;
-+
-+  for (i = 0; i < buflen; i += char_len)
-+    {
-+      int c = buffer[i];
-+
-+      char_len = 1;
-+
-+      /* Find the first potential character of a string.  */
-+      if (! STRING_ISGRAPHIC (c))
-+	{
-+	  num_found = 0;
-+	  continue;
-+	}
-+
-+      if (c > 126)
-+	{
-+	  if (c < 0xc0)
-+	    {
-+	      num_found = 0;
-+	      continue;
-+	    }
-+
-+	  if ((char_len = is_valid_utf8 (buffer + i, buflen - i)) == 0)
-+	    {
-+	      char_len = 1;
-+	      num_found = 0;
-+	      continue;
-+	    }
-+
-+	  if (unicode_display == unicode_invalid)
-+	    {
-+	      /* We have found a valid UTF-8 character, but we treat it as non-graphic.  */
-+	      num_found = 0;
-+	      continue;
-+	    }
-+	}
-+
-+      if (num_found == 0)
-+	/* We have found a potential starting point for a string.  */
-+	start_point = i;
-+
-+      ++ num_found;
-+
-+      if (num_found >= string_min)
-+	break;
-+    }
-+
-+  if (num_found < string_min)
-+    return;
-+
-+  print_filename_and_address (filename, address + start_point);
-+
-+  /* We have found string_min characters.  Display them and any
-+     more that follow.  */
-+  for (i = start_point; i < buflen; i += char_len)
-+    {
-+      int c = buffer[i];
-+
-+      char_len = 1;
-+
-+      if (! STRING_ISGRAPHIC (c))
-+	break;
-+      else if (c < 127)
-+	putchar (c);
-+      else if (! is_valid_utf8 (buffer + i, buflen - i))
-+	break;
-+      else if (unicode_display == unicode_invalid)
-+	break;
-+      else
-+	char_len = display_utf8_char (buffer + i);
-+    }
-+
-+  if (output_separator)
-+    fputs (output_separator, stdout);
-+  else
-+    putchar ('\n');
-+
-+  /* FIXME: Using tail recursion here is lazy programming...  */
-+  print_unicode_buffer (filename, address + i, buffer + i, buflen - i);
-+}
-+
-+static int
-+get_unicode_byte (FILE *          stream,
-+		  unsigned char * putback,
-+		  unsigned int *  num_putback,
-+		  unsigned int *  num_read)
-+{
-+  if (* num_putback > 0)
-+    {
-+      * num_putback = * num_putback - 1;
-+      return putback [* num_putback];
-+    }
-+
-+  * num_read = * num_read + 1;
-+
-+#if defined(HAVE_GETC_UNLOCKED) && HAVE_DECL_GETC_UNLOCKED
-+  return getc_unlocked (stream);
-+#else
-+  return getc (stream);
-+#endif
-+}
-+
-+/* Helper function for print_unicode_stream.  */
-+
-+static void
-+print_unicode_stream_body (const char *     filename,
-+			   file_ptr         address,
-+			   FILE *           stream,
-+			   unsigned char *  putback_buf,
-+			   unsigned int     num_putback,
-+			   unsigned char *  print_buf)
-+{
-+  /* It would be nice if we could just read the stream into a buffer
-+     and then process if with print_unicode_buffer.  But the input
-+     might be huge or it might time-locked (eg stdin).  So instead
-+     we go one byte at a time...  */
-+
-+  file_ptr start_point = 0;
-+  unsigned int num_read = 0;
-+  unsigned int num_chars = 0;
-+  unsigned int num_print = 0;
-+  int c = 0;
-+
-+  /* Find a series of string_min characters.  Put them into print_buf.  */
-+  do
-+    {
-+      if (num_chars >= string_min)
-+	break;
-+
-+      c = get_unicode_byte (stream, putback_buf, & num_putback, & num_read);
-+      if (c == EOF)
-+	break;
-+
-+      if (! STRING_ISGRAPHIC (c))
-+	{
-+	  num_chars = num_print = 0;
-+	  continue;
-+	}
-+
-+      if (num_chars == 0)
-+	start_point = num_read - 1;
-+
-+      if (c < 127)
-+	{
-+	  print_buf[num_print] = c;
-+	  num_chars ++;
-+	  num_print ++;
-+	  continue;
-+	}
-+
-+      if (c < 0xc0)
-+	{
-+	  num_chars = num_print = 0;
-+	  continue;
-+	}
-+
-+      /* We *might* have a UTF-8 sequence.  Time to start peeking.  */
-+      char utf8[4];
-+
-+      utf8[0] = c;
-+      c = get_unicode_byte (stream, putback_buf, & num_putback, & num_read);
-+      if (c == EOF)
-+	break;
-+      utf8[1] = c;
-+
-+      if ((utf8[1] & 0xc0) != 0x80)
-+	{
-+	  /* Invalid UTF-8.  */
-+	  putback_buf[num_putback++] = utf8[1];
-+	  num_chars = num_print = 0;
-+	  continue;
-+	}
-+      else if ((utf8[0] & 0x20) == 0)
-+	{
-+	  /* A valid 2-byte UTF-8 encoding.  */
-+	  if (unicode_display == unicode_invalid)
-+	    {
-+	      putback_buf[num_putback++] = utf8[1];
-+	      num_chars = num_print = 0;
-+	    }
-+	  else
-+	    {
-+	      print_buf[num_print ++] = utf8[0];
-+	      print_buf[num_print ++] = utf8[1];
-+	      num_chars ++;
-+	    }
-+	  continue;
-+	}
-+
-+      c = get_unicode_byte (stream, putback_buf, & num_putback, & num_read);
-+      if (c == EOF)
-+	break;
-+      utf8[2] = c;
-+
-+      if ((utf8[2] & 0xc0) != 0x80)
-+	{
-+	  /* Invalid UTF-8.  */
-+	  putback_buf[num_putback++] = utf8[2];
-+	  putback_buf[num_putback++] = utf8[1];
-+	  num_chars = num_print = 0;
-+	  continue;
-+	}
-+      else if ((utf8[0] & 0x10) == 0)
-+	{
-+	  /* A valid 3-byte UTF-8 encoding.  */
-+	  if (unicode_display == unicode_invalid)
-+	    {
-+	      putback_buf[num_putback++] = utf8[2];
-+	      putback_buf[num_putback++] = utf8[1];
-+	      num_chars = num_print = 0;
-+	    }
-+	  else
-+	    {
-+	      print_buf[num_print ++] = utf8[0];
-+	      print_buf[num_print ++] = utf8[1];
-+	      print_buf[num_print ++] = utf8[2];
-+	      num_chars ++;
-+	    }
-+	  continue;
-+	}
-+
-+      c = get_unicode_byte (stream, putback_buf, & num_putback, & num_read);
-+      if (c == EOF)
-+	break;
-+      utf8[3] = c;
-+
-+      if ((utf8[3] & 0xc0) != 0x80)
-+	{
-+	  /* Invalid UTF-8.  */
-+	  putback_buf[num_putback++] = utf8[3];
-+	  putback_buf[num_putback++] = utf8[2];
-+	  putback_buf[num_putback++] = utf8[1];
-+	  num_chars = num_print = 0;
-+	}
-+      /* We have a valid 4-byte UTF-8 encoding.  */
-+      else if (unicode_display == unicode_invalid)
-+	{
-+	  putback_buf[num_putback++] = utf8[3];
-+	  putback_buf[num_putback++] = utf8[1];
-+	  putback_buf[num_putback++] = utf8[2];
-+	  num_chars = num_print = 0;
-+	}
-+      else
-+	{
-+	  print_buf[num_print ++] = utf8[0];
-+	  print_buf[num_print ++] = utf8[1];
-+	  print_buf[num_print ++] = utf8[2];
-+	  print_buf[num_print ++] = utf8[3];
-+	  num_chars ++;
-+	}
-+    }
-+  while (1);
-+
-+  if (num_chars >= string_min)
-+    {
-+      /* We know that we have string_min valid characters in print_buf,
-+	 and there may be more to come in the stream.  Start displaying
-+	 them.  */
-+
-+      print_filename_and_address (filename, address + start_point);
-+
-+      unsigned int i;
-+      for (i = 0; i < num_print;)
-+	{
-+	  if (print_buf[i] < 127)
-+	    putchar (print_buf[i++]);
-+	  else
-+	    i += display_utf8_char (print_buf + i);
-+	}
-+
-+      /* OK so now we have to start read unchecked bytes.  */
-+
-+      /* Find a series of string_min characters.  Put them into print_buf.  */
-+      do
-+	{
-+	  c = get_unicode_byte (stream, putback_buf, & num_putback, & num_read);
-+	  if (c == EOF)
-+	    break;
-+
-+	  if (! STRING_ISGRAPHIC (c))
-+	    break;
-+
-+	  if (c < 127)
-+	    {
-+	      putchar (c);
-+	      continue;
-+	    }
-+
-+	  if (c < 0xc0)
-+	    break;
-+
-+	  /* We *might* have a UTF-8 sequence.  Time to start peeking.  */
-+	  unsigned char utf8[4];
-+
-+	  utf8[0] = c;
-+	  c = get_unicode_byte (stream, putback_buf, & num_putback, & num_read);
-+	  if (c == EOF)
-+	    break;
-+	  utf8[1] = c;
-+
-+	  if ((utf8[1] & 0xc0) != 0x80)
-+	    {
-+	      /* Invalid UTF-8.  */
-+	      putback_buf[num_putback++] = utf8[1];
-+	      break;
-+	    }
-+	  else if ((utf8[0] & 0x20) == 0)
-+	    {
-+	      /* Valid 2-byte UTF-8.  */
-+	      if (unicode_display == unicode_invalid)
-+		{
-+		  putback_buf[num_putback++] = utf8[1];
-+		  break;
-+		}
-+	      else
-+		{
-+		  (void) display_utf8_char (utf8);
-+		  continue;
-+		}
-+	    }
-+
-+	  c = get_unicode_byte (stream, putback_buf, & num_putback, & num_read);
-+	  if (c == EOF)
-+	    break;
-+	  utf8[2] = c;
-+
-+	  if ((utf8[2] & 0xc0) != 0x80)
-+	    {
-+	      /* Invalid UTF-8.  */
-+	      putback_buf[num_putback++] = utf8[2];
-+	      putback_buf[num_putback++] = utf8[1];
-+	      break;
-+	    }
-+	  else if ((utf8[0] & 0x10) == 0)
-+	    {
-+	      /* Valid 3-byte UTF-8.  */
-+	      if (unicode_display == unicode_invalid)
-+		{
-+		  putback_buf[num_putback++] = utf8[2];
-+		  putback_buf[num_putback++] = utf8[1];
-+		  break;
-+		}
-+	      else
-+		{
-+		  (void) display_utf8_char (utf8);
-+		  continue;
-+		}
-+	    }
-+
-+	  c = get_unicode_byte (stream, putback_buf, & num_putback, & num_read);
-+	  if (c == EOF)
-+	    break;
-+	  utf8[3] = c;
-+
-+	  if ((utf8[3] & 0xc0) != 0x80)
-+	    {
-+	      /* Invalid UTF-8.  */
-+	      putback_buf[num_putback++] = utf8[3];
-+	      putback_buf[num_putback++] = utf8[2];
-+	      putback_buf[num_putback++] = utf8[1];
-+	      break;
-+	    }
-+	  else if (unicode_display == unicode_invalid)
-+	    {
-+	      putback_buf[num_putback++] = utf8[3];
-+	      putback_buf[num_putback++] = utf8[2];
-+	      putback_buf[num_putback++] = utf8[1];
-+	      break;
-+	    }
-+	  else
-+	    /* A valid 4-byte UTF-8 encoding.  */
-+	    (void) display_utf8_char (utf8);
-+	}
-+      while (1);
-+
-+      if (output_separator)
-+	fputs (output_separator, stdout);
-+      else
-+	putchar ('\n');
-+    }
-+
-+  if (c != EOF)
-+    /* FIXME: Using tail recursion here is lazy, but it works.  */
-+    print_unicode_stream_body (filename, address + num_read, stream, putback_buf, num_putback, print_buf);
-+}
-+
-+/* Display strings read in from STREAM.  Treat any UTF-8 encoded characters
-+   encountered according to the setting of the unicode_display variable.
-+   The stream is positioned at ADDRESS and is attached to FILENAME.  */
-+
-+static void
-+print_unicode_stream (const char * filename,
-+		      file_ptr     address,
-+		      FILE *       stream)
-+{
-+  /* Paranoia checks...  */
-+  if (filename == NULL
-+      || stream == NULL
-+      || unicode_display == unicode_default
-+      || encoding != 'S'
-+      || encoding_bytes != 1)
-+    {
-+      fprintf (stderr, "ICE: bad arguments to print_unicode_stream\n");
-+      return;
-+    }
-+
-+  /* Allocate space for string_min 4-byte utf-8 characters.  */
-+  unsigned char * print_buf = xmalloc ((4 * string_min) + 1);
-+  /* We should never have to put back more than 4 bytes.  */
-+  unsigned char putback_buf[5];
-+  unsigned int num_putback = 0;
-+
-+  print_unicode_stream_body (filename, address, stream, putback_buf, num_putback, print_buf);
-+  free (print_buf);
-+}
- 
- /* Find the strings in file FILENAME, read from STREAM.
-    Assume that STREAM is positioned so that the next byte read
-@@ -566,20 +1236,29 @@ unget_part_char (long c, file_ptr *addre
- 
- static void
- print_strings (const char *filename, FILE *stream, file_ptr address,
--	       int stop_point, int magiccount, char *magic)
-+	       int magiccount, char *magic)
- {
-+  if (unicode_display != unicode_default)
-+    {
-+      if (magic != NULL)
-+	print_unicode_buffer (filename, address,
-+			      (const unsigned char *) magic, magiccount);
-+
-+      if (stream != NULL)
-+	print_unicode_stream (filename, address, stream);
-+      return;
-+    }
-+
-   char *buf = (char *) xmalloc (sizeof (char) * (string_min + 1));
- 
-   while (1)
-     {
-       file_ptr start;
--      int i;
-+      unsigned int i;
-       long c;
- 
-       /* See if the next `string_min' chars are all graphic chars.  */
-     tryline:
--      if (stop_point && address >= stop_point)
--	break;
-       start = address;
-       for (i = 0; i < string_min; i++)
- 	{
-@@ -601,51 +1280,7 @@ print_strings (const char *filename, FIL
- 
-       /* We found a run of `string_min' graphic characters.  Print up
- 	 to the next non-graphic character.  */
--
--      if (print_filenames)
--	printf ("%s: ", filename);
--      if (print_addresses)
--	switch (address_radix)
--	  {
--	  case 8:
--	    if (sizeof (start) > sizeof (long))
--	      {
--#ifndef __MSVCRT__
--		printf ("%7llo ", (unsigned long long) start);
--#else
--		printf ("%7I64o ", (unsigned long long) start);
--#endif
--	      }
--	    else
--	      printf ("%7lo ", (unsigned long) start);
--	    break;
--
--	  case 10:
--	    if (sizeof (start) > sizeof (long))
--	      {
--#ifndef __MSVCRT__
--		printf ("%7llu ", (unsigned long long) start);
--#else
--		printf ("%7I64d ", (unsigned long long) start);
--#endif
--	      }
--	    else
--	      printf ("%7ld ", (long) start);
--	    break;
--
--	  case 16:
--	    if (sizeof (start) > sizeof (long))
--	      {
--#ifndef __MSVCRT__
--		printf ("%7llx ", (unsigned long long) start);
--#else
--		printf ("%7I64x ", (unsigned long long) start);
--#endif
--	      }
--	    else
--	      printf ("%7lx ", (unsigned long) start);
--	    break;
--	  }
-+      print_filename_and_address (filename, start);
- 
-       buf[i] = '\0';
-       fputs (buf, stdout);
-@@ -697,6 +1332,8 @@ usage (FILE *stream, int status)
-   -T --target=<BFDNAME>     Specify the binary file format\n\
-   -e --encoding={s,S,b,l,B,L} Select character size and endianness:\n\
-                             s = 7-bit, S = 8-bit, {b,l} = 16-bit, {B,L} = 32-bit\n\
-+  --unicode={default|show|invalid|hex|escape|highlight}\n\
-+  -u {d|s|i|x|e|h}          Specify how to treat UTF-8 encoded unicode characters\n\
-   -s --output-separator=<string> String used to separate strings in output.\n\
-   @<file>                   Read options from <file>\n\
-   -h --help                 Display this information\n\

+ 6 - 6
recipes-devtools/binutils/binutils/0001-binutils-crosssdk-Generate-relocatable-SDKs.patch

@@ -1,4 +1,4 @@
-From 257ad1ce148417e1cefe2332d8acc5c8216c2522 Mon Sep 17 00:00:00 2001
+From a0ac147aec127c66c9e38292faa50bb56d3c2a19 Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Mon, 2 Mar 2015 01:58:54 +0000
 Subject: [PATCH] binutils-crosssdk: Generate relocatable SDKs
@@ -21,10 +21,10 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
  3 files changed, 6 insertions(+), 3 deletions(-)
 
 diff --git a/gold/layout.cc b/gold/layout.cc
-index a27cb071c75..32b52890b39 100644
+index 3efe8d98ae9..9cc389664a6 100644
 --- a/gold/layout.cc
 +++ b/gold/layout.cc
-@@ -5032,7 +5032,7 @@ Layout::create_interp(const Target* target)
+@@ -5033,7 +5033,7 @@ Layout::create_interp(const Target* target)
        gold_assert(interp != NULL);
      }
  
@@ -34,7 +34,7 @@ index a27cb071c75..32b52890b39 100644
    Output_section_data* odata = new Output_data_const(interp, len, 1);
  
 diff --git a/ld/genscripts.sh b/ld/genscripts.sh
-index 088417ef2d5..46a2db7005c 100755
+index 278f212bdad..0c52ebee4d0 100755
 --- a/ld/genscripts.sh
 +++ b/ld/genscripts.sh
 @@ -304,6 +304,7 @@ DATA_ALIGNMENT_u="${DATA_ALIGNMENT_u-${DATA_ALIGNMENT_r}}"
@@ -59,10 +59,10 @@ index 088417ef2d5..46a2db7005c 100755
  DATA_ALIGNMENT=${DATA_ALIGNMENT_}
  RELOCATING=" "
 diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc
-index 29a8f0781d5..75e46f4adaf 100644
+index bf2268bb0ad..b1811ef130f 100644
 --- a/ld/scripttempl/elf.sc
 +++ b/ld/scripttempl/elf.sc
-@@ -147,8 +147,8 @@ if test -z "$DATA_SEGMENT_ALIGN"; then
+@@ -148,8 +148,8 @@ if test -z "$DATA_SEGMENT_ALIGN"; then
      DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);"
    fi
  fi

+ 0 - 927
recipes-devtools/binutils/binutils/0001-merge-from-dubhe-pr-06-30-to-support-b0.94.patch

@@ -1,927 +0,0 @@
-From cc2d8c8bed31f441206b53009d5d681132c6e332 Mon Sep 17 00:00:00 2001
-From: "max.ma" <max.ma@starfivetech.com>
-Date: Wed, 29 Sep 2021 02:42:26 -0700
-Subject: [PATCH 01/11] merge from dubhe-pr-06-30 to support b0.94
-
----
- gas/config/tc-riscv.c              |  24 +++
- gas/testsuite/gas/riscv/b-ext-64.d |  69 +++++++
- gas/testsuite/gas/riscv/b-ext-64.s |  69 +++++++
- gas/testsuite/gas/riscv/b-ext.d    |  39 ++++
- gas/testsuite/gas/riscv/b-ext.s    |  39 ++++
- include/opcode/riscv-opc.h         | 206 +++++++++++++++++++
- include/opcode/riscv.h             |  12 ++
- opcodes/riscv-opc.c                | 316 +++++++++++++++++++++++++++++
- 8 files changed, 774 insertions(+)
-
-diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
-index 70cbc8190f..e5d8070b75 100644
---- a/gas/config/tc-riscv.c
-+++ b/gas/config/tc-riscv.c
-@@ -343,6 +343,30 @@ riscv_multi_subset_supports (enum riscv_insn_class insn_class)
-     case INSN_CLASS_ZBC:
-       return riscv_subset_supports ("zbc");
- 
-+    case INSN_CLASS_ZBE:
-+      return riscv_subset_supports ("zbe");
-+    case INSN_CLASS_ZBF:
-+      return riscv_subset_supports ("zbf");
-+    case INSN_CLASS_ZBM:
-+      return riscv_subset_supports ("zbm");
-+    case INSN_CLASS_ZBP:
-+      return riscv_subset_supports ("zbp");
-+    case INSN_CLASS_ZBR:
-+      return riscv_subset_supports ("zbr");
-+    case INSN_CLASS_ZBS:
-+      return riscv_subset_supports ("zbs");
-+    case INSN_CLASS_ZBT:
-+      return riscv_subset_supports ("zbt");
-+    case INSN_CLASS_ZBB_OR_ZBP:
-+      return (riscv_subset_supports ("zbb") || riscv_subset_supports ("zbp"));
-+    case INSN_CLASS_ZBS_OR_ZBE:
-+      return (riscv_subset_supports ("zbs") || riscv_subset_supports ("zbe"));
-+    case INSN_CLASS_ZBP_OR_ZBM:
-+      return (riscv_subset_supports ("zbp") || riscv_subset_supports ("zbm"));
-+    case INSN_CLASS_ZBP_OR_ZBE_OR_ZBF:
-+      return (riscv_subset_supports ("zbp") || riscv_subset_supports ("zbe") || riscv_subset_supports ("zbf"));
-+    case INSN_CLASS_ZBP_OR_ZBE_OR_ZBF_OR_ZBM:
-+      return (riscv_subset_supports ("zbp") || riscv_subset_supports ("zbe") || riscv_subset_supports ("zbf") || riscv_subset_supports ("zbm"));
-     default:
-       as_fatal ("internal: unreachable");
-       return false;
-diff --git a/gas/testsuite/gas/riscv/b-ext-64.d b/gas/testsuite/gas/riscv/b-ext-64.d
-index f4a7abf02d..d1b512b9e9 100644
---- a/gas/testsuite/gas/riscv/b-ext-64.d
-+++ b/gas/testsuite/gas/riscv/b-ext-64.d
-@@ -46,3 +46,72 @@ Disassembly of section .text:
- [ 	]+8c:[ 	]+08c5853b[ 	]+add.uw[ 	]+a0,a1,a2
- [ 	]+90:[ 	]+0805853b[ 	]+zext.w[ 	]+a0,a1
- [ 	]+94:[ 	]+0825951b[ 	]+slli.uw[ 	]+a0,a1,0x2
-+[ 	]+98:[ 	]+08c5c533[ 	]+pack[ 	]+a0,a1,a2
-+[ 	]+9c:[ 	]+48c5c533[ 	]+packu[ 	]+a0,a1,a2
-+[ 	]+a0:[ 	]+08c5f533[ 	]+packh[ 	]+a0,a1,a2
-+[ 	]+a4:[ 	]+0825c53b[ 	]+packw[ 	]+a0,a1,0x2
-+[ 	]+a8:[ 	]+4825c53b[ 	]+packuw[ 	]+a0,a1,0x2
-+[ 	]+ac:[ 	]+68c5d533[ 	]+grev[ 	]+a0,a1,a2
-+[ 	]+b0:[ 	]+6825d513[ 	]+rev2.n[ 	]+a0,a1
-+[ 	]+b4:[ 	]+6825d53b[ 	]+grevw[ 	]+a0,a1,0x2
-+[ 	]+b8:[ 	]+6825d51b[ 	]+greviw[ 	]+a0,a1,0x2
-+[ 	]+bc:[ 	]+28c5d533[ 	]+gorc[ 	]+a0,a1,a2
-+[ 	]+c0:[ 	]+2825d513[ 	]+orc2.n[ 	]+a0,a1
-+[ 	]+c4:[ 	]+2825d53b[ 	]+gorcw[ 	]+a0,a1,0x2
-+[ 	]+c8:[ 	]+2825d51b[ 	]+gorciw[ 	]+a0,a1,0x2
-+[ 	]+cc:[ 	]+08c59533[ 	]+shfl[ 	]+a0,a1,a2
-+[ 	]+d0:[ 	]+08259513[ 	]+zip2.b[ 	]+a0,a1
-+[ 	]+d4:[ 	]+0825953b[ 	]+shflw[ 	]+a0,a1,0x2
-+[ 	]+d8:[ 	]+08c5d533[ 	]+unshfl[ 	]+a0,a1,a2
-+[ 	]+dc:[ 	]+0825d513[ 	]+unzip2.b[ 	]+a0,a1
-+[ 	]+e0:[ 	]+0825d53b[ 	]+unshflw[ 	]+a0,a1,0x2
-+[ 	]+e4:[ 	]+28c5a533[ 	]+xperm.n[ 	]+a0,a1,a2
-+[ 	]+e8:[ 	]+28c5c533[ 	]+xperm.b[ 	]+a0,a1,a2
-+[ 	]+ec:[ 	]+28c5e533[ 	]+xperm.h[ 	]+a0,a1,a2
-+[ 	]+f0:[ 	]+28258533[ 	]+xperm.w[ 	]+a0,a1,0x2
-+[ 	]+f4:[ 	]+28c59533[ 	]+bset[ 	]+a0,a1,a2
-+[ 	]+f8:[ 	]+48c59533[ 	]+bclr[ 	]+a0,a1,a2
-+[ 	]+fc:[ 	]+68c59533[ 	]+binv[ 	]+a0,a1,a2
-+[ 	]+100:[ 	]+48c5d533[ 	]+bext[ 	]+a0,a1,a2
-+[ 	]+104:[ 	]+48c5e533[ 	]+bdecompress[ 	]+a0,a1,a2
-+[ 	]+108:[ 	]+28259513[ 	]+bseti[ 	]+a0,a1,0x2
-+[ 	]+10c:[ 	]+48259513[ 	]+bclri[ 	]+a0,a1,0x2
-+[ 	]+110:[ 	]+68259513[ 	]+binvi[ 	]+a0,a1,0x2
-+[ 	]+114:[ 	]+4825d513[ 	]+bexti[ 	]+a0,a1,0x2
-+[ 	]+118:[ 	]+28c5953b[ 	]+bsetw[ 	]+a0,a1,a2
-+[ 	]+11c:[ 	]+48c5953b[ 	]+bclrw[ 	]+a0,a1,a2
-+[ 	]+120:[ 	]+68c5953b[ 	]+binvw[ 	]+a0,a1,a2
-+[ 	]+124:[ 	]+48c5d53b[ 	]+bextw[ 	]+a0,a1,a2
-+[ 	]+128:[ 	]+4825e53b[ 	]+bdecompressw[ 	]+a0,a1,0x2
-+[ 	]+12c:[ 	]+2825951b[ 	]+bsetiw[ 	]+a0,a1,0x2
-+[ 	]+130:[ 	]+4825951b[ 	]+bclriw[ 	]+a0,a1,0x2
-+[ 	]+134:[ 	]+6825951b[ 	]+binviw[ 	]+a0,a1,0x2
-+[ 	]+138:[ 	]+20c59533[ 	]+slo[ 	]+a0,a1,a2
-+[ 	]+13c:[ 	]+20c5d533[ 	]+sro[ 	]+a0,a1,a2
-+[ 	]+140:[ 	]+20259513[ 	]+sloi[ 	]+a0,a1,0x2
-+[ 	]+144:[ 	]+2025d513[ 	]+sroi[ 	]+a0,a1,0x2
-+[ 	]+148:[ 	]+2025953b[ 	]+slow[ 	]+a0,a1,0x2
-+[ 	]+14c:[ 	]+2025d53b[ 	]+srow[ 	]+a0,a1,0x2
-+[ 	]+150:[ 	]+2025951b[ 	]+sloiw[ 	]+a0,a1,0x2
-+[ 	]+154:[ 	]+2025d51b[ 	]+sroiw[ 	]+a0,a1,0x2
-+[ 	]+158:[ 	]+48c5f533[ 	]+bfp[ 	]+a0,a1,a2
-+[ 	]+15c:[ 	]+4825f53b[ 	]+bfpw[ 	]+a0,a1,0x2
-+[ 	]+160:[ 	]+08c5b533[ 	]+bmator[ 	]+a0,a1,a2
-+[ 	]+164:[ 	]+48c5b533[ 	]+bmatxor[ 	]+a0,a1,a2
-+[ 	]+168:[ 	]+60351513[ 	]+bmatflip[ 	]+a0,a0
-+[ 	]+16c:[ 	]+61051513[ 	]+crc32.b[ 	]+a0,a0
-+[ 	]+170:[ 	]+61151513[ 	]+crc32.h[ 	]+a0,a0
-+[ 	]+174:[ 	]+61251513[ 	]+crc32.w[ 	]+a0,a0
-+[ 	]+178:[ 	]+61851513[ 	]+crc32c.b[ 	]+a0,a0
-+[ 	]+17c:[ 	]+61951513[ 	]+crc32c.h[ 	]+a0,a0
-+[ 	]+180:[ 	]+61a51513[ 	]+crc32c.w[ 	]+a0,a0
-+[ 	]+184:[ 	]+61351513[ 	]+crc32.d[ 	]+a0,a0
-+[ 	]+188:[ 	]+61b51513[ 	]+crc32c.d[ 	]+a0,a0
-+[ 	]+18c:[ 	]+6ec59533[ 	]+cmix[ 	]+a0,a1,a2,a3
-+[ 	]+190:[ 	]+6ec5d533[ 	]+cmov[ 	]+a0,a1,a2,a3
-+[ 	]+194:[ 	]+6cc59533[ 	]+fsl[ 	]+a0,a1,a2,a3
-+[ 	]+198:[ 	]+6cc5d533[ 	]+fsr[ 	]+a0,a1,a2,a3
-+[ 	]+19c:[ 	]+6c25d513[ 	]+fsri[ 	]+a0,a1,0x2,a3
-+[ 	]+1a0:[ 	]+6c25953b[ 	]+fslw[ 	]+a0,a1,0x2,a3
-+[ 	]+1a4:[ 	]+6c25d53b[ 	]+fsrw[ 	]+a0,a1,0x2,a3
-+[ 	]+1a8:[ 	]+6c25d51b[ 	]+fsriw[ 	]+a0,a1,0x2,a3
-\ No newline at end of file
-diff --git a/gas/testsuite/gas/riscv/b-ext-64.s b/gas/testsuite/gas/riscv/b-ext-64.s
-index c3ac377f4b..23b1cbe473 100644
---- a/gas/testsuite/gas/riscv/b-ext-64.s
-+++ b/gas/testsuite/gas/riscv/b-ext-64.s
-@@ -37,3 +37,72 @@ target:
- 	add.uw	a0, a1, a2
- 	zext.w	a0, a1
- 	slli.uw	a0, a1, 2
-+	pack	a0, a1, a2
-+	packu	a0, a1, a2
-+	packh	a0, a1, a2
-+	packw	a0, a1, 2
-+	packuw	a0, a1, 2
-+	grev	a0, a1, a2
-+	grevi	a0, a1, 2
-+	grevw	a0, a1, 2
-+	greviw	a0, a1, 2
-+	gorc	a0, a1, a2
-+	gorci	a0, a1, 2
-+	gorcw	a0, a1, 2
-+	gorciw	a0, a1, 2
-+	shfl	a0, a1, a2
-+	shfli	a0, a1, 2
-+	shflw	a0, a1, 2
-+	unshfl	a0, a1, a2
-+	unshfli	a0, a1, 2
-+	unshflw	a0, a1, 2
-+	xperm.n	a0, a1, a2
-+	xperm.b	a0, a1, a2
-+	xperm.h	a0, a1, a2
-+	xperm.w	a0, a1, 2
-+	bset	a0, a1, a2
-+	bclr	a0, a1, a2
-+	binv	a0, a1, a2
-+	bext	a0, a1, a2
-+	bdecompress	a0, a1, a2
-+	bseti	a0, a1, 2
-+	bclri	a0, a1, 2
-+	binvi	a0, a1, 2
-+	bexti	a0, a1, 2
-+	bsetw	a0, a1, a2
-+	bclrw	a0, a1, a2
-+	binvw	a0, a1, a2
-+	bextw	a0, a1, a2
-+	bdecompressw	a0, a1, 2
-+	bsetiw	a0, a1, 2
-+	bclriw	a0, a1, 2
-+	binviw	a0, a1, 2
-+	slo	a0, a1, a2
-+	sro	a0, a1, a2
-+	sloi	a0, a1, 2
-+	sroi	a0, a1, 2
-+	slow	a0, a1, 2
-+	srow	a0, a1, 2
-+	sloiw	a0, a1, 2
-+	sroiw	a0, a1, 2
-+	bfp	a0, a1, a2
-+	bfpw	a0, a1, 2
-+	bmator	a0, a1, a2
-+	bmatxor	a0, a1, a2
-+	bmatflip	a0, a0
-+	crc32.b	a0, a0
-+	crc32.h	a0, a0
-+	crc32.w	a0, a0
-+	crc32c.b	a0, a0
-+	crc32c.h	a0, a0
-+	crc32c.w	a0, a0
-+	crc32.d	a0, a0
-+	crc32c.d	a0, a0
-+	cmix	a0, a1, a2, a3
-+	cmov	a0, a1, a2, a3
-+	fsl	a0, a1, a2, a3
-+	fsr	a0, a1, a2, a3
-+	fsri	a0, a1,  2, a3
-+	fslw	a0, a1,  2, a3
-+	fsrw	a0, a1,  2, a3
-+	fsriw	a0, a1,  2, a3
-\ No newline at end of file
-diff --git a/gas/testsuite/gas/riscv/b-ext.d b/gas/testsuite/gas/riscv/b-ext.d
-index 7410796a3b..059a8fa146 100644
---- a/gas/testsuite/gas/riscv/b-ext.d
-+++ b/gas/testsuite/gas/riscv/b-ext.d
-@@ -33,3 +33,42 @@ Disassembly of section .text:
- [ 	]+58:[ 	]+0ac59533[ 	]+clmul[ 	]+a0,a1,a2
- [ 	]+5c:[ 	]+0ac5b533[ 	]+clmulh[ 	]+a0,a1,a2
- [ 	]+60:[ 	]+0ac5a533[ 	]+clmulr[ 	]+a0,a1,a2
-+[ 	]+64:[ 	]+08c5c533[ 	]+pack[ 	]+a0,a1,a2
-+[ 	]+68:[ 	]+48c5c533[ 	]+packu[ 	]+a0,a1,a2
-+[ 	]+6c:[ 	]+08c5f533[ 	]+packh[ 	]+a0,a1,a2
-+[ 	]+70:[ 	]+68c5d533[ 	]+grev[ 	]+a0,a1,a2
-+[ 	]+74:[ 	]+6825d513[ 	]+rev2.n[ 	]+a0,a1
-+[ 	]+78:[ 	]+28c5d533[ 	]+gorc[ 	]+a0,a1,a2
-+[ 	]+7c:[ 	]+2825d513[ 	]+orc2.n[ 	]+a0,a1
-+[ 	]+80:[ 	]+08c59533[ 	]+shfl[ 	]+a0,a1,a2
-+[ 	]+84:[ 	]+08259513[ 	]+zip2.b[ 	]+a0,a1
-+[ 	]+88:[ 	]+08c5d533[ 	]+unshfl[ 	]+a0,a1,a2
-+[ 	]+8c:[ 	]+0825d513[ 	]+unzip2.b[ 	]+a0,a1
-+[ 	]+90:[ 	]+28c5a533[ 	]+xperm.n[ 	]+a0,a1,a2
-+[ 	]+94:[ 	]+28c5c533[ 	]+xperm.b[ 	]+a0,a1,a2
-+[ 	]+98:[ 	]+28c5e533[ 	]+xperm.h[ 	]+a0,a1,a2
-+[ 	]+9c:[ 	]+28c59533[ 	]+bset[ 	]+a0,a1,a2
-+[ 	]+a0:[ 	]+48c59533[ 	]+bclr[ 	]+a0,a1,a2
-+[ 	]+a4:[ 	]+68c59533[ 	]+binv[ 	]+a0,a1,a2
-+[ 	]+a8:[ 	]+48c5d533[ 	]+bext[ 	]+a0,a1,a2
-+[ 	]+ac:[ 	]+48c5e533[ 	]+bdecompress[ 	]+a0,a1,a2
-+[ 	]+b0:[ 	]+28259513[ 	]+bseti[ 	]+a0,a1,0x2
-+[ 	]+b4:[ 	]+48259513[ 	]+bclri[ 	]+a0,a1,0x2
-+[ 	]+b8:[ 	]+68259513[ 	]+binvi[ 	]+a0,a1,0x2
-+[ 	]+bc:[ 	]+4825d513[ 	]+bexti[ 	]+a0,a1,0x2
-+[ 	]+c0:[ 	]+20c59533[ 	]+slo[ 	]+a0,a1,a2
-+[ 	]+c4:[ 	]+20c5d533[ 	]+sro[ 	]+a0,a1,a2
-+[ 	]+c8:[ 	]+20259513[ 	]+sloi[ 	]+a0,a1,0x2
-+[ 	]+cc:[ 	]+2025d513[ 	]+sroi[ 	]+a0,a1,0x2
-+[ 	]+d0:[ 	]+48c5f533[ 	]+bfp[ 	]+a0,a1,a2
-+[ 	]+d4:[ 	]+61051513[ 	]+crc32.b[ 	]+a0,a0
-+[ 	]+d8:[ 	]+61151513[ 	]+crc32.h[ 	]+a0,a0
-+[ 	]+dc:[ 	]+61251513[ 	]+crc32.w[ 	]+a0,a0
-+[ 	]+e0:[ 	]+61851513[ 	]+crc32c.b[ 	]+a0,a0
-+[ 	]+e4:[ 	]+61951513[ 	]+crc32c.h[ 	]+a0,a0
-+[ 	]+e8:[ 	]+61a51513[ 	]+crc32c.w[ 	]+a0,a0
-+[ 	]+ec:[ 	]+6ec59533[ 	]+cmix[ 	]+a0,a1,a2,a3
-+[ 	]+f0:[ 	]+6ec5d533[ 	]+cmov[ 	]+a0,a1,a2,a3
-+[ 	]+f4:[ 	]+6cc59533[ 	]+fsl[ 	]+a0,a1,a2,a3
-+[ 	]+f8:[ 	]+6cc5d533[ 	]+fsr[ 	]+a0,a1,a2,a3
-+[ 	]+fc:[ 	]+6c25d513[ 	]+fsri[ 	]+a0,a1,0x2,a3
-\ No newline at end of file
-diff --git a/gas/testsuite/gas/riscv/b-ext.s b/gas/testsuite/gas/riscv/b-ext.s
-index 051dafd171..041af79bbd 100644
---- a/gas/testsuite/gas/riscv/b-ext.s
-+++ b/gas/testsuite/gas/riscv/b-ext.s
-@@ -24,3 +24,42 @@ target:
- 	clmul	a0, a1, a2
- 	clmulh	a0, a1, a2
- 	clmulr	a0, a1, a2
-+	pack	 a0, a1, a2
-+	packu	 a0, a1, a2
-+	packh	 a0, a1, a2
-+	grev	 a0, a1, a2
-+	grevi	 a0, a1, 2
-+	gorc	 a0, a1, a2
-+	gorci	 a0, a1, 2
-+	shfl	 a0, a1, a2
-+	shfli	 a0, a1, 2
-+	unshfl	 a0, a1, a2
-+	unshfli	 a0, a1, 2
-+	xperm.n	 a0, a1, a2
-+	xperm.b	 a0, a1, a2
-+	xperm.h	 a0, a1, a2
-+	bset	 a0, a1, a2
-+	bclr	 a0, a1, a2
-+	binv	 a0, a1, a2
-+	bext	 a0, a1, a2
-+	bdecompress	 a0, a1, a2
-+	bseti	 a0, a1, 2
-+	bclri	 a0, a1, 2
-+	binvi	 a0, a1, 2
-+	bexti	 a0, a1, 2
-+	slo	 a0, a1, a2
-+	sro	 a0, a1, a2
-+	sloi	 a0, a1, 2
-+	sroi	 a0, a1, 2
-+	bfp	 a0, a1, a2
-+	crc32.b	 a0, a0
-+	crc32.h	 a0, a0
-+	crc32.w	 a0, a0
-+	crc32c.b	 a0, a0
-+	crc32c.h	 a0, a0
-+	crc32c.w	 a0, a0
-+	cmix	 a0, a1, a2, a3
-+	cmov	 a0, a1, a2, a3
-+	fsl	 a0, a1, a2, a3
-+	fsr	 a0, a1, a2, a3
-+	fsri	 a0, a1, 2, a3
-\ No newline at end of file
-diff --git a/include/opcode/riscv-opc.h b/include/opcode/riscv-opc.h
-index 9999da6241..1a80dbf87d 100644
---- a/include/opcode/riscv-opc.h
-+++ b/include/opcode/riscv-opc.h
-@@ -113,6 +113,18 @@
- #define MASK_SRL  0xfe00707f
- #define MATCH_SRA 0x40005033
- #define MASK_SRA  0xfe00707f
-+#define MATCH_SLO 0x20001033
-+#define MASK_SLO  0xfe00707f
-+#define MATCH_SLOI 0x20001013
-+#define MASK_SLOI  0xfc00707f
-+#define MATCH_SLOW 0x2000103b
-+#define MASK_SLOW  0xfe00707f
-+#define MATCH_SRO 0x20005033
-+#define MASK_SRO  0xfe00707f
-+#define MATCH_SROI 0x20005013
-+#define MASK_SROI  0xfc00707f
-+#define MATCH_SROW 0x2000503b
-+#define MASK_SROW  0xfe00707f
- #define MATCH_OR 0x6033
- #define MASK_OR  0xfe00707f
- #define MATCH_AND 0x7033
-@@ -429,6 +441,24 @@
- #define MASK_CTZ  0xfff0707f
- #define MATCH_CPOP 0x60201013
- #define MASK_CPOP  0xfff0707f
-+#define MATCH_BMATFLIP 0x60301013
-+#define MASK_BMATFLIP  0xfff0707f
-+#define MATCH_CRC32_B 0x61001013
-+#define MASK_CRC32_B  0xfff0707f
-+#define MATCH_CRC32_H 0x61101013
-+#define MASK_CRC32_H  0xfff0707f
-+#define MATCH_CRC32_W 0x61201013
-+#define MASK_CRC32_W  0xfff0707f
-+#define MATCH_CRC32_D 0x61301013
-+#define MASK_CRC32_D  0xfff0707f
-+#define MATCH_CRC32C_B 0x61801013
-+#define MASK_CRC32C_B  0xfff0707f
-+#define MATCH_CRC32C_H 0x61901013
-+#define MASK_CRC32C_H  0xfff0707f
-+#define MATCH_CRC32C_W 0x61A01013
-+#define MASK_CRC32C_W  0xfff0707f
-+#define MATCH_CRC32C_D 0x61B01013
-+#define MASK_CRC32C_D  0xfff0707f
- #define MATCH_MIN 0xa004033
- #define MASK_MIN  0xfe00707f
- #define MATCH_MINU 0xa005033
-@@ -437,14 +467,38 @@
- #define MASK_MAX  0xfe00707f
- #define MATCH_MAXU 0xa007033
- #define MASK_MAXU  0xfe00707f
-+#define MATCH_SHFL 0x8001033
-+#define MASK_SHFL  0xfe00707f
-+#define MATCH_SHFLI 0x8001013
-+#define MASK_SHFLI  0xfc00707f
-+#define MATCH_UNSHFL 0x8005033
-+#define MASK_UNSHFL  0xfe00707f
-+#define MATCH_UNSHFLI 0x8005013
-+#define MASK_UNSHFLI  0xfc00707f
-+#define MATCH_BCOMPRESS 0x8006033
-+#define MASK_BCOMPRESS  0xfe00707f
-+#define MATCH_BDECOMPRESS 0x48006033
-+#define MASK_BDECOMPRESS  0xfe00707f
- #define MATCH_SEXT_B 0x60401013
- #define MASK_SEXT_B  0xfff0707f
- #define MATCH_SEXT_H 0x60501013
- #define MASK_SEXT_H  0xfff0707f
- #define MATCH_PACK 0x8004033
- #define MASK_PACK  0xfe00707f
-+#define MATCH_PACKU 0x48004033
-+#define MASK_PACKU  0xfe00707f
-+#define MATCH_BMATOR 0x8003033
-+#define MASK_BMATOR  0xfe00707f
-+#define MATCH_BMATXOR 0x48003033
-+#define MASK_BMATXOR  0xfe00707f
-+#define MATCH_PACKH 0x8007033
-+#define MASK_PACKH  0xfe00707f
-+#define MATCH_BFP 0x48007033
-+#define MASK_BFP  0xfe00707f
- #define MATCH_PACKW 0x800403b
- #define MASK_PACKW  0xfe00707f
-+#define MATCH_PACKUW 0x4800403b
-+#define MASK_PACKUW  0xfe00707f
- #define MATCH_ANDN 0x40007033
- #define MASK_ANDN  0xfe00707f
- #define MATCH_ORN 0x40006033
-@@ -457,10 +511,40 @@
- #define MASK_ROR  0xfe00707f
- #define MATCH_RORI 0x60005013
- #define MASK_RORI  0xfc00707f
-+#define MATCH_BCLR 0x48001033
-+#define MASK_BCLR  0xfe00707f
-+#define MATCH_BCLRI 0x48001013
-+#define MASK_BCLRI  0xfc00707f
-+#define MATCH_BSET 0x28001033
-+#define MASK_BSET  0xfe00707f
-+#define MATCH_BSETI 0x28001013
-+#define MASK_BSETI  0xfc00707f
-+#define MATCH_BINV 0x68001033
-+#define MASK_BINV  0xfe00707f
-+#define MATCH_BINVI 0x68001013
-+#define MASK_BINVI  0xfc00707f
-+#define MATCH_BEXT 0x48005033
-+#define MASK_BEXT  0xfe00707f
-+#define MATCH_BEXTI 0x48005013
-+#define MASK_BEXTI  0xfc00707f
-+#define MATCH_GREV 0x68005033
-+#define MASK_GREV  0xfe00707f
- #define MATCH_GREVI 0x68005013
- #define MASK_GREVI  0xfc00707f
-+#define MATCH_GORC 0x28005033
-+#define MASK_GORC  0xfe00707f
- #define MATCH_GORCI 0x28005013
- #define MASK_GORCI  0xfc00707f
-+#define MATCH_CMIX 0x6001033
-+#define MASK_CMIX  0x600707f
-+#define MATCH_CMOV 0x6005033
-+#define MASK_CMOV  0x600707f
-+#define MATCH_FSL 0x4001033
-+#define MASK_FSL  0x600707f
-+#define MATCH_FSR 0x4005033
-+#define MASK_FSR  0x600707f
-+#define MATCH_FSRI 0x4005013
-+#define MASK_FSRI  0x400707f
- #define MATCH_CLZW 0x6000101b
- #define MASK_CLZW  0xfff0707f
- #define MATCH_CTZW 0x6010101b
-@@ -485,6 +569,56 @@
- #define MASK_SH2ADD_UW  0xfe00707f
- #define MATCH_SH3ADD_UW 0x2000603b
- #define MASK_SH3ADD_UW  0xfe00707f
-+#define MATCH_BCLRW 0x4800103b
-+#define MASK_BCLRW  0xfe00707f
-+#define MATCH_BSETW 0x2800103b
-+#define MASK_BSETW  0xfe00707f
-+#define MATCH_BINVW 0x6800103b
-+#define MASK_BINVW  0xfe00707f
-+#define MATCH_BEXTW 0x4800503b
-+#define MASK_BEXTW  0xfe00707f
-+#define MATCH_GORCW 0x2800503b
-+#define MASK_GORCW  0xfe00707f
-+#define MATCH_GREVW 0x6800503b
-+#define MASK_GREVW  0xfe00707f
-+#define MATCH_SLOIW 0x2000101b
-+#define MASK_SLOIW  0xfe00707f
-+#define MATCH_SROIW 0x2000501b
-+#define MASK_SROIW  0xfe00707f
-+#define MATCH_BCLRIW 0x4800101b
-+#define MASK_BCLRIW  0xfe00707f
-+#define MATCH_BSETIW 0x2800101b
-+#define MASK_BSETIW  0xfe00707f
-+#define MATCH_BINVIW 0x6800101b
-+#define MASK_BINVIW  0xfe00707f
-+#define MATCH_GORCIW 0x2800501b
-+#define MASK_GORCIW  0xfe00707f
-+#define MATCH_GREVIW 0x6800501b
-+#define MASK_GREVIW  0xfe00707f
-+#define MATCH_FSLW 0x400103b
-+#define MASK_FSLW  0x600707f
-+#define MATCH_FSRW 0x400503B
-+#define MASK_FSRW  0x600707f
-+#define MATCH_FSRIW 0x400501B
-+#define MASK_FSRIW  0x600707f
-+#define MATCH_SHFLW 0x800103b
-+#define MASK_SHFLW  0xfe00707f
-+#define MATCH_UNSHFLW 0x800503b
-+#define MASK_UNSHFLW  0xfe00707f
-+#define MATCH_BCOMPRESSW 0x800603B
-+#define MASK_BCOMPRESSW  0xfe00707f
-+#define MATCH_BDECOMPRESSW 0x4800603b
-+#define MASK_BDECOMPRESSW  0xfe00707f
-+#define MATCH_BFPW 0x4800703b
-+#define MASK_BFPW  0xfe00707f
-+#define MATCH_XPERM_N 0x28002033
-+#define MASK_XPERM_N  0xfe00707f
-+#define MATCH_XPERM_B 0x28004033
-+#define MASK_XPERM_B  0xfe00707f
-+#define MATCH_XPERM_H 0x28006033
-+#define MASK_XPERM_H  0xfe00707f
-+#define MATCH_XPERM_W 0x28000033
-+#define MASK_XPERM_W  0xfe00707f
- #define MATCH_ADD_UW 0x800003b
- #define MASK_ADD_UW  0xfe00707f
- #define MATCH_SLLI_UW 0x800101b
-@@ -1102,6 +1236,78 @@ DECLARE_INSN(slli_uw, MATCH_SLLI_UW, MASK_SLLI_UW)
- DECLARE_INSN(clmul, MATCH_CLMUL, MASK_CLMUL)
- DECLARE_INSN(clmulh, MATCH_CLMULH, MASK_CLMULH)
- DECLARE_INSN(clmulr, MATCH_CLMULR, MASK_CLMULR)
-+DECLARE_INSN(pack, MATCH_PACK, MASK_PACK)
-+DECLARE_INSN(packu, MATCH_PACKU, MASK_PACKU)
-+DECLARE_INSN(packh, MATCH_PACKH, MASK_PACKH)
-+DECLARE_INSN(packw, MATCH_PACKW, MASK_PACKW)
-+DECLARE_INSN(packuw, MATCH_PACKUW, MASK_PACKUW)
-+DECLARE_INSN(grev, MATCH_GREV, MASK_GREV)
-+DECLARE_INSN(grevi, MATCH_GREVI, MASK_GREVI)
-+DECLARE_INSN(grevw, MATCH_GREVW, MASK_GREVW)
-+DECLARE_INSN(greviw, MATCH_GREVIW, MASK_GREVIW)
-+DECLARE_INSN(gorc, MATCH_GORC, MASK_GORC)
-+DECLARE_INSN(gorci, MATCH_GORCI, MASK_GORCI)
-+DECLARE_INSN(gorcw, MATCH_GORCW, MASK_GORCW)
-+DECLARE_INSN(gorciw, MATCH_GORCIW, MASK_GORCIW)
-+DECLARE_INSN(shfl, MATCH_SHFL, MASK_SHFL)
-+DECLARE_INSN(shfli, MATCH_SHFLI, MASK_SHFLI)
-+DECLARE_INSN(shflw, MATCH_SHFLW, MASK_SHFLW)
-+DECLARE_INSN(unshfl, MATCH_UNSHFL, MASK_UNSHFL)
-+DECLARE_INSN(unshfli, MATCH_UNSHFLI, MASK_UNSHFLI)
-+DECLARE_INSN(unshflw, MATCH_UNSHFLW, MASK_UNSHFLW)
-+DECLARE_INSN(xperm_n, MATCH_XPERM_N, MASK_XPERM_N)
-+DECLARE_INSN(xperm_b, MATCH_XPERM_B, MASK_XPERM_B)
-+DECLARE_INSN(xperm_h, MATCH_XPERM_H, MASK_XPERM_H)
-+DECLARE_INSN(xperm_w, MATCH_XPERM_W, MASK_XPERM_W)
-+DECLARE_INSN(bset, MATCH_BSET, MASK_BSET)
-+DECLARE_INSN(bclr, MATCH_BCLR, MASK_BCLR)
-+DECLARE_INSN(binv, MATCH_BINV, MASK_BINV)
-+DECLARE_INSN(bext, MATCH_BEXT, MASK_BEXT)
-+DECLARE_INSN(bcompress, MATCH_BCOMPRESS, MASK_BCOMPRESS)
-+DECLARE_INSN(bdecompress, MATCH_BDECOMPRESS, MASK_BDECOMPRESS)
-+DECLARE_INSN(bseti, MATCH_BSETI, MASK_BSETI)
-+DECLARE_INSN(bclri, MATCH_BCLRI, MASK_BCLRI)
-+DECLARE_INSN(binvi, MATCH_BINVI, MASK_BINVI)
-+DECLARE_INSN(bexti, MATCH_BEXTI, MASK_BEXTI)
-+DECLARE_INSN(bsetw, MATCH_BSETW, MASK_BSETW)
-+DECLARE_INSN(bclrw, MATCH_BCLRW, MASK_BCLRW)
-+DECLARE_INSN(binvw, MATCH_BINVW, MASK_BINVW)
-+DECLARE_INSN(bextw, MATCH_BEXTW, MASK_BEXTW)
-+DECLARE_INSN(bcompressw, MATCH_BCOMPRESSW, MASK_BCOMPRESSW)
-+DECLARE_INSN(bdecompressw, MATCH_BDECOMPRESSW, MASK_BDECOMPRESSW)
-+DECLARE_INSN(bsetiw, MATCH_BSETIW, MASK_BSETIW)
-+DECLARE_INSN(bclriw, MATCH_BCLRIW, MASK_BCLRIW)
-+DECLARE_INSN(binviw, MATCH_BINVIW, MASK_BINVIW)
-+DECLARE_INSN(slo, MATCH_SLO, MASK_SLO)
-+DECLARE_INSN(sro, MATCH_SRO, MASK_SRO)
-+DECLARE_INSN(sloi, MATCH_SLOI, MASK_SLOI)
-+DECLARE_INSN(sroi, MATCH_SROI, MASK_SROI)
-+DECLARE_INSN(slow, MATCH_SLOW, MASK_SLOW)
-+DECLARE_INSN(srow, MATCH_SROW, MASK_SROW)
-+DECLARE_INSN(sloiw, MATCH_SLOIW, MASK_SLOIW)
-+DECLARE_INSN(sroiw, MATCH_SROIW, MASK_SROIW)
-+DECLARE_INSN(bfp, MATCH_BFP, MASK_BFP)
-+DECLARE_INSN(bfpw, MATCH_BFPW, MASK_BFPW)
-+DECLARE_INSN(bmator, MATCH_BMATOR, MASK_BMATOR)
-+DECLARE_INSN(bmatxor, MATCH_BMATXOR, MASK_BMATXOR)
-+DECLARE_INSN(bmatflip, MATCH_BMATFLIP, MASK_BMATFLIP)
-+DECLARE_INSN(crc32_b, MATCH_CRC32_B, MASK_CRC32_B)
-+DECLARE_INSN(crc32_h, MATCH_CRC32_H, MASK_CRC32_H)
-+DECLARE_INSN(crc32_w, MATCH_CRC32_W, MASK_CRC32_W)
-+DECLARE_INSN(crc32c_b, MATCH_CRC32C_B, MASK_CRC32C_B)
-+DECLARE_INSN(crc32c_h, MATCH_CRC32C_H, MASK_CRC32C_H)
-+DECLARE_INSN(crc32c_w, MATCH_CRC32C_W, MASK_CRC32C_W)
-+DECLARE_INSN(crc32_d, MATCH_CRC32_D, MASK_CRC32_D)
-+DECLARE_INSN(crc32c_d, MATCH_CRC32C_D, MASK_CRC32C_D)
-+DECLARE_INSN(cmix, MATCH_CMIX, MASK_CMIX)
-+DECLARE_INSN(cmov, MATCH_CMOV, MASK_CMOV)
-+DECLARE_INSN(fsl, MATCH_FSL, MASK_FSL)
-+DECLARE_INSN(fsr, MATCH_FSR, MASK_FSR)
-+DECLARE_INSN(fsri, MATCH_FSRI, MASK_FSRI)
-+DECLARE_INSN(fslw, MATCH_FSLW, MASK_FSLW)
-+DECLARE_INSN(fsrw, MATCH_FSRW, MASK_FSRW)
-+DECLARE_INSN(fsriw, MATCH_FSRIW, MASK_FSRIW)
-+DECLARE_INSN(flh, MATCH_FLH, MASK_FLH)
- DECLARE_INSN(flw, MATCH_FLW, MASK_FLW)
- DECLARE_INSN(fld, MATCH_FLD, MASK_FLD)
- DECLARE_INSN(flq, MATCH_FLQ, MASK_FLQ)
-diff --git a/include/opcode/riscv.h b/include/opcode/riscv.h
-index fdf3df4f5c..ae8c6bd33f 100644
---- a/include/opcode/riscv.h
-+++ b/include/opcode/riscv.h
-@@ -319,6 +319,18 @@ enum riscv_insn_class
-   INSN_CLASS_ZBA,
-   INSN_CLASS_ZBB,
-   INSN_CLASS_ZBC,
-+  INSN_CLASS_ZBP,
-+  INSN_CLASS_ZBB_OR_ZBP,
-+  INSN_CLASS_ZBS,
-+  INSN_CLASS_ZBE,
-+  INSN_CLASS_ZBS_OR_ZBE,
-+  INSN_CLASS_ZBF,
-+  INSN_CLASS_ZBM,
-+  INSN_CLASS_ZBP_OR_ZBM,
-+  INSN_CLASS_ZBR,
-+  INSN_CLASS_ZBT,
-+  INSN_CLASS_ZBP_OR_ZBE_OR_ZBF,
-+  INSN_CLASS_ZBP_OR_ZBE_OR_ZBF_OR_ZBM,
- };
- 
- /* This structure holds information for a particular instruction.  */
-diff --git a/opcodes/riscv-opc.c b/opcodes/riscv-opc.c
-index f55a01b071..3d9240262c 100644
---- a/opcodes/riscv-opc.c
-+++ b/opcodes/riscv-opc.c
-@@ -24,6 +24,130 @@
- #include "opcode/riscv.h"
- #include <stdio.h>
- 
-+#define MASK_SHAMT (OP_MASK_SHAMT << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV_32     (0b11111 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV_64     (0b111111 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV_P_32   (0b00001 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV_P_64   (0b000001 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV_N_32   (0b00011 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV_N_64   (0b000011 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV_B_32   (0b00111 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV_B_64   (0b000111 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV_H_32   (0b01111 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV_H_64   (0b001111 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV_W_64   (0b011111 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV2_32    (0b11110 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV2_64    (0b111110 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV2_N_32  (0b00010 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV2_N_64  (0b000010 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV2_B_32  (0b00110 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV2_B_64  (0b000110 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV2_H_32  (0b01110 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV2_H_64  (0b001110 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV2_W_64  (0b011110 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV4_32    (0b11100 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV4_64    (0b111100 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV4_B_32  (0b00100 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV4_B_64  (0b000100 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV4_H_32  (0b01100 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV4_H_64  (0b001100 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV4_W_64  (0b011100 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV8_32    (0b11000 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV8_64    (0b111000 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV8_H_32  (0b01000 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV8_H_64  (0b001000 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV8_W_64  (0b011000 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV16_32   (0b10000 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV16_64   (0b110000 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV16_W_64 (0b010000 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_REV32_64   (0b100000 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ZIP_32     (0b1111 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ZIP_64     (0b11111 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ZIP_N_32   (0b0001 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ZIP_N_64   (0b00001 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ZIP_B_32   (0b0011 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ZIP_B_64   (0b00011 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ZIP_H_32   (0b0111 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ZIP_H_64   (0b00111 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ZIP_W_64   (0b01111 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ZIP2_32    (0b1110 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ZIP2_64    (0b11110 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ZIP2_B_32  (0b0010 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ZIP2_B_64  (0b00010 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ZIP2_H_32  (0b0110 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ZIP2_H_64  (0b00110 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ZIP2_W_64  (0b01110 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ZIP4_32    (0b1100 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ZIP4_64    (0b11100 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ZIP4_H_32  (0b0100 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ZIP4_H_64  (0b00100 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ZIP4_W_64  (0b01100 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ZIP8_32    (0b1000 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ZIP8_64    (0b11000 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ZIP8_W_64  (0b01000 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ZIP16_64   (0b10000 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_UNZIP_32     (0b1111 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_UNZIP_64     (0b11111 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_UNZIP_N_32   (0b0001 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_UNZIP_N_64   (0b00001 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_UNZIP_B_32   (0b0011 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_UNZIP_B_64   (0b00011 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_UNZIP_H_32   (0b0111 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_UNZIP_H_64   (0b00111 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_UNZIP_W_64   (0b01111 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_UNZIP2_32    (0b1110 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_UNZIP2_64    (0b11110 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_UNZIP2_B_32  (0b0010 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_UNZIP2_B_64  (0b00010 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_UNZIP2_H_32  (0b0110 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_UNZIP2_H_64  (0b00110 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_UNZIP2_W_64  (0b01110 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_UNZIP4_32    (0b1100 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_UNZIP4_64    (0b11100 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_UNZIP4_H_32  (0b0100 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_UNZIP4_H_64  (0b00100 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_UNZIP4_W_64  (0b01100 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_UNZIP8_32    (0b1000 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_UNZIP8_64    (0b11000 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_UNZIP8_W_64  (0b01000 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_UNZIP16_64   (0b10000 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC_32     (0b11111 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC_64     (0b111111 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC_P_32   (0b00001 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC_P_64   (0b000001 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC_N_32   (0b00011 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC_N_64   (0b000011 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC_B_32   (0b00111 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC_B_64   (0b000111 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC_H_32   (0b01111 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC_H_64   (0b001111 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC_W_64   (0b011111 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC2_32    (0b11110 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC2_64    (0b111110 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC2_N_32  (0b00010 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC2_N_64  (0b000010 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC2_B_32  (0b00110 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC2_B_64  (0b000110 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC2_H_32  (0b01110 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC2_H_64  (0b001110 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC2_W_64  (0b011110 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC4_32    (0b11100 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC4_64    (0b111100 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC4_B_32  (0b00100 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC4_B_64  (0b000100 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC4_H_32  (0b01100 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC4_H_64  (0b001100 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC4_W_64  (0b011100 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC8_32    (0b11000 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC8_64    (0b111000 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC8_H_32  (0b01000 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC8_H_64  (0b001000 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC8_W_64  (0b011000 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC16_32   (0b10000 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC16_64   (0b110000 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC16_W_64 (0b010000 << OP_SH_SHAMT)
-+#define MATCH_SHAMT_ORC32_64   (0b100000 << OP_SH_SHAMT)
-+
- /* Register names used by gas and objdump.  */
- 
- const char * const riscv_gpr_names_numeric[NGPR] =
-@@ -827,6 +951,198 @@ const struct riscv_opcode riscv_opcodes[] =
- {"clmulh",     0, INSN_CLASS_ZBC,  "d,s,t", MATCH_CLMULH, MASK_CLMULH, match_opcode, 0 },
- {"clmulr",     0, INSN_CLASS_ZBC,  "d,s,t", MATCH_CLMULR, MASK_CLMULR, match_opcode, 0 },
- 
-+/* ZBS instructions */
-+{"bclr",       0, INSN_CLASS_ZBS,  "d,s,t",    MATCH_BCLR, MASK_BCLR, match_opcode, 0 },
-+{"bclri",      0, INSN_CLASS_ZBS,  "d,s,>",    MATCH_BCLRI, MASK_BCLRI, match_opcode, 0 },
-+{"bext",       0, INSN_CLASS_ZBS_OR_ZBE,  "d,s,t",    MATCH_BEXT, MASK_BEXT, match_opcode, 0 },
-+{"bexti",      0, INSN_CLASS_ZBS,  "d,s,>",    MATCH_BEXTI, MASK_BEXTI, match_opcode, 0 },
-+{"binv",       0, INSN_CLASS_ZBS,  "d,s,t",    MATCH_BINV, MASK_BINV, match_opcode, 0 },
-+{"binvi",      0, INSN_CLASS_ZBS,  "d,s,>",    MATCH_BINVI, MASK_BINVI, match_opcode, 0 },
-+{"bset",       0, INSN_CLASS_ZBS,  "d,s,t",    MATCH_BSET, MASK_BSET, match_opcode, 0 },
-+{"bseti",      0, INSN_CLASS_ZBS,  "d,s,>",    MATCH_BSETI, MASK_BSETI, match_opcode, 0 },
-+
-+/* B instructions excluded from spec1.0 */
-+{"rev",       32, INSN_CLASS_ZBP,  "d,s",      MATCH_GREVI|MATCH_SHAMT_REV_32, MASK_GREVI|MASK_SHAMT, match_opcode, 0 },
-+{"rev",       64, INSN_CLASS_ZBP,  "d,s",      MATCH_GREVI|MATCH_SHAMT_REV_64, MASK_GREVI|MASK_SHAMT, match_opcode, 0 },
-+{"rev.p",     32, INSN_CLASS_ZBP,  "d,s",      MATCH_GREVI|MATCH_SHAMT_REV_P_32, MASK_GREVI|MASK_SHAMT, match_opcode, 0 },
-+{"rev.p",     64, INSN_CLASS_ZBP,  "d,s",      MATCH_GREVI|MATCH_SHAMT_REV_P_64, MASK_GREVI|MASK_SHAMT, match_opcode, 0 },
-+{"rev.n",     32, INSN_CLASS_ZBP,  "d,s",      MATCH_GREVI|MATCH_SHAMT_REV_N_32, MASK_GREVI|MASK_SHAMT, match_opcode, 0 },
-+{"rev.n",     64, INSN_CLASS_ZBP,  "d,s",      MATCH_GREVI|MATCH_SHAMT_REV_N_64, MASK_GREVI|MASK_SHAMT, match_opcode, 0 },
-+{"rev.b",     32, INSN_CLASS_ZBP,  "d,s",      MATCH_GREVI|MATCH_SHAMT_REV_B_32, MASK_GREVI|MASK_SHAMT, match_opcode, 0 },
-+{"rev.b",     64, INSN_CLASS_ZBP,  "d,s",      MATCH_GREVI|MATCH_SHAMT_REV_B_64, MASK_GREVI|MASK_SHAMT, match_opcode, 0 },
-+{"rev.h",     32, INSN_CLASS_ZBP,  "d,s",      MATCH_GREVI|MATCH_SHAMT_REV_H_32, MASK_GREVI|MASK_SHAMT, match_opcode, 0 },
-+{"rev.h",     64, INSN_CLASS_ZBP,  "d,s",      MATCH_GREVI|MATCH_SHAMT_REV_H_64, MASK_GREVI|MASK_SHAMT, match_opcode, 0 },
-+{"rev.w",     64, INSN_CLASS_ZBP,  "d,s",      MATCH_GREVI|MATCH_SHAMT_REV_W_64, MASK_GREVI|MASK_SHAMT, match_opcode, 0 },
-+{"rev2",      32, INSN_CLASS_ZBP,  "d,s",      MATCH_GREVI|MATCH_SHAMT_REV2_32, MASK_GREVI|MASK_SHAMT, match_opcode, 0 },
-+{"rev2",      64, INSN_CLASS_ZBP,  "d,s",      MATCH_GREVI|MATCH_SHAMT_REV2_64, MASK_GREVI|MASK_SHAMT, match_opcode, 0 },
-+{"rev2.n",    32, INSN_CLASS_ZBP,  "d,s",      MATCH_GREVI|MATCH_SHAMT_REV2_N_32, MASK_GREVI|MASK_SHAMT, match_opcode, 0 },
-+{"rev2.n",    64, INSN_CLASS_ZBP,  "d,s",      MATCH_GREVI|MATCH_SHAMT_REV2_N_64, MASK_GREVI|MASK_SHAMT, match_opcode, 0 },
-+{"rev2.b",    32, INSN_CLASS_ZBP,  "d,s",      MATCH_GREVI|MATCH_SHAMT_REV2_B_32, MASK_GREVI|MASK_SHAMT, match_opcode, 0 },
-+{"rev2.b",    64, INSN_CLASS_ZBP,  "d,s",      MATCH_GREVI|MATCH_SHAMT_REV2_B_64, MASK_GREVI|MASK_SHAMT, match_opcode, 0 },
-+{"rev2.h",    32, INSN_CLASS_ZBP,  "d,s",      MATCH_GREVI|MATCH_SHAMT_REV2_H_32, MASK_GREVI|MASK_SHAMT, match_opcode, 0 },
-+{"rev2.h",    64, INSN_CLASS_ZBP,  "d,s",      MATCH_GREVI|MATCH_SHAMT_REV2_H_64, MASK_GREVI|MASK_SHAMT, match_opcode, 0 },
-+{"rev2.w",    64, INSN_CLASS_ZBP,  "d,s",      MATCH_GREVI|MATCH_SHAMT_REV2_W_64, MASK_GREVI|MASK_SHAMT, match_opcode, 0 },
-+{"rev4",      32, INSN_CLASS_ZBP,  "d,s",      MATCH_GREVI|MATCH_SHAMT_REV4_32, MASK_GREVI|MASK_SHAMT, match_opcode, 0 },
-+{"rev4",      64, INSN_CLASS_ZBP,  "d,s",      MATCH_GREVI|MATCH_SHAMT_REV4_64, MASK_GREVI|MASK_SHAMT, match_opcode, 0 },
-+{"rev4.b",    32, INSN_CLASS_ZBP,  "d,s",      MATCH_GREVI|MATCH_SHAMT_REV4_B_32, MASK_GREVI|MASK_SHAMT, match_opcode, 0 },
-+{"rev4.b",    64, INSN_CLASS_ZBP,  "d,s",      MATCH_GREVI|MATCH_SHAMT_REV4_B_64, MASK_GREVI|MASK_SHAMT, match_opcode, 0 },
-+{"rev4.h",    32, INSN_CLASS_ZBP,  "d,s",      MATCH_GREVI|MATCH_SHAMT_REV4_H_32, MASK_GREVI|MASK_SHAMT, match_opcode, 0 },
-+{"rev4.h",    64, INSN_CLASS_ZBP,  "d,s",      MATCH_GREVI|MATCH_SHAMT_REV4_H_64, MASK_GREVI|MASK_SHAMT, match_opcode, 0 },
-+{"rev4.w",    64, INSN_CLASS_ZBP,  "d,s",      MATCH_GREVI|MATCH_SHAMT_REV4_W_64, MASK_GREVI|MASK_SHAMT, match_opcode, 0 },
-+{"rev8.h",    32, INSN_CLASS_ZBP,  "d,s",      MATCH_GREVI|MATCH_SHAMT_REV8_H_32, MASK_GREVI|MASK_SHAMT, match_opcode, 0 },
-+{"rev8.h",    64, INSN_CLASS_ZBP,  "d,s",      MATCH_GREVI|MATCH_SHAMT_REV8_H_64, MASK_GREVI|MASK_SHAMT, match_opcode, 0 },
-+{"rev8.w",    64, INSN_CLASS_ZBP,  "d,s",      MATCH_GREVI|MATCH_SHAMT_REV8_W_64, MASK_GREVI|MASK_SHAMT, match_opcode, 0 },
-+{"rev16",     32, INSN_CLASS_ZBP,  "d,s",      MATCH_GREVI|MATCH_SHAMT_REV16_32, MASK_GREVI|MASK_SHAMT, match_opcode, 0 },
-+{"rev16",     64, INSN_CLASS_ZBP,  "d,s",      MATCH_GREVI|MATCH_SHAMT_REV16_64, MASK_GREVI|MASK_SHAMT, match_opcode, 0 },
-+{"rev16.w",   64, INSN_CLASS_ZBP,  "d,s",      MATCH_GREVI|MATCH_SHAMT_REV16_W_64, MASK_GREVI|MASK_SHAMT, match_opcode, 0 },
-+{"rev32",     64, INSN_CLASS_ZBP,  "d,s",      MATCH_GREVI|MATCH_SHAMT_REV32_64, MASK_GREVI|MASK_SHAMT, match_opcode, 0 },
-+{"zip",       32, INSN_CLASS_ZBP,  "d,s",      MATCH_SHFLI|MATCH_SHAMT_ZIP_32, MASK_SHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"zip",       64, INSN_CLASS_ZBP,  "d,s",      MATCH_SHFLI|MATCH_SHAMT_ZIP_64, MASK_SHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"zip.n",     32, INSN_CLASS_ZBP,  "d,s",      MATCH_SHFLI|MATCH_SHAMT_ZIP_N_32, MASK_SHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"zip.n",     64, INSN_CLASS_ZBP,  "d,s",      MATCH_SHFLI|MATCH_SHAMT_ZIP_N_64, MASK_SHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"zip.b",     32, INSN_CLASS_ZBP,  "d,s",      MATCH_SHFLI|MATCH_SHAMT_ZIP_B_32, MASK_SHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"zip.b",     64, INSN_CLASS_ZBP,  "d,s",      MATCH_SHFLI|MATCH_SHAMT_ZIP_B_64, MASK_SHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"zip.h",     32, INSN_CLASS_ZBP,  "d,s",      MATCH_SHFLI|MATCH_SHAMT_ZIP_H_32, MASK_SHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"zip.h",     64, INSN_CLASS_ZBP,  "d,s",      MATCH_SHFLI|MATCH_SHAMT_ZIP_H_64, MASK_SHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"zip.w",     64, INSN_CLASS_ZBP,  "d,s",      MATCH_SHFLI|MATCH_SHAMT_ZIP_W_64, MASK_SHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"zip2",      32, INSN_CLASS_ZBP,  "d,s",      MATCH_SHFLI|MATCH_SHAMT_ZIP2_32, MASK_SHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"zip2",      64, INSN_CLASS_ZBP,  "d,s",      MATCH_SHFLI|MATCH_SHAMT_ZIP2_64, MASK_SHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"zip2.b",    32, INSN_CLASS_ZBP,  "d,s",      MATCH_SHFLI|MATCH_SHAMT_ZIP2_B_32, MASK_SHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"zip2.b",    64, INSN_CLASS_ZBP,  "d,s",      MATCH_SHFLI|MATCH_SHAMT_ZIP2_B_64, MASK_SHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"zip2.h",    32, INSN_CLASS_ZBP,  "d,s",      MATCH_SHFLI|MATCH_SHAMT_ZIP2_H_32, MASK_SHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"zip2.h",    64, INSN_CLASS_ZBP,  "d,s",      MATCH_SHFLI|MATCH_SHAMT_ZIP2_H_64, MASK_SHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"zip2.w",    64, INSN_CLASS_ZBP,  "d,s",      MATCH_SHFLI|MATCH_SHAMT_ZIP2_W_64, MASK_SHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"zip4",      32, INSN_CLASS_ZBP,  "d,s",      MATCH_SHFLI|MATCH_SHAMT_ZIP4_32, MASK_SHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"zip4",      64, INSN_CLASS_ZBP,  "d,s",      MATCH_SHFLI|MATCH_SHAMT_ZIP4_64, MASK_SHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"zip4.h",    32, INSN_CLASS_ZBP,  "d,s",      MATCH_SHFLI|MATCH_SHAMT_ZIP4_H_32, MASK_SHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"zip4.h",    64, INSN_CLASS_ZBP,  "d,s",      MATCH_SHFLI|MATCH_SHAMT_ZIP4_H_64, MASK_SHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"zip4.w",    64, INSN_CLASS_ZBP,  "d,s",      MATCH_SHFLI|MATCH_SHAMT_ZIP4_W_64, MASK_SHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"zip8",      32, INSN_CLASS_ZBP,  "d,s",      MATCH_SHFLI|MATCH_SHAMT_ZIP8_32, MASK_SHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"zip8",      64, INSN_CLASS_ZBP,  "d,s",      MATCH_SHFLI|MATCH_SHAMT_ZIP8_64, MASK_SHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"zip8.w",    64, INSN_CLASS_ZBP,  "d,s",      MATCH_SHFLI|MATCH_SHAMT_ZIP8_W_64, MASK_SHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"zip16",     64, INSN_CLASS_ZBP,  "d,s",      MATCH_SHFLI|MATCH_SHAMT_ZIP16_64, MASK_SHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"unzip",     32, INSN_CLASS_ZBP,  "d,s",      MATCH_UNSHFLI|MATCH_SHAMT_UNZIP_32, MASK_UNSHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"unzip",     64, INSN_CLASS_ZBP,  "d,s",      MATCH_UNSHFLI|MATCH_SHAMT_UNZIP_64, MASK_UNSHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"unzip.n",   32, INSN_CLASS_ZBP,  "d,s",      MATCH_UNSHFLI|MATCH_SHAMT_UNZIP_N_32, MASK_UNSHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"unzip.n",   64, INSN_CLASS_ZBP,  "d,s",      MATCH_UNSHFLI|MATCH_SHAMT_UNZIP_N_64, MASK_UNSHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"unzip.b",   32, INSN_CLASS_ZBP,  "d,s",      MATCH_UNSHFLI|MATCH_SHAMT_UNZIP_B_32, MASK_UNSHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"unzip.b",   64, INSN_CLASS_ZBP,  "d,s",      MATCH_UNSHFLI|MATCH_SHAMT_UNZIP_B_64, MASK_UNSHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"unzip.h",   32, INSN_CLASS_ZBP,  "d,s",      MATCH_UNSHFLI|MATCH_SHAMT_UNZIP_H_32, MASK_UNSHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"unzip.h",   64, INSN_CLASS_ZBP,  "d,s",      MATCH_UNSHFLI|MATCH_SHAMT_UNZIP_H_64, MASK_UNSHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"unzip.w",   64, INSN_CLASS_ZBP,  "d,s",      MATCH_UNSHFLI|MATCH_SHAMT_UNZIP_W_64, MASK_UNSHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"unzip2",    32, INSN_CLASS_ZBP,  "d,s",      MATCH_UNSHFLI|MATCH_SHAMT_UNZIP2_32, MASK_UNSHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"unzip2",    64, INSN_CLASS_ZBP,  "d,s",      MATCH_UNSHFLI|MATCH_SHAMT_UNZIP2_64, MASK_UNSHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"unzip2.b",  32, INSN_CLASS_ZBP,  "d,s",      MATCH_UNSHFLI|MATCH_SHAMT_UNZIP2_B_32, MASK_UNSHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"unzip2.b",  64, INSN_CLASS_ZBP,  "d,s",      MATCH_UNSHFLI|MATCH_SHAMT_UNZIP2_B_64, MASK_UNSHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"unzip2.h",  32, INSN_CLASS_ZBP,  "d,s",      MATCH_UNSHFLI|MATCH_SHAMT_UNZIP2_H_32, MASK_UNSHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"unzip2.h",  64, INSN_CLASS_ZBP,  "d,s",      MATCH_UNSHFLI|MATCH_SHAMT_UNZIP2_H_64, MASK_UNSHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"unzip2.w",  64, INSN_CLASS_ZBP,  "d,s",      MATCH_UNSHFLI|MATCH_SHAMT_UNZIP2_W_64, MASK_UNSHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"unzip4",    32, INSN_CLASS_ZBP,  "d,s",      MATCH_UNSHFLI|MATCH_SHAMT_UNZIP4_32, MASK_UNSHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"unzip4",    64, INSN_CLASS_ZBP,  "d,s",      MATCH_UNSHFLI|MATCH_SHAMT_UNZIP4_64, MASK_UNSHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"unzip4.h",  32, INSN_CLASS_ZBP,  "d,s",      MATCH_UNSHFLI|MATCH_SHAMT_UNZIP4_H_32, MASK_UNSHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"unzip4.h",  64, INSN_CLASS_ZBP,  "d,s",      MATCH_UNSHFLI|MATCH_SHAMT_UNZIP4_H_64, MASK_UNSHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"unzip4.w",  64, INSN_CLASS_ZBP,  "d,s",      MATCH_UNSHFLI|MATCH_SHAMT_UNZIP4_W_64, MASK_UNSHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"unzip8",    32, INSN_CLASS_ZBP,  "d,s",      MATCH_UNSHFLI|MATCH_SHAMT_UNZIP8_32, MASK_UNSHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"unzip8",    64, INSN_CLASS_ZBP,  "d,s",      MATCH_UNSHFLI|MATCH_SHAMT_UNZIP8_64, MASK_UNSHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"unzip8.w",  64, INSN_CLASS_ZBP,  "d,s",      MATCH_UNSHFLI|MATCH_SHAMT_UNZIP8_W_64, MASK_UNSHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"unzip16",   64, INSN_CLASS_ZBP,  "d,s",      MATCH_UNSHFLI|MATCH_SHAMT_UNZIP16_64, MASK_UNSHFLI|MASK_SHAMT, match_opcode, 0 },
-+{"orc",       32, INSN_CLASS_ZBP,  "d,s",      MATCH_GORCI|MATCH_SHAMT_ORC_32, MASK_GORCI|MASK_SHAMT, match_opcode, 0 },
-+{"orc",       64, INSN_CLASS_ZBP,  "d,s",      MATCH_GORCI|MATCH_SHAMT_ORC_64, MASK_GORCI|MASK_SHAMT, match_opcode, 0 },
-+{"orc.p",     32, INSN_CLASS_ZBP,  "d,s",      MATCH_GORCI|MATCH_SHAMT_ORC_P_32, MASK_GORCI|MASK_SHAMT, match_opcode, 0 },
-+{"orc.p",     64, INSN_CLASS_ZBP,  "d,s",      MATCH_GORCI|MATCH_SHAMT_ORC_P_64, MASK_GORCI|MASK_SHAMT, match_opcode, 0 },
-+{"orc.n",     32, INSN_CLASS_ZBP,  "d,s",      MATCH_GORCI|MATCH_SHAMT_ORC_N_32, MASK_GORCI|MASK_SHAMT, match_opcode, 0 },
-+{"orc.n",     64, INSN_CLASS_ZBP,  "d,s",      MATCH_GORCI|MATCH_SHAMT_ORC_N_64, MASK_GORCI|MASK_SHAMT, match_opcode, 0 },
-+{"orc.h",     32, INSN_CLASS_ZBP,  "d,s",      MATCH_GORCI|MATCH_SHAMT_ORC_H_32, MASK_GORCI|MASK_SHAMT, match_opcode, 0 },
-+{"orc.h",     64, INSN_CLASS_ZBP,  "d,s",      MATCH_GORCI|MATCH_SHAMT_ORC_H_64, MASK_GORCI|MASK_SHAMT, match_opcode, 0 },
-+{"orc.w",     64, INSN_CLASS_ZBP,  "d,s",      MATCH_GORCI|MATCH_SHAMT_ORC_W_64, MASK_GORCI|MASK_SHAMT, match_opcode, 0 },
-+{"orc2",      32, INSN_CLASS_ZBP,  "d,s",      MATCH_GORCI|MATCH_SHAMT_ORC2_32, MASK_GORCI|MASK_SHAMT, match_opcode, 0 },
-+{"orc2",      64, INSN_CLASS_ZBP,  "d,s",      MATCH_GORCI|MATCH_SHAMT_ORC2_64, MASK_GORCI|MASK_SHAMT, match_opcode, 0 },
-+{"orc2.n",    32, INSN_CLASS_ZBP,  "d,s",      MATCH_GORCI|MATCH_SHAMT_ORC2_N_32, MASK_GORCI|MASK_SHAMT, match_opcode, 0 },
-+{"orc2.n",    64, INSN_CLASS_ZBP,  "d,s",      MATCH_GORCI|MATCH_SHAMT_ORC2_N_64, MASK_GORCI|MASK_SHAMT, match_opcode, 0 },
-+{"orc2.b",    32, INSN_CLASS_ZBP,  "d,s",      MATCH_GORCI|MATCH_SHAMT_ORC2_B_32, MASK_GORCI|MASK_SHAMT, match_opcode, 0 },
-+{"orc2.b",    64, INSN_CLASS_ZBP,  "d,s",      MATCH_GORCI|MATCH_SHAMT_ORC2_B_64, MASK_GORCI|MASK_SHAMT, match_opcode, 0 },
-+{"orc2.h",    32, INSN_CLASS_ZBP,  "d,s",      MATCH_GORCI|MATCH_SHAMT_ORC2_H_32, MASK_GORCI|MASK_SHAMT, match_opcode, 0 },
-+{"orc2.h",    64, INSN_CLASS_ZBP,  "d,s",      MATCH_GORCI|MATCH_SHAMT_ORC2_H_64, MASK_GORCI|MASK_SHAMT, match_opcode, 0 },
-+{"orc2.w",    64, INSN_CLASS_ZBP,  "d,s",      MATCH_GORCI|MATCH_SHAMT_ORC2_W_64, MASK_GORCI|MASK_SHAMT, match_opcode, 0 },
-+{"orc4",      32, INSN_CLASS_ZBP,  "d,s",      MATCH_GORCI|MATCH_SHAMT_ORC4_32, MASK_GORCI|MASK_SHAMT, match_opcode, 0 },
-+{"orc4",      64, INSN_CLASS_ZBP,  "d,s",      MATCH_GORCI|MATCH_SHAMT_ORC4_64, MASK_GORCI|MASK_SHAMT, match_opcode, 0 },
-+{"orc4.b",    32, INSN_CLASS_ZBP,  "d,s",      MATCH_GORCI|MATCH_SHAMT_ORC4_B_32, MASK_GORCI|MASK_SHAMT, match_opcode, 0 },
-+{"orc4.b",    64, INSN_CLASS_ZBP,  "d,s",      MATCH_GORCI|MATCH_SHAMT_ORC4_B_64, MASK_GORCI|MASK_SHAMT, match_opcode, 0 },
-+{"orc4.h",    32, INSN_CLASS_ZBP,  "d,s",      MATCH_GORCI|MATCH_SHAMT_ORC4_H_32, MASK_GORCI|MASK_SHAMT, match_opcode, 0 },
-+{"orc4.h",    64, INSN_CLASS_ZBP,  "d,s",      MATCH_GORCI|MATCH_SHAMT_ORC4_H_64, MASK_GORCI|MASK_SHAMT, match_opcode, 0 },
-+{"orc4.w",    64, INSN_CLASS_ZBP,  "d,s",      MATCH_GORCI|MATCH_SHAMT_ORC4_W_64, MASK_GORCI|MASK_SHAMT, match_opcode, 0 },
-+{"orc8",      32, INSN_CLASS_ZBP,  "d,s",      MATCH_GORCI|MATCH_SHAMT_ORC8_32, MASK_GORCI|MASK_SHAMT, match_opcode, 0 },
-+{"orc8",      64, INSN_CLASS_ZBP,  "d,s",      MATCH_GORCI|MATCH_SHAMT_ORC8_64, MASK_GORCI|MASK_SHAMT, match_opcode, 0 },
-+{"orc8.h",    32, INSN_CLASS_ZBP,  "d,s",      MATCH_GORCI|MATCH_SHAMT_ORC8_H_32, MASK_GORCI|MASK_SHAMT, match_opcode, 0 },
-+{"orc8.h",    64, INSN_CLASS_ZBP,  "d,s",      MATCH_GORCI|MATCH_SHAMT_ORC8_H_64, MASK_GORCI|MASK_SHAMT, match_opcode, 0 },
-+{"orc8.w",    64, INSN_CLASS_ZBP,  "d,s",      MATCH_GORCI|MATCH_SHAMT_ORC8_W_64, MASK_GORCI|MASK_SHAMT, match_opcode, 0 },
-+{"orc16",     32, INSN_CLASS_ZBP,  "d,s",      MATCH_GORCI|MATCH_SHAMT_ORC16_32, MASK_GORCI|MASK_SHAMT, match_opcode, 0 },
-+{"orc16",     64, INSN_CLASS_ZBP,  "d,s",      MATCH_GORCI|MATCH_SHAMT_ORC16_64, MASK_GORCI|MASK_SHAMT, match_opcode, 0 },
-+{"orc16.w",   64, INSN_CLASS_ZBP,  "d,s",      MATCH_GORCI|MATCH_SHAMT_ORC16_W_64, MASK_GORCI|MASK_SHAMT, match_opcode, 0 },
-+{"orc32",     64, INSN_CLASS_ZBP,  "d,s",      MATCH_GORCI|MATCH_SHAMT_ORC32_64, MASK_GORCI|MASK_SHAMT, match_opcode, 0 },
-+{"pack",       0, INSN_CLASS_ZBP_OR_ZBE_OR_ZBF_OR_ZBM,  "d,s,t",    MATCH_PACK, MASK_PACK, match_opcode, 0 },
-+{"packu",      0, INSN_CLASS_ZBP_OR_ZBM,  "d,s,t",    MATCH_PACKU, MASK_PACKU, match_opcode, 0 },
-+{"packh",      0, INSN_CLASS_ZBP_OR_ZBE_OR_ZBF,  "d,s,t",    MATCH_PACKH, MASK_PACKH, match_opcode, 0 },
-+{"packw",     64, INSN_CLASS_ZBP_OR_ZBE_OR_ZBF,  "d,s,<",    MATCH_PACKW, MASK_PACKW, match_opcode, 0 },
-+{"packuw",    64, INSN_CLASS_ZBP,  "d,s,<",    MATCH_PACKUW, MASK_PACKUW, match_opcode, 0 },
-+{"grev",       0, INSN_CLASS_ZBP,  "d,s,t",    MATCH_GREV, MASK_GREV, match_opcode, 0 },
-+{"grevi",      0, INSN_CLASS_ZBP,  "d,s,>",    MATCH_GREVI, MASK_GREVI, match_opcode, 0 },
-+{"grevw",     64, INSN_CLASS_ZBP,  "d,s,<",    MATCH_GREVW, MASK_GREVW, match_opcode, 0 },
-+{"greviw",    64, INSN_CLASS_ZBP,  "d,s,<",    MATCH_GREVIW, MASK_GREVIW, match_opcode, 0 },
-+{"gorc",       0, INSN_CLASS_ZBP,  "d,s,t",    MATCH_GORC, MASK_GORC, match_opcode, 0 },
-+{"gorci",      0, INSN_CLASS_ZBP,  "d,s,>",    MATCH_GORCI, MASK_GORCI, match_opcode, 0 },
-+{"gorcw",     64, INSN_CLASS_ZBP,  "d,s,<",    MATCH_GORCW, MASK_GORCW, match_opcode, 0 },
-+{"gorciw",    64, INSN_CLASS_ZBP,  "d,s,<",    MATCH_GORCIW, MASK_GORCIW, match_opcode, 0 },
-+{"shfl",       0, INSN_CLASS_ZBP,  "d,s,t",    MATCH_SHFL, MASK_SHFL, match_opcode, 0 },
-+{"shfli",      0, INSN_CLASS_ZBP,  "d,s,>",    MATCH_SHFLI, MASK_SHFLI, match_opcode, 0 },
-+{"shflw",     64, INSN_CLASS_ZBP,  "d,s,<",    MATCH_SHFLW, MASK_SHFLW, match_opcode, 0 },
-+{"unshfl",     0, INSN_CLASS_ZBP,  "d,s,t",    MATCH_UNSHFL, MASK_UNSHFL, match_opcode, 0 },
-+{"unshfli",    0, INSN_CLASS_ZBP,  "d,s,>",    MATCH_UNSHFLI, MASK_UNSHFLI, match_opcode, 0 },
-+{"unshflw",   64, INSN_CLASS_ZBP,  "d,s,<",    MATCH_UNSHFLW, MASK_UNSHFLW, match_opcode, 0 },
-+{"xperm.n",    0, INSN_CLASS_ZBP,  "d,s,t",    MATCH_XPERM_N, MASK_XPERM_N, match_opcode, 0 },
-+{"xperm.b",    0, INSN_CLASS_ZBP,  "d,s,t",    MATCH_XPERM_B, MASK_XPERM_B, match_opcode, 0 },
-+{"xperm.h",    0, INSN_CLASS_ZBP,  "d,s,t",    MATCH_XPERM_H, MASK_XPERM_H, match_opcode, 0 },
-+{"xperm.w",   64, INSN_CLASS_ZBP,  "d,s,<",    MATCH_XPERM_W, MASK_XPERM_W, match_opcode, 0 },
-+{"bcompress",0, INSN_CLASS_ZBE,  "d,s,t",    MATCH_BCOMPRESS, MASK_BCOMPRESS, match_opcode, 0 },
-+{"bdecompress",0, INSN_CLASS_ZBE,  "d,s,t",    MATCH_BDECOMPRESS, MASK_BDECOMPRESS, match_opcode, 0 },
-+{"bsetw",     64, INSN_CLASS_ZBS,  "d,s,t",    MATCH_BSETW, MASK_BSETW, match_opcode, 0 },
-+{"bclrw",     64, INSN_CLASS_ZBS,  "d,s,t",    MATCH_BCLRW, MASK_BCLRW, match_opcode, 0 },
-+{"binvw",     64, INSN_CLASS_ZBS,  "d,s,t",    MATCH_BINVW, MASK_BINVW, match_opcode, 0 },
-+{"bextw",     64, INSN_CLASS_ZBS_OR_ZBE,  "d,s,t",    MATCH_BEXTW, MASK_BEXTW, match_opcode, 0 },
-+{"bcompressw",64, INSN_CLASS_ZBE,  "d,s,<",    MATCH_BCOMPRESSW, MASK_BCOMPRESSW, match_opcode, 0 },
-+{"bdecompressw",64, INSN_CLASS_ZBE,  "d,s,<",    MATCH_BDECOMPRESSW, MASK_BDECOMPRESSW, match_opcode, 0 },
-+{"bsetiw",    64, INSN_CLASS_ZBS,  "d,s,<",    MATCH_BSETIW, MASK_BSETIW, match_opcode, 0 },
-+{"bclriw",    64, INSN_CLASS_ZBS,  "d,s,<",    MATCH_BCLRIW, MASK_BCLRIW, match_opcode, 0 },
-+{"binviw",    64, INSN_CLASS_ZBS,  "d,s,<",    MATCH_BINVIW, MASK_BINVIW, match_opcode, 0 },
-+{"slo",        0, INSN_CLASS_ZBS,  "d,s,t",    MATCH_SLO, MASK_SLO, match_opcode, 0 },
-+{"sro",        0, INSN_CLASS_ZBS,  "d,s,t",    MATCH_SRO, MASK_SRO, match_opcode, 0 },
-+{"sloi",       0, INSN_CLASS_ZBS,  "d,s,>",    MATCH_SLOI, MASK_SLOI, match_opcode, 0 },
-+{"sroi",       0, INSN_CLASS_ZBS,  "d,s,>",    MATCH_SROI, MASK_SROI, match_opcode, 0 },
-+{"slow",      64, INSN_CLASS_ZBS,  "d,s,<",    MATCH_SLOW, MASK_SLOW, match_opcode, 0 },
-+{"srow",      64, INSN_CLASS_ZBS,  "d,s,<",    MATCH_SROW, MASK_SROW, match_opcode, 0 },
-+{"sloiw",     64, INSN_CLASS_ZBS,  "d,s,<",    MATCH_SLOIW, MASK_SLOIW, match_opcode, 0 },
-+{"sroiw",     64, INSN_CLASS_ZBS,  "d,s,<",    MATCH_SROIW, MASK_SROIW, match_opcode, 0 },
-+{"bfp",        0, INSN_CLASS_ZBF,  "d,s,t",    MATCH_BFP, MASK_BFP, match_opcode, 0 },
-+{"bfpw",      64, INSN_CLASS_ZBF,  "d,s,<",    MATCH_BFPW, MASK_BFPW, match_opcode, 0 },
-+{"bmator",    64, INSN_CLASS_ZBM,  "d,s,t",    MATCH_BMATOR, MASK_BMATOR, match_opcode, 0 },
-+{"bmatxor",   64, INSN_CLASS_ZBM,  "d,s,t",    MATCH_BMATXOR, MASK_BMATXOR, match_opcode, 0 },
-+{"bmatflip",  64, INSN_CLASS_ZBM,  "d,s",      MATCH_BMATFLIP, MASK_BMATFLIP, match_opcode, 0 },
-+{"crc32.b",    0, INSN_CLASS_ZBR,  "d,s",      MATCH_CRC32_B, MASK_CRC32_B, match_opcode, 0 },
-+{"crc32.h",    0, INSN_CLASS_ZBR,  "d,s",      MATCH_CRC32_H, MASK_CRC32_H, match_opcode, 0 },
-+{"crc32.w",    0, INSN_CLASS_ZBR,  "d,s",      MATCH_CRC32_W, MASK_CRC32_W, match_opcode, 0 },
-+{"crc32c.b",   0, INSN_CLASS_ZBR,  "d,s",      MATCH_CRC32C_B, MASK_CRC32C_B, match_opcode, 0 },
-+{"crc32c.h",   0, INSN_CLASS_ZBR,  "d,s",      MATCH_CRC32C_H, MASK_CRC32C_H, match_opcode, 0 },
-+{"crc32c.w",   0, INSN_CLASS_ZBR,  "d,s",      MATCH_CRC32C_W, MASK_CRC32C_W, match_opcode, 0 },
-+{"crc32.d",   64, INSN_CLASS_ZBR,  "d,s",      MATCH_CRC32_D, MASK_CRC32_D, match_opcode, 0 },
-+{"crc32c.d",  64, INSN_CLASS_ZBR,  "d,s",      MATCH_CRC32C_D, MASK_CRC32C_D, match_opcode, 0 },
-+{"cmix",       0, INSN_CLASS_ZBT,  "d,s,t,r",  MATCH_CMIX, MASK_CMIX, match_opcode, 0 },
-+{"cmov",       0, INSN_CLASS_ZBT,  "d,s,t,r",  MATCH_CMOV, MASK_CMOV, match_opcode, 0 },
-+{"fsl",        0, INSN_CLASS_ZBT,  "d,s,t,r",  MATCH_FSL, MASK_FSL, match_opcode, 0 },
-+{"fsr",        0, INSN_CLASS_ZBT,  "d,s,t,r",  MATCH_FSR, MASK_FSR, match_opcode, 0 },
-+{"fsri",       0, INSN_CLASS_ZBT,  "d,s,>,r",  MATCH_FSRI, MASK_FSRI, match_opcode, 0 },
-+{"fslw",      64, INSN_CLASS_ZBT,  "d,s,<,r",  MATCH_FSLW, MASK_FSLW, match_opcode, 0 },
-+{"fsrw",      64, INSN_CLASS_ZBT,  "d,s,<,r",  MATCH_FSRW, MASK_FSRW, match_opcode, 0 },
-+{"fsriw",     64, INSN_CLASS_ZBT,  "d,s,<,r",  MATCH_FSRIW, MASK_FSRIW, match_opcode, 0 },
- 
- /* Terminate the list.  */
- {0, 0, INSN_CLASS_NONE, 0, 0, 0, 0, 0}
--- 
-2.33.1
-

+ 25 - 0
recipes-devtools/binutils/binutils/0002-Automatic-date-update-in-version.in.patch

@@ -0,0 +1,25 @@
+From 8b5c16b504a5af8508b3fc72ae7b0edcb9857be8 Mon Sep 17 00:00:00 2001
+From: GDB Administrator <gdbadmin@sourceware.org>
+Date: Sun, 21 Aug 2022 00:05:27 +0000
+Subject: [PATCH 02/20] Automatic date update in version.in
+
+---
+ bfd/version.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/bfd/version.h b/bfd/version.h
+index c5c3ce4fd5..d15b543bdb 100644
+--- a/bfd/version.h
++++ b/bfd/version.h
+@@ -16,7 +16,7 @@
+ 
+    In releases, the date is not included in either version strings or
+    sonames.  */
+-#define BFD_VERSION_DATE 20220820
++#define BFD_VERSION_DATE 20220821
+ #define BFD_VERSION @bfd_version@
+ #define BFD_VERSION_STRING  @bfd_version_package@ @bfd_version_string@
+ #define REPORT_BUGS_TO @report_bugs_to@
+-- 
+2.25.1
+

+ 2 - 2
recipes-devtools/binutils/binutils/0002-binutils-cross-Do-not-generate-linker-script-directo.patch

@@ -1,4 +1,4 @@
-From 6e93d0328f499569db7ce6396f94f304ce340df8 Mon Sep 17 00:00:00 2001
+From fd7065bfd20364679e3c3f329b19059bbc51ab02 Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Mon, 6 Mar 2017 23:37:05 -0800
 Subject: [PATCH] binutils-cross: Do not generate linker script directories
@@ -22,7 +22,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
  1 file changed, 25 deletions(-)
 
 diff --git a/ld/genscripts.sh b/ld/genscripts.sh
-index 46a2db7005c..4bb7c33f560 100755
+index 0c52ebee4d0..1acbe66bd2e 100755
 --- a/ld/genscripts.sh
 +++ b/ld/genscripts.sh
 @@ -235,31 +235,6 @@ append_to_lib_path()

Some files were not shown because too many files changed in this diff