abi::__cxa_demangle provides invalid result on non-mangled symbols

Ed Maste emaste at freebsd.org
Tue Jun 10 02:44:38 UTC 2014


On 9 June 2014 21:48, Ryan Stone <rysto32 at gmail.com> wrote:
> abi::__cxa_demangle is giving me an invalid result if I pass it a
> symbol that is not mangled.  This is causing me problems as in my
> application, I'm getting symbol names from libelf and have no way of
> know a priori whether a symbol is mangled or not.

I had the same issue in LLVM, and as hacky as it seems, the solution
is to check that the name starts with "_Z" before passing it to
__cxa_demangle.

For reference the LLVM review for the change is here:
http://reviews.llvm.org/D2552

I didn't get around to testing it on Linux; since you have a test
application ready it would be interesting to see the result of
__cxa_demangle("f") there.


More information about the freebsd-toolchain mailing list