Check that COFF .obj files have sections with zero virtual address spaces.
When talking about the virtual address of sections the coff spec says: ... for simplicity, compilers should set this to zero. Otherwise, it is an arbitrary value that is subtracted from offsets during relocation. We don't currently subtract it, so check that it is zero. If some producer does create such files, we can change getRelocationOffset instead. llvm-svn: 241447
This commit is contained in:
@@ -361,6 +361,8 @@ getFirstReloc(const coff_section *Sec, MemoryBufferRef M, const uint8_t *Base) {
|
||||
relocation_iterator COFFObjectFile::section_rel_begin(DataRefImpl Ref) const {
|
||||
const coff_section *Sec = toSec(Ref);
|
||||
const coff_relocation *begin = getFirstReloc(Sec, Data, base());
|
||||
if (begin && Sec->VirtualAddress != 0)
|
||||
report_fatal_error("Sections with relocations should have an address of 0");
|
||||
DataRefImpl Ret;
|
||||
Ret.p = reinterpret_cast<uintptr_t>(begin);
|
||||
return relocation_iterator(RelocationRef(Ret, this));
|
||||
|
||||
Reference in New Issue
Block a user