From: Mark Wielaard Date: Sat, 13 Jan 2018 13:33:50 +0000 (+0100) Subject: Additional fix for gnu debug alt file resolving. X-Git-Tag: VALGRIND_3_14_0~181 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7d0403032250c8985ae99a96af7bcd9190ad654b;p=thirdparty%2Fvalgrind.git Additional fix for gnu debug alt file resolving. Also handle the case where the symlink itself contains a relative path. Then we need to add the symlink dir before it. https://bugs.kde.org/show_bug.cgi?id=387773 --- diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c index c19ff212b7..70c28e6292 100644 --- a/coregrind/m_debuginfo/readelf.c +++ b/coregrind/m_debuginfo/readelf.c @@ -1582,6 +1582,24 @@ static HChar* readlink_path (const HChar *path) return NULL; } + if (buf[0] == '/') + return buf; + + /* Relative path, add link dir. */ + HChar *linkdirptr; + SizeT linkdir_len = VG_(strlen)(path); + if ((linkdirptr = VG_(strrchr)(path, '/')) != NULL) + linkdir_len -= VG_(strlen)(linkdirptr + 1); + + SizeT buflen = VG_(strlen)(buf); + SizeT needed = linkdir_len + buflen + 1; + if (bufsiz < needed) + buf = ML_(dinfo_realloc)("readlink_path.linkdir", buf, needed); + + VG_(memmove)(buf + linkdir_len, buf, buflen); + VG_(memcpy)(buf, path, linkdir_len); + buf[needed - 1] = '\0'; + return buf; }