[lld] 197bda5 - [WebAssembly] Teach lld how to demangle "__main_argc_argv".

Dan Gohman via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 27 07:55:07 PST 2020


Author: Dan Gohman
Date: 2020-02-27T07:55:01-08:00
New Revision: 197bda587b4bb5e7603ad05fc1106332edc6afbd

URL: https://github.com/llvm/llvm-project/commit/197bda587b4bb5e7603ad05fc1106332edc6afbd
DIFF: https://github.com/llvm/llvm-project/commit/197bda587b4bb5e7603ad05fc1106332edc6afbd.diff

LOG: [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.

Added: 
    

Modified: 
    lld/wasm/Symbols.cpp

Removed: 
    


################################################################################
diff  --git a/lld/wasm/Symbols.cpp b/lld/wasm/Symbols.cpp
index 3d8fec412797..349fc651533e 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);


        


More information about the llvm-commits mailing list