[PATCH] D90948: [WebAssembly] call_indirect issues table number relocs

Andy Wingo via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 15 05:25:19 PST 2021


wingo added a comment.

Thinking about this a bit more after a nap -- how about I put some ensure-there's-a-function-table logic back to WasmObjectWriter in response to a TABLE_INDEX reloc, but I remove the feature detection from there.  I remove the logic from AsmPrinter (maybe; see below).

I have a new idea about how to determine when to write a symtab entry for `__indirect_function_table`.  How about, in WasmObjectWriter, we only write table symtab entries if they are needed.  If any table symtab entry is needed, all tables should have symtab entries.
A table needs a symtab entry if:

- it is used in a reloc (call_indirect issued a symbol reference); or
- it is not the indirect function table (check via name and isFunctionTable())

With this strategy, we may get a reference-types file which needs a `__indirect_function_table` because of a function bitcast, but it's not used in a reloc so no symtab entry is emitted.  That's fine with the linker logic from D96001 <https://reviews.llvm.org/D96001>.  The indirect function table will not be relocatable in that case but that's fine; the indirect function table will be assigned table number 0 anyway.  Only way that can fail is if the linker output defines `__indirect_function_table` locally but some other compilation unit imports a table; perhaps that is an argument for not removing the AsmPrinter case.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90948/new/

https://reviews.llvm.org/D90948



More information about the llvm-commits mailing list