Is it possible to demangle C++ symbols by hand?
c++, demangler
Solution
The symbol looks like one produced by clang or gcc. Both of these compilers use an ABI based on the Itanium ABI. This document includes a section on demangling describing how external symbols are constructed. If you internalize the corresponding rules, you should be able to demangle the names.
I couldn't locate the document on the original site and off-hand I don't know where the official document lives.
Problem
I'm getting some errors like this: ``` dyld: lazy symbol binding failed: Symbol not found: __ZN2nm8RationalIxEC1ERKNS_10RubyObjectE Referenced from: /Users/jwoods/Projects/nmatrix/lib/nmatrix.bundle Expected in: flat namespace dyld: Symbol not found: __ZN2nm8RationalIxEC1ERKNS_10RubyObjectE Referenced from: /Users/jwoods/Projects/nmatrix/lib/nmatrix.bundle Expected in: flat namespace ``` and then the same for `__ZN2nm7ComplexIfEC1ERKNS_10RubyObjectE`. Unfortunately, `c++filt` doesn't seem to want to demangle these. When I try inputting them in the c++filtjs online interface, I get "Not a mangled C++ symbol." I'm a bit puzzled by the error message, since the example `c++filtjs` gives is `_ZN9wikipedia7article8wikilinkC1ERKSs`, which represents `wikipedia::article::wikilink::wikilink(std::string const&)`. I see several patterns, among them `ZN#`, `7` and `8` for `::`, and `C1ERK` for what I'm guessing is some kind of pass-by-reference to a constructor. I'd guess it's complaining that it's missing one of my constructors for `class Rational`, such as `Rational::Rational(RubyObject const&)`. `Rational` is a template, however, so it would be helpful for me to understand which version is missing. But the question here is really how I can demangle by hand. =)