1 //===- DWARF.cpp ----------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
10 #include "InputFiles.h"
11 #include "InputSection.h"
12 #include "OutputSegment.h"
17 using namespace lld::macho
;
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
) {
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
)
37 *s
= toStringRef(isec
->data
);