commit:     0aaf24bffa7167ec92ae380cefc031ce812fd5dd
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 14 04:40:23 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Jan 14 04:40:23 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0aaf24bf

dev-debug/valgrind: backport fixes from 3.22.0 stable branch

Mark Wielaard (2):
      valgrind-monitor.py regular expressions should use raw strings
      Add fchmodat2 syscall on linux

Paul Floyd (1):
      Bug 476548 - valgrind 3.22.0 fails on assertion when loading debuginfo 
file produced by mold

Signed-off-by: Sam James <sam <AT> gentoo.org>

 ...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 +++++++++++++++++++++
 ...grind-9999.ebuild => valgrind-3.22.0-r1.ebuild} |   7 +-
 dev-debug/valgrind/valgrind-9999.ebuild            |   4 +-
 5 files changed, 432 insertions(+), 2 deletions(-)

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 <[email protected]>
+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 <[email protected]>
+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 <[email protected]>
+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-9999.ebuild 
b/dev-debug/valgrind/valgrind-3.22.0-r1.ebuild
similarity index 94%
copy from dev-debug/valgrind/valgrind-9999.ebuild
copy to dev-debug/valgrind/valgrind-3.22.0-r1.ebuild
index 3d0c31f598dc..0fb45ef9955d 100644
--- a/dev-debug/valgrind/valgrind-9999.ebuild
+++ b/dev-debug/valgrind/valgrind-3.22.0-r1.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,10 @@ 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
+       
"${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() {
@@ -64,7 +70,6 @@ src_prepare() {
 
        default
 
-       # Regenerate autotools files
        eautoreconf
 }
 

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
 }
 

Reply via email to