[lld][WebAssembly] Handle weakly defined symbols in shared libraries.
authorSam Clegg <sbc@chromium.org>
Wed, 18 Aug 2021 16:57:34 +0000 (12:57 -0400)
committerSam Clegg <sbc@chromium.org>
Thu, 19 Aug 2021 23:25:49 +0000 (19:25 -0400)
commitc468dc1b12d8db2c2f881db5b0166f73345631c2
tree8bdc3e14fe18c8018b3cc533163a1770177ea324
parentfd3bd63df26ad0a3865fd1fcbdbbd0063f2b0761
[lld][WebAssembly] Handle weakly defined symbols in shared libraries.

In the case of weakly defined symbols in shared libraries we now
generate both an import and an export.  The dynamic linker can then
choose how a winner from among all the shared libraries that define a
given symbol.

Previously any direct usage of a weakly defined symbol would use the
DSO-local definition (For example, even through there would be single
address for a weakly defined function, each DSO could end up directly
calling its local version).

Fixes: https://github.com/emscripten-core/emscripten/issues/13773

Differential Revision: https://reviews.llvm.org/D108413
lld/test/wasm/shared-weak-symbols.s [new file with mode: 0644]
lld/wasm/Symbols.cpp
lld/wasm/Symbols.h
lld/wasm/SyntheticSections.cpp
lld/wasm/Writer.cpp