[PATCH] D43947: [WebAssembly] Add assertion for init function signature

Nicholas Wilson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 1 09:04:21 PST 2018


ncw created this revision.
ncw added reviewers: ruiu, sbc100.
Herald added subscribers: llvm-commits, sunfish, aheejin, jgravelle-google, dschuff, jfb.

Split out from https://reviews.llvm.org/D43933


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D43947

Files:
  wasm/Writer.cpp


Index: wasm/Writer.cpp
===================================================================
--- wasm/Writer.cpp
+++ wasm/Writer.cpp
@@ -893,9 +893,12 @@
 void Writer::calculateInitFunctions() {
   for (ObjFile *File : Symtab->ObjectFiles) {
     const WasmLinkingData &L = File->getWasmObj()->linkingData();
-    for (const WasmInitFunc &F : L.InitFunctions)
-      InitFunctions.emplace_back(
-          WasmInitEntry{File->getFunctionSymbol(F.Symbol), F.Priority});
+    for (const WasmInitFunc &F : L.InitFunctions) {
+      FunctionSymbol *Sym = File->getFunctionSymbol(F.Symbol);
+      if (*Sym->getFunctionType() != WasmSignature{{}, WASM_TYPE_NORESULT})
+        error("invalid signature for init func");
+      InitFunctions.emplace_back(WasmInitEntry{Sym, F.Priority});
+    }
   }
 
   // Sort in order of priority (lowest first) so that they are called


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43947.136543.patch
Type: text/x-patch
Size: 864 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180301/fb763ff2/attachment.bin>


More information about the llvm-commits mailing list