1 //===- DWARF.h -----------------------------------------------*- C++ -*-===//
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 //===-------------------------------------------------------------------===//
8 
9 #ifndef LLD_MACHO_DWARF_H
10 #define LLD_MACHO_DWARF_H
11 
12 #include "llvm/ADT/StringRef.h"
13 #include "llvm/DebugInfo/DWARF/DWARFObject.h"
14 
15 namespace lld {
16 namespace macho {
17 
18 class ObjFile;
19 
20 // Implements the interface between LLVM's DWARF-parsing utilities and LLD's
21 // InputSection structures.
22 class DwarfObject final : public llvm::DWARFObject {
23 public:
isLittleEndian()24   bool isLittleEndian() const override { return true; }
25 
find(const llvm::DWARFSection & sec,uint64_t pos)26   llvm::Optional<llvm::RelocAddrEntry> find(const llvm::DWARFSection &sec,
27                                             uint64_t pos) const override {
28     // TODO: implement this
29     return llvm::None;
30   }
31 
forEachInfoSections(llvm::function_ref<void (const llvm::DWARFSection &)> f)32   void forEachInfoSections(
33       llvm::function_ref<void(const llvm::DWARFSection &)> f) const override {
34     f(infoSection);
35   }
36 
getAbbrevSection()37   llvm::StringRef getAbbrevSection() const override { return abbrevSection; }
getStrSection()38   llvm::StringRef getStrSection() const override { return strSection; }
39 
40   // Returns an instance of DwarfObject if the given object file has the
41   // relevant DWARF debug sections.
42   static std::unique_ptr<DwarfObject> create(ObjFile *);
43 
44 private:
45   llvm::DWARFSection infoSection;
46   llvm::StringRef abbrevSection;
47   llvm::StringRef strSection;
48 };
49 
50 } // namespace macho
51 } // namespace lld
52 
53 #endif
54