3

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. =)

Translunar
  • 3,739
  • 33
  • 55
  • 5
    You probably have to remove one of the `_` from the front of the mangled name. – Shafik Yaghmour Aug 13 '13 at 21:54
  • 2
    `nm::Complex::Complex(nm::RubyObject const&)` is the first one, `nm::Rational::Rational(nm::RubyObject const&)` is the second one. You have to remove the first `_` from the mangled name. – Rapptz Aug 13 '13 at 21:54
  • 2
    It is absolutely possible to do by hand. However, you need to know the mangling rules, which vary from compiler to compiler... Remove the first underscore (there are two), and it will most likely work. – Mats Petersson Aug 13 '13 at 21:56
  • Ahh! Thanks, guys. This is helpful. Not directly related to this question: I know how to explicitly compile a specific template class, e.g., `Rational`, but how do I explicitly compile a specific template class constructor? – Translunar Aug 13 '13 at 21:59
  • @mohawkjohn: The most straightforward way would be to create an instance of the class, using the constructor you want. Most compilers won't generate code that's never used, particularly from a template. Once the compiler sees you're actually using the constructor, though, it'll include that in the code it generates (though it may do so inline). – cHao Aug 13 '13 at 22:21
  • 1
    did you try playing around with the c++filt switches? Sometimes passing `c++filt -t -n` to not ignore `_` can demangle the names. – greatwolf Aug 13 '13 at 22:46

1 Answers1

5

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.

Dietmar Kühl
  • 150,225
  • 13
  • 225
  • 380