From 192efa1357a0fe543cb4d54693a74d7df2e0a85d Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Sat, 21 May 2022 20:16:11 +0800 Subject: [PATCH] [Mach-O] Demangle symbols --- macho/mold.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/macho/mold.h b/macho/mold.h index e9328658f0..63944afe73 100644 --- a/macho/mold.h +++ b/macho/mold.h @@ -811,7 +811,7 @@ struct Context { bool dead_strip = false; bool dead_strip_dylibs = false; bool deduplicate = true; - bool demangle = false; + bool demangle = true; bool dylib = false; bool dynamic = true; bool export_dynamic = false; @@ -956,7 +956,10 @@ inline Symbol *get_symbol(Context &ctx, std::string_view name) { template inline std::ostream &operator<<(std::ostream &out, const Symbol &sym) { - out << sym.name; + if (opt_demangle && sym.name.starts_with("__Z")) + out << demangle(sym.name.substr(1)); + else + out << sym.name; return out; }