[llvm] [WebAssembly] Define `__funcref_call_table` in generated asm and objects (PR #180900)

Sam Clegg via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 10 11:55:16 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);
----------------
sbc100 wrote:

I see.  So you are trying to essentially convert this symbols from "weak undefined" to "weak defined" during ASM generation?

This still seems wrong.   Can/should we not instead change the original definition of `__indirect_function_table` from weak undefined to weak defined?

Better still shouldn't the symbol be "strong" + "undefined"?   i.e. the symbol is not optional, right?

https://github.com/llvm/llvm-project/pull/180900


More information about the llvm-commits mailing list