Re: libstdc++ compatibility frustrations under linux x86
- From: Spoon <root@localhost>
- Date: Tue, 27 Nov 2007 13:10:57 +0100
Henrik Goldman wrote:
Assume you have a static library LIB written in C++ that exports a C interface like LIB_init(), LIB_action() and LIB_free(). Internally this LIB is in C++ but from outsiders it must from C.
I think you might need to rephrase the last sentence.
LIB is depending on STL and therefore depends on libstdc++. We cannot have dynamic linking with libstdc++ since it causes compatibility problems if LIB is used with a different compiler version for linking. libstdc++ only guarranties binary compatibility between minor versions. To overcome this we do static re-linking of the symbols into our library.
This relinking is done like:
ld -r $TMP/to_be_fixed.$O `$CXX --print-file-name=libstdc++.a` `$CXX --print-file-name=libgcc_eh.a` -o $filename;
This will merge the libstdc++ symbols into our library... which is good. Afterwards we need to hide them and we wrote a simple tool that works together with objcopy. objcopy does the job of hiding the symbols... but we furthermore change the section names to avoid same names between our library and other code.
So now we have a another user who is using LIB into his application APP (also c++ application).
This APP is compiled with an older g++ compiler more specifically g++ 3.3.6.
However for now he wants that his users should be able to use his application on older linux.
He is therefore sending his libstdc++.so.* and libgcc.so* to the end-users...
Now hell breaks loose though... since the library LIB starts to act weird and not as documented. This has caused a number of days of work only to realise what the problem is.
So LIB is suppose to use it's own private copy of libstdc++ instead of the public one... however I'm not sure about the legality of sending out libstdc++ libraries to other machines.
I said for now that the user should try to link the application statically so they won't have a shared copy.
I'm unsure about this whole scenario. There is very little and sparse documentation on this on the internet... this doesn't help in actually finding out which of these steps are legal and which should be avoided.
Can anyone shed some light on this complex issue?
Paul Pluzhnikov is one of the linker guruz :-)
You might find him in the gnu.gcc.help newsgroup.
Regards.
.
- Follow-Ups:
- Re: libstdc++ compatibility frustrations under linux x86
- From: Henrik Goldman
- Re: libstdc++ compatibility frustrations under linux x86
- References:
- libstdc++ compatibility frustrations under linux x86
- From: Henrik Goldman
- libstdc++ compatibility frustrations under linux x86
- Prev by Date: Re: new filesystem module
- Next by Date: Re: termios/ioctl: What is the function to force a keystroke into a tty?
- Previous by thread: libstdc++ compatibility frustrations under linux x86
- Next by thread: Re: libstdc++ compatibility frustrations under linux x86
- Index(es):
Relevant Pages
|
|