From: Gary V. Vaughan Date: Sun, 8 Apr 2001 10:44:49 +0000 (+0000) Subject: * libltdl/ltdl.c (sys_shl_open): Cache a handle for the `self' X-Git-Tag: multi-language-merge-point~33 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=eb2ef810ddad716c9033a0181c892530d33a6bc9;p=thirdparty%2Flibtool.git * libltdl/ltdl.c (sys_shl_open): Cache a handle for the `self' module, since HPUX adds module symbols into the `self' pool if it is opened later. Return the cached pointer if the caller subsequently tries to open `self'. (sys_shl_sym): Diagnose NULL modules. --- diff --git a/ChangeLog b/ChangeLog index 600c1a6ba..c6e16f0e1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2001-04-08 Gary V. Vaughan + * libltdl/ltdl.c (sys_shl_open): Cache a handle for the `self' + module, since HPUX adds module symbols into the `self' pool if + it is opened later. Return the cached pointer if the caller + subsequently tries to open `self'. + (sys_shl_sym): Diagnose NULL modules. + From Peter Eisentraut * ltmain.in (clean,uninstall): test -e is not portable. Well, neither is -L, but I'm hoping that redirecting error messages diff --git a/libltdl/ltdl.c b/libltdl/ltdl.c index b7417ceb5..4e5971a9a 100644 --- a/libltdl/ltdl.c +++ b/libltdl/ltdl.c @@ -687,13 +687,22 @@ sys_shl_open (loader_data, filename) lt_user_data loader_data; const char *filename; { + static shl_t self = (shl_t) 0; lt_module module = shl_load (filename, LT_BIND_FLAGS, 0L); - + + /* Since searching for a symbol against a NULL module handle will also + look in everything else that was already loaded and exported with + the -E compiler flag, we always cache a handle saved before any + modules are loaded. */ + if (!self) + { + lt_ptr address; + shl_findsym (&self, "main", TYPE_UNDEFINED, &address); + } + if (!filename) { - /* A NULL handle is used to get symbols from self and everything - else already loaded that was exported with -E compiler flag. */ - module = (lt_module) 0; + module = self; } else { @@ -730,14 +739,14 @@ sys_shl_sym (loader_data, module, symbol) lt_module module; const char *symbol; { - int is_module_self = (module == (lt_module) 0); - lt_ptr address = 0; + lt_ptr address = 0; - /* shl_findsym considers zero valued MODULE as an indicator to saerch - for a symbol among all loaded (and exported) symbols including those - in the main executable. However, it sets MODULE to a valid module - address which breaks the semantics of libltdl's module management. */ - if (shl_findsym ((shl_t*) &module, symbol, TYPE_UNDEFINED, &address) == 0) + /* sys_shl_open should never return a NULL module handle */ + if (module == (lt_module) 0) + { + MUTEX_SETERROR (LT_DLSTRERROR (INVALID_HANDLE)); + } + else if (!shl_findsym((shl_t*) &module, symbol, TYPE_UNDEFINED, &address)) { if (!address) { @@ -745,9 +754,6 @@ sys_shl_sym (loader_data, module, symbol) } } - if (is_module_self) - module = (lt_module) 0; - return address; }