exporting symbols from shared library

exporting symbols from shared library

Post by Liviu Nicoar » Sun, 14 Nov 1999 04:00:00



Hi,

I have come upon a  problem and due to lack of documentation (or
persistence in finding it :)) I need to know :
- How are the symbols exported from a shared/static library?

RSVP, TIA,
SS

 
 
 

exporting symbols from shared library

Post by segg » Mon, 15 Nov 1999 04:00:00



> Hi,

> I have come upon a  problem and due to lack of documentation (or
> persistence in finding it :)) I need to know :
> - How are the symbols exported from a shared/static library?

> RSVP, TIA,
> SS

Depend on the language used.

You can see which one are with the tool nm

$ nm --extern-only myobj.?[oa]

 
 
 

exporting symbols from shared library

Post by Victor Wagn » Mon, 15 Nov 1999 04:00:00


: Hi,

: I have come upon a  problem and due to lack of documentation (or
: persistence in finding it :)) I need to know :
: - How are the symbols exported from a shared/static library?

They are exported. Period. Unless you define variable as static (and
thus constrain its visibility to one source file, it would be exported.
Functions are always exported by default.

It is much more complicated to avoid exporting symbols from unix shared
library than vice versa.
: RSVP, TIA,
: SS

--

I don't answer questions by private E-Mail from this address.

 
 
 

exporting symbols from shared library

Post by Kelly Burkhar » Mon, 15 Nov 1999 04:00:00



> Hi,

> I have come upon a  problem and due to lack of documentation (or
> persistence in finding it :)) I need to know :
> - How are the symbols exported from a shared/static library?

By default, all external symbols are exported from a shared and static
libraries in Linux.  If you need to limit the symbols exported in a
shared library use a version script.  AFAIK there is no way to do this
for static libraries.

Attatched is an example of creating a shared library with and without
a version script.  (ripped from a message I posted back in August).

-K

slib1.h -------------------------------------------------

extern int slib_i;

int slib00();
int slib01();
int slib02();  

slib1.c --------------------------------------------------

#include <stdio.h>

int slib_i=5;

int slib00() { printf("slib00\n"); }
int slib01() { printf("slib01\n"); }
int slib02() { printf("slib02\n"); }

main.c -----------------------------------------------------

#include <stdio.h>

#include "slib1.h"

int main()
{
    int i = slib_i;
    slib00();
    slib01();
    slib02();

Quote:}                  

libslib1.ver ------------------------------------------------

#
# Export file for libslib1_ver
#
libslib1_ver.so.1.0 {
    global:
        slib_i;
        slib00;
        slib01;
        slib02;
    local:
        *;

Quote:};      

Makefile ---------------------------------------------------

all: main main_ver

main: main.c libslib1.so.1.0
        gcc -o main main.c -L. -lslib1

main_ver: main.c libslib1_ver.so.1.0
        gcc -o main_ver main.c -L. -lslib1_ver

libslib1.so.1.0 : slib1.c
        gcc -c -fPIC slib1.c
        gcc -shared -Wl,-soname,libslib1.so.1 -o libslib1.so.1.0 slib1.o        
        ln -sf libslib1.so.1.0 libslib1.so.1
        ln -sf libslib1.so.1.0 libslib1.so

libslib1_ver.so.1.0 : slib1.c libslib1.ver
        gcc -c -fPIC slib1.c
        gcc -shared -Wl,-soname,libslib1_ver.so.1,-version-script=libslib1.ver -o libslib1_ver.so.1.0 slib1.o        
        ln -sf libslib1_ver.so.1.0 libslib1_ver.so.1
        ln -sf libslib1_ver.so.1.0 libslib1_ver.so

clean:
        rm -f *.o *.a *.so *.so.* *~ main main_ver

-------------------------------------------------------------

--
Kelly R. Burkhart

(H)ow do you give Microsoft the benefit of the doubt when you know that if
you throw it into a room with truth, you'd risk a matter/anti-matter
explosion?
   -- Nicholas Petreley

 
 
 

1. Limiting exported symbols from a shared library

This might be a FAQ somewhere, but I sure can't find it!

Here goes;

How do I limit the symbols that are exported from a shared library?  I
have inherited some libraries for a project that need to get ported
from Windows.  For better or worse, these libraries have name
collisions that are resolved under Windows by making each library a
DLL and limiting the exported symbols to just API functions using
export files.  

Does the GNU linker support a mechanism similar to this?

Please post and email replies,

Thanks,

Jon Prettyman

2. Q:Send signal when a user login?

3. How to export specific symbols from shared libraries?

4. HP Jornada - Strong ARM Linux

5. Shared libraries/ Resolving Sybmbols on AIX/Exporting symbols

6. how to know ?

7. Shared Library exported symbols

8. GCC 2.7.2.1 4 GNUSTEP out 4 PowerPC architectures!

9. Exporting symbols in a dynamic library

10. Shared libs and exported symbols

11. Extracting exported symbol information from shared object files

12. replacing an exported symbol in a standard static library

13. How to specify an export list for linux shared libraries