[lld] 9c5d43f - [lld-macho] Try to fix MSAN "uninitialized memory" error

Jez Ng via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 13 20:47:28 PDT 2021


Author: Jez Ng
Date: 2021-06-13T23:47:09-04:00
New Revision: 9c5d43fb5513260dad86c135755bc5313a81e768

URL: https://github.com/llvm/llvm-project/commit/9c5d43fb5513260dad86c135755bc5313a81e768
DIFF: https://github.com/llvm/llvm-project/commit/9c5d43fb5513260dad86c135755bc5313a81e768.diff

LOG: [lld-macho] Try to fix MSAN "uninitialized memory" error

I *think* this is the fix, with the regression being introduced by
D104199. Not 100% sure since MSAN isn't supported on my Mac machine, and
it'll take some time to spin up a Linux box... will look at the
buildbots for answers

Added: 
    

Modified: 
    lld/MachO/Writer.cpp

Removed: 
    


################################################################################
diff  --git a/lld/MachO/Writer.cpp b/lld/MachO/Writer.cpp
index ebb2a5e8fa7b..c620d847441e 100644
--- a/lld/MachO/Writer.cpp
+++ b/lld/MachO/Writer.cpp
@@ -1074,10 +1074,11 @@ void macho::createSyntheticSections() {
 
   // This section contains space for just a single word, and will be used by
   // dyld to cache an address to the image loader it uses.
-  ArrayRef<uint8_t> data{bAlloc.Allocate<uint8_t>(target->wordSize),
-                         target->wordSize};
+  uint8_t *arr = bAlloc.Allocate<uint8_t>(target->wordSize);
+  memset(arr, 0, target->wordSize);
   in.imageLoaderCache = make<ConcatInputSection>(
-      segment_names::data, section_names::data, /*file=*/nullptr, data,
+      segment_names::data, section_names::data, /*file=*/nullptr,
+      ArrayRef<uint8_t>{arr, target->wordSize},
       /*align=*/target->wordSize, /*flags=*/S_REGULAR);
   // References from dyld are not visible to us, so ensure this section is
   // always treated as live.


        


More information about the llvm-commits mailing list