[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
This commit is contained in:
Jez Ng 2021-06-13 23:30:33 -04:00
parent 167e7afcd5
commit 9c5d43fb55
1 changed files with 4 additions and 3 deletions

View File

@ -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.