11cf9926bSpatrick //===- DWARF.h -----------------------------------------------*- C++ -*-===// 21cf9926bSpatrick // 31cf9926bSpatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 41cf9926bSpatrick // See https://llvm.org/LICENSE.txt for license information. 51cf9926bSpatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 61cf9926bSpatrick // 71cf9926bSpatrick //===-------------------------------------------------------------------===// 81cf9926bSpatrick 91cf9926bSpatrick #ifndef LLD_MACHO_DWARF_H 101cf9926bSpatrick #define LLD_MACHO_DWARF_H 111cf9926bSpatrick 121cf9926bSpatrick #include "llvm/ADT/StringRef.h" 131cf9926bSpatrick #include "llvm/DebugInfo/DWARF/DWARFObject.h" 141cf9926bSpatrick 15*dfe94b16Srobert namespace lld::macho { 161cf9926bSpatrick 171cf9926bSpatrick class ObjFile; 181cf9926bSpatrick 191cf9926bSpatrick // Implements the interface between LLVM's DWARF-parsing utilities and LLD's 201cf9926bSpatrick // InputSection structures. 211cf9926bSpatrick class DwarfObject final : public llvm::DWARFObject { 221cf9926bSpatrick public: isLittleEndian()231cf9926bSpatrick bool isLittleEndian() const override { return true; } 241cf9926bSpatrick find(const llvm::DWARFSection & sec,uint64_t pos)25*dfe94b16Srobert std::optional<llvm::RelocAddrEntry> find(const llvm::DWARFSection &sec, 261cf9926bSpatrick uint64_t pos) const override { 271cf9926bSpatrick // TODO: implement this 28*dfe94b16Srobert return std::nullopt; 291cf9926bSpatrick } 301cf9926bSpatrick forEachInfoSections(llvm::function_ref<void (const llvm::DWARFSection &)> f)311cf9926bSpatrick void forEachInfoSections( 321cf9926bSpatrick llvm::function_ref<void(const llvm::DWARFSection &)> f) const override { 331cf9926bSpatrick f(infoSection); 341cf9926bSpatrick } 351cf9926bSpatrick getAbbrevSection()361cf9926bSpatrick llvm::StringRef getAbbrevSection() const override { return abbrevSection; } getStrSection()371cf9926bSpatrick llvm::StringRef getStrSection() const override { return strSection; } 381cf9926bSpatrick getLineSection()39*dfe94b16Srobert llvm::DWARFSection const &getLineSection() const override { 40*dfe94b16Srobert return lineSection; 41*dfe94b16Srobert } 42*dfe94b16Srobert getStrOffsetsSection()43*dfe94b16Srobert llvm::DWARFSection const &getStrOffsetsSection() const override { 44*dfe94b16Srobert return strOffsSection; 45*dfe94b16Srobert } 46*dfe94b16Srobert 471cf9926bSpatrick // Returns an instance of DwarfObject if the given object file has the 481cf9926bSpatrick // relevant DWARF debug sections. 491cf9926bSpatrick static std::unique_ptr<DwarfObject> create(ObjFile *); 501cf9926bSpatrick 511cf9926bSpatrick private: 521cf9926bSpatrick llvm::DWARFSection infoSection; 53*dfe94b16Srobert llvm::DWARFSection lineSection; 54*dfe94b16Srobert llvm::DWARFSection strOffsSection; 551cf9926bSpatrick llvm::StringRef abbrevSection; 561cf9926bSpatrick llvm::StringRef strSection; 571cf9926bSpatrick }; 581cf9926bSpatrick 59*dfe94b16Srobert } // namespace lld::macho 601cf9926bSpatrick 611cf9926bSpatrick #endif 62