tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Incorrect demangling



On Thu, Apr 26, 2012 at 12:12:35PM +0200, Joerg Sonnenberger wrote:
 > > >So it looks like you won't convince the GCC maintainers in
 > > >changing the compiler. Plus, PCC and CLANG will probably give you
 > > >similar problems.
 > > 
 > > It looks as though anything that performs demangling should have
 > > some way other than the symbol name of figuring out whether the
 > > symbol came from C++, so that it is not tripped up by valid C
 > > symbols that happen to mean something special when viewed as C++
 > > symbols.
 > 
 > It can't. Just look at the history of C++ and the way it has always been
 > implemented. On most systems it is simply not possible to use
 > non-C-compatible identifiers as result of the mangling, because the
 > assembler or linker would reject them. There is no bug here. Newer ld
 > defaults to mangling off again. It is purely cosmetic anyway. If you
 > want to use C and C++ in the same program, you either *depend* on being
 > able to create functions that can be used from C++ (including
 > overloading etc) or you will get a linker complain about redefinition on
 > accidental matches.

Buncombe.

You may recall that in a.out days, the C symbol "foo" appeared in the
assembler and linker namespace as "_foo", providing a large namespace
that C programs wouldn't overlap with. For some reason this practice
was dropped by the guys who designed ELF.

...furthermore, nothing prevents attaching a separate language code to
symbol names, except that our antiquated binary format doesn't support
it.

-- 
David A. Holland
dholland%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index