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
39 llvm::DWARFSection const &getLineSection() const override {
40 return lineSection;
41 }
42
43 llvm::DWARFSection const &getStrOffsetsSection() const override {
44 return strOffsSection;
45 }
46
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 *);
50
51private:
52 llvm::DWARFSection infoSection;
53 llvm::DWARFSection lineSection;
54 llvm::DWARFSection strOffsSection;
55 llvm::StringRef abbrevSection;
56 llvm::StringRef strSection;
57};
58
59} // namespace lld::macho
60
61#endif
62