diff --git a/lld/wasm/Relocations.cpp b/lld/wasm/Relocations.cpp --- a/lld/wasm/Relocations.cpp +++ b/lld/wasm/Relocations.cpp @@ -32,17 +32,13 @@ } static bool allowUndefined(const Symbol* sym) { - // Undefined functions and globals with explicit import name are allowed to be - // undefined at link time. - if (auto *f = dyn_cast(sym)) - if (f->importName || config->importUndefined) - return true; - if (auto *g = dyn_cast(sym)) - if (g->importName) - return true; - if (auto *g = dyn_cast(sym)) - if (g->importName) - return true; + // Symbols with explicit import names are always allowed to be undefined at + // link time. + if (sym->importName) + return true; + if (isa(sym) || config->importUndefined) + return true; + return config->allowUndefinedSymbols.count(sym->getName()) != 0; }