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
15namespace lld::macho {
16
17class ObjFile;
18
19// Implements the interface between LLVM's DWARF-parsing utilities and LLD's
20// InputSection structures.
21class DwarfObject final : public llvm::DWARFObject {
22public:
23 bool isLittleEndian() const override { return true; }
24
25 std::optional<llvm::RelocAddrEntry> find(const llvm::DWARFSection &sec,
26 uint64_t pos) const override {
27 // TODO: implement this
28 return std::nullopt;
29 }
30
31 void forEachInfoSections(
32 llvm::function_ref<void(const llvm::DWARFSection &)> f) const override {
33 f(infoSection);
34 }
35
36 llvm::StringRef getAbbrevSection() const override { return abbrevSection; }
37 llvm::StringRef getStrSection() const override { return strSection; }
38 llvm::StringRef getLineStrSection() const override { return lineStrSection; }
39
40 llvm::DWARFSection const &getLineSection() const override {
41 return lineSection;
42 }
43
44 llvm::DWARFSection const &getStrOffsetsSection() const override {
45 return strOffsSection;
46 }
47
48 // Returns an instance of DwarfObject if the given object file has the
49 // relevant DWARF debug sections.
50 static std::unique_ptr<DwarfObject> create(ObjFile *);
51
52private:
53 llvm::DWARFSection infoSection;
54 llvm::DWARFSection lineSection;
55 llvm::DWARFSection strOffsSection;
56 llvm::StringRef abbrevSection;
57 llvm::StringRef strSection;
58 llvm::StringRef lineStrSection;
59};
60
61} // namespace lld::macho
62
63#endif
64