[llvm-symbolizer] Use correct path when resolving .gnu_debuglink in .debug

Summary:
The symbolizer was checking for .debug as a subdirectory of the
binary file itself, not of the directory containing the binary. This led to
a failure to find split debug info when it was contained in a .debug directory.

Reviewers: rnk, glider, zturner

Subscribers: llvm-commits, aprantl

Differential Revision: https://reviews.llvm.org/D44025

llvm-svn: 326630
diff --git a/llvm/test/tools/llvm-symbolizer/split-debug.test b/llvm/test/tools/llvm-symbolizer/split-debug.test
new file mode 100644
index 0000000..2d5b073
--- /dev/null
+++ b/llvm/test/tools/llvm-symbolizer/split-debug.test
@@ -0,0 +1,26 @@
+#Source:
+##include <stdio.h>
+#static inline int inctwo (int *a) {
+#  printf ("%d\n",(*a)++);
+#  return (*a)++;
+#}
+#static inline int inc (int *a) {
+#  printf ("%d\n",inctwo(a));
+#  return (*a)++;
+#}
+#
+#
+#int main () {
+#  int x = 1;
+#  return inc(&x);
+#}
+#
+#Build as : clang -g -O2 addr.c
+
+RUN: mkdir -p %t/.debug
+RUN: llvm-objcopy --keep=.debug_info %p/Inputs/addr.exe %t/.debug/addr
+RUN: llvm-objcopy --strip-debug --add-gnu-debuglink=%t/.debug/addr %p/Inputs/addr.exe %t/addr.exe
+RUN: llvm-symbolizer -print-address -obj=%t/addr.exe < %p/Inputs/addr.inp | FileCheck %s
+
+#CHECK: 0x40054d
+#CHECK: {{[/\]+}}tmp{{[/\]+}}x.c:14:0