[lld][WebAssembly] Initialize bss segments using memory.fill
commit1eb79e732c47386258e04c4b59a78047c422c0f4
authorSam Clegg <sbc@chromium.org>
Wed, 27 Oct 2021 01:08:07 +0000 (26 18:08 -0700)
committerSam Clegg <sbc@chromium.org>
Fri, 29 Oct 2021 00:15:08 +0000 (28 17:15 -0700)
treec71a618e880889df23042cb0268ac79a7a3c59a2
parentb65f24a74c64ae3b727c3d9e76594ddbbd403790
[lld][WebAssembly] Initialize bss segments using memory.fill

Previously we were relying on the dynamic loader to take care of this
but it simple and correct for us to do it here instead.

Now we initialize bss segments as part of `__wasm_init_memory` at the
same time we initialize passive segments.

In addition we extent the us of `__wasm_init_memory` outside of shared
memory situations.  Specifically it is now used to initialize bss
segments when the memory is imported.

Differential Revision: https://reviews.llvm.org/D112667
lld/test/wasm/data-segments.ll
lld/test/wasm/shared-memory-bss.s [new file with mode: 0644]
lld/test/wasm/tls.s
lld/wasm/Config.h
lld/wasm/OutputSections.cpp
lld/wasm/OutputSegment.h
lld/wasm/SyntheticSections.cpp
lld/wasm/Writer.cpp
llvm/include/llvm/BinaryFormat/Wasm.h