Summary: Help needed with "ld -r -B reduce -M mapfile"

From: David L. Markowitz (David.Markowitz@litronic.com)
Date: Thu Oct 09 1997 - 13:16:01 CDT


I got one very succinct response from Casper Dik <casper@holland.Sun.COM>.

Thanks Casper!

The original request:
>I am trying to generate an object file suitable for loading into
>another program using dlopen(). It has numerous functions in it
>which must remain hidden to the outside world. Only one function
>should be visible externally; it will be used to access everything
>else.
>
>The ld man page says to use "-B reduce" or "-B local" to make
>everything local, and to use "-M mapfile" to specify those symbols
>which must remain global. It then points to the "Linker and Libraries
>manual" for instructions. This manual talks at length about using
>mapfiles, but never about how to specify global symbols with them.

Casper's response:

> Here's an example:

> % cat mapfile
> {
> global:
> foo;
> bar;
> baz;
> local: *;
> };

> Then link the library with:

> cc -M mapfile -G *.o -o lib.so

> and you'll only get foo bar baz as globals (and the builtin symbols).

> The "local: *" directive makes all symbols local. Global: lists the
> exceptions.
---

        David L. Markowitz Director, UNIX Software
        David.Markowitz@litronic.com Litronic Industries
        http://intra.litronic.com/davem http://www.litronic.com/



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:12:05 CDT