PATCH: Fix demangler in symbol versioning

Daniel Jacobowitz drow@mvista.com
Fri Dec 5 16:56:00 GMT 2003


On Fri, Dec 05, 2003 at 03:52:23AM +0100, Carlo Wood wrote:
> On Thu, Dec 04, 2003 at 08:04:01PM -0500, Ian Lance Taylor wrote:
> > "H. J. Lu" <hjl@lucon.org> writes:
> > 
> > > > It could conceivably lead to incorrect output.  I don't know.  For
> > > > example, if you call cplus_demangle ("i", DMGL_TYPES), you will get
> > > > "int".  So if there is an external variable named `i', it seems
> > > > conceivable that the wrong thing would happen.  I haven't thought
> > > > about whether this could really happen, though.
> > > 
> > > In that case, we have a regression with cxxfilt. The old one:
> > > 
> > > # cxxfilt i
> > > i
> > > 
> > > The new one:
> > > 
> > > # ./cxxfilt i
> > > int
> > 
> > What is ``the old one'' in this case?
> > 
> > I think a c++filt built from any sources in 2003 will print `int' when
> > passed `i'.  Certainly I have one which does that.
> 
> The correct behaviour is to print 'i'.
> 
> Documentation of __cxa_demangle:
> 
> // Ambiguities are possible between extern "C" object names and
> // internal built-in type names, e.g. "i" may be either an object
> // named "i" or the built-in "int" type.  Such ambiguities should
> // be resolved to user names over built-in names.  Builtin types
> // are any single lower case character.  Any other single
> // character is not a mangled type so we can treat those the same
> // here.
> 
> In other words, any single character input to c++filt should
> print 'i' if you call __cxa_demangle().

But cxxfilt deliberately uses DMGL_TYPES for command line input.
  /* For command line args, also try to demangle type encodings.  */
  result = cplus_demangle (mangled_name, flags | DMGL_TYPES);

cxxfilt should print int.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer



More information about the Binutils mailing list