summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-07-06 14:26:07 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-07-06 14:26:07 +0000
commit76d650e8d77f19b9ee0ae708fff38109ff79e360 (patch)
tree1321f8e2cea2f151c47ec2e7059a0f7b21a4cca0 /llvm/lib/Object
parent5c235c09665d7b30529a8e88f66b353026cbf8ff (diff)
downloadbcm5719-llvm-76d650e8d77f19b9ee0ae708fff38109ff79e360.tar.gz
bcm5719-llvm-76d650e8d77f19b9ee0ae708fff38109ff79e360.zip
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
Diffstat (limited to 'llvm/lib/Object')
-rw-r--r--llvm/lib/Object/COFFObjectFile.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/llvm/lib/Object/COFFObjectFile.cpp b/llvm/lib/Object/COFFObjectFile.cpp
index 19b53d8028d..fcdd7d2c13b 100644
--- a/llvm/lib/Object/COFFObjectFile.cpp
+++ b/llvm/lib/Object/COFFObjectFile.cpp
@@ -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));
OpenPOWER on IntegriCloud