resolveSectionAndAddress(const COFFObjectFile *Obj, const SymbolRef &Sym,
const coff_section *&ResolvedSection,
uint64_t &ResolvedAddr) {
- if (std::error_code EC = Sym.getAddress(ResolvedAddr))
+ ErrorOr<uint64_t> ResolvedAddrOrErr = Sym.getAddress();
+ if (std::error_code EC = ResolvedAddrOrErr.getError())
return EC;
+ ResolvedAddr = *ResolvedAddrOrErr;
section_iterator iter(Obj->section_begin());
if (std::error_code EC = Sym.getSection(iter))
return EC;
ResolvedSection = Obj->getCOFFSection(*iter);
- return object_error::success;
+ return std::error_code();
}
// Given a vector of relocations for a section and an offset into this section
for (std::vector<RelocationRef>::const_iterator I = Rels.begin(),
E = Rels.end();
I != E; ++I) {
- uint64_t Ofs;
- if (std::error_code EC = I->getOffset(Ofs))
- return EC;
+ uint64_t Ofs = I->getOffset();
if (Ofs == Offset) {
Sym = *I->getSymbol();
- return object_error::success;
+ return std::error_code();
}
}
return object_error::parse_failed;
return EC;
if (std::error_code EC = Obj->getSectionContents(Section, Contents))
return EC;
- return object_error::success;
+ return std::error_code();
}
// Given a vector of relocations for a section and an offset into this section
SymbolRef Sym;
if (std::error_code EC = resolveSymbol(Rels, Offset, Sym))
return EC;
- if (std::error_code EC = Sym.getName(Name))
+ ErrorOr<StringRef> NameOrErr = Sym.getName();
+ if (std::error_code EC = NameOrErr.getError())
return EC;
- return object_error::success;
+ Name = *NameOrErr;
+ return std::error_code();
}
static void printCOFFSymbolAddress(llvm::raw_ostream &Out,
if (!PE32Header)
return;
- const coff_file_header *Header;
- if (error(Obj->getCOFFHeader(Header)))
- return;
// Currently only x86 is supported
- if (Header->Machine != COFF::IMAGE_FILE_MACHINE_I386)
+ if (Obj->getMachine() != COFF::IMAGE_FILE_MACHINE_I386)
return;
const data_directory *DataDir;
const import_lookup_table_entry32 *entry;
if (I->getImportLookupEntry(entry))
return;
- for (; entry->data; ++entry) {
+ for (; entry->Data; ++entry) {
if (entry->isOrdinal()) {
outs() << format(" % 6d\n", entry->getOrdinal());
continue;
}
void llvm::printCOFFUnwindInfo(const COFFObjectFile *Obj) {
- const coff_file_header *Header;
- if (error(Obj->getCOFFHeader(Header)))
- return;
-
- if (Header->Machine != COFF::IMAGE_FILE_MACHINE_AMD64) {
+ if (Obj->getMachine() != COFF::IMAGE_FILE_MACHINE_AMD64) {
errs() << "Unsupported image machine type "
"(currently only AMD64 is supported).\n";
return;