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

Re: Symbol-versioning a C++ library

On Thu, May 24, 2007 at 05:03:42PM +0200, Bas Wijnen wrote:

> Then I tried to give the whole shevek::fd class a different version by
> adding:

> SHEVEK_2 {
> 	global:
> 		shevek::fd::*;
> };

> (and some variations.)  That didn't work at all: it defines the version:
> 00000000 g    DO *ABS*  00000000  SHEVEK_2    SHEVEK_2
> But no symbol actually uses it.

> Inserting the mangled name does work (if I do it before the SHEVEK_1
> version, which makes sense).  However, I would like to use the symbols
> from my code, and not the things gcc makes of them.  Especially because
> I never know if gcc doesn't change the way it mangles in the future.

> So the question is: is that possible, and if so, how?

Linker scripts (what you're doing above) are input to ld, not to gcc; and ld
acts on raw objects with mangled symbol names, not on language-specific
source names; so I don't think the above is ever going to work for you,

Another option might be to put the symbol version information in the source
code, the way glibc does; since this has to be done per-symbol, you probably
want to make heavy use of preprocessing to accomplish this, and I'm not sure
that even this will work since this too is an embedded assembler directive
used by as rather than something handled by gcc directly.  Anyway, if you
want to give it a shot, it's documented somewhere in one of the info pages
for the toolchain (don't remember which, sorry), or you can find an example
in the glibc source in include/libc-symbols.h.

As far as future changes to symbol mangling are concerned:  there is a
standard for the C++ ABI, and the changes to C++ symbol mangling throughout
gcc 3.x were done specifically to bring gcc in line with the standard, so
there shouldn't really be much cause for worry in that regard.

Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
vorlon@debian.org                                   http://www.debian.org/

Reply to: