From 197bda587b4bb5e7603ad05fc1106332edc6afbd Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 27 Feb 2020 07:51:37 -0800 Subject: [PATCH] [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. --- lld/wasm/Symbols.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lld/wasm/Symbols.cpp b/lld/wasm/Symbols.cpp index 3d8fec4..349fc65 100644 --- a/lld/wasm/Symbols.cpp +++ b/lld/wasm/Symbols.cpp @@ -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); -- 2.7.4