From 4ad8c480ac1a4bffce94b41e5d4d0579b7dddddf Mon Sep 17 00:00:00 2001
From: "A. Wilcox" <AWilcox@Wilcox-Tech.com>
Date: Tue, 11 Jun 2024 16:41:10 -0500
Subject: [PATCH] system/binutils: Fix format specifiers in libctf

Closes: #1181
---
 system/binutils/APKBUILD                |  4 +++-
 system/binutils/libctf-32bit-test.patch | 27 +++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)
 create mode 100644 system/binutils/libctf-32bit-test.patch

diff --git a/system/binutils/APKBUILD b/system/binutils/APKBUILD
index 0ba1673637..017f080e36 100644
--- a/system/binutils/APKBUILD
+++ b/system/binutils/APKBUILD
@@ -1,7 +1,7 @@
 # Maintainer: Adelie Platform Group <adelie-devel@lists.adelielinux.org>
 pkgname=binutils
 pkgver=2.41
-pkgrel=0
+pkgrel=1
 pkgdesc="Tools necessary to build programs"
 url="https://www.gnu.org/software/binutils/"
 arch="all"
@@ -22,6 +22,7 @@ source="https://ftp.gnu.org/gnu/$pkgname/$pkgname-$pkgver.tar.xz
 	disable-sframe-tests.patch
 	disable-textrel-test.patch
 	fix-pr28158-test.patch
+	libctf-32bit-test.patch
 	musl-preinit-array.patch
 	musl-versioned-syms.patch
 	ppc32-pic-required.patch
@@ -154,6 +155,7 @@ b2d5da2705366f5919d3f8310225620493b88406b6e909ddf9bd8c9ef50f13757816ff2947eb33c1
 e8ebb984e9b13b75114c8092d1ad2d0c1b3bb59bf10e66ca250151e79844125a23f74b8c4142210c8e574785c35e0ee1df0499e0cfd6ef59e8e80d58121963e1  disable-sframe-tests.patch
 8213bc7e965b7c93e24c755e3ca47c522e3ba0d8504ec1def58fad398dd215158740164276ec8a0b48f2058c7025b5b8b6b2e16e646baf4f7dc1841d4fc5a504  disable-textrel-test.patch
 2972b86e1741866db244cd262469eaef244fc3fb0d569b58cb1ad427d31b3ffc9ccbde904e7bd78f10367a5bfe8ec7f4076253abe03edbabbb0e5894ccc20487  fix-pr28158-test.patch
+4948b963906a72075873f2988289294f6c1eb60297ac2bdee5d8646ad8a23f8f16d98b3e4f048fb625d347be28028a87247241a8dca030b4847450951b7aca32  libctf-32bit-test.patch
 8ef144efc8c0cc71b48d7ed9444fa70906c9a4894058588e3f49c1826975675ab8091681912a15ecbed6772aa5bba31935c92abef0095548fc8a9ecaa5d26526  musl-preinit-array.patch
 ab4d03394073bb6dbd4a046637e9bf57f8b4dad163c551b0d9bb2202025b243161149c8622c2fae072c43082bbf19e15b667483831a58a5d1bc93b464763cdcc  musl-versioned-syms.patch
 7b5ee15c9e5a3567cb000a4ac07699f9d0f11354cf5ee20fd375e483945fd45d0e1551f3f28bdb8ebb49355b3180cc90977e81ae0c3c210cdc689add504952a7  ppc32-pic-required.patch
diff --git a/system/binutils/libctf-32bit-test.patch b/system/binutils/libctf-32bit-test.patch
new file mode 100644
index 0000000000..788c46259e
--- /dev/null
+++ b/system/binutils/libctf-32bit-test.patch
@@ -0,0 +1,27 @@
+We need to use the proper format specifiers.
+
+Upstream-Status: Pending
+Upstream-URL: https://sourceware.org/bugzilla/show_bug.cgi?id=31882
+
+--- binutils-2.41/libctf/testsuite/libctf-lookup/struct-iteration.c.old	2023-07-02 18:00:00.000000000 -0500
++++ binutils-2.41/libctf/testsuite/libctf-lookup/struct-iteration.c	2024-06-11 16:22:32.976649333 -0500
+@@ -53,7 +53,7 @@
+     {
+       char *type_name = ctf_type_aname (fp, membtype);
+ 
+-      printf ("next test: %s, offset %lx, has type %lx/%s\n",
++      printf ("next test: %s, offset %zi, has type %lx/%s\n",
+ 	      name, offset, membtype, type_name);
+       free (type_name);
+     }
+--- binutils-2.41/libctf/testsuite/libctf-lookup/unnamed-field-info.c.old	2023-07-02 18:00:00.000000000 -0500
++++ binutils-2.41/libctf/testsuite/libctf-lookup/unnamed-field-info.c	2024-06-11 16:23:19.191708550 -0500
+@@ -16,7 +16,7 @@
+     goto err;
+ 
+   if (mi.ctm_offset != offset * 8)
+-    fprintf (stderr, "field %s inconsistency: offsetof() says %zi bits, CTF says %zi\n",
++    fprintf (stderr, "field %s inconsistency: offsetof() says %zi bits, CTF says %li\n",
+ 	     name, offset * 8, mi.ctm_offset);
+ 
+   return;
-- 
GitLab