diff options
Diffstat (limited to 'lld/wasm/SymbolTable.cpp')
-rw-r--r-- | lld/wasm/SymbolTable.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lld/wasm/SymbolTable.cpp b/lld/wasm/SymbolTable.cpp index c46eec41146..44417b076c7 100644 --- a/lld/wasm/SymbolTable.cpp +++ b/lld/wasm/SymbolTable.cpp @@ -425,9 +425,16 @@ Symbol *SymbolTable::addUndefinedFunction(StringRef name, StringRef importName, } if (!existingFunction->signature && sig) existingFunction->signature = sig; - if (isCalledDirectly && !signatureMatches(existingFunction, sig)) - if (getFunctionVariant(s, sig, file, &s)) + if (isCalledDirectly && !signatureMatches(existingFunction, sig)) { + auto* existingUndefined = dyn_cast<UndefinedFunction>(existingFunction); + // If the existing undefined functions is not called direcltly then let + // this one take precedence. Otherwise the existing function is either + // direclty called or defined, in which case we need a function variant. + if (existingUndefined && !existingUndefined->isCalledDirectly) replaceSym(); + else if (getFunctionVariant(s, sig, file, &s)) + replaceSym(); + } } return s; |