3.13.0-11 - Add valgrind-3.13.0-debug-alt-file.patch.
This commit is contained in:
parent
5c9a40daf7
commit
6cc1e8596b
113
valgrind-3.13.0-debug-alt-file.patch
Normal file
113
valgrind-3.13.0-debug-alt-file.patch
Normal file
@ -0,0 +1,113 @@
|
||||
From f3521f1d69312eb476c53eea06ee1187844efe18 Mon Sep 17 00:00:00 2001
|
||||
From: Mark Wielaard <mark@klomp.org>
|
||||
Date: Sat, 9 Dec 2017 23:01:29 +0100
|
||||
Subject: [PATCH] Fix gnu debug alt file resolving.
|
||||
|
||||
The path to the alt file is relative to the actual debug file.
|
||||
Make sure that we got the real file, not a (build-id) symlink.
|
||||
---
|
||||
coregrind/m_debuginfo/readelf.c | 57 +++++++++++++++++++++++++++++++++++++++--
|
||||
1 file changed, 55 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c
|
||||
index e612250..2d52322 100644
|
||||
--- a/coregrind/m_debuginfo/readelf.c
|
||||
+++ b/coregrind/m_debuginfo/readelf.c
|
||||
@@ -33,6 +33,7 @@
|
||||
|
||||
#include "pub_core_basics.h"
|
||||
#include "pub_core_vki.h"
|
||||
+#include "pub_core_vkiscnums.h"
|
||||
#include "pub_core_debuginfo.h"
|
||||
#include "pub_core_libcbase.h"
|
||||
#include "pub_core_libcprint.h"
|
||||
@@ -40,6 +41,7 @@
|
||||
#include "pub_core_machine.h" /* VG_ELF_CLASS */
|
||||
#include "pub_core_options.h"
|
||||
#include "pub_core_oset.h"
|
||||
+#include "pub_core_syscall.h"
|
||||
#include "pub_core_tooliface.h" /* VG_(needs) */
|
||||
#include "pub_core_xarray.h"
|
||||
#include "priv_misc.h" /* dinfo_zalloc/free/strdup */
|
||||
@@ -1527,6 +1529,51 @@ static Bool check_compression(ElfXX_Shdr* h, DiSlice* s) {
|
||||
return True;
|
||||
}
|
||||
|
||||
+/* Helper function to get the readlink path. Returns NULL on error.
|
||||
+ Otherwise the result needs to be released with dinfo_free.
|
||||
+*/
|
||||
+static HChar* readlink_path (const HChar *path)
|
||||
+{
|
||||
+ SizeT bufsiz = VG_(strlen)(path);
|
||||
+ HChar *buf = ML_(dinfo_strdup)("readlink_path.strdup", path);
|
||||
+ UInt tries = 8;
|
||||
+
|
||||
+ while (tries > 0) {
|
||||
+ SysRes res;
|
||||
+#if defined(VGP_arm64_linux)
|
||||
+ res = VG_(do_syscall4)(__NR_readlinkat, VKI_AT_FDCWD,
|
||||
+ (UWord)path, (UWord)buf, bufsiz);
|
||||
+#elif defined(VGO_linux) || defined(VGO_darwin)
|
||||
+ res = VG_(do_syscall3)(__NR_readlink, (UWord)path, (UWord)buf, bufsiz);
|
||||
+#elif defined(VGO_solaris)
|
||||
+ res = VG_(do_syscall4)(__NR_readlinkat, VKI_AT_FDCWD, (UWord)path,
|
||||
+ (UWord)buf, bufsiz);
|
||||
+#else
|
||||
+# error Unknown OS
|
||||
+#endif
|
||||
+ if (sr_isError(res))
|
||||
+ return NULL;
|
||||
+
|
||||
+ SSizeT r = sr_Res(res);
|
||||
+ if (r < 0) break;
|
||||
+ if (r == bufsiz) { // buffer too small; increase and retry
|
||||
+ bufsiz *= 2 + 16;
|
||||
+ buf = ML_(dinfo_realloc)("readlink_path.realloc", buf, bufsiz);
|
||||
+ tries--;
|
||||
+ continue;
|
||||
+ }
|
||||
+ buf[r] = '\0';
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ if (tries == 0) { // We tried, but weird long path?
|
||||
+ ML_(dinfo_free)(buf);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ return buf;
|
||||
+}
|
||||
+
|
||||
/* The central function for reading ELF debug info. For the
|
||||
object/exe specified by the DebugInfo, find ELF sections, then read
|
||||
the symbols, line number info, file name info, CFA (stack-unwind
|
||||
@@ -2926,8 +2973,12 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di )
|
||||
(debugaltlink_escn.szB - buildid_offset)
|
||||
* 2 + 1);
|
||||
|
||||
- /* The altfile might be relative to the debug file or main file. */
|
||||
+ /* The altfile might be relative to the debug file or main file.
|
||||
+ Make sure that we got the real file, not a symlink. */
|
||||
HChar *dbgname = di->fsm.dbgname ? di->fsm.dbgname : di->fsm.filename;
|
||||
+ HChar* rdbgname = readlink_path (dbgname);
|
||||
+ if (rdbgname == NULL)
|
||||
+ rdbgname = ML_(dinfo_strdup)("rdbgname", dbgname);
|
||||
|
||||
for (j = 0; j < debugaltlink_escn.szB - buildid_offset; j++)
|
||||
VG_(sprintf)(
|
||||
@@ -2937,9 +2988,11 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di )
|
||||
+ buildid_offset + j));
|
||||
|
||||
/* See if we can find a matching debug file */
|
||||
- aimg = find_debug_file( di, dbgname, altbuildid,
|
||||
+ aimg = find_debug_file( di, rdbgname, altbuildid,
|
||||
altfile_str_m, 0, True );
|
||||
|
||||
+ ML_(dinfo_free)(rdbgname);
|
||||
+
|
||||
if (altfile_str_m)
|
||||
ML_(dinfo_free)(altfile_str_m);
|
||||
ML_(dinfo_free)(altbuildid);
|
||||
--
|
||||
1.8.3.1
|
||||
|
@ -3,7 +3,7 @@
|
||||
Summary: Tool for finding memory management bugs in programs
|
||||
Name: %{?scl_prefix}valgrind
|
||||
Version: 3.13.0
|
||||
Release: 10%{?dist}
|
||||
Release: 11%{?dist}
|
||||
Epoch: 1
|
||||
License: GPLv2+
|
||||
URL: http://www.valgrind.org/
|
||||
@ -147,6 +147,9 @@ Patch16: valgrind-3.13.0-static-tls.patch
|
||||
# KDE#386397 PPC64 valgrind truncates powerpc timebase to 32-bits.
|
||||
Patch17: valgrind-3.13.0-ppc64-timebase.patch
|
||||
|
||||
# KDE#387773 - Files in .gnu_debugaltlink should be resolved relative to .debug
|
||||
Patch18: valgrind-3.13.0-debug-alt-file.patch
|
||||
|
||||
%if %{build_multilib}
|
||||
# Ensure glibc{,-devel} is installed for both multilib arches
|
||||
BuildRequires: /lib/libc.so.6 /usr/lib/libc.so /lib64/libc.so.6 /usr/lib64/libc.so
|
||||
@ -278,6 +281,7 @@ Valgrind User Manual for details.
|
||||
%patch15 -p1
|
||||
%patch16 -p1
|
||||
%patch17 -p1
|
||||
%patch18 -p1
|
||||
|
||||
%build
|
||||
# We need to use the software collection compiler and binutils if available.
|
||||
@ -480,6 +484,9 @@ echo ===============END TESTING===============
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Sun Dec 10 2017 Mark Wielaard <mjw@fedoraproject.org> - 3.13.0-11
|
||||
- Add valgrind-3.13.0-debug-alt-file.patch.
|
||||
|
||||
* Thu Nov 2 2017 Mark Wielaard <mjw@fedoraproject.org> - 3.13.0-10
|
||||
- Add valgrind-3.13.0-ppc64-timebase.patch.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user