]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
binutils: backport gold changes to use mallinfo2 instead of deprecated mallinfo jansa/binutils
authorMartin Jansa <Martin.Jansa@gmail.com>
Wed, 12 May 2021 15:42:36 +0000 (17:42 +0200)
committerMartin Jansa <Martin.Jansa@gmail.com>
Wed, 12 May 2021 15:47:39 +0000 (17:47 +0200)
* mallinfo got deprecacted in glibc-2.33 with:
  https://sourceware.org/git/?p=glibc.git;a=commit;h=e3960d1c57e57f33e0e846d615788f4ede73b945
  https://sourceware.org/git/?p=glibc.git;a=commit;h=30e5069c7d4b51288d3e6f75f53a6ad2f5e71b0f
* resolves this warning:
  oe-core$ grep mallinfo tmp-glibc/work/x86_64-linux/binutils-cross-x86_64/2.36.1-r0/temp/log.do_compile
  checking whether sbrk is declared... checking for mallinfo... yes
  ../../gold/main.cc:294:36: warning: ‘mallinfo mallinfo()’ is deprecated [-Wdeprecated-declarations]
* after:
  oe-core$ grep mallinfo tmp-glibc/work/x86_64-linux/binutils-cross-x86_64/2.36.1-r0/temp/log.do_compile
  checking for struct stat.st_mtim.tv_nsec in sys/stat.h... checking for mallinfo... yes
  checking whether snprintf is declared... checking for mallinfo2... configure: updating cache ./config.cache

  the configure output is badly mixed together, but mallinfo2 support was detected OK:
  oe-core$ grep _mallinfo tmp-glibc/work/x86_64-linux/binutils-cross-x86_64/2.36.1-r0/git/build.x86_64-linux.x86_64-oe-linux/gold/config.log
  ac_cv_func_mallinfo2=yes
  ac_cv_func_mallinfo=yes

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
meta/recipes-devtools/binutils/binutils-2.36.inc
meta/recipes-devtools/binutils/binutils/0019-Fix-gold-to-use-mallinfo2-if-available-instead-of-de.patch [new file with mode: 0644]
meta/recipes-devtools/binutils/binutils/0020-Fix-typo-in-previous-patch-should-use-struct-mallinf.patch [new file with mode: 0644]
meta/recipes-devtools/binutils/binutils/0021-Regenerate-config.in-missing-from-previous-commit.patch [new file with mode: 0644]

index d54e2a34576eb022ac2859196fb14def21358e34..5dd9141ea7e16089de07d8275358dfeaab18bdd0 100644 (file)
@@ -37,6 +37,9 @@ SRC_URI = "\
      file://0016-Check-for-clang-before-checking-gcc-version.patch \
      file://0017-Add-support-for-the-DW_FORM_strx-forms-to-the-BFD-li.patch \
      file://0018-Add-DWARF-5-support-in-gold.patch \
+     file://0019-Fix-gold-to-use-mallinfo2-if-available-instead-of-de.patch \
+     file://0020-Fix-typo-in-previous-patch-should-use-struct-mallinf.patch \
+     file://0021-Regenerate-config.in-missing-from-previous-commit.patch \
      file://CVE-2021-20197.patch \
 "
 S  = "${WORKDIR}/git"
diff --git a/meta/recipes-devtools/binutils/binutils/0019-Fix-gold-to-use-mallinfo2-if-available-instead-of-de.patch b/meta/recipes-devtools/binutils/binutils/0019-Fix-gold-to-use-mallinfo2-if-available-instead-of-de.patch
new file mode 100644 (file)
index 0000000..d6e4e25
--- /dev/null
@@ -0,0 +1,78 @@
+From 5a47430c1dc7b998b9db3ca9e4c93394c7a9972e Mon Sep 17 00:00:00 2001
+From: Duncan Simpson <dr.duncan.p.simpson@gmail.com>
+Date: Fri, 19 Mar 2021 14:22:08 -0700
+Subject: [PATCH] Fix gold to use mallinfo2 if available instead of deprecated
+ mallinfo.
+
+gold/
+       PR gold/26585
+       * configure.ac: Add check for mallinfo2.
+       * configure: Regenerate.
+       * main.cc (main): Use mallinfo2 if available.
+
+Upstream-Status: Backport [4ee60495054 Fix gold to use mallinfo2 if available instead of deprecated mallinfo.]
+
+Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
+---
+ gold/configure    | 2 +-
+ gold/configure.ac | 2 +-
+ gold/main.cc      | 9 +++++++--
+ 3 files changed, 9 insertions(+), 4 deletions(-)
+
+diff --git a/gold/configure b/gold/configure
+index e264a65ac3c..b9f062b68eb 100755
+--- a/gold/configure
++++ b/gold/configure
+@@ -9967,7 +9967,7 @@ case "$ac_cv_search_dlopen" in
+ esac
+-for ac_func in mallinfo posix_fallocate fallocate readv sysconf times mkdtemp
++for ac_func in mallinfo mallinfo2 posix_fallocate fallocate readv sysconf times mkdtemp
+ do :
+   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ ac_fn_cxx_check_func "$LINENO" "$ac_func" "$as_ac_var"
+diff --git a/gold/configure.ac b/gold/configure.ac
+index eed45664093..1716a779416 100644
+--- a/gold/configure.ac
++++ b/gold/configure.ac
+@@ -636,7 +636,7 @@ case "$ac_cv_search_dlopen" in
+ esac
+ AC_SUBST(DLOPEN_LIBS)
+-AC_CHECK_FUNCS(mallinfo posix_fallocate fallocate readv sysconf times mkdtemp)
++AC_CHECK_FUNCS(mallinfo mallinfo2 posix_fallocate fallocate readv sysconf times mkdtemp)
+ AC_CHECK_DECLS([basename, ffs, asprintf, vasprintf, snprintf, vsnprintf, strverscmp, strndup, memmem])
+ # Use of ::std::tr1::unordered_map::rehash causes undefined symbols
+diff --git a/gold/main.cc b/gold/main.cc
+index ea77ca3ebbe..89bc40b22af 100644
+--- a/gold/main.cc
++++ b/gold/main.cc
+@@ -25,7 +25,7 @@
+ #include <cstdio>
+ #include <cstring>
+-#ifdef HAVE_MALLINFO
++#if defined(HAVE_MALLINFO) || defined(HAVE_MALLINFO2)
+ #include <malloc.h>
+ #endif
+@@ -290,11 +290,16 @@ main(int argc, char** argv)
+               elapsed.sys / 1000, (elapsed.sys % 1000) * 1000,
+               elapsed.wall / 1000, (elapsed.wall % 1000) * 1000);
+-#ifdef HAVE_MALLINFO
++#if defined(HAVE_MALLINFO2)
++      struct mallinfo m = mallinfo2();
++      fprintf(stderr, _("%s: total space allocated by malloc: %lld bytes\n"),
++            program_name, static_cast<long long>(m.arena));
++#elif defined(HAVE_MALLINFO)
+       struct mallinfo m = mallinfo();
+       fprintf(stderr, _("%s: total space allocated by malloc: %lld bytes\n"),
+             program_name, static_cast<long long>(m.arena));
+ #endif
++
+       File_read::print_stats();
+       Archive::print_stats();
+       Lib_group::print_stats();
diff --git a/meta/recipes-devtools/binutils/binutils/0020-Fix-typo-in-previous-patch-should-use-struct-mallinf.patch b/meta/recipes-devtools/binutils/binutils/0020-Fix-typo-in-previous-patch-should-use-struct-mallinf.patch
new file mode 100644 (file)
index 0000000..fe59ba7
--- /dev/null
@@ -0,0 +1,28 @@
+From 0b97c4b07830c0873f0d863ee8a63b294f0112e4 Mon Sep 17 00:00:00 2001
+From: Cary Coutant <ccoutant@gmail.com>
+Date: Fri, 19 Mar 2021 15:29:49 -0700
+Subject: [PATCH] Fix typo in previous patch: should use struct mallinfo2.
+
+       PR gold/26585
+       * main.cc (main): Fix typo in previous patch.
+
+Upstream-Status: Backport [cc1849716f5 Fix typo in previous patch: should use struct mallinfo2.]
+
+Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
+---
+ gold/main.cc | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/gold/main.cc b/gold/main.cc
+index 89bc40b22af..ff44cbb7add 100644
+--- a/gold/main.cc
++++ b/gold/main.cc
+@@ -291,7 +291,7 @@ main(int argc, char** argv)
+               elapsed.wall / 1000, (elapsed.wall % 1000) * 1000);
+ #if defined(HAVE_MALLINFO2)
+-      struct mallinfo m = mallinfo2();
++      struct mallinfo2 m = mallinfo2();
+       fprintf(stderr, _("%s: total space allocated by malloc: %lld bytes\n"),
+             program_name, static_cast<long long>(m.arena));
+ #elif defined(HAVE_MALLINFO)
diff --git a/meta/recipes-devtools/binutils/binutils/0021-Regenerate-config.in-missing-from-previous-commit.patch b/meta/recipes-devtools/binutils/binutils/0021-Regenerate-config.in-missing-from-previous-commit.patch
new file mode 100644 (file)
index 0000000..4f302cc
--- /dev/null
@@ -0,0 +1,29 @@
+From 60d4cc811201809e036a578db74fc4320323d03f Mon Sep 17 00:00:00 2001
+From: Cary Coutant <ccoutant@gmail.com>
+Date: Fri, 19 Mar 2021 15:23:49 -0700
+Subject: [PATCH] Regenerate config.in, missing from previous commit.
+
+       PR gold/26585
+       * config.in: Regenerate from previous commit.
+
+Upstream-Status: Backport [9331846e44b Regenerate config.in, missing from previous commit.]
+
+Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
+---
+ gold/config.in | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/gold/config.in b/gold/config.in
+index aaad1bee706..ca0b9d2e2f9 100644
+--- a/gold/config.in
++++ b/gold/config.in
+@@ -124,6 +124,9 @@
+ /* Define to 1 if you have the `mallinfo' function. */
+ #undef HAVE_MALLINFO
++/* Define to 1 if you have the `mallinfo2' function. */
++#undef HAVE_MALLINFO2
++
+ /* Define to 1 if you have the <memory.h> header file. */
+ #undef HAVE_MEMORY_H