diff --git a/lld/test/wasm/demangle.ll b/lld/test/wasm/demangle.ll new file mode 100644 index 000000000000..07f992745565 --- /dev/null +++ b/lld/test/wasm/demangle.ll @@ -0,0 +1,17 @@ +; RUN: llc -filetype=obj %s -o %t.o +; RUN: not wasm-ld --check-signatures --undefined _Z3fooi \ +; RUN: -o %t.wasm %t.o 2>&1 | FileCheck %s + +; CHECK: error: undefined symbol: foo(int) + +; RUN: not wasm-ld --check-signatures --no-demangle --undefined _Z3fooi \ +; RUN: -o %t.wasm %t.o 2>&1 | FileCheck -check-prefix=CHECK-NODEMANGLE %s + +; CHECK-NODEMANGLE: error: undefined symbol: _Z3fooi + +target triple = "wasm32-unknown-unknown-wasm" + +define hidden void @_start() local_unnamed_addr { +entry: + ret void +} diff --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp index 0de180a2c94a..443def7587db 100644 --- a/lld/wasm/Driver.cpp +++ b/lld/wasm/Driver.cpp @@ -280,6 +280,7 @@ void LinkerDriver::link(ArrayRef ArgsArr) { Config->AllowUndefined = Args.hasArg(OPT_allow_undefined); Config->CheckSignatures = Args.hasFlag(OPT_check_signatures, OPT_no_check_signatures, false); + Config->Demangle = Args.hasFlag(OPT_demangle, OPT_no_demangle, true); Config->Entry = getEntry(Args, Args.hasArg(OPT_relocatable) ? "" : "_start"); Config->ImportMemory = Args.hasArg(OPT_import_memory); Config->OutputFile = Args.getLastArgValue(OPT_o); diff --git a/lld/wasm/Options.td b/lld/wasm/Options.td index 6260d4d9843e..8c9baad2eece 100644 --- a/lld/wasm/Options.td +++ b/lld/wasm/Options.td @@ -11,6 +11,11 @@ multiclass Eq { def _eq: Joined<["--", "-"], name # "=">, Alias(NAME)>; } +multiclass B { + def NAME: Flag<["--", "-"], name>, HelpText; + def no_ # NAME: Flag<["--", "-"], "no-" # name>, HelpText; +} + // The follow flags are shared with the ELF linker def color_diagnostics: F<"color-diagnostics">, HelpText<"Use colors in diagnostics">; @@ -18,6 +23,10 @@ def color_diagnostics: F<"color-diagnostics">, def color_diagnostics_eq: J<"color-diagnostics=">, HelpText<"Use colors in diagnostics">; +defm demangle: B<"demangle", + "Demangle symbol names", + "Do not demangle symbol names">; + def entry: S<"entry">, MetaVarName<"">, HelpText<"Name of entry point symbol">;