Setting symbol versions to use without stub libraries

Mike Hearn <[email protected]>
Newsgroups gmane.linux.lsb.discuss
Message-ID <1057094504.7022.22.camel@littlegreen>
Hi,

You know how the LSB CC dev environment uses stub libs? Well, I think
it'd be cleaner to use this approach:

[mike@littlegreen test]$ cat test.c
#include <stdlib.h>
 
__asm__(".symver realpath,realpath@GLIBC_2.0");
 
int main() {
  char *rp;
  printf("foo\n");
 
  rp = malloc(512);
   
  realpath("/lib", rp);
   
  return 0;
}


Ignore the program itself, it just uses the "realpath" function which
has several versions. You can use that asm directive to set the one you
want. Try it! Good clean fun for all the family.

Anyway, I think embedding these directives in the header files might
have the following advantages:

* No need for stub libs, just use a different set of headers.
* Simpler
* You can link against your system libs, which means you can link
against other libs as well (obviously not a concern for the LSB as you
need to statically link it all anyway, but I want to do this).

Disadvantage: well, it's effort to change the current build process, and
I don't know how well it'd fit in with the database approach.

OTOH I am willing to do some of the work for this, because at the moment
in order to compile a binary that happens to use an older set of glibc
symvers, we need to use a hacked up lsbcc style program, which is less
than ideal. In particular, it means we need to create stub libs for
everything we link against, due to lds habit of attempting to close the
symbol set. 

Just being able to alter the headers in use would be a MUCH easier way
of building binaries using old symbol versions.

Thoughts? Comments?
thanks -mike
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.