This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: NO_DOLLAR_IN_LABEL



> Here's a dumb question: if gas and gld can handle arbitrary strings as
> names, why not skip name mangling and assembling entirely?  Wouldn't
> this be cleanest?

Fully expanded C++ template names can be huge; it can actually be shorter
to use mangled names (with -fnew-abi), because the long names are highly
redundant.

Example: map<string,string>, an STL map that maps strings to strings.
(Let's ignore the std namespace for the moment).
There is a default template parameter, so this is really
map<string,string,less<string> >.
And string is itself a template,
string = basic_string<char,string_char_traits<char>,allocator<char> >.

So once this is fully expanded you have a very long string:

map<basic_string<char,string_char_traits<char>,allocator<char> >,
    basic_string<char,string_char_traits<char>,allocator<char> >,
    less<basic_string<char,string_char_traits<char>,allocator<char> > > >

Then consider the name of the copy constructor:

map<basic_string<char,string_char_traits<char>,allocator<char> >,
    basic_string<char,string_char_traits<char>,allocator<char> >,
    less<basic_string<char,string_char_traits<char>,allocator<char> > >
>::
map<basic_string<char,string_char_traits<char>,allocator<char> >,
    basic_string<char,string_char_traits<char>,allocator<char> >,
    less<basic_string<char,string_char_traits<char>,allocator<char> > > >
(const
map<basic_string<char,string_char_traits<char>,allocator<char> >,
    basic_string<char,string_char_traits<char>,allocator<char> >,
    less<basic_string<char,string_char_traits<char>,allocator<char> > > >
&);

However, it is highly redundant, and the -fnew-abi encoding needs
to only give the expansion of each sub-part once.  This way neither
the user, the assembler, nor the linker ever has to deal with these
huge names.  This encoding only needs two or three characters to repeat
an already named class or template class.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]