diff --git a/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp b/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp --- a/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp +++ b/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp @@ -16,7 +16,6 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/BinaryFormat/COFF.h" -#include "llvm/Config/config.h" #include "llvm/DebugInfo/DWARF/DWARFContext.h" #include "llvm/DebugInfo/PDB/PDB.h" #include "llvm/DebugInfo/PDB/PDBContext.h" @@ -33,7 +32,6 @@ #include "llvm/Support/Path.h" #include #include -#include #include #if defined(_MSC_VER) @@ -168,14 +166,7 @@ bool findDebugBinary(const std::string &OrigPath, const std::string &DebuglinkName, uint32_t CRCHash, std::string &Result) { - std::string OrigRealPath = OrigPath; -#if defined(HAVE_REALPATH) - if (char *RP = realpath(OrigPath.c_str(), nullptr)) { - OrigRealPath = RP; - free(RP); - } -#endif - SmallString<16> OrigDir(OrigRealPath); + SmallString<16> OrigDir(OrigPath); llvm::sys::path::remove_filename(OrigDir); SmallString<16> DebugPath = OrigDir; // Try /path/to/original_binary/debuglink_name diff --git a/llvm/test/DebugInfo/symbolize-gnu-debuglink-no-realpath.test b/llvm/test/DebugInfo/symbolize-gnu-debuglink-no-realpath.test new file mode 100644 --- /dev/null +++ b/llvm/test/DebugInfo/symbolize-gnu-debuglink-no-realpath.test @@ -0,0 +1,17 @@ +# REQUIRES: shell +# Ensure that no realpath assumptions are made about .gnu_debuglink paths. + +# Copy inputs to some other location with arbitrary names, with the original +# filenames just being symlinks to the copies. Real files go in the "objs" dir, +# symlinks (with original names) go in "runfiles". +RUN: rm -rf %t/objs %t/runfiles +RUN: mkdir %t/objs %t/runfiles +RUN: cp %p/Inputs/dwarfdump-test.elf-x86-64 %t/objs/prog +RUN: cp %p/Inputs/dwarfdump-test.elf-x86-64.debuglink %t/objs/link +RUN: ln -s %t/objs/prog %t/runfiles/dwarfdump-test.elf-x86-64 +RUN: ln -s %t/objs/link %t/runfiles/dwarfdump-test.elf-x86-64.debuglink + +RUN: llvm-symbolizer --obj=%t/runfiles/dwarfdump-test.elf-x86-64.debuglink 0x40113f | FileCheck %s + +CHECK: main +CHECK-NEXT: /tmp/dbginfo{{[/\\]}}dwarfdump-test.cc:16