diff options
Diffstat (limited to 'bolt/lib/Rewrite/ExecutableFileMemoryManager.cpp')
-rw-r--r-- | bolt/lib/Rewrite/ExecutableFileMemoryManager.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/bolt/lib/Rewrite/ExecutableFileMemoryManager.cpp b/bolt/lib/Rewrite/ExecutableFileMemoryManager.cpp index 8c41ca9..bc0dd2f 100644 --- a/bolt/lib/Rewrite/ExecutableFileMemoryManager.cpp +++ b/bolt/lib/Rewrite/ExecutableFileMemoryManager.cpp @@ -27,6 +27,12 @@ uint8_t *ExecutableFileMemoryManager::allocateSection( uint8_t *Ret = static_cast<uint8_t *>(llvm::allocate_buffer(Size, Alignment)); AllocatedSections.push_back(AllocInfo{Ret, Size, Alignment}); + // A Size of 1 might mean an empty section for which RuntimeDyld decided to + // allocate 1 byte. In this case, the allocation will never be initialized + // causing non-deterministic output section contents. + if (Size == 1) + *Ret = 0; + // Register a debug section as a note section. if (!ObjectsLoaded && RewriteInstance::isDebugSection(SectionName)) { BinarySection &Section = |