[WebAssembly] Add support for table linking to wasm-ld
authorAndy Wingo <wingo@igalia.com>
Thu, 14 Jan 2021 09:15:56 +0000 (10:15 +0100)
committerAndy Wingo <wingo@igalia.com>
Mon, 18 Jan 2021 15:57:18 +0000 (16:57 +0100)
commit63393828078c382e8e69d9b8146372b70bbce20f
tree120d0d05c366eb8f669633e6bf4c6e4db7949fe2
parentce06475da94f1040d17d46d471dd48478576a76f
[WebAssembly] Add support for table linking to wasm-ld

This patch adds support to wasm-ld for linking multiple table references
together, in a manner similar to wasm globals. The indirect function
table is synthesized as needed.

To manage the transitional period in which the compiler doesn't yet
produce TABLE_NUMBER relocations and doesn't residualize table symbols,
the linker will detect object files which have table imports or
definitions, but no table symbols. In that case it will synthesize
symbols for the defined and imported tables.

As a change, relocatable objects are now written with table symbols,
which can cause symbol renumbering in some of the tests. If no object
file requires an indirect function table, none will be written to the
file. Note that for legacy ObjFile inputs, this test is conservative: as
we don't have relocs for each use of the indirecy function table, we
just assume that any incoming indirect function table should be
propagated to the output.

Differential Revision: https://reviews.llvm.org/D91870
22 files changed:
lld/test/wasm/alias.s
lld/test/wasm/export-table-explicit.test [new file with mode: 0644]
lld/test/wasm/init-fini.ll
lld/test/wasm/local-symbols.ll
lld/test/wasm/locals-duplicate.test
lld/test/wasm/pie.ll
lld/test/wasm/section-symbol-relocs.yaml
lld/test/wasm/shared.ll
lld/test/wasm/signature-mismatch.ll
lld/test/wasm/stack-pointer.ll
lld/test/wasm/weak-alias.ll
lld/wasm/Driver.cpp
lld/wasm/InputFiles.cpp
lld/wasm/InputFiles.h
lld/wasm/MarkLive.cpp
lld/wasm/SymbolTable.cpp
lld/wasm/SymbolTable.h
lld/wasm/Symbols.cpp
lld/wasm/Symbols.h
lld/wasm/SyntheticSections.cpp
lld/wasm/SyntheticSections.h
lld/wasm/Writer.cpp