[PATCH] D34668: llvm-nm: Add suport for symbol demangling (-C/--demangle)

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 27 11:37:31 PDT 2017


sbc100 added inline comments.


================
Comment at: tools/llvm-nm/llvm-nm.cpp:668-669
+static Optional<std::string> demangle(StringRef Name) {
+  if ((Name.size() > 2 && Name.startswith("_Z")) ||
+      (Name.size() > 3 && Name.startswith("___Z"))) {
+    int Status;
----------------
davide wrote:
> I'm aware that Itanium mangled symbols start with `_Z` but I'm not aware of the `___Z` prefix, do you have an example?
I'm mostly cargo culting this from elsewhere in the codebase.

See tools/llvm-cxxdump/llvm-cxxdump.cpp.  It does a lot of checking for _Z symbols and it always checks for the double under version as well.

tools/llvm-objdump/MachODump.cpp seems to only check for the double under version.  

tools/llvm-cxxfilt/llvm-cxxfilt.cpp checks both.

`git grep __Z` seems to indicate that its the Mach-O format the includes the extra _ which would explain why MachODump.cpp only checks for that.

I'll dig a bit deeper and try to add another test.





https://reviews.llvm.org/D34668





More information about the llvm-commits mailing list