[WebAssembly] Teach lld how to demangle "__main_argc_argv".

WebAssembly requires that caller and callee signatures match, so it
can't do the usual trick of passing more arguments to main than it
expects. Instead WebAssembly will mangle "main" with argc/argv
parameters as "__main_argc_argv". This patch teaches lld how to
demangle it.

This patch is part of https://reviews.llvm.org/D70700.
This commit is contained in:
Dan Gohman 2020-02-27 07:51:37 -08:00
parent c08384a3ae
commit 197bda587b
1 changed files with 4 additions and 0 deletions

View File

@ -29,6 +29,10 @@ std::string toString(const wasm::Symbol &sym) {
}
std::string maybeDemangleSymbol(StringRef name) {
// WebAssembly requires caller and callee signatures to match, so we mangle
// `main` in the case where we need to pass it arguments.
if (name == "__main_argc_argv")
return "main";
if (wasm::config->demangle)
return demangleItanium(name);
return std::string(name);