From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Berlin To: Andrew Cagney Cc: gdb-patches@sources.redhat.com Subject: Re: [PATCH] New C++ abstraction patch Date: Wed, 21 Feb 2001 13:31:00 -0000 Message-id: References: <3A940ED9.317F856@cygnus.com> X-SW-Source: 2001-02/msg00432.html Andrew Cagney writes: > Daniel Berlin wrote: > > > > Includes Elena's requested changes, moves gnu-v2-abi.c and gnu-v3-abi.c to > > the root directory. > > Dan, > > If I understand things correctly, in C++, a function signature > determines not just the calling convention but also the symbols real > name. If either of these requirements are not met then the code won't > work. Yes. It won't even link, though there's probably some pathological case i'm missing where it will. If for some reason, it does link, it certainly won't work. > Consequently, for C++, the mangler and other C++ stuff really > make up part of the over all application binary interface. Yes. Mangling is integral to any C++ ABI, because it is through mangling that you get unique names for overloaded methods and class names, and these unique names are the same, given the same function signature, as required by the One Definition Rule (which C doesn't have). The ODR, simplified, is as follow: 1. In any one translation unit, a template, type, function, or object can have no more than one definition. (Some of these can have any number of declarations. A definition provides an instance.) 2. In the entire program, an object or non-inline function cannot have more than one definition; if an object or function is used, it must have exactly one definition. (You can declare an object or function that is never used, in which case you don't have to provide a definition. In no event can there be more than one definition.) 3. Some things, like types, templates, and extern inline functions, can be defined in more than one translation unit. For a given entity, each definition must be the same. (Non-extern objects and functions in different translation units are different entities, even if their names and types are the same.) (On a side note, this is why we can ignore duplicate C++ symbols just based on the mangled name. Anytime we see another debug symbol, anywhere, with the same name as something we've already seen, by the ODR, it must be the exact same, and thus, have the exact same debug info). > > Hence the choice of ``cp-abi.*'' as the basename. Yup. > > Andrew