This is the mail archive of the
mailing list for the GCC project.
Mistake in C++ ABI substitution rules?
- From: Stan Shebs <shebs at apple dot com>
- To: gcc at gcc dot gnu dot org
- Date: Tue, 19 Feb 2002 14:42:02 -0800
- Subject: Mistake in C++ ABI substitution rules?
One of our tasks in migrating Darwin / Mac OS X to use GCC 3.x is
to provide a way to load I/O drivers written in C++ and compiled
with GCC 2.95. (Yeah yeah, bad idea, but the deed is done, and
alternative is to compile the kernel's I/O subsystem with 2.95
forever, I'll work hard to avoid that fate.)
Anyway, to translate the symbols we have a homemade 2.95 compat
demangler (written using a spec I handed to the kernel hacker,
poor guy) feeding into a remangler written using the spec at
http://www.codesourcery.com/cxx-abi/abi.html#mangling. So far
so good, we have something that actually does the right thing
most of the time. However, there is a troublesome point in the
substitution rules for the new C++ ABI, where it says
"Logically, the substitutable components of a mangled name are
considered left-to-right, components before the composite structure
of which they are a part. If a component has been encountered
before, it is substituted as described below. This decision is
independent of whether its components have been substituted,
so an implementation MAY OPTIMIZE by considering large structures
for substitution before their components. If a component has not
been encountered before, its mangling is identified, and it is
added to a dictionary of substitution candidates. No entity is
added to the dictionary twice." (emphasis mine)
This sure sounds like it's allowing different compilers to mangle
names differently, by choosing to substitute in different ways.
And indeed we had to determine 3.x's behavior empirically. But
this seems like a fatal blow to the goal of an ABI that could
allow object files from different compilers to be linked together,
or to link code from two different 3.x versions of GCC.
Am I missing something here, or is there an unresolved omission
in the name mangling rules of the C++ ABI?