summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorAndrew Kaylor <andrew.kaylor@intel.com>2013-10-16 00:32:24 +0000
committerAndrew Kaylor <andrew.kaylor@intel.com>2013-10-16 00:32:24 +0000
commit877b931a41366e22110c68335e8b92d7437bd09e (patch)
treef8797265100adf2a0280fedcda1057a41cb5e81e /llvm/lib
parentc442a76c601310c36f3c5fad32c05b9846ceec73 (diff)
downloadbcm5719-llvm-877b931a41366e22110c68335e8b92d7437bd09e.tar.gz
bcm5719-llvm-877b931a41366e22110c68335e8b92d7437bd09e.zip
Adding padding to the .eh_frame section in RuntimeDyld
llvm-svn: 192754
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
index 49f8dc378e3..febc81cde0b 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
@@ -258,6 +258,7 @@ unsigned RuntimeDyldImpl::emitSection(ObjectImage &Obj,
bool IsZeroInit;
bool IsReadOnly;
uint64_t DataSize;
+ unsigned PaddingSize = 0;
StringRef Name;
Check(Section.isRequiredForExecution(IsRequired));
Check(Section.isVirtual(IsVirtual));
@@ -272,6 +273,12 @@ unsigned RuntimeDyldImpl::emitSection(ObjectImage &Obj,
StubBufSize += StubAlignment - EndAlignment;
}
+ // The .eh_frame section (at least on Linux) needs an extra four bytes padded
+ // with zeroes added at the end. For MachO objects, this section has a
+ // slightly different name, so this won't have any effect for MachO objects.
+ if (Name == ".eh_frame")
+ PaddingSize = 4;
+
unsigned Allocate;
unsigned SectionID = Sections.size();
uint8_t *Addr;
@@ -280,7 +287,7 @@ unsigned RuntimeDyldImpl::emitSection(ObjectImage &Obj,
// Some sections, such as debug info, don't need to be loaded for execution.
// Leave those where they are.
if (IsRequired) {
- Allocate = DataSize + StubBufSize;
+ Allocate = DataSize + PaddingSize + StubBufSize;
Addr = IsCode
? MemMgr->allocateCodeSection(Allocate, Alignment, SectionID, Name)
: MemMgr->allocateDataSection(Allocate, Alignment, SectionID, Name,
@@ -298,6 +305,13 @@ unsigned RuntimeDyldImpl::emitSection(ObjectImage &Obj,
else
memcpy(Addr, pData, DataSize);
+ // Fill in any extra bytes we allocated for padding
+ if (PaddingSize != 0) {
+ memset(Addr + DataSize, 0, PaddingSize);
+ // Update the DataSize variable so that the stub offset is set correctly.
+ DataSize += PaddingSize;
+ }
+
DEBUG(dbgs() << "emitSection SectionID: " << SectionID
<< " Name: " << Name
<< " obj addr: " << format("%p", pData)
OpenPOWER on IntegriCloud