xref: /freebsd/contrib/llvm-project/lld/MachO/Dwarf.h (revision 81ad626541db97eb356e2c1d4a20eb2a26a766ab)
1e8d8bef9SDimitry Andric //===- DWARF.h -----------------------------------------------*- C++ -*-===//
2e8d8bef9SDimitry Andric //
3e8d8bef9SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4e8d8bef9SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5e8d8bef9SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6e8d8bef9SDimitry Andric //
7e8d8bef9SDimitry Andric //===-------------------------------------------------------------------===//
8e8d8bef9SDimitry Andric 
9e8d8bef9SDimitry Andric #ifndef LLD_MACHO_DWARF_H
10e8d8bef9SDimitry Andric #define LLD_MACHO_DWARF_H
11e8d8bef9SDimitry Andric 
12e8d8bef9SDimitry Andric #include "llvm/ADT/StringRef.h"
13e8d8bef9SDimitry Andric #include "llvm/DebugInfo/DWARF/DWARFObject.h"
14e8d8bef9SDimitry Andric 
15e8d8bef9SDimitry Andric namespace lld {
16e8d8bef9SDimitry Andric namespace macho {
17e8d8bef9SDimitry Andric 
18e8d8bef9SDimitry Andric class ObjFile;
19e8d8bef9SDimitry Andric 
20e8d8bef9SDimitry Andric // Implements the interface between LLVM's DWARF-parsing utilities and LLD's
21e8d8bef9SDimitry Andric // InputSection structures.
22e8d8bef9SDimitry Andric class DwarfObject final : public llvm::DWARFObject {
23e8d8bef9SDimitry Andric public:
24e8d8bef9SDimitry Andric   bool isLittleEndian() const override { return true; }
25e8d8bef9SDimitry Andric 
26e8d8bef9SDimitry Andric   llvm::Optional<llvm::RelocAddrEntry> find(const llvm::DWARFSection &sec,
27e8d8bef9SDimitry Andric                                             uint64_t pos) const override {
28e8d8bef9SDimitry Andric     // TODO: implement this
29e8d8bef9SDimitry Andric     return llvm::None;
30e8d8bef9SDimitry Andric   }
31e8d8bef9SDimitry Andric 
32e8d8bef9SDimitry Andric   void forEachInfoSections(
33e8d8bef9SDimitry Andric       llvm::function_ref<void(const llvm::DWARFSection &)> f) const override {
34e8d8bef9SDimitry Andric     f(infoSection);
35e8d8bef9SDimitry Andric   }
36e8d8bef9SDimitry Andric 
37e8d8bef9SDimitry Andric   llvm::StringRef getAbbrevSection() const override { return abbrevSection; }
38e8d8bef9SDimitry Andric   llvm::StringRef getStrSection() const override { return strSection; }
39e8d8bef9SDimitry Andric 
40*81ad6265SDimitry Andric   llvm::DWARFSection const &getLineSection() const override {
41*81ad6265SDimitry Andric     return lineSection;
42*81ad6265SDimitry Andric   }
43*81ad6265SDimitry Andric 
44e8d8bef9SDimitry Andric   // Returns an instance of DwarfObject if the given object file has the
45e8d8bef9SDimitry Andric   // relevant DWARF debug sections.
46e8d8bef9SDimitry Andric   static std::unique_ptr<DwarfObject> create(ObjFile *);
47e8d8bef9SDimitry Andric 
48e8d8bef9SDimitry Andric private:
49e8d8bef9SDimitry Andric   llvm::DWARFSection infoSection;
50*81ad6265SDimitry Andric   llvm::DWARFSection lineSection;
51e8d8bef9SDimitry Andric   llvm::StringRef abbrevSection;
52e8d8bef9SDimitry Andric   llvm::StringRef strSection;
53e8d8bef9SDimitry Andric };
54e8d8bef9SDimitry Andric 
55e8d8bef9SDimitry Andric } // namespace macho
56e8d8bef9SDimitry Andric } // namespace lld
57e8d8bef9SDimitry Andric 
58e8d8bef9SDimitry Andric #endif
59