diff --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp --- a/lld/wasm/Driver.cpp +++ b/lld/wasm/Driver.cpp @@ -441,10 +441,8 @@ static UndefinedGlobal * createUndefinedGlobal(StringRef name, llvm::wasm::WasmGlobalType *type) { - auto *sym = - cast(symtab->addUndefinedGlobal(name, name, - defaultModule, 0, - nullptr, type)); + auto *sym = cast(symtab->addUndefinedGlobal( + name, name, defaultModule, WASM_SYMBOL_UNDEFINED, nullptr, type)); config->allowUndefinedSymbols.insert(sym->getName()); sym->isUsedInRegularObj = true; return sym; @@ -582,7 +580,8 @@ }; static Symbol *addUndefined(StringRef name) { - return symtab->addUndefinedFunction(name, "", "", 0, nullptr, nullptr, false); + return symtab->addUndefinedFunction(name, "", "", WASM_SYMBOL_UNDEFINED, + nullptr, nullptr, false); } // Handles -wrap option. diff --git a/lld/wasm/InputFiles.cpp b/lld/wasm/InputFiles.cpp --- a/lld/wasm/InputFiles.cpp +++ b/lld/wasm/InputFiles.cpp @@ -421,7 +421,7 @@ Symbol *ObjFile::createUndefined(const WasmSymbol &sym, bool isCalledDirectly) { StringRef name = sym.Info.Name; - uint32_t flags = sym.Info.Flags; + uint32_t flags = sym.Info.Flags | WASM_SYMBOL_UNDEFINED; switch (sym.Info.Kind) { case WASM_SYMBOL_TYPE_FUNCTION: @@ -509,6 +509,7 @@ bool excludedByComdat = c != -1 && !keptComdats[c]; if (objSym.isUndefined() || excludedByComdat) { + flags |= WASM_SYMBOL_UNDEFINED; if (objSym.isExecutable()) return symtab->addUndefinedFunction(name, name, defaultModule, flags, &f, nullptr, true); diff --git a/lld/wasm/SymbolTable.cpp b/lld/wasm/SymbolTable.cpp --- a/lld/wasm/SymbolTable.cpp +++ b/lld/wasm/SymbolTable.cpp @@ -401,6 +401,7 @@ LLVM_DEBUG(dbgs() << "addUndefinedFunction: " << name << " [" << (sig ? toString(*sig) : "none") << "] IsCalledDirectly:" << isCalledDirectly << "\n"); + assert(flags && WASM_SYMBOL_UNDEFINED); Symbol *s; bool wasInserted; @@ -443,6 +444,7 @@ Symbol *SymbolTable::addUndefinedData(StringRef name, uint32_t flags, InputFile *file) { LLVM_DEBUG(dbgs() << "addUndefinedData: " << name << "\n"); + assert(flags && WASM_SYMBOL_UNDEFINED); Symbol *s; bool wasInserted; @@ -464,6 +466,7 @@ InputFile *file, const WasmGlobalType *type) { LLVM_DEBUG(dbgs() << "addUndefinedGlobal: " << name << "\n"); + assert(flags && WASM_SYMBOL_UNDEFINED); Symbol *s; bool wasInserted;