Date: Mon, 9 Jun 2014 23:01:50 -0400 From: Ryan Stone <rysto32@gmail.com> To: Ed Maste <emaste@freebsd.org> Cc: freebsd-toolchain@freebsd.org Subject: Re: abi::__cxa_demangle provides invalid result on non-mangled symbols Message-ID: <CAFMmRNynAWrKvS7tpbCVn2ahqP6ZfqWHSsaPeUS1CRJPCUvHYw@mail.gmail.com> In-Reply-To: <CAPyFy2Buh4BUEuYW5nfQFdEMio9=yaDAkivg1zXPnEBzr_CzJQ@mail.gmail.com> References: <CAFMmRNw_9hS3YuDbjFJH0btvoPADJ7_4=L13z2sK71gctPzXhQ@mail.gmail.com> <CAPyFy2Buh4BUEuYW5nfQFdEMio9=yaDAkivg1zXPnEBzr_CzJQ@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Jun 9, 2014 at 10:44 PM, Ed Maste <emaste@freebsd.org> wrote: > On 9 June 2014 21:48, Ryan Stone <rysto32@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. You're right, it is a problem in Linux: [rstone@rstone-desktop shm]./demangle f __cxa_demangle("f") = "float", status=0 [rstone@rstone-desktop shm]./demangle i __cxa_demangle("i") = "int", status=0 [rstone@rstone-desktop shm]./demangle m __cxa_demangle("m") = "unsigned long", status=0 [rstone@rstone-desktop shm]./demangle main __cxa_demangle("main") = "(null)", status=-2 The GNU version is just a little smarter about erroring out properly on "main", but there's nothing stopping anybody from using a function called "f" so I'll use your recommended workaround. Thanks.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAFMmRNynAWrKvS7tpbCVn2ahqP6ZfqWHSsaPeUS1CRJPCUvHYw>