+error_code COFFObjectFile::getRelocationNext(DataRefImpl Rel,
+ RelocationRef &Res) const {
+ const coff_section *Sect = NULL;
+ if (error_code ec = getSection(Rel.d.b, Sect))
+ return ec;
+ if (++Rel.d.a >= Sect->NumberOfRelocations) {
+ Rel.d.a = 0;
+ while (++Rel.d.b < Header->NumberOfSections) {
+ const coff_section *Sect = NULL;
+ getSection(Rel.d.b, Sect);
+ if (Sect->NumberOfRelocations > 0)
+ break;
+ }
+ }
+ Res = RelocationRef(Rel, this);
+ return object_error::success;
+}
+error_code COFFObjectFile::getRelocationAddress(DataRefImpl Rel,
+ uint64_t &Res) const {
+ const coff_section *Sect = NULL;
+ if (error_code ec = getSection(Rel.d.b, Sect))
+ return ec;
+ const coff_relocation* R = toRel(Rel);
+ Res = reinterpret_cast<uintptr_t>(base() +
+ Sect->PointerToRawData +
+ R->VirtualAddress);
+ return object_error::success;
+}
+error_code COFFObjectFile::getRelocationSymbol(DataRefImpl Rel,
+ SymbolRef &Res) const {
+ const coff_relocation* R = toRel(Rel);
+ DataRefImpl Symb;
+ Symb.p = reinterpret_cast<uintptr_t>(SymbolTable + R->SymbolTableIndex);
+ Res = SymbolRef(Symb, this);
+ return object_error::success;
+}
+error_code COFFObjectFile::getRelocationType(DataRefImpl Rel,
+ uint32_t &Res) const {
+ const coff_relocation* R = toRel(Rel);
+ Res = R->Type;
+ return object_error::success;
+}
+error_code COFFObjectFile::getRelocationAdditionalInfo(DataRefImpl Rel,
+ int64_t &Res) const {
+ Res = 0;
+ return object_error::success;
+}
+ObjectFile::relocation_iterator COFFObjectFile::begin_relocations() const {
+ DataRefImpl ret;
+ ret.d.a = 0;
+ ret.d.b = 1;
+ return relocation_iterator(RelocationRef(ret, this));
+}
+ObjectFile::relocation_iterator COFFObjectFile::end_relocations() const {
+ DataRefImpl ret;
+ ret.d.a = 0;
+ ret.d.b = Header->NumberOfSections;
+ return relocation_iterator(RelocationRef(ret, this));
+}
+