[llvm] [WebAssembly] Define `__funcref_call_table` in generated asm and objects (PR #180900)
Demetrius Kanios via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 10 12:51:49 PDT 2026
================
@@ -392,6 +392,22 @@ void WebAssemblyAsmPrinter::emitEndOfAsmFile(Module &M) {
// emitDecls() is not called until now.
emitDecls(M);
+ {
+ StringRef Name = "__funcref_call_table";
+ auto *Sym = static_cast<MCSymbolWasm *>(OutContext.lookupSymbol(Name));
+ if (Sym) {
+ if (!Sym->isFunctionTable())
+ OutContext.reportError(SMLoc(), "symbol is not a wasm funcref table");
+
+ if (Sym->isWeak()) {
+ OutStreamer->emitSymbolAttribute(Sym, MCSA_Weak);
+ }
+ if (!Sym->isDefined()) {
+ OutStreamer->emitLabel(Sym);
----------------
QuantumSegfault wrote:
Well...what is actually defining it, versus just declaring it? That's the key question, what's the "correct" way to define an arbitrary MCSymbol?
For most tables, they are created through IR level globals. emitGlobalVariable handles defining (through emitLabel) the MCSymbol if the Global has been defined.
But we are in the unusual situation where we synthesized a table with no attached global (the only other case of this in `__indirect_function_table`, which needs to be handled/populated/defined specially by the linker; so N/A).
https://github.com/llvm/llvm-project/pull/180900
More information about the llvm-commits
mailing list