How to export specific symbols from shared libraries?

How to export specific symbols from shared libraries?

Post by Lutz Viewe » Thu, 11 Apr 1996 04:00:00



Hi,

I need to create a shared library that exports only two (of
its many) symbols to programs that link with it. Under HP-UX,
this can be done with the "+e" option to ld, but how is this
possible with the Solaris ld?

Thanks for any hint in advance,

Lutz Vieweg

--
 Lutz Vieweg

 Kaiserstrasse 65          | Phone: +49-69-236929
 60329 Frankfurt am Main   | Fax:   +49-69-236930

 
 
 

How to export specific symbols from shared libraries?

Post by Bart Smaalde » Thu, 11 Apr 1996 04:00:00


Quote:> I need to create a shared library that exports only two (of
> its many) symbols to programs that link with it. Under HP-UX,
> this can be done with the "+e" option to ld, but how is this
> possible with the Solaris ld?

You'lll want to read the Linker and Libraries Manual sections regarding
mapfiles.  In short:

cc -M mapfile -h libname.so.1 -o libname.so.1 -G file.o -lc

where mapfile contains:

{
global:
        public_symbol1;
        public_symbol2;
local:
        *;

Quote:};

See the answerbook for the details....

---
Bart Smaalders                  Solaris Clustering      SunSoft

http://playground.sun.com/~barts                   2550 Garcia Ave
                                                        Mt View, CA 94043-1100

 
 
 

How to export specific symbols from shared libraries?

Post by Rod Eva » Thu, 11 Apr 1996 04:00:00


Quote:> > I need to create a shared library that exports only two (of
> > its many) symbols to programs that link with it. Under HP-UX,
> > this can be done with the "+e" option to ld, but how is this
> > possible with the Solaris ld?

> You'll want to read the Linker and Libraries Manual sections regarding
> mapfiles.  In short:

> cc -M mapfile -h libname.so.1 -o libname.so.1 -G file.o -lc

> where mapfile contains:

> {
> global:
>    public_symbol1;
>    public_symbol2;
> local:
>    *;
> };

> See the answerbook for the details....

This functionality was first made available in Solaris 2.5.

In the 2.5 Linker and Libraries Guide (part of the Software Developer
Answerbook) see:

  o     Chapter 2, starting at section `Defining Additional Symbols'
        for an introduction to the new mapfile syntax.

  o     The new Chapter 5 for an overall guide to Versioning - this
        new mapfile syntax allows for establishing internal versions
        (symbol groupings) within a dynamic object.

  o     Appendix B provides a Versioning Cheat Sheet.

Rod.

 
 
 

How to export specific symbols from shared libraries?

Post by Lutz Viewe » Sat, 13 Apr 1996 04:00:00



> > > I need to create a shared library that exports only two (of
> > > its many) symbols to programs that link with it. Under HP-UX,
> > > this can be done with the "+e" option to ld, but how is this
> > > possible with the Solaris ld?
> This functionality was first made available in Solaris 2.5.

That's odd, we want to support Solaris 2.4 as well... is there
any way to make it work under 2.4?

Regards,

Lutz Vieweg

--
 Lutz Vieweg

 Kaiserstrasse 65          | Phone: +49-69-236929
 60329 Frankfurt am Main   | Fax:   +49-69-236930

 
 
 

How to export specific symbols from shared libraries?

Post by Rod Eva » Sat, 13 Apr 1996 04:00:00


Quote:> > > > I need to create a shared library that exports only two (of
> > > > its many) symbols to programs that link with it. Under HP-UX,
> > > > this can be done with the "+e" option to ld, but how is this
> > > > possible with the Solaris ld?

> > This functionality was first made available in Solaris 2.5.

> That's odd, we want to support Solaris 2.4 as well... is there
> any way to make it work under 2.4?

ld(1) didn't get extended to use the new mapfile syntax until 2.5.

You can build your shared object on 2.5 using this new ld(1) feature
and still use the object on 2.4.

Note, part of this ld(1) technology records an internal version name
to represent the symbol interface you've defined.  If you intend to use
the shared object to link against on 2.4, I'd recommend that you suppress
this internal version name recording:

        cc -G -o libfoo.so.1 -Mmapfile -Wl,-znoversion $(OBJS)

Rod.

 
 
 

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. FS: High-end Serial (Rocketport)

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

4. Freezing sessions.

5. Shared Library exported symbols

6. x86 vold doesn't recognize the CD but can boot from CD...

7. exporting symbols from shared library

8. Modelines for TV out

9. Exporting symbols in a dynamic library

10. replacing an exported symbol in a standard static library

11. Shared libs and exported symbols

12. Extracting exported symbol information from shared object files

13. Can gdb be set to stop at a specific shared library?