Skip to content

Commit 197bda5

Browse files
committed
[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.
1 parent c08384a commit 197bda5

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lld/wasm/Symbols.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ std::string toString(const wasm::Symbol &sym) {
2929
}
3030

3131
std::string maybeDemangleSymbol(StringRef name) {
32+
// WebAssembly requires caller and callee signatures to match, so we mangle
33+
// `main` in the case where we need to pass it arguments.
34+
if (name == "__main_argc_argv")
35+
return "main";
3236
if (wasm::config->demangle)
3337
return demangleItanium(name);
3438
return std::string(name);

0 commit comments

Comments
 (0)