[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to know what modules were dlpreopen-ed?
From: |
Gary V. Vaughan |
Subject: |
Re: How to know what modules were dlpreopen-ed? |
Date: |
Mon, 13 Oct 2003 11:20:56 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20030925 Thunderbird/0.3 |
Kevin P. Fleming wrote:
I've got an application here with a number of plugin modules (about 30).
The user can pick and choose which ones they want to build at configure
time, and that all works fine.
I now want to support the user building an all-static version of the
application if they desire; to that end, I have switched to using ltdl
instead of libdl directly, so that I prepare for using dlpreopen-ed
modules. Switching to ltdl has not been a problem, I can still build a
shared-library version of the app and everything works fine.
Now I'm trying to set up support for the preopened modules; I have added
the call to LTDL_SET_PRELOADED_SYMBOLS at the appropriate place in the
code. However, I cannot find any way to determine the _list_ of modules
that were preopened, so that I can lt_dlsym them to get symbol
addresses. I don't want to have to know this ahead of time if at all
possible, but if I have to build a static list to compile into the
program I can do so. I'd much rather just interate through the "real"
lt_dlsymlist structure myself and determine what modules were preopened,
then go from there.
Is this possible?
I've not come across needing to dynamically determine the names of statically
preopened modules with ltdl before, and there is no API support for that, but
since your Makefile.am has to know which modules were preopened (when it
passes the -dlopen flags to libtool), why not generate a header that contains
the module names?
Makefile.am:
preopened.h: Makefile
@echo "#define MODULE_NAMES \"$(MODULE_NAMES)\"" > preopened.h
configure.ac:
AC_MSG_CHECKING(for modules to preload)
DLPREOPEN=
MODULE_NAMES=
default_preload='foo bar baz'
AC_ARG_WITH([modules],
[AC_HELP_STRING([--with-modules=MODULES], [preload MODULES])],
[use_modules="$withval"],
[use_modules="$default_preload"])
DLPREOPEN="-dlpreopen force"
if test -z "$use_modules"; then
use_modules=none
elif test "$use_modules" != yes; then
for module in $use_modules; do
DLPREOPEN="$DLPREOPEN -dlpreopen ../modules/$module.la"
MODULE_NAMES="$MODULE_NAMES $module"
done
fi
AC_MSG_RESULT($use_modules)
AC_SUBST(DLPREOPEN)
AC_SUBST(MODULE_NAMES)
Maybe you can persuade us that API support for this would be good, and supply
us with a patch to implement it? It should just be a simple matter of walking
through lt_preloaded_symbols and looking for elements with NULL addresses
(these are the module names, or @SELF@ for dlpreopened self).
HTH,
Gary.
--
())_. Gary V. Vaughan gary@(lilith.warpmail.net|gnu.org)
( '/ Research Scientist http://www.oranda.demon.co.uk ,_())____
/ )= GNU Hacker http://www.gnu.org/software/libtool \' `&
`(_~)_ Tech' Author http://sources.redhat.com/autobook =`---d__/