[PATCH] D149243: [BOLT] Make sure all section allocations have deterministic contents

Job Noorman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 2 07:24:56 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rGf3ea4228fd35: [BOLT] Make sure all section allocations have deterministic contents (authored by jobnoorman).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149243/new/

https://reviews.llvm.org/D149243

Files:
  bolt/lib/Rewrite/ExecutableFileMemoryManager.cpp


Index: bolt/lib/Rewrite/ExecutableFileMemoryManager.cpp
===================================================================
--- bolt/lib/Rewrite/ExecutableFileMemoryManager.cpp
+++ bolt/lib/Rewrite/ExecutableFileMemoryManager.cpp
@@ -27,6 +27,12 @@
   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 =


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149243.518719.patch
Type: text/x-patch
Size: 800 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230502/cccc12b3/attachment.bin>


More information about the llvm-commits mailing list