[lld] r326579 - [WebAssembly] Add validation for init function signature
Nicholas Wilson via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 2 06:46:54 PST 2018
Author: ncw
Date: Fri Mar 2 06:46:54 2018
New Revision: 326579
URL: http://llvm.org/viewvc/llvm-project?rev=326579&view=rev
Log:
[WebAssembly] Add validation for init function signature
Differential Revision: https://reviews.llvm.org/D43947
Modified:
lld/trunk/wasm/Writer.cpp
Modified: lld/trunk/wasm/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/Writer.cpp?rev=326579&r1=326578&r2=326579&view=diff
==============================================================================
--- lld/trunk/wasm/Writer.cpp (original)
+++ lld/trunk/wasm/Writer.cpp Fri Mar 2 06:46:54 2018
@@ -893,9 +893,12 @@ void Writer::createCtorFunction() {
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: " + toString(*Sym));
+ InitFunctions.emplace_back(WasmInitEntry{Sym, F.Priority});
+ }
}
// Sort in order of priority (lowest first) so that they are called
More information about the llvm-commits
mailing list