Re: dlopen() and parent symbols

2004-02-05 Thread Francesco Casadei
Joe Lewis wrote:
I've read that I can't export symbols from the parent executable to
modules opened with dlopen().  So, I have a (hopefully) quick question. 
How can I export function(s) to those modules?

Joe Lewis
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]
Read the autobook at http://sources.redhat.com/autobook/ .
From section 18.1:
[...]
For instance, your main application may provide some utility function, 
`my_function', which you want a module to have access to. There are two 
ways to do that:

* You could use Libtool to link your application, using the 
`-export-dynamic' option to ensure that the global application symbols 
are available to modules. When libltdl loads a module into an 
application compiled like this, it will back-link symbols from the 
application to resolve any otherwise undefined symbols in a module. When 
the module is `ltdlopen'ed, libltdl will arrange for calls to 
`my_function' in the module, to execute the `my_function' implementation 
in the application.

  If you have need of this functionality, relying on back-linking 
is the simplest way to achieve it. Unfortunately, this simplicity is at 
the expense of portability: some platforms have no support for 
back-linking at all, and others will not allow a module to be created 
with unresolved symbols. Never-the-less, libltdl allows you to do this 
if you want to.

* You could split the code that implements the symbols you need to 
share with modules into a separate library. This library would then be 
used to resolve the symbols you wish to share, by linking it into 
modules and application alike. The definition of `my_function' would be 
compiled separately into a library, `libmy_function.la'. References to 
`my_function' from the application would be resolved by linking it with 
`libmy_function.la', and the library would be installed so that modules 
which need to call `my_function' would be able to resolve the symbol by 
linking with `-lmy_function'.

  This method requires support for neither back-linking nor 
unresolved link time symbols from the host platform. The disadvantage is 
that when you realise you need this functionality, it may be quite 
complicated to extract the shared functionality from the application to 
be compiled in a stand alone library.
[...]

Francesco Casadei
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


dlopen() and parent symbols

2004-02-04 Thread Joe Lewis
I've read that I can't export symbols from the parent executable to
modules opened with dlopen().  So, I have a (hopefully) quick question. 
How can I export function(s) to those modules?


Joe Lewis
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: dlopen() and parent symbols

2004-02-04 Thread Chris Pressey
On Wed, 4 Feb 2004 19:48:31 -0700 (MST)
Joe Lewis [EMAIL PROTECTED] wrote:

 I've read that I can't export symbols from the parent executable to
 modules opened with dlopen().  So, I have a (hopefully) quick
 question. How can I export function(s) to those modules?

Can you pass them a function pointer (callback)?  Don't know, never
tried it with a dlopen()'ed object, but I can't immediately see why it
wouldn't work...

-Chris
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: dlopen() and parent symbols

2004-02-04 Thread Dan Nelson
In the last episode (Feb 04), Joe Lewis said:
 I've read that I can't export symbols from the parent executable to
 modules opened with dlopen().  So, I have a (hopefully) quick
 question.  How can I export function(s) to those modules?

ld --export-dynamic?

  -E
  --export-dynamic
 When creating a dynamically linked executable, add all  symbols  to
 the  dynamic  symbol table.  The dynamic symbol table is the set of
 symbols which are visible from dynamic objects at run time.

 If you do not use this option, the dynamic symbol table  will  nor-
 mally  contain  only  those  symbols  which  are referenced by some
 dynamic object mentioned in the link.

 If you use dlopen to load a dynamic object which needs  to  refer
 back  to the symbols defined by the program, rather than some other
 dynamic object, then you will probably need to use this option when
 linking the program itself.



-- 
Dan Nelson
[EMAIL PROTECTED]
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]