[PATCH] D44028: [WebAssembly] Handle weak undefined functions with a synthetic stub

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 7 10:52:54 PST 2018


sbc100 added inline comments.


================
Comment at: wasm/MarkLive.cpp:78-85
+      Symbol *Sym = C->File->getSymbol(Reloc.Index);
+      // Don't mark functions live if we're taking the address of a function
+      // that won't actually go in the function table (has index zero).  This
+      // is the case for some synthetic functions.
+      if ((Reloc.Type == R_WEBASSEMBLY_TABLE_INDEX_SLEB ||
+           Reloc.Type == R_WEBASSEMBLY_TABLE_INDEX_I32) &&
+          cast<FunctionSymbol>(Sym)->hasNullTableIndex())
----------------
ruiu wrote:
> Adding a special rule for a weak symbol seems a bit odd to me because they are orthogonal in concept. What if you create functions after you garbage-collect symbols? Then you can remove this logic, can't you?
I also find this part of the change a little bit strange.   And I think the hasNullTableIndex() method helps to describe what is going on here.  However, inlineing hasNullTableIndex() along with a good comment is OK too.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D44028





More information about the llvm-commits mailing list