1 //===- DWARF.h -----------------------------------------------*- C++ -*-===//
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 //===-------------------------------------------------------------------===//
9 #ifndef LLD_MACHO_DWARF_H
10 #define LLD_MACHO_DWARF_H
12 #include "llvm/ADT/StringRef.h"
13 #include "llvm/DebugInfo/DWARF/DWARFObject.h"
15 namespace lld::macho
{
19 // Implements the interface between LLVM's DWARF-parsing utilities and LLD's
20 // InputSection structures.
21 class DwarfObject final
: public llvm::DWARFObject
{
23 bool isLittleEndian() const override
{ return true; }
25 llvm::Optional
<llvm::RelocAddrEntry
> find(const llvm::DWARFSection
&sec
,
26 uint64_t pos
) const override
{
27 // TODO: implement this
31 void forEachInfoSections(
32 llvm::function_ref
<void(const llvm::DWARFSection
&)> f
) const override
{
36 llvm::StringRef
getAbbrevSection() const override
{ return abbrevSection
; }
37 llvm::StringRef
getStrSection() const override
{ return strSection
; }
39 llvm::DWARFSection
const &getLineSection() const override
{
43 llvm::DWARFSection
const &getStrOffsetsSection() const override
{
44 return strOffsSection
;
47 // Returns an instance of DwarfObject if the given object file has the
48 // relevant DWARF debug sections.
49 static std::unique_ptr
<DwarfObject
> create(ObjFile
*);
52 llvm::DWARFSection infoSection
;
53 llvm::DWARFSection lineSection
;
54 llvm::DWARFSection strOffsSection
;
55 llvm::StringRef abbrevSection
;
56 llvm::StringRef strSection
;
59 } // namespace lld::macho