summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2015-10-15 06:41:45 +0000
committerLang Hames <lhames@gmail.com>2015-10-15 06:41:45 +0000
commit86a4593dd22de63127f232eb2e02fa7d358989d7 (patch)
tree38b979fa2c5386772bceb7e5cf9ad48757d1b7ff /llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
parent8ad7399f8ec69ec2c8790711810a4ab2fcef2a28 (diff)
downloadbcm5719-llvm-86a4593dd22de63127f232eb2e02fa7d358989d7.tar.gz
bcm5719-llvm-86a4593dd22de63127f232eb2e02fa7d358989d7.zip
[RuntimeDyld] Don't try to get the contents of sections that don't have any
(e.g. bss sections). MachO and ELF have been silently letting this pass, but COFFObjectFile contains an assertion to catch this kind of (ab)use of the getSectionContents, and this was causing the JIT to crash on COFF objects with BSS sections. This patch should fix that. llvm-svn: 250371
Diffstat (limited to 'llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp')
-rw-r--r--llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
index b2f017c94cb..27cd09834df 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
@@ -182,8 +182,6 @@ RuntimeDyldImpl::loadObjectImpl(const object::ObjectFile &Obj) {
continue;
uint64_t SectOffset;
Check(getOffset(*I, *SI, SectOffset));
- StringRef SectionData;
- Check(SI->getContents(SectionData));
bool IsCode = SI->isText();
unsigned SectionID =
findOrEmitSection(Obj, *SI, IsCode, LocalSections);
@@ -568,12 +566,14 @@ unsigned RuntimeDyldImpl::emitSection(const ObjectFile &Obj,
uint8_t *Addr;
const char *pData = nullptr;
- // In either case, set the location of the unrelocated section in memory,
- // since we still process relocations for it even if we're not applying them.
- Check(Section.getContents(data));
- // Virtual sections have no data in the object image, so leave pData = 0
- if (!IsVirtual)
+ // If this section contains any bits (i.e. isn't a virtual or bss section),
+ // grab a reference to them.
+ if (!IsVirtual && !IsZeroInit) {
+ // In either case, set the location of the unrelocated section in memory,
+ // since we still process relocations for it even if we're not applying them.
+ Check(Section.getContents(data));
pData = data.data();
+ }
// Code section alignment needs to be at least as high as stub alignment or
// padding calculations may by incorrect when the section is remapped to a
OpenPOWER on IntegriCloud