[LLD][COFF] Ignore DEBUG_S_XFGHASH_TYPE/VIRTUAL
[llvm-project.git] / lld / MachO / Dwarf.cpp
blob47dc51e6196d12099731880203bfad82f8bad6fc
1 //===- DWARF.cpp ----------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "Dwarf.h"
10 #include "InputFiles.h"
11 #include "InputSection.h"
12 #include "OutputSegment.h"
14 #include <memory>
16 using namespace lld;
17 using namespace lld::macho;
18 using namespace llvm;
20 std::unique_ptr<DwarfObject> DwarfObject::create(ObjFile *obj) {
21 auto dObj = std::make_unique<DwarfObject>();
22 bool hasDwarfInfo = false;
23 // LLD only needs to extract the source file path and line numbers from the
24 // debug info, so we initialize DwarfObject with just the sections necessary
25 // to get that path. The debugger will locate the debug info via the object
26 // file paths that we emit in our STABS symbols, so we don't need to process &
27 // emit them ourselves.
28 for (const InputSection *isec : obj->debugSections) {
29 if (StringRef *s =
30 StringSwitch<StringRef *>(isec->getName())
31 .Case(section_names::debugInfo, &dObj->infoSection.Data)
32 .Case(section_names::debugLine, &dObj->lineSection.Data)
33 .Case(section_names::debugStrOffs, &dObj->strOffsSection.Data)
34 .Case(section_names::debugAbbrev, &dObj->abbrevSection)
35 .Case(section_names::debugStr, &dObj->strSection)
36 .Default(nullptr)) {
37 *s = toStringRef(isec->data);
38 hasDwarfInfo = true;
42 if (hasDwarfInfo)
43 return dObj;
44 return nullptr;