From fe1e3bbca60a6b4b9a1889f5252e02c27b459f63 Mon Sep 17 00:00:00 2001
From: V3n3RiX <venerix@koprulu.sector>
Date: Sun, 14 Jan 2024 07:13:52 +0000
Subject: gentoo auto-resync : 14:01:2024 - 07:13:52

---
 dev-debug/Manifest.gz                              | Bin 1041 -> 1046 bytes
 dev-debug/valgrind/Manifest                        |  10 +-
 ...nitor.py-regular-expressions-should-use-r.patch |  61 ++++++
 ...valgrind-3.22.0-fails-on-assertion-when-l.patch | 144 ++++++++++++++
 .../0003-Add-fchmodat2-syscall-on-linux.patch      | 218 +++++++++++++++++++++
 dev-debug/valgrind/valgrind-3.21.0-r1.ebuild       |   2 +-
 dev-debug/valgrind/valgrind-3.21.0-r2.ebuild       |   2 +-
 dev-debug/valgrind/valgrind-3.22.0-r1.ebuild       | 157 +++++++++++++++
 dev-debug/valgrind/valgrind-9999.ebuild            |   4 +-
 9 files changed, 592 insertions(+), 6 deletions(-)
 create mode 100644 dev-debug/valgrind/files/0001-valgrind-monitor.py-regular-expressions-should-use-r.patch
 create mode 100644 dev-debug/valgrind/files/0002-Bug-476548-valgrind-3.22.0-fails-on-assertion-when-l.patch
 create mode 100644 dev-debug/valgrind/files/0003-Add-fchmodat2-syscall-on-linux.patch
 create mode 100644 dev-debug/valgrind/valgrind-3.22.0-r1.ebuild

(limited to 'dev-debug')

diff --git a/dev-debug/Manifest.gz b/dev-debug/Manifest.gz
index b50d5f7b94a8..4e76affdfffa 100644
Binary files a/dev-debug/Manifest.gz and b/dev-debug/Manifest.gz differ
diff --git a/dev-debug/valgrind/Manifest b/dev-debug/valgrind/Manifest
index b32e4c100f92..942b463461f7 100644
--- a/dev-debug/valgrind/Manifest
+++ b/dev-debug/valgrind/Manifest
@@ -1,3 +1,6 @@
+AUX 0001-valgrind-monitor.py-regular-expressions-should-use-r.patch 2242 BLAKE2B ad7b3ff4565764b457b42ab0ce1de891c7edc5d9efaeb5fb2b4fb3d1d0bc60838cfb0eb05514720ed4baf01e317b2a31afd723db5ce87469cb5594e6bef51093 SHA512 d2d562c33c938894dfba22215bef0abb0d9d0a5efeada4dc7e8c7cbb7de91ad7234fb59f804361d63287e20f322b55fc30585426f496dc38b881de4aa1cc4e1c
+AUX 0002-Bug-476548-valgrind-3.22.0-fails-on-assertion-when-l.patch 5649 BLAKE2B 075ebe79637735aff7e55f970c5b6c9fe25504ea381e9f927d35c6f00f099edc5eebc97b1c6a58686ea913dc491128800f1533eadc32f7ff7f43d331950ef67f SHA512 d6cbc7991ff7f6ffd181a2208e3b168957035967931173098dc226909979006f7948fb7dc47b70bf3eba7a0cd2501a0d3ebf8b2e4773f1abd76b5e8803b29538
+AUX 0003-Add-fchmodat2-syscall-on-linux.patch 9010 BLAKE2B ddc222f921cb69c5954f8e39aa7f8a3b0742165bdc22f9cdc68e4951465d75142edac37b44dff92d10b9b93a045cc1a9f3134fd0d712f5cf883c7c44e3f4e068 SHA512 dd9b2516d71eb4c0a34d675ccf0288a6fbec16649af59e702b0f2e1c74bb89d63b1740a97e18da4c7f299098d0f3ef3987af3d30030d28c54dd625ad899cb2bc
 AUX valgrind-3.13.0-malloc.patch 1024 BLAKE2B 3917fe49e5b7f8f678801edd3236b76fbc3eaf790bc19db7a1055cd949df802fc7612b8ec8fb40371814790d24f15fc2cdfd5349297ed5b48e28d3224bb2d170 SHA512 57086a768f3876b26b0e507bc159a73f0955f03d5af8cc30e21103e348ca67f2e58b5555a5a97f299751c6602692ad43d8346bb68a80917d740fb4d65bba9665
 AUX valgrind-3.15.0-Build-ldst_multiple-test-with-fno-pie.patch 650 BLAKE2B ffb545d6af214a5bd43ff800d52e0d7cfc03feac8d2466da8d4935db659172cd50cf3e2d63b3aff46d81b21846b304671506cd235b710037218fc16e0ef66438 SHA512 7cb5a46c2d8ed4360053289994014b334e32d48b0608ed58662486bd432c31835ef16e2cdfd734f3e4d720e272d2507ec76f0b77e1364237e9f6dbbd97a8abb6
 AUX valgrind-3.20.0-gcc-13.patch 1181 BLAKE2B a7cdca7b99e822444ab3c453efba979a341c31ad0882a8a8232ba96af4ccc94277b142a833435afc911b06b743c5bc6e7bd126b7f65246308147130ab0ee86c4 SHA512 c4d14851f7ea41d8b3f8391f3e2c0fd72afae0944594d126bf2d3dbbf65fd3cd5fdf5303c4b7b3f40c5fe48f0e965dcd6265d268b8e3483c9354ede8e5c53af5
@@ -13,8 +16,9 @@ DIST valgrind-3.21.0.tar.bz2.asc 488 BLAKE2B 6297bc925c16526a51de4f589232a8d5bcb
 DIST valgrind-3.22.0.tar.bz2 16565502 BLAKE2B 80024371b3e70521996077fba24e233097a6190477ced1b311cd41fead687dcc2511ac0ef723792488f4af08867dff3e1f474816fda09c1604b89059e31c2514 SHA512 2904c13f68245bbafcea70998c6bd20725271300a7e94b6751ca00916943595fc3fac8557da7ea8db31b54a43f092823a0a947bc142829da811d074e1fe49777
 DIST valgrind-3.22.0.tar.bz2.asc 488 BLAKE2B 9e4d4cfac4dcc09bb62beeaa7b9f78bfafd0a6ae8d63e423ff81b7b8f5444a301e4c3030a241644c8070c36ee040832ce99f444678f22611457e325ceae18dd1 SHA512 c2317db564ef816d2b5d1a7f2f680dc1c6ea05abbffde660587946c986af179ea7ca2314d94c792f63f3043b6a44819ddf5661fd60ec2454a2c562e7d2711b36
 EBUILD valgrind-3.20.0-r2.ebuild 4290 BLAKE2B a948bd03fabd0b5f7b7aab5e7b38d2e2d109f93f9f60575a03dc591664d81758e924634a8e56c9b6a7baf0b616a2ad820ebdff6e2cf852308552b18b9d0bf6d0 SHA512 e859ab336717bd76a8341c94cfac95d222d4f8faabae0f13b833272951bb94e96fe4d51e7627d47bab44d204e9ba093f97d328e385e17e58834b149e8d442d73
-EBUILD valgrind-3.21.0-r1.ebuild 4077 BLAKE2B cfee838cfd981a10f1e5eadfdee7e8ebee5fdd0333d3e8e0b73e3b006defaa26ec909263e6cd4938e89c84b28910d951c9aff9668f027f9a3483e507431616ea SHA512 12aef097f3358d7ecfc4a64d59b00339b0ec052ba7b54b662c963b60fe18c5e89cc218991d5667de9c9152c64b6910b7a31a8a5897113ba847cb4fa43a4ad9e6
-EBUILD valgrind-3.21.0-r2.ebuild 4449 BLAKE2B 8079d0980286a026dfe0a00be78b2cc9f9f2732dd9909dd35e2019bef9f9fb692bd5d0e682834a761937c8ce6d1d38301758dda2ba099172010d6f90541dad50 SHA512 8ef4c0c5422a2c8a37be2a45022020edb8f5a09cbd5d639df49ea089815b7ee5bea3b5fb9b0d2202f00d4e4c40783cd39a3de7bdfff4980700e9d3f513463e71
+EBUILD valgrind-3.21.0-r1.ebuild 4075 BLAKE2B 06c7d359248ebcdab7c99c06e1f8ffe978f92e22ef866bcc936ec719b61a79404e6f1831f968624063da083da27911ea804f6223734d2dd16d4883e7d097fa87 SHA512 edcad8bf726f8991a561e51a42e8ee2bb4f52a9641c12bacc86ad578cd38b3f7bcb10eada151c8ed9b739fd08fdb5d595131ed71c40170f3276d7cb04344161e
+EBUILD valgrind-3.21.0-r2.ebuild 4445 BLAKE2B 411c77687c2a5c58755213b2f5ae50c3bcd8bd6bdcf17894acc9b4b1a2ca24b684f5ab3642f0bcf213e908c74f159c81ae4ed3fb58f196a04494b4dd8b1f1f44 SHA512 d2db8635cc329ecd1279ff476035cb5facc349bbdea49551f1cc9352ed1c9280a22c18a08fb5db6ee352c8ecbdae3847b20a4a57748b835f36fee925fa43c72b
+EBUILD valgrind-3.22.0-r1.ebuild 5057 BLAKE2B 0ad7f4cd500dbb147389f3c110912fd6125ec4417d558f22f01e91242f660b22b88b6edea3af3e7e74e394e4ef78b677a01ff88cfe1aedc8187eb55d67bf39ee SHA512 1e04ebd54d63fa26971ff8706ca4c4ed74d2e459500efb8757a09778e5e394128493ef187ab6afcd6a8440f2b8d3ad426ffe531df6e97e1c80dc68c9226994c2
 EBUILD valgrind-3.22.0.ebuild 4787 BLAKE2B 5fbb27d3b93352215576a032e048d97618b575c9788fc694c627e5334c6b19b2696caf4e578f4dd3ba0bccc98437765e81caecf83129a84d590a08f0ee082e09 SHA512 33d9d941d9007de7c6b3b9dec776fd38c09589aa390ed891862479b72128491197c40bc9d5802e2d8d2b22a06ea4e6ff5154c590468fb11fc1f5f1aa3e290f63
-EBUILD valgrind-9999.ebuild 4787 BLAKE2B 5fbb27d3b93352215576a032e048d97618b575c9788fc694c627e5334c6b19b2696caf4e578f4dd3ba0bccc98437765e81caecf83129a84d590a08f0ee082e09 SHA512 33d9d941d9007de7c6b3b9dec776fd38c09589aa390ed891862479b72128491197c40bc9d5802e2d8d2b22a06ea4e6ff5154c590468fb11fc1f5f1aa3e290f63
+EBUILD valgrind-9999.ebuild 4842 BLAKE2B eae9f32b2ee888ad390d5a67f04e5e7e97da00d06ea0df5a4da2c914ad091ceff47e2b31083198284e5ff3791ba1d826bb56fd852cdb609dfe4f6f9d55eb600a SHA512 bf97bfae37c916e96509f3c4592e5214406670ca4c4ecd4b2b6e4c4ec75b4f6b65024effbcb90d89ce8ce79d554c4af7fcdf8338f056566107805e965127e4a3
 MISC metadata.xml 1123 BLAKE2B 17b5501b05acd9384ab57a15018bc0d1ede50d7b5b9a5c38fcce816f68e8946010bc86233a197df89ad208957f90ab643942b7e1a3ceaa6e8d456320828b84e8 SHA512 a8c32063f3afd28c4a2d5c5c0f437c08772e822aaed4feb71f79e0f5a6cf81530d056bd8ae2ef73ac70792bd78fc095c069ef0d4304ff0a1c365f289d1191fe1
diff --git a/dev-debug/valgrind/files/0001-valgrind-monitor.py-regular-expressions-should-use-r.patch b/dev-debug/valgrind/files/0001-valgrind-monitor.py-regular-expressions-should-use-r.patch
new file mode 100644
index 000000000000..cc51bc219456
--- /dev/null
+++ b/dev-debug/valgrind/files/0001-valgrind-monitor.py-regular-expressions-should-use-r.patch
@@ -0,0 +1,61 @@
+From 027b649fdb831868e71be01cafdacc49a5f419ab Mon Sep 17 00:00:00 2001
+From: Mark Wielaard <mark@klomp.org>
+Date: Fri, 17 Nov 2023 14:01:21 +0100
+Subject: [PATCH 1/3] valgrind-monitor.py regular expressions should use raw
+ strings
+
+With python 3.12 gdb will produce the following SyntaxWarning when
+loading valgrind-monitor-def.py:
+
+  /usr/share/gdb/auto-load/valgrind-monitor-def.py:214:
+  SyntaxWarning: invalid escape sequence '\['
+    if re.fullmatch("^0x[0123456789ABCDEFabcdef]+\[[^\[\]]+\]$", arg_str):
+
+In a future python version this will become an SyntaxError.
+
+Use a raw strings for the regular expression.
+
+https://bugs.kde.org/show_bug.cgi?id=476708
+(cherry picked from commit 0fbfbe05028ad18efda786a256a2738d2c231ed4)
+---
+ NEWS                                          | 13 +++++++++++++
+ coregrind/m_gdbserver/valgrind-monitor-def.py |  2 +-
+ 2 files changed, 14 insertions(+), 1 deletion(-)
+
+diff --git a/NEWS b/NEWS
+index f11da4be8..ee5b4ff11 100644
+--- a/NEWS
++++ b/NEWS
+@@ -1,3 +1,16 @@
++Branch 3.22
++~~~~~~~~~~~
++
++* ==================== FIXED BUGS ====================
++
++The following bugs have been fixed or resolved on this branch.
++
++476708  valgrind-monitor.py regular expressions should use raw strings
++
++To see details of a given bug, visit
++  https://bugs.kde.org/show_bug.cgi?id=XXXXXX
++where XXXXXX is the bug number as listed above.
++
+ Release 3.22.0 (31 Oct 2023)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ 
+diff --git a/coregrind/m_gdbserver/valgrind-monitor-def.py b/coregrind/m_gdbserver/valgrind-monitor-def.py
+index b4e7b992d..d74b1590c 100644
+--- a/coregrind/m_gdbserver/valgrind-monitor-def.py
++++ b/coregrind/m_gdbserver/valgrind-monitor-def.py
+@@ -211,7 +211,7 @@ class Valgrind_ADDR_LEN_opt(Valgrind_Command):
+ For compatibility reason with the Valgrind gdbserver monitor command,
+ we detect and accept usages such as 0x1234ABCD[10]."""
+     def invoke(self, arg_str : str, from_tty : bool) -> None:
+-        if re.fullmatch("^0x[0123456789ABCDEFabcdef]+\[[^\[\]]+\]$", arg_str):
++        if re.fullmatch(r"^0x[0123456789ABCDEFabcdef]+\[[^\[\]]+\]$", arg_str):
+             arg_str = arg_str.replace("[", " ")
+             arg_str = arg_str.replace("]", " ")
+         eval_execute_2(self, arg_str,
+-- 
+2.43.0
+
diff --git a/dev-debug/valgrind/files/0002-Bug-476548-valgrind-3.22.0-fails-on-assertion-when-l.patch b/dev-debug/valgrind/files/0002-Bug-476548-valgrind-3.22.0-fails-on-assertion-when-l.patch
new file mode 100644
index 000000000000..40885a04d850
--- /dev/null
+++ b/dev-debug/valgrind/files/0002-Bug-476548-valgrind-3.22.0-fails-on-assertion-when-l.patch
@@ -0,0 +1,144 @@
+From 1d00e5ce0fb069911c4b525ec38289fb5d9021b0 Mon Sep 17 00:00:00 2001
+From: Paul Floyd <pjfloyd@wanadoo.fr>
+Date: Sat, 18 Nov 2023 08:49:34 +0100
+Subject: [PATCH 2/3] Bug 476548 - valgrind 3.22.0 fails on assertion when
+ loading debuginfo file produced by mold
+
+(cherry picked from commit 9ea4ae66707a4dcc6f4328e11911652e4418c585)
+---
+ NEWS                               |  2 ++
+ coregrind/m_debuginfo/image.c      | 14 +++++++++
+ coregrind/m_debuginfo/priv_image.h |  4 +++
+ coregrind/m_debuginfo/readelf.c    | 49 ++++++++++++++++++++++++++++--
+ 4 files changed, 66 insertions(+), 3 deletions(-)
+
+diff --git a/NEWS b/NEWS
+index ee5b4ff11..6cd13429a 100644
+--- a/NEWS
++++ b/NEWS
+@@ -5,6 +5,8 @@ Branch 3.22
+ 
+ The following bugs have been fixed or resolved on this branch.
+ 
++476548  valgrind 3.22.0 fails on assertion when loading debuginfo
++        file produced by mold
+ 476708  valgrind-monitor.py regular expressions should use raw strings
+ 
+ To see details of a given bug, visit
+diff --git a/coregrind/m_debuginfo/image.c b/coregrind/m_debuginfo/image.c
+index 02e509071..445f95555 100644
+--- a/coregrind/m_debuginfo/image.c
++++ b/coregrind/m_debuginfo/image.c
+@@ -1221,6 +1221,20 @@ Int ML_(img_strcmp_c)(DiImage* img, DiOffT off1, const HChar* str2)
+    }
+ }
+ 
++Int ML_(img_strcmp_n)(DiImage* img, DiOffT off1, const HChar* str2, Word n)
++{
++   ensure_valid(img, off1, 1, "ML_(img_strcmp_c)");
++   while (n) {
++      UChar c1 = get(img, off1);
++      UChar c2 = *(const UChar*)str2;
++      if (c1 < c2) return -1;
++      if (c1 > c2) return 1;
++      if (c1 == 0) return 0;
++      off1++; str2++; --n;
++   }
++   return 0;
++}
++
+ UChar ML_(img_get_UChar)(DiImage* img, DiOffT offset)
+ {
+    ensure_valid(img, offset, 1, "ML_(img_get_UChar)");
+diff --git a/coregrind/m_debuginfo/priv_image.h b/coregrind/m_debuginfo/priv_image.h
+index a49846f14..c91e49f01 100644
+--- a/coregrind/m_debuginfo/priv_image.h
++++ b/coregrind/m_debuginfo/priv_image.h
+@@ -115,6 +115,10 @@ Int ML_(img_strcmp)(DiImage* img, DiOffT off1, DiOffT off2);
+    cast to HChar before comparison. */
+ Int ML_(img_strcmp_c)(DiImage* img, DiOffT off1, const HChar* str2);
+ 
++/* Do strncmp of a C string in the image vs a normal one.  Chars are
++   cast to HChar before comparison. */
++Int ML_(img_strcmp_n)(DiImage* img, DiOffT off1, const HChar* str2, Word n);
++
+ /* Do strlen of a C string in the image. */
+ SizeT ML_(img_strlen)(DiImage* img, DiOffT off);
+ 
+diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c
+index fb64ed976..46f8c8343 100644
+--- a/coregrind/m_debuginfo/readelf.c
++++ b/coregrind/m_debuginfo/readelf.c
+@@ -2501,8 +2501,7 @@ Bool ML_(read_elf_object) ( struct _DebugInfo* di )
+             di->rodata_avma += inrw1->bias;
+             di->rodata_bias = inrw1->bias;
+             di->rodata_debug_bias = inrw1->bias;
+-         }
+-         else {
++         } else {
+             BAD(".rodata");  /* should not happen? */
+          }
+          di->rodata_present = True;
+@@ -2977,6 +2976,46 @@ Bool ML_(read_elf_object) ( struct _DebugInfo* di )
+    return retval;
+ }
+ 
++static void find_rodata(Word i, Word shnum, DiImage* dimg, struct _DebugInfo* di, DiOffT shdr_dioff,
++                        UWord shdr_dent_szB, DiOffT shdr_strtab_dioff, PtrdiffT rw_dbias)
++{
++   ElfXX_Shdr a_shdr;
++   ElfXX_Shdr a_extra_shdr;
++   ML_(img_get)(&a_shdr, dimg,
++                INDEX_BIS(shdr_dioff, i, shdr_dent_szB),
++                sizeof(a_shdr));
++   if (di->rodata_present &&
++       0 == ML_(img_strcmp_c)(dimg, shdr_strtab_dioff
++                                    + a_shdr.sh_name, ".rodata")) {
++      Word sh_size = a_shdr.sh_size;
++      Word j;
++      Word next_addr = a_shdr.sh_addr + a_shdr.sh_size;
++      for (j = i  + 1; j < shnum; ++j) {
++         ML_(img_get)(&a_extra_shdr, dimg,
++                      INDEX_BIS(shdr_dioff, j, shdr_dent_szB),
++                      sizeof(a_shdr));
++         if (0 == ML_(img_strcmp_n)(dimg, shdr_strtab_dioff
++                                             + a_extra_shdr.sh_name, ".rodata", 7)) {
++            if (a_extra_shdr.sh_addr ==
++                VG_ROUNDUP(next_addr, a_extra_shdr.sh_addralign)) {
++               sh_size = VG_ROUNDUP(sh_size, a_extra_shdr.sh_addralign) + a_extra_shdr.sh_size;
++            }
++            next_addr = a_extra_shdr.sh_addr + a_extra_shdr.sh_size;
++         } else {
++            break;
++         }
++      }
++      vg_assert(di->rodata_size == sh_size);
++      vg_assert(di->rodata_avma +  a_shdr.sh_addr + rw_dbias);
++      di->rodata_debug_svma = a_shdr.sh_addr;
++      di->rodata_debug_bias = di->rodata_bias +
++                             di->rodata_svma - di->rodata_debug_svma;
++      TRACE_SYMTAB("acquiring .rodata  debug svma = %#lx .. %#lx\n",
++                   di->rodata_debug_svma,
++                   di->rodata_debug_svma + di->rodata_size - 1);
++      TRACE_SYMTAB("acquiring .rodata debug bias = %#lx\n", (UWord)di->rodata_debug_bias);
++   }
++}
+ Bool ML_(read_elf_debug) ( struct _DebugInfo* di )
+ {
+    Word     i, j;
+@@ -3391,7 +3430,11 @@ Bool ML_(read_elf_debug) ( struct _DebugInfo* di )
+             FIND(text,   rx)
+             FIND(data,   rw)
+             FIND(sdata,  rw)
+-            FIND(rodata, rw)
++            // https://bugs.kde.org/show_bug.cgi?id=476548
++            // special handling for rodata as adjacent
++            // rodata sections may have been merged in ML_(read_elf_object)
++            //FIND(rodata, rw)
++            find_rodata(i, ehdr_dimg.e_shnum, dimg, di, shdr_dioff, shdr_dent_szB, shdr_strtab_dioff, rw_dbias);
+             FIND(bss,    rw)
+             FIND(sbss,   rw)
+ 
+-- 
+2.43.0
+
diff --git a/dev-debug/valgrind/files/0003-Add-fchmodat2-syscall-on-linux.patch b/dev-debug/valgrind/files/0003-Add-fchmodat2-syscall-on-linux.patch
new file mode 100644
index 000000000000..a65178a585f4
--- /dev/null
+++ b/dev-debug/valgrind/files/0003-Add-fchmodat2-syscall-on-linux.patch
@@ -0,0 +1,218 @@
+From a43e62dddcf51ec6578a90c5988a41e856b44b05 Mon Sep 17 00:00:00 2001
+From: Mark Wielaard <mark@klomp.org>
+Date: Sat, 18 Nov 2023 21:17:02 +0100
+Subject: [PATCH 3/3] Add fchmodat2 syscall on linux
+
+fchmodat2 is a new syscall on linux 6.6. It is a variant of fchmodat
+that takes an extra flags argument.
+
+https://bugs.kde.org/show_bug.cgi?id=477198
+
+(cherry picked from commit 372d09fd9a8d76847c81092ebff71c80fd6c145d)
+---
+ NEWS                                         |  1 +
+ coregrind/m_syswrap/priv_syswrap-linux.h     |  3 +++
+ coregrind/m_syswrap/syswrap-amd64-linux.c    |  2 ++
+ coregrind/m_syswrap/syswrap-arm-linux.c      |  2 ++
+ coregrind/m_syswrap/syswrap-arm64-linux.c    |  2 ++
+ coregrind/m_syswrap/syswrap-linux.c          | 11 +++++++++++
+ coregrind/m_syswrap/syswrap-mips32-linux.c   |  2 ++
+ coregrind/m_syswrap/syswrap-mips64-linux.c   |  1 +
+ coregrind/m_syswrap/syswrap-nanomips-linux.c |  1 +
+ coregrind/m_syswrap/syswrap-ppc32-linux.c    |  2 ++
+ coregrind/m_syswrap/syswrap-ppc64-linux.c    |  2 ++
+ coregrind/m_syswrap/syswrap-s390x-linux.c    |  2 ++
+ coregrind/m_syswrap/syswrap-x86-linux.c      |  2 ++
+ include/vki/vki-scnums-shared-linux.h        |  2 ++
+ 14 files changed, 35 insertions(+)
+
+diff --git a/NEWS b/NEWS
+index 6cd13429a..da0f8c1aa 100644
+--- a/NEWS
++++ b/NEWS
+@@ -8,6 +8,7 @@ The following bugs have been fixed or resolved on this branch.
+ 476548  valgrind 3.22.0 fails on assertion when loading debuginfo
+         file produced by mold
+ 476708  valgrind-monitor.py regular expressions should use raw strings
++477198  Add fchmodat2 syscall on linux
+ 
+ To see details of a given bug, visit
+   https://bugs.kde.org/show_bug.cgi?id=XXXXXX
+diff --git a/coregrind/m_syswrap/priv_syswrap-linux.h b/coregrind/m_syswrap/priv_syswrap-linux.h
+index 7c9decf5a..798c456c9 100644
+--- a/coregrind/m_syswrap/priv_syswrap-linux.h
++++ b/coregrind/m_syswrap/priv_syswrap-linux.h
+@@ -331,6 +331,9 @@ DECL_TEMPLATE(linux, sys_openat2);
+ // Linux-specific (new in Linux 5.14)
+ DECL_TEMPLATE(linux, sys_memfd_secret);
+ 
++// Since Linux 6.6
++DECL_TEMPLATE(linux, sys_fchmodat2);
++
+ /* ---------------------------------------------------------------------
+    Wrappers for sockets and ipc-ery.  These are split into standalone
+    procedures because x86-linux hides them inside multiplexors
+diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c b/coregrind/m_syswrap/syswrap-amd64-linux.c
+index 008600798..fe17d118b 100644
+--- a/coregrind/m_syswrap/syswrap-amd64-linux.c
++++ b/coregrind/m_syswrap/syswrap-amd64-linux.c
+@@ -886,6 +886,8 @@ static SyscallTableEntry syscall_table[] = {
+    LINXY(__NR_epoll_pwait2,      sys_epoll_pwait2),      // 441
+ 
+    LINXY(__NR_memfd_secret,      sys_memfd_secret),      // 447
++
++   LINX_(__NR_fchmodat2,         sys_fchmodat2),         // 452
+ };
+ 
+ SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno )
+diff --git a/coregrind/m_syswrap/syswrap-arm-linux.c b/coregrind/m_syswrap/syswrap-arm-linux.c
+index 9a7a1e0d2..811931d3b 100644
+--- a/coregrind/m_syswrap/syswrap-arm-linux.c
++++ b/coregrind/m_syswrap/syswrap-arm-linux.c
+@@ -1059,6 +1059,8 @@ static SyscallTableEntry syscall_main_table[] = {
+    LINX_(__NR_faccessat2,    sys_faccessat2),           // 439
+ 
+    LINXY(__NR_epoll_pwait2,      sys_epoll_pwait2),      // 441
++
++   LINX_(__NR_fchmodat2,         sys_fchmodat2),         // 452
+ };
+ 
+ 
+diff --git a/coregrind/m_syswrap/syswrap-arm64-linux.c b/coregrind/m_syswrap/syswrap-arm64-linux.c
+index 6af7bab83..3307bc2ca 100644
+--- a/coregrind/m_syswrap/syswrap-arm64-linux.c
++++ b/coregrind/m_syswrap/syswrap-arm64-linux.c
+@@ -840,6 +840,8 @@ static SyscallTableEntry syscall_main_table[] = {
+    LINXY(__NR_epoll_pwait2,      sys_epoll_pwait2),      // 441
+ 
+    LINXY(__NR_memfd_secret,      sys_memfd_secret),      // 447
++
++   LINX_(__NR_fchmodat2,         sys_fchmodat2),         // 452
+ };
+ 
+ 
+diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c
+index d571fc327..efa47f2e6 100644
+--- a/coregrind/m_syswrap/syswrap-linux.c
++++ b/coregrind/m_syswrap/syswrap-linux.c
+@@ -6059,6 +6059,17 @@ PRE(sys_fchmodat)
+    PRE_MEM_RASCIIZ( "fchmodat(path)", ARG2 );
+ }
+ 
++PRE(sys_fchmodat2)
++{
++   PRINT("sys_fchmodat2 ( %ld, %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u, %"
++	  FMT_REGWORD "u )",
++         SARG1, ARG2, (HChar*)(Addr)ARG2, ARG3, ARG4);
++   PRE_REG_READ4(long, "fchmodat2",
++                 int, dfd, const char *, path, vki_mode_t, mode,
++                 unsigned int, flags);
++   PRE_MEM_RASCIIZ( "fchmodat2(pathname)", ARG2 );
++}
++
+ PRE(sys_faccessat)
+ {
+    PRINT("sys_faccessat ( %ld, %#" FMT_REGWORD "x(%s), %ld )",
+diff --git a/coregrind/m_syswrap/syswrap-mips32-linux.c b/coregrind/m_syswrap/syswrap-mips32-linux.c
+index 6268a00dd..74a1f6eac 100644
+--- a/coregrind/m_syswrap/syswrap-mips32-linux.c
++++ b/coregrind/m_syswrap/syswrap-mips32-linux.c
+@@ -1143,6 +1143,8 @@ static SyscallTableEntry syscall_main_table[] = {
+    LINX_ (__NR_faccessat2,             sys_faccessat2),              // 439
+ 
+    LINXY(__NR_epoll_pwait2,      sys_epoll_pwait2),      // 441
++
++   LINX_(__NR_fchmodat2,               sys_fchmodat2),               // 452
+ };
+ 
+ SyscallTableEntry* ML_(get_linux_syscall_entry) (UInt sysno)
+diff --git a/coregrind/m_syswrap/syswrap-mips64-linux.c b/coregrind/m_syswrap/syswrap-mips64-linux.c
+index 6cdf25893..4e8508b7a 100644
+--- a/coregrind/m_syswrap/syswrap-mips64-linux.c
++++ b/coregrind/m_syswrap/syswrap-mips64-linux.c
+@@ -820,6 +820,7 @@ static SyscallTableEntry syscall_main_table[] = {
+    LINXY (__NR_close_range, sys_close_range),
+    LINX_ (__NR_faccessat2, sys_faccessat2),
+    LINXY(__NR_epoll_pwait2, sys_epoll_pwait2),
++   LINX_ (__NR_fchmodat2, sys_fchmodat2),
+ };
+ 
+ SyscallTableEntry * ML_(get_linux_syscall_entry) ( UInt sysno )
+diff --git a/coregrind/m_syswrap/syswrap-nanomips-linux.c b/coregrind/m_syswrap/syswrap-nanomips-linux.c
+index d724cde74..7859900c1 100644
+--- a/coregrind/m_syswrap/syswrap-nanomips-linux.c
++++ b/coregrind/m_syswrap/syswrap-nanomips-linux.c
+@@ -829,6 +829,7 @@ static SyscallTableEntry syscall_main_table[] = {
+    LINXY (__NR_close_range,            sys_close_range),
+    LINX_ (__NR_faccessat2,             sys_faccessat2),
+    LINXY (__NR_epoll_pwait2,           sys_epoll_pwait2),
++   LINX_ (__NR_fchmodat2,              sys_fchmodat2),
+ };
+ 
+ SyscallTableEntry* ML_(get_linux_syscall_entry) (UInt sysno)
+diff --git a/coregrind/m_syswrap/syswrap-ppc32-linux.c b/coregrind/m_syswrap/syswrap-ppc32-linux.c
+index c0cfef235..1e19116ee 100644
+--- a/coregrind/m_syswrap/syswrap-ppc32-linux.c
++++ b/coregrind/m_syswrap/syswrap-ppc32-linux.c
+@@ -1063,6 +1063,8 @@ static SyscallTableEntry syscall_table[] = {
+    LINX_(__NR_faccessat2,        sys_faccessat2),       // 439
+ 
+    LINXY (__NR_epoll_pwait2,     sys_epoll_pwait2),      // 441
++
++   LINX_ (__NR_fchmodat2,        sys_fchmodat2),         // 452
+ };
+ 
+ SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno )
+diff --git a/coregrind/m_syswrap/syswrap-ppc64-linux.c b/coregrind/m_syswrap/syswrap-ppc64-linux.c
+index f5976f30c..1097212a4 100644
+--- a/coregrind/m_syswrap/syswrap-ppc64-linux.c
++++ b/coregrind/m_syswrap/syswrap-ppc64-linux.c
+@@ -1032,6 +1032,8 @@ static SyscallTableEntry syscall_table[] = {
+    LINX_(__NR_faccessat2,        sys_faccessat2),       // 439
+ 
+    LINXY (__NR_epoll_pwait2,     sys_epoll_pwait2),      // 441
++
++   LINX_ (__NR_fchmodat2,        sys_fchmodat2),         // 452
+ };
+ 
+ SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno )
+diff --git a/coregrind/m_syswrap/syswrap-s390x-linux.c b/coregrind/m_syswrap/syswrap-s390x-linux.c
+index afba154e7..3588672c7 100644
+--- a/coregrind/m_syswrap/syswrap-s390x-linux.c
++++ b/coregrind/m_syswrap/syswrap-s390x-linux.c
+@@ -873,6 +873,8 @@ static SyscallTableEntry syscall_table[] = {
+    LINX_(__NR_faccessat2,  sys_faccessat2),                           // 439
+ 
+    LINXY(__NR_epoll_pwait2, sys_epoll_pwait2),                        // 441
++
++   LINX_ (__NR_fchmodat2, sys_fchmodat2),                             // 452
+ };
+ 
+ SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno )
+diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c
+index da4fd8fa2..58badc6b0 100644
+--- a/coregrind/m_syswrap/syswrap-x86-linux.c
++++ b/coregrind/m_syswrap/syswrap-x86-linux.c
+@@ -1658,6 +1658,8 @@ static SyscallTableEntry syscall_table[] = {
+    LINXY(__NR_epoll_pwait2,      sys_epoll_pwait2),     // 441
+ 
+    LINXY(__NR_memfd_secret,      sys_memfd_secret),      // 447
++
++   LINX_(__NR_fchmodat2,         sys_fchmodat2),         // 452
+ };
+ 
+ SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno )
+diff --git a/include/vki/vki-scnums-shared-linux.h b/include/vki/vki-scnums-shared-linux.h
+index 542382b53..a4cd87149 100644
+--- a/include/vki/vki-scnums-shared-linux.h
++++ b/include/vki/vki-scnums-shared-linux.h
+@@ -50,4 +50,6 @@
+ 
+ #define __NR_memfd_secret		447
+ 
++#define __NR_fchmodat2		452
++
+ #endif
+-- 
+2.43.0
+
diff --git a/dev-debug/valgrind/valgrind-3.21.0-r1.ebuild b/dev-debug/valgrind/valgrind-3.21.0-r1.ebuild
index 9b78aebad2fb..632b096a9c08 100644
--- a/dev-debug/valgrind/valgrind-3.21.0-r1.ebuild
+++ b/dev-debug/valgrind/valgrind-3.21.0-r1.ebuild
@@ -15,7 +15,7 @@ else
 	inherit verify-sig
 	SRC_URI="https://sourceware.org/pub/valgrind/${P}.tar.bz2"
 	SRC_URI+=" verify-sig? ( https://sourceware.org/pub/valgrind/${P}.tar.bz2.asc )"
-	KEYWORDS="-* amd64 ~arm arm64 ~ppc ppc64 x86 ~amd64-linux ~x86-linux ~x64-macos ~x64-solaris"
+	KEYWORDS="-* amd64 arm arm64 ppc ppc64 x86 ~amd64-linux ~x86-linux ~x64-macos ~x64-solaris"
 fi
 
 LICENSE="GPL-2"
diff --git a/dev-debug/valgrind/valgrind-3.21.0-r2.ebuild b/dev-debug/valgrind/valgrind-3.21.0-r2.ebuild
index 1c6ad6cb0422..9f38c6b898d2 100644
--- a/dev-debug/valgrind/valgrind-3.21.0-r2.ebuild
+++ b/dev-debug/valgrind/valgrind-3.21.0-r2.ebuild
@@ -20,7 +20,7 @@ else
 	inherit verify-sig
 	SRC_URI="https://sourceware.org/pub/valgrind/${P}.tar.bz2"
 	SRC_URI+=" verify-sig? ( https://sourceware.org/pub/valgrind/${P}.tar.bz2.asc )"
-	KEYWORDS="-* ~amd64 ~arm ~arm64 ~ppc ~ppc64 ~x86 ~amd64-linux ~x86-linux ~x64-macos ~x64-solaris"
+	KEYWORDS="-* amd64 ~arm arm64 ~ppc ppc64 x86 ~amd64-linux ~x86-linux ~x64-macos ~x64-solaris"
 fi
 
 LICENSE="GPL-2"
diff --git a/dev-debug/valgrind/valgrind-3.22.0-r1.ebuild b/dev-debug/valgrind/valgrind-3.22.0-r1.ebuild
new file mode 100644
index 000000000000..0fb45ef9955d
--- /dev/null
+++ b/dev-debug/valgrind/valgrind-3.22.0-r1.ebuild
@@ -0,0 +1,157 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+# The Valgrind upstream maintainer also maintains it in Fedora and will
+# backport fixes there which haven't yet made it into a release. Keep an eye
+# on it for fixes we should cherry-pick too:
+# https://src.fedoraproject.org/rpms/valgrind/tree/rawhide
+#
+# Also check the ${PV}_STABLE branch upstream for backports.
+
+inherit autotools flag-o-matic toolchain-funcs multilib pax-utils
+
+DESCRIPTION="An open-source memory debugger for GNU/Linux"
+HOMEPAGE="https://valgrind.org"
+if [[ ${PV} == 9999 ]]; then
+	EGIT_REPO_URI="https://sourceware.org/git/${PN}.git"
+	inherit git-r3
+else
+	VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/valgrind.gpg
+	inherit verify-sig
+
+	MY_P="${P/_rc/.RC}"
+	SRC_URI="https://sourceware.org/pub/valgrind/${MY_P}.tar.bz2"
+	SRC_URI+=" verify-sig? ( https://sourceware.org/pub/valgrind/${MY_P}.tar.bz2.asc )"
+	S="${WORKDIR}"/${MY_P}
+
+	if [[ ${PV} != *_rc* ]] ; then
+		KEYWORDS="-* ~amd64 ~arm ~arm64 ~ppc ~ppc64 ~x86 ~amd64-linux ~x86-linux ~x64-macos ~x64-solaris"
+	fi
+fi
+
+LICENSE="GPL-2"
+SLOT="0"
+IUSE="mpi"
+
+DEPEND="mpi? ( virtual/mpi )"
+RDEPEND="${DEPEND}"
+if [[ ${PV} != 9999 ]] ; then
+	BDEPEND="verify-sig? ( sec-keys/openpgp-keys-valgrind )"
+fi
+
+PATCHES=(
+	# Respect CFLAGS, LDFLAGS
+	"${FILESDIR}"/${PN}-3.7.0-respect-flags.patch
+	"${FILESDIR}"/${PN}-3.15.0-Build-ldst_multiple-test-with-fno-pie.patch
+	"${FILESDIR}"/${PN}-3.21.0-glibc-2.34-suppressions.patch
+	# From stable branch
+	"${FILESDIR}"/0001-valgrind-monitor.py-regular-expressions-should-use-r.patch
+	"${FILESDIR}"/0002-Bug-476548-valgrind-3.22.0-fails-on-assertion-when-l.patch
+	"${FILESDIR}"/0003-Add-fchmodat2-syscall-on-linux.patch
+)
+
+src_prepare() {
+	# Correct hard coded doc location
+	sed -i -e "s:doc/valgrind:doc/${PF}:" docs/Makefile.am || die
+
+	# Don't force multiarch stuff on OSX, bug #306467
+	sed -i -e 's:-arch \(i386\|x86_64\)::g' Makefile.all.am || die
+
+	if [[ ${CHOST} == *-solaris* ]] ; then
+		# upstream doesn't support this, but we don't build with
+		# Sun/Oracle ld, we have a GNU toolchain, so get some things
+		# working the Linux/GNU way
+		find "${S}" -name "Makefile.am" -o -name "Makefile.tool.am" | xargs \
+			sed -i -e 's:-M,/usr/lib/ld/map.noexstk:-z,noexecstack:' || die
+		cp "${S}"/coregrind/link_tool_exe_{linux,solaris}.in
+	fi
+
+	default
+
+	eautoreconf
+}
+
+src_configure() {
+	local myconf=(
+		--with-gdbscripts-dir="${EPREFIX}"/usr/share/gdb/auto-load
+	)
+
+	# Respect ar, bug #468114
+	tc-export AR
+
+	# -fomit-frame-pointer	"Assembler messages: Error: junk `8' after expression"
+	#                       while compiling insn_sse.c in none/tests/x86
+	# -fstack-protector     more undefined references to __guard and __stack_smash_handler
+	#                       because valgrind doesn't link to glibc (bug #114347)
+	# -fstack-protector-all    Fails same way as -fstack-protector/-fstack-protector-strong.
+	#                          Note: -fstack-protector-explicit is a no-op for Valgrind, no need to strip it
+	# -fstack-protector-strong See -fstack-protector (bug #620402)
+	# -m64 -mx32			for multilib-portage, bug #398825
+	# -fharden-control-flow-redundancy: breaks runtime ('jump to the invalid address stated on the next line')
+	# -flto*                fails to build, bug #858509
+	filter-flags -fomit-frame-pointer
+	filter-flags -fstack-protector
+	filter-flags -fstack-protector-all
+	filter-flags -fstack-protector-strong
+	filter-flags -m64 -mx32
+	filter-flags -fsanitize -fsanitize=*
+	filter-flags -fharden-control-flow-redundancy
+	append-cflags $(test-flags-CC -fno-harden-control-flow-redundancy)
+	filter-lto
+
+	if use amd64 || use ppc64; then
+		! has_multilib_profile && myconf+=("--enable-only64bit")
+	fi
+
+	# Force bitness on darwin, bug #306467
+	use x64-macos && myconf+=("--enable-only64bit")
+
+	# Don't use mpicc unless the user asked for it (bug #258832)
+	if ! use mpi; then
+		myconf+=("--without-mpicc")
+	fi
+
+	econf "${myconf[@]}"
+}
+
+src_test() {
+	# fxsave.o, tronical.o have textrels
+	emake LDFLAGS="${LDFLAGS} -Wl,-z,notext" check
+}
+
+src_install() {
+	default
+
+	if [[ ${PV} == "9999" ]]; then
+		# Otherwise FAQ.txt won't exist:
+		emake -C docs FAQ.txt
+		mv docs/FAQ.txt . || die "Couldn't move FAQ.txt"
+	fi
+
+	dodoc FAQ.txt
+
+	pax-mark m "${ED}"/usr/$(get_libdir)/valgrind/*-*-linux
+
+	# See README_PACKAGERS
+	dostrip -x /usr/libexec/valgrind/vgpreload* /usr/$(get_libdir)/valgrind/*
+
+	if [[ ${CHOST} == *-darwin* ]] ; then
+		# fix install_names on shared libraries, can't turn them into bundles,
+		# as dyld won't load them any more then, bug #306467
+		local l
+		for l in "${ED}"/usr/lib/valgrind/*.so ; do
+			install_name_tool -id "${EPREFIX}"/usr/lib/valgrind/${l##*/} "${l}"
+		done
+	fi
+}
+
+pkg_postinst() {
+	elog "Valgrind will not work if libc (e.g. glibc) does not have debug symbols."
+	elog "To fix this you can add splitdebug to FEATURES in make.conf"
+	elog "and remerge glibc. See:"
+	elog "https://bugs.gentoo.org/214065"
+	elog "https://bugs.gentoo.org/274771"
+	elog "https://bugs.gentoo.org/388703"
+}
diff --git a/dev-debug/valgrind/valgrind-9999.ebuild b/dev-debug/valgrind/valgrind-9999.ebuild
index 3d0c31f598dc..e79b850d13a3 100644
--- a/dev-debug/valgrind/valgrind-9999.ebuild
+++ b/dev-debug/valgrind/valgrind-9999.ebuild
@@ -7,6 +7,8 @@ EAPI=8
 # backport fixes there which haven't yet made it into a release. Keep an eye
 # on it for fixes we should cherry-pick too:
 # https://src.fedoraproject.org/rpms/valgrind/tree/rawhide
+#
+# Also check the ${PV}_STABLE branch upstream for backports.
 
 inherit autotools flag-o-matic toolchain-funcs multilib pax-utils
 
@@ -44,6 +46,7 @@ PATCHES=(
 	"${FILESDIR}"/${PN}-3.7.0-respect-flags.patch
 	"${FILESDIR}"/${PN}-3.15.0-Build-ldst_multiple-test-with-fno-pie.patch
 	"${FILESDIR}"/${PN}-3.21.0-glibc-2.34-suppressions.patch
+	# From stable branch
 )
 
 src_prepare() {
@@ -64,7 +67,6 @@ src_prepare() {
 
 	default
 
-	# Regenerate autotools files
 	eautoreconf
 }
 
-- 
cgit v1.2.3