bool SectionRef::containsSymbol(SymbolRef S) const { Expected<section_iterator> SymSec = S.getSection(); if (!SymSec) { // TODO: Actually report errors helpfully. consumeError(SymSec.takeError()); return false; } return *this == **SymSec; }
// Given a symbol sym this functions returns the address and section of it. static error_code resolveSectionAndAddress(const COFFObjectFile *Obj, const SymbolRef &Sym, const coff_section *&ResolvedSection, uint64_t &ResolvedAddr) { if (error_code ec = Sym.getAddress(ResolvedAddr)) return ec; section_iterator iter(Obj->begin_sections()); if (error_code ec = Sym.getSection(iter)) return ec; ResolvedSection = Obj->getCOFFSection(iter); return object_error::success; }
// Given a symbol sym this functions returns the address and section of it. static std::error_code resolveSectionAndAddress(const COFFObjectFile *Obj, const SymbolRef &Sym, const coff_section *&ResolvedSection, uint64_t &ResolvedAddr) { if (std::error_code EC = Sym.getAddress(ResolvedAddr)) return EC; section_iterator iter(Obj->section_begin()); if (std::error_code EC = Sym.getSection(iter)) return EC; ResolvedSection = Obj->getCOFFSection(*iter); return std::error_code(); }
// Given a symbol sym this functions returns the address and section of it. static std::error_code resolveSectionAndAddress(const COFFObjectFile *Obj, const SymbolRef &Sym, const coff_section *&ResolvedSection, uint64_t &ResolvedAddr) { ErrorOr<uint64_t> ResolvedAddrOrErr = Sym.getAddress(); if (std::error_code EC = ResolvedAddrOrErr.getError()) return EC; ResolvedAddr = *ResolvedAddrOrErr; Expected<section_iterator> Iter = Sym.getSection(); if (!Iter) return errorToErrorCode(Iter.takeError()); ResolvedSection = Obj->getCOFFSection(**Iter); return std::error_code(); }
static std::error_code resolveRelocation(const Dumper::Context &Ctx, const coff_section *Section, uint64_t Offset, const coff_section *&ResolvedSection, uint64_t &ResolvedAddress) { SymbolRef Symbol; if (std::error_code EC = Ctx.ResolveSymbol(Section, Offset, Symbol, Ctx.UserData)) return EC; ErrorOr<uint64_t> ResolvedAddressOrErr = Symbol.getAddress(); if (std::error_code EC = ResolvedAddressOrErr.getError()) return EC; ResolvedAddress = *ResolvedAddressOrErr; ErrorOr<section_iterator> SI = Symbol.getSection(); ResolvedSection = Ctx.COFF.getCOFFSection(**SI); return std::error_code(); }
static std::error_code getOffset(const SymbolRef &Sym, uint64_t &Result) { uint64_t Address; if (std::error_code EC = Sym.getAddress(Address)) return EC; if (Address == UnknownAddressOrSize) { Result = UnknownAddressOrSize; return object_error::success; } const ObjectFile *Obj = Sym.getObject(); section_iterator SecI(Obj->section_begin()); if (std::error_code EC = Sym.getSection(SecI)) return EC; if (SecI == Obj->section_end()) { Result = UnknownAddressOrSize; return object_error::success; } uint64_t SectionAddress = SecI->getAddress(); Result = Address - SectionAddress; return object_error::success; }
bool SectionRef::containsSymbol(SymbolRef S) const { section_iterator SymSec = getObject()->section_end(); if (S.getSection(SymSec)) return false; return *this == *SymSec; }