Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create backwards-compatible dynamic linkage?

It seems that glibc 2.14 introduced a new version of memcpy (to fix bug 12518). Programs compiled against glibc 2.14+, then, will contain a dynamic link to memcpy@GLIBC_2.14, which is clearly not available in older versions of glibc.

However, glibc 2.14+ obviously still contains the old memcpy@GLIBC_2.2.5 symbol for backwards compatibility. I'd like to be able to compile a few programs in such a way that they are binary-compatible with older glibc versions. How would one do to compile a program, on a system which has glibc 2.14+, so that it uses this old symbol version? If the procedure necessarily is compiler-specific, I'm using GCC (but it would be nice to know how to do it on other compilers as well).

(On a side note, I must admit don't know a whole lot about versioned symbols, such as how to produce them and how to use them, or whether they are ELF-specific or should be considered a standard part of modern ABIs; and I haven't managed to find any documentation about it. Are there any good sources of information on the subject?)

like image 755
Dolda2000 Avatar asked Jan 29 '14 01:01

Dolda2000


People also ask

Is glibc backwards compatible?

Glibc has a versioning system that allows backward compatibility (older programs built to run on older versions of glibc will continue to run on new glibc); but it is of no help the other way around: programs that depend on newer glibc will usually not run on systems with older glibc.

Is G ++ backwards compatible?

In order to allow compilation of C++ written to such drafts, G++ contains some backwards compatibilities. All such backwards compatibility features are liable to disappear in future versions of G++.

Is Adobe backwards compatible?

Adobe maintains compatibility within major release versions of Premiere Pro. Within a major release, project files are forward and backward compatible: you can open and save any Premiere Pro v15. x project with any 15.


1 Answers

The canonical document on shared libraries, symbol versioning, and related issues is Ulrich Drepper's http://www.akkadia.org/drepper/dsohowto.pdf‎ .

To make a reference to an older symbol, you would need to find a header that declares it, then use an assembler directive:

extern void nftw_old (int) ;
asm (".symver nftw_old,nftw@GLIBC_2.3.3");
void main ()
{
   nftw_old(0);
}

Note that the "nm" of the compiled executable refers to the expected previous-ABI nftw@GLIBC_2.3.3 implementation. (Don't try to run this program - the real nftw(3) function signature is different.)

like image 159
fche Avatar answered Sep 28 '22 06:09

fche