]> git.pld-linux.org Git - packages/valgrind.git/commitdiff
upstream fix for assertion failure on loading debuginfo produced by mold; rel 3 master auto/th/valgrind-3.22.0-3
authorJan Palus <atler@pld-linux.org>
Sat, 18 Nov 2023 13:02:45 +0000 (14:02 +0100)
committerJan Palus <atler@pld-linux.org>
Sat, 18 Nov 2023 13:02:45 +0000 (14:02 +0100)
see https://bugs.kde.org/show_bug.cgi?id=476548

mold-debuginfo.patch [new file with mode: 0644]
valgrind.spec

diff --git a/mold-debuginfo.patch b/mold-debuginfo.patch
new file mode 100644 (file)
index 0000000..d452846
--- /dev/null
@@ -0,0 +1,130 @@
+From 9ea4ae66707a4dcc6f4328e11911652e4418c585 Mon Sep 17 00:00:00 2001
+From: Paul Floyd <pjfloyd@wanadoo.fr>
+Date: Sat, 18 Nov 2023 08:49:34 +0100
+Subject: [PATCH] Bug 476548 - valgrind 3.22.0 fails on assertion when loading
+ debuginfo file produced by mold
+
+---
+ NEWS                               |  1 +
+ coregrind/m_debuginfo/image.c      | 14 +++++++++
+ coregrind/m_debuginfo/priv_image.h |  4 +++
+ coregrind/m_debuginfo/readelf.c    | 49 ++++++++++++++++++++++++++++--
+ 4 files changed, 65 insertions(+), 3 deletions(-)
+
+diff --git a/coregrind/m_debuginfo/image.c b/coregrind/m_debuginfo/image.c
+index 02e5090713..445f955551 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 a49846f149..c91e49f015 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 3af8072d20..418ee8627c 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.39.3
+
index 745707de222a9c64a1f67de8f800eec64369ac0e..376e94750194e799c33ac46e87161b7bed0efdb3 100644 (file)
@@ -7,15 +7,16 @@
 Summary:       An open-source memory debugger
 Summary(pl.UTF-8):     Otwarty odpluskwiacz pamięci
 Name:          valgrind
-Version:       3.18.1
-Release:       1
+Version:       3.22.0
+Release:       3
 License:       GPL v2+
 Group:         Development/Tools
 Source0:       https://sourceware.org/pub/valgrind/%{name}-%{version}.tar.bz2
-# Source0-md5: de56a5532b0c81781db677ca712c585a
+# Source0-md5: 38ea14f567efa09687a822b33b4d9d60
 Patch0:                %{name}-native-cpuid.patch
 Patch1:                %{name}-ld_linux_strlen.patch
 Patch2:                %{name}-datadir.patch
+Patch3:                mold-debuginfo.patch
 URL:           https://www.valgrind.org/
 BuildRequires: autoconf >= 2.50
 BuildRequires: automake >= 1:1.10
@@ -28,9 +29,10 @@ BuildRequires:       glibc-devel >= 6:2.2
 BuildRequires: libgomp-devel
 BuildRequires: libstdc++-devel
 %{?with_mpi:BuildRequires:     mpi-devel}
+BuildRequires: rpmbuild(macros) >= 2.007
 Obsoletes:     valgrind-callgrind < 0.11
 Obsoletes:     valgrind-calltree < 0.10
-ExclusiveArch: %{ix86} %{x8664} armv7hl armv7hnl armv7l ppc ppc64 s390x x32 aarch64
+ExclusiveArch: %{ix86} %{x8664} %{armv7} ppc ppc64 s390x x32 aarch64
 BuildRoot:     %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
 %define                _noautostrip    .*/vgpreload.*\\.so
@@ -38,6 +40,8 @@ BuildRoot:    %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 # ld portion broken
 %undefine      with_ccache
 
+%define                specflags_arm   -marm
+
 %description
 Valgrind is a GPL'd system for debugging and profiling Linux programs.
 With the tools that come with Valgrind, you can automatically detect
@@ -59,8 +63,16 @@ pracować.
 %patch0 -p1
 %patch1 -p1
 %patch2 -p1
+%patch3 -p1
+
+%{__sed} -E -i -e '1s,#!\s*/usr/bin/env\s+python3(\s|$),#!%{__python3}\1,' \
+       cachegrind/cg_annotate.in \
+       cachegrind/cg_merge.in \
+       cachegrind/cg_diff.in
 
-sed -i -e 's:^CFLAGS="-Wno-long-long":CFLAGS="$CFLAGS -Wno-long-long":' configure.ac
+%{__sed} -E -i -e '1s,#!\s*/usr/bin/env\s+perl(\s|$),#!%{__perl}\1,' \
+       callgrind/callgrind_annotate.in \
+       callgrind/callgrind_control.in
 
 %build
 %{__aclocal}
@@ -70,7 +82,6 @@ sed -i -e 's:^CFLAGS="-Wno-long-long":CFLAGS="$CFLAGS -Wno-long-long":' configur
 
 ac_cv_path_GDB=/usr/bin/gdb \
 %configure \
-       CC=gcc \
        --enable-tls \
        %{!?with_mpi:--with-mpicc=/bin/false} \
 %if "%{_lib}" != "lib"
@@ -118,6 +129,8 @@ rm -rf $RPM_BUILD_ROOT
 %dir %{_libexecdir}/%{name}
 %endif
 %attr(755,root,root) %{_libexecdir}/%{name}/*-linux
+%attr(755,root,root) %{_libexecdir}/%{name}/valgrind-monitor.py
+%attr(755,root,root) %{_libexecdir}/%{name}/valgrind-monitor-def.py
 %attr(755,root,root) %{_libexecdir}/%{name}/vgpreload_*-linux.so
 %{_libexecdir}/%{name}/*.xml
 %{_libexecdir}/%{name}/default.supp
This page took 0.184686 seconds and 4 git commands to generate.