Index: lld/COFF/CMakeLists.txt =================================================================== --- lld/COFF/CMakeLists.txt +++ lld/COFF/CMakeLists.txt @@ -37,7 +37,6 @@ Object Option Support - Symbolize WindowsManifest LINK_LIBS Index: lld/COFF/Config.h =================================================================== --- lld/COFF/Config.h +++ lld/COFF/Config.h @@ -18,12 +18,6 @@ #include #include -namespace llvm { -namespace symbolize { -class LLVMSymbolizer; -} -} // namespace llvm - namespace lld { namespace coff { @@ -232,8 +226,6 @@ bool swaprunNet = false; bool thinLTOEmitImportsFiles; bool thinLTOIndexOnly; - - llvm::symbolize::LLVMSymbolizer *symbolizer = nullptr; }; extern Configuration *config; Index: lld/COFF/InputFiles.h =================================================================== --- lld/COFF/InputFiles.h +++ lld/COFF/InputFiles.h @@ -26,6 +26,7 @@ #include namespace llvm { +struct DILineInfo; namespace pdb { class DbiModuleDescriptorBuilder; } @@ -206,6 +207,9 @@ llvm::Optional> getVariableLocation(StringRef var); + llvm::Optional getDILineInfo(uint32_t offset, + uint32_t sectionIndex); + private: const coff_section* getSection(uint32_t i); const coff_section *getSection(COFFSymbolRef sym) { Index: lld/COFF/InputFiles.cpp =================================================================== --- lld/COFF/InputFiles.cpp +++ lld/COFF/InputFiles.cpp @@ -807,6 +807,19 @@ return std::make_pair(saver.save(ret->first), ret->second); } +// Used only for DWARF debug info, which is not common (except in MinGW +// environments). +Optional ObjFile::getDILineInfo(uint32_t offset, + uint32_t sectionIndex) { + if (!dwarf) { + dwarf = make(DWARFContext::create(*getCOFFObj())); + if (!dwarf) + return None; + } + + return dwarf->getDILineInfo(offset, sectionIndex); +} + StringRef ltrim1(StringRef s, const char *chars) { if (!s.empty() && strchr(chars, s[0])) return s.substr(1); Index: lld/COFF/SymbolTable.cpp =================================================================== --- lld/COFF/SymbolTable.cpp +++ lld/COFF/SymbolTable.cpp @@ -110,13 +110,11 @@ static Optional> getFileLineDwarf(const SectionChunk *c, uint32_t addr) { - if (!config->symbolizer) - config->symbolizer = make(); - Expected expectedLineInfo = config->symbolizer->symbolizeCode( - *c->file->getCOFFObj(), {addr, c->getSectionNumber() - 1}); - if (!expectedLineInfo) + Optional optionalLineInfo = + c->file->getDILineInfo(addr, c->getSectionNumber() - 1); + if (!optionalLineInfo) return None; - const DILineInfo &lineInfo = *expectedLineInfo; + const DILineInfo &lineInfo = *optionalLineInfo; if (lineInfo.FileName == DILineInfo::BadString) return None; return std::make_pair(saver.save(lineInfo.FileName), lineInfo.Line);