diff --git a/lld/MachO/Dwarf.h b/lld/MachO/Dwarf.h --- a/lld/MachO/Dwarf.h +++ b/lld/MachO/Dwarf.h @@ -22,7 +22,8 @@ class ObjFile; class MachODWARFSection final : public llvm::DWARFSection { - InputSection *isec = nullptr; +public: + const InputSection *isec = nullptr; }; // Implements the interface between LLVM's DWARF-parsing utilities and LLD's @@ -48,7 +49,7 @@ } llvm::StringRef getAbbrevSection() const override { return abbrevSection; } - StringRef getLineStrSection() const override { return lineStrSection; } + llvm::StringRef getLineStrSection() const override { return lineStrSection; } llvm::StringRef getStrSection() const override { return strSection; } // Returns an instance of DwarfObject if the given object file has the diff --git a/lld/MachO/Dwarf.cpp b/lld/MachO/Dwarf.cpp --- a/lld/MachO/Dwarf.cpp +++ b/lld/MachO/Dwarf.cpp @@ -10,6 +10,7 @@ #include "InputFiles.h" #include "InputSection.h" #include "OutputSegment.h" +#include "Symbols.h" #include @@ -36,7 +37,7 @@ continue; } - if (MachODWARFSection *m = StringSwitch(isec->name) + if (MachODWARFSection *m = StringSwitch(isec->name) .Case("__debug_addr", &dObj->addrSection) .Case("__debug_info", &dObj->infoSection) .Case("__debug_line", &dObj->lineSection) @@ -53,15 +54,20 @@ return nullptr; } -Optional DwarfObject::find(const llvm::DWARFSection &sec, - uint64_t pos) { - const auto &sec = dynamic_cast(sec); - if (sec.isec == nullptr) +static uint64_t resolver(uint64_t Type, uint64_t Offset, uint64_t S, + uint64_t LocData, int64_t Addend) { + return S + Addend; +} + +llvm::Optional DwarfObject::find(const llvm::DWARFSection &sec, + uint64_t pos) const { + auto &msec = static_cast(sec); + if (msec.isec == nullptr) return llvm::None; const Reloc *found = nullptr; // FIXME: relocs might be sorted already? (in which case, better to bisct?) - for (const auto &reloc : sec.isec->relocs) { + for (const auto &reloc : msec.isec->relocs) { if (reloc.offset == pos) { found = &reloc; break; @@ -70,7 +76,7 @@ if (!found) return llvm::None; - const auto *sym = found->referent.dyn_cast(); + const Symbol *sym = found->referent.dyn_cast(); if (!sym) return llvm::None; @@ -80,10 +86,10 @@ val = def->value; } - DataRefImpl d; + object::DataRefImpl d; d.p = found->addend; - return RelocAddrEntry{secIndex, RelocationRef(d, nullptr), - val, Optional(), - 0, LLDRelocationResolver::resolve}; + return RelocAddrEntry{secIndex, object::RelocationRef(d, nullptr), + val, llvm::Optional(), + 0, resolver}; }