]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Additional fix for gnu debug alt file resolving.
authorMark Wielaard <mark@klomp.org>
Sat, 13 Jan 2018 13:33:50 +0000 (14:33 +0100)
committerMark Wielaard <mark@klomp.org>
Sat, 13 Jan 2018 13:33:50 +0000 (14:33 +0100)
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

coregrind/m_debuginfo/readelf.c

index c19ff212b7851f6a09af66fa2bcb99ff3e11bdb5..70c28e629240496eff733dc590f23b84cb3f7d46 100644 (file)
@@ -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;
 }