From de41dcf07b49c89ed11681e8b38c941e468a611f Mon Sep 17 00:00:00 2001 From: "yan.yihao 10263201" Date: Fri, 17 Oct 2025 20:34:20 +0800 Subject: [PATCH] tests: fix build against upcoming `gcc-14` (`-Werror=calloc-transposed-args`) `gcc-14` added a new `-Wcalloc-transposed-args` warning recently. It detected minor infelicity in `calloc()` API usage in `elfutils`: elfstrmerge.c: In function 'main': elfstrmerge.c:450:32: error: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Werror=calloc-transposed-args] 450 | newscnbufs = calloc (sizeof (void *), newshnums); | ^~~~ elfstrmerge.c:450:32: note: earlier argument should specify number of elements, later size of each element --- ...against-upcoming-gcc-14-Werror-callo.patch | 37 +++++++++++++++++++ elfutils.spec | 7 +++- 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 0002-tests-fix-build-against-upcoming-gcc-14-Werror-callo.patch diff --git a/0002-tests-fix-build-against-upcoming-gcc-14-Werror-callo.patch b/0002-tests-fix-build-against-upcoming-gcc-14-Werror-callo.patch new file mode 100644 index 0000000..979f556 --- /dev/null +++ b/0002-tests-fix-build-against-upcoming-gcc-14-Werror-callo.patch @@ -0,0 +1,37 @@ +From ae580d48278b9924da7503886b37be34378e1b04 Mon Sep 17 00:00:00 2001 +From: Sergei Trofimovich +Date: Thu, 21 Dec 2023 09:23:30 +0000 +Subject: [PATCH] tests: fix build against upcoming `gcc-14` + (`-Werror=calloc-transposed-args`) + +`gcc-14` added a new `-Wcalloc-transposed-args` warning recently. It +detected minor infelicity in `calloc()` API usage in `elfutils`: + + elfstrmerge.c: In function 'main': + elfstrmerge.c:450:32: error: + 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Werror=calloc-transposed-args] + 450 | newscnbufs = calloc (sizeof (void *), newshnums); + | ^~~~ + elfstrmerge.c:450:32: note: earlier argument should specify number of elements, later size of each element + +Signed-off-by: Sergei Trofimovich +--- + tests/elfstrmerge.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tests/elfstrmerge.c b/tests/elfstrmerge.c +index 56350bb9..4eb58bbb 100644 +--- a/tests/elfstrmerge.c ++++ b/tests/elfstrmerge.c +@@ -447,7 +447,7 @@ main (int argc, char **argv) + } + + newshnums = shdrnum - 1; +- newscnbufs = calloc (sizeof (void *), newshnums); ++ newscnbufs = calloc (newshnums, sizeof (void *)); + if (newscnbufs == NULL) + fail_errno ("Couldn't allocate memory for new section buffers", NULL); + +-- +2.43.5 + diff --git a/elfutils.spec b/elfutils.spec index 48b7631..c265695 100644 --- a/elfutils.spec +++ b/elfutils.spec @@ -1,4 +1,4 @@ -%define anolis_release 3 +%define anolis_release 4 %global source_url ftp://sourceware.org/pub/elfutils/%{version}/ %global _gnu %{nil} %define __brp_remove_la_files %{nil} @@ -18,6 +18,7 @@ Source1: elfutils-debuginfod.sysusers Patch0: add-sw_64-support.patch # https://sourceware.org/git/?p=elfutils.git;a=commit;h=373f5212677235fc3ca6068b887111554790f944 Patch1: 0001-Fix-CVE-2024-25260.patch +Patch2: 0002-tests-fix-build-against-upcoming-gcc-14-Werror-callo.patch Requires: elfutils-libelf = %{version}-%{release} Requires: elfutils-libs = %{version}-%{release} @@ -204,6 +205,7 @@ such servers to download those files on demand. %patch -P0 -p1 %endif %patch -P1 -p1 +%patch -P2 -p1 autoreconf -f -v -i find . -name \*.sh ! -perm -0100 -print | xargs chmod +x @@ -364,6 +366,9 @@ exit 0 %systemd_postun_with_restart debuginfod.service %changelog +* Fri Oct 17 2025 Yihao Yan - 0.190-4 +- tests: fix build against upcoming `gcc-14` (`-Werror=calloc-transposed-args`) + * Thu Aug 28 2025 mgb01105731 - 0.190-3 - Add patch to fix CVE-2024-25260 - skip tests if it failed on riscv64 -- Gitee