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: 24 bool isLittleEndian() const override { return true; } 25 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 32 void forEachInfoSections( 33 llvm::function_ref<void(const llvm::DWARFSection &)> f) const override { 34 f(infoSection); 35 } 36 37 llvm::StringRef getAbbrevSection() const override { return abbrevSection; } 38 llvm::StringRef getStrSection() const override { return strSection; } 39 40 llvm::DWARFSection const &getLineSection() const override { 41 return lineSection; 42 } 43 44 // Returns an instance of DwarfObject if the given object file has the 45 // relevant DWARF debug sections. 46 static std::unique_ptr<DwarfObject> create(ObjFile *); 47 48 private: 49 llvm::DWARFSection infoSection; 50 llvm::DWARFSection lineSection; 51 llvm::StringRef abbrevSection; 52 llvm::StringRef strSection; 53 }; 54 55 } // namespace macho 56 } // namespace lld 57 58 #endif 59