1998-11-18 15:29:36 +08:00
|
|
|
/* ltdl.c -- system independent dlopen wrapper
|
1999-01-07 05:04:20 +08:00
|
|
|
Copyright (C) 1998-1999 Free Software Foundation, Inc.
|
|
|
|
Originally by Thomas Tanner <tanner@gmx.de>
|
1998-11-18 15:29:36 +08:00
|
|
|
This file is part of GNU Libtool.
|
|
|
|
|
1998-11-24 05:26:38 +08:00
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
1998-11-18 15:29:36 +08:00
|
|
|
|
1998-11-24 05:26:38 +08:00
|
|
|
This library is distributed in the hope that it will be useful,
|
1998-11-18 15:29:36 +08:00
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
1998-11-24 05:26:38 +08:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
1998-11-18 15:29:36 +08:00
|
|
|
|
1998-11-24 05:26:38 +08:00
|
|
|
You should have received a copy of the GNU Library General Public
|
|
|
|
License along with this library; if not, write to the Free
|
|
|
|
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define _LTDL_COMPILE_
|
1998-11-18 15:29:36 +08:00
|
|
|
|
1998-12-16 10:39:15 +08:00
|
|
|
#if HAVE_STRING_H
|
1998-11-18 15:29:36 +08:00
|
|
|
#include <string.h>
|
|
|
|
#endif
|
|
|
|
|
1998-12-16 10:39:15 +08:00
|
|
|
#if HAVE_STRINGS_H
|
1998-12-02 21:05:23 +08:00
|
|
|
#include <strings.h>
|
|
|
|
#endif
|
|
|
|
|
1998-12-19 06:23:51 +08:00
|
|
|
#if HAVE_CTYPE_H
|
|
|
|
#include <ctype.h>
|
|
|
|
#endif
|
|
|
|
|
1998-12-16 10:39:15 +08:00
|
|
|
#if HAVE_MALLOC_H
|
|
|
|
#include <malloc.h>
|
|
|
|
#endif
|
|
|
|
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
#if HAVE_MEMORY_H
|
|
|
|
#include <memory.h>
|
|
|
|
#endif
|
|
|
|
|
1998-12-16 10:39:15 +08:00
|
|
|
#if HAVE_STDLIB_H
|
|
|
|
#include <stdlib.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAVE_STDIO_H
|
1998-11-24 05:26:38 +08:00
|
|
|
#include <stdio.h>
|
1998-12-16 10:39:15 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "ltdl.h"
|
1998-11-24 05:26:38 +08:00
|
|
|
|
1999-01-10 04:05:55 +08:00
|
|
|
static const char *unknown_error = "unknown error";
|
1999-01-13 04:42:47 +08:00
|
|
|
static const char *dlopen_not_supported_error = "dlopen support not available";
|
|
|
|
static const char *dlpreopen_not_supported_error = "dlpreopen support not available";
|
1999-01-10 04:05:55 +08:00
|
|
|
static const char *file_not_found_error = "file not found";
|
|
|
|
static const char *no_symbols_error = "no symbols defined";
|
|
|
|
static const char *symbol_error = "symbol not found";
|
|
|
|
static const char *memory_error = "not enough memory";
|
|
|
|
static const char *invalid_handle_error = "invalid handle";
|
|
|
|
static const char *buffer_overflow_error = "internal buffer overflow";
|
1999-01-14 05:39:14 +08:00
|
|
|
static const char *shutdown_error = "library already shutdown";
|
1999-01-10 04:05:55 +08:00
|
|
|
|
1999-01-15 00:31:23 +08:00
|
|
|
static const char *last_error = 0;
|
|
|
|
static const char *usr_search_path = 0;
|
* ltmain.in (libobjs_save, oldobjs): when building an
old-fashioned archive, use a copy of libobjs saved before
convenience libraries are appended
* libltdl/ltdl.h (_LTDLL_EXPORT, _LTDLL_IMPORT): use cygwin or
unix library import/export primitives; this may be convenient for
people willing to create DLLs
(_LTDLL_EXTERN): select _LTDLL_EXPORT or _LTDLL_IMPORT depending
on _LTDL_COMPILE_
* libltdl/ltdl.h, libltdl/ltdl.c (lt_dlpreopen): new function,
that replaces the current preloaded_symbols list with its
argument, and returns the old value, initially NULL
(dldpre_init): don't refer to dld_preloaded_symbols any more
(dldpre_open, dldpre_sym): search preloaded_symbols
(lt_dlpreopen_default): call lt_dlpreopen with
dld_preloaded_symbols, that is declared as extern; it should be
called from the main program or from some static library without
-no-undefined
(lt_dlerror): new function, that returns the error message for the
last error occurred; the error message is kept in the static
variable last_error
* libltdl/configure.in (enable-ltdl-install): moved back from
enable-install; other packages might use enable-install already,
better have fine grained control over this.
* libltdl/Makefile.am (libltdls.la): discarded
1999-01-06 07:13:44 +08:00
|
|
|
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
typedef struct lt_dltype_t {
|
|
|
|
struct lt_dltype_t *next;
|
1999-01-15 00:31:23 +08:00
|
|
|
const char *sym_prefix; /* prefix for symbols */
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
int (*mod_init) __P((void));
|
|
|
|
int (*mod_exit) __P((void));
|
|
|
|
int (*lib_open) __P((lt_dlhandle handle, const char *filename));
|
|
|
|
int (*lib_close) __P((lt_dlhandle handle));
|
1998-12-19 06:23:51 +08:00
|
|
|
lt_ptr_t (*find_sym) __P((lt_dlhandle handle, const char *symbol));
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
} lt_dltype_t, *lt_dltype;
|
|
|
|
|
1998-12-25 18:39:59 +08:00
|
|
|
#define LT_DLTYPE_TOP 0
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
|
1998-12-02 21:05:23 +08:00
|
|
|
typedef struct lt_dlhandle_t {
|
|
|
|
struct lt_dlhandle_t *next;
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
lt_dltype_t *type; /* dlopening interface */
|
1998-12-02 21:05:23 +08:00
|
|
|
char *filename; /* file name */
|
|
|
|
char *name; /* module name */
|
|
|
|
int usage; /* usage */
|
1999-01-13 04:42:47 +08:00
|
|
|
int depcount; /* number of dependencies */
|
|
|
|
lt_dlhandle *deps; /* dependencies */
|
1998-12-19 06:23:51 +08:00
|
|
|
lt_ptr_t handle; /* system handle */
|
|
|
|
lt_ptr_t system; /* system specific data */
|
1998-12-02 21:05:23 +08:00
|
|
|
} lt_dlhandle_t;
|
|
|
|
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
#if ! HAVE_STRDUP
|
1998-12-02 21:05:23 +08:00
|
|
|
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
#undef strdup
|
|
|
|
#define strdup xstrdup
|
1998-11-24 05:26:38 +08:00
|
|
|
|
|
|
|
static char *
|
1998-12-02 21:05:23 +08:00
|
|
|
strdup(str)
|
1998-12-20 03:30:30 +08:00
|
|
|
const char *str;
|
1998-11-24 05:26:38 +08:00
|
|
|
{
|
|
|
|
char *tmp;
|
|
|
|
|
|
|
|
if (!str)
|
|
|
|
return str;
|
|
|
|
tmp = malloc(strlen(str)+1);
|
|
|
|
if (tmp)
|
|
|
|
strcpy(tmp, str);
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
1998-12-23 21:28:28 +08:00
|
|
|
#if ! HAVE_STRCHR
|
|
|
|
|
|
|
|
# if HAVE_INDEX
|
|
|
|
|
|
|
|
# define strchr index
|
|
|
|
|
|
|
|
# else
|
|
|
|
|
|
|
|
# define strchr xstrchr
|
|
|
|
|
|
|
|
static const char*
|
|
|
|
strchr(str, ch)
|
|
|
|
const char *str;
|
|
|
|
int ch;
|
|
|
|
{
|
|
|
|
const char *p;
|
|
|
|
|
|
|
|
for (p = str; *p != (char)ch && p != '\0'; p++)
|
|
|
|
/*NOWORK*/;
|
|
|
|
|
1998-12-25 18:39:59 +08:00
|
|
|
return (*p == (char)ch) ? p : 0;
|
1998-12-23 21:28:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
# endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
#if ! HAVE_STRRCHR
|
|
|
|
|
|
|
|
# if HAVE_RINDEX
|
1998-12-02 21:05:23 +08:00
|
|
|
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
# define strrchr rindex
|
|
|
|
|
|
|
|
# else
|
|
|
|
|
|
|
|
# define strrchr xstrrchr
|
|
|
|
|
|
|
|
static const char*
|
1998-12-02 21:05:23 +08:00
|
|
|
strrchr(str, ch)
|
1998-12-20 03:30:30 +08:00
|
|
|
const char *str;
|
|
|
|
int ch;
|
1998-12-02 21:05:23 +08:00
|
|
|
{
|
1998-12-20 03:30:30 +08:00
|
|
|
const char *p;
|
1998-12-02 21:05:23 +08:00
|
|
|
|
1998-12-20 03:30:30 +08:00
|
|
|
for (p = str; p != '\0'; p++)
|
|
|
|
/*NOWORK*/;
|
1998-12-02 21:05:23 +08:00
|
|
|
|
* ltmain.in (libobjs_save, oldobjs): when building an
old-fashioned archive, use a copy of libobjs saved before
convenience libraries are appended
* libltdl/ltdl.h (_LTDLL_EXPORT, _LTDLL_IMPORT): use cygwin or
unix library import/export primitives; this may be convenient for
people willing to create DLLs
(_LTDLL_EXTERN): select _LTDLL_EXPORT or _LTDLL_IMPORT depending
on _LTDL_COMPILE_
* libltdl/ltdl.h, libltdl/ltdl.c (lt_dlpreopen): new function,
that replaces the current preloaded_symbols list with its
argument, and returns the old value, initially NULL
(dldpre_init): don't refer to dld_preloaded_symbols any more
(dldpre_open, dldpre_sym): search preloaded_symbols
(lt_dlpreopen_default): call lt_dlpreopen with
dld_preloaded_symbols, that is declared as extern; it should be
called from the main program or from some static library without
-no-undefined
(lt_dlerror): new function, that returns the error message for the
last error occurred; the error message is kept in the static
variable last_error
* libltdl/configure.in (enable-ltdl-install): moved back from
enable-install; other packages might use enable-install already,
better have fine grained control over this.
* libltdl/Makefile.am (libltdls.la): discarded
1999-01-06 07:13:44 +08:00
|
|
|
while (*p != (char)ch && p >= str)
|
1998-12-20 03:30:30 +08:00
|
|
|
p--;
|
1998-12-02 21:05:23 +08:00
|
|
|
|
1998-12-25 18:39:59 +08:00
|
|
|
return (*p == (char)ch) ? p : 0;
|
1998-12-02 21:05:23 +08:00
|
|
|
}
|
|
|
|
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
# endif
|
1998-11-18 15:29:36 +08:00
|
|
|
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
#endif
|
1998-11-18 15:29:36 +08:00
|
|
|
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
#if HAVE_LIBDL
|
1998-11-18 15:29:36 +08:00
|
|
|
|
|
|
|
/* dynamic linking with dlopen/dlsym */
|
|
|
|
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
#if HAVE_DLFCN_H
|
|
|
|
# include <dlfcn.h>
|
1998-11-18 15:29:36 +08:00
|
|
|
#endif
|
|
|
|
|
1999-01-10 04:05:55 +08:00
|
|
|
#if ! HAVE_DLERROR /* not all platforms have dlerror() */
|
|
|
|
#define dlerror() unknown_error
|
|
|
|
#endif
|
|
|
|
|
1999-01-13 16:59:34 +08:00
|
|
|
#if RTLD_GLOBAL
|
|
|
|
# define LTDL_GLOBAL RTLD_GLOBAL
|
1999-01-10 04:05:55 +08:00
|
|
|
#else
|
|
|
|
# if DL_GLOBAL
|
|
|
|
# define LTDL_GLOBAL DL_GLOBAL
|
|
|
|
# else
|
|
|
|
# define LTDL_GLOBAL 0
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
1999-01-13 16:59:34 +08:00
|
|
|
#if RTLD_NOW
|
|
|
|
# define LTDL_NOW RTLD_NOW
|
1998-11-18 15:29:36 +08:00
|
|
|
#else
|
1999-01-10 04:05:55 +08:00
|
|
|
# if DL_NOW
|
|
|
|
# define LTDL_NOW DL_NOW
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
# else
|
1999-01-10 04:05:55 +08:00
|
|
|
# define LTDL_NOW 0
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
# endif
|
1998-11-18 15:29:36 +08:00
|
|
|
#endif
|
|
|
|
|
1998-11-24 05:26:38 +08:00
|
|
|
static int
|
* ltmain.in (libobjs_save, oldobjs): when building an
old-fashioned archive, use a copy of libobjs saved before
convenience libraries are appended
* libltdl/ltdl.h (_LTDLL_EXPORT, _LTDLL_IMPORT): use cygwin or
unix library import/export primitives; this may be convenient for
people willing to create DLLs
(_LTDLL_EXTERN): select _LTDLL_EXPORT or _LTDLL_IMPORT depending
on _LTDL_COMPILE_
* libltdl/ltdl.h, libltdl/ltdl.c (lt_dlpreopen): new function,
that replaces the current preloaded_symbols list with its
argument, and returns the old value, initially NULL
(dldpre_init): don't refer to dld_preloaded_symbols any more
(dldpre_open, dldpre_sym): search preloaded_symbols
(lt_dlpreopen_default): call lt_dlpreopen with
dld_preloaded_symbols, that is declared as extern; it should be
called from the main program or from some static library without
-no-undefined
(lt_dlerror): new function, that returns the error message for the
last error occurred; the error message is kept in the static
variable last_error
* libltdl/configure.in (enable-ltdl-install): moved back from
enable-install; other packages might use enable-install already,
better have fine grained control over this.
* libltdl/Makefile.am (libltdls.la): discarded
1999-01-06 07:13:44 +08:00
|
|
|
dl_init ()
|
1998-11-18 15:29:36 +08:00
|
|
|
{
|
1998-11-24 05:26:38 +08:00
|
|
|
return 0;
|
1998-11-18 15:29:36 +08:00
|
|
|
}
|
|
|
|
|
1998-11-24 05:26:38 +08:00
|
|
|
static int
|
* ltmain.in (libobjs_save, oldobjs): when building an
old-fashioned archive, use a copy of libobjs saved before
convenience libraries are appended
* libltdl/ltdl.h (_LTDLL_EXPORT, _LTDLL_IMPORT): use cygwin or
unix library import/export primitives; this may be convenient for
people willing to create DLLs
(_LTDLL_EXTERN): select _LTDLL_EXPORT or _LTDLL_IMPORT depending
on _LTDL_COMPILE_
* libltdl/ltdl.h, libltdl/ltdl.c (lt_dlpreopen): new function,
that replaces the current preloaded_symbols list with its
argument, and returns the old value, initially NULL
(dldpre_init): don't refer to dld_preloaded_symbols any more
(dldpre_open, dldpre_sym): search preloaded_symbols
(lt_dlpreopen_default): call lt_dlpreopen with
dld_preloaded_symbols, that is declared as extern; it should be
called from the main program or from some static library without
-no-undefined
(lt_dlerror): new function, that returns the error message for the
last error occurred; the error message is kept in the static
variable last_error
* libltdl/configure.in (enable-ltdl-install): moved back from
enable-install; other packages might use enable-install already,
better have fine grained control over this.
* libltdl/Makefile.am (libltdls.la): discarded
1999-01-06 07:13:44 +08:00
|
|
|
dl_exit ()
|
1998-11-18 15:29:36 +08:00
|
|
|
{
|
1998-11-24 05:26:38 +08:00
|
|
|
return 0;
|
1998-11-18 15:29:36 +08:00
|
|
|
}
|
|
|
|
|
1998-11-24 05:26:38 +08:00
|
|
|
static int
|
1998-12-20 03:30:30 +08:00
|
|
|
dl_open (handle, filename)
|
|
|
|
lt_dlhandle handle;
|
|
|
|
const char *filename;
|
1998-11-24 05:26:38 +08:00
|
|
|
{
|
1999-01-10 04:05:55 +08:00
|
|
|
handle->handle = dlopen(filename, LTDL_GLOBAL | LTDL_NOW);
|
|
|
|
if (!handle->handle) {
|
|
|
|
last_error = dlerror();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
1998-11-24 05:26:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1998-12-20 03:30:30 +08:00
|
|
|
dl_close (handle)
|
|
|
|
lt_dlhandle handle;
|
1998-11-18 15:29:36 +08:00
|
|
|
{
|
1999-01-10 04:05:55 +08:00
|
|
|
if (dlclose(handle->handle) != 0) {
|
|
|
|
last_error = dlerror();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
1998-11-18 15:29:36 +08:00
|
|
|
}
|
|
|
|
|
1998-12-19 06:23:51 +08:00
|
|
|
static lt_ptr_t
|
1998-12-20 03:30:30 +08:00
|
|
|
dl_sym (handle, symbol)
|
|
|
|
lt_dlhandle handle;
|
|
|
|
const char *symbol;
|
1998-11-18 15:29:36 +08:00
|
|
|
{
|
1999-01-10 04:05:55 +08:00
|
|
|
lt_ptr_t address = dlsym(handle->handle, symbol);
|
|
|
|
|
|
|
|
if (!address)
|
|
|
|
last_error = dlerror();
|
|
|
|
return address;
|
1998-11-18 15:29:36 +08:00
|
|
|
}
|
|
|
|
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
static
|
|
|
|
lt_dltype_t
|
1999-01-15 00:31:23 +08:00
|
|
|
#ifdef NEED_USCORE
|
|
|
|
dl = { LT_DLTYPE_TOP, "_", dl_init, dl_exit,
|
|
|
|
dl_open, dl_close, dl_sym };
|
|
|
|
#else
|
|
|
|
dl = { LT_DLTYPE_TOP, 0, dl_init, dl_exit,
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
dl_open, dl_close, dl_sym };
|
1999-01-15 00:31:23 +08:00
|
|
|
#endif
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
|
|
|
|
#undef LT_DLTYPE_TOP
|
|
|
|
#define LT_DLTYPE_TOP &dl
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAVE_SHL_LOAD
|
1998-11-18 15:29:36 +08:00
|
|
|
|
|
|
|
/* dynamic linking with shl_load (HP-UX) */
|
|
|
|
|
|
|
|
#ifdef HAVE_DL_H
|
|
|
|
#include <dl.h>
|
|
|
|
#endif
|
|
|
|
|
1998-12-25 18:39:59 +08:00
|
|
|
/* some flags are missing on some systems, so we provide
|
|
|
|
* harmless defaults.
|
|
|
|
*
|
|
|
|
* Mandatory:
|
|
|
|
* BIND_IMMEDIATE - Resolve symbol references when the library is loaded.
|
|
|
|
* BIND_DEFERRED - Delay code symbol resolution until actual reference.
|
|
|
|
*
|
|
|
|
* Optionally:
|
|
|
|
* BIND_FIRST - Place the library at the head of the symbol search order.
|
|
|
|
* BIND_NONFATAL - The default BIND_IMMEDIATE behavior is to treat all unsatisfied
|
|
|
|
* symbols as fatal. This flag allows binding of unsatisfied code
|
|
|
|
* symbols to be deferred until use.
|
|
|
|
* [Perl: For certain libraries, like DCE, deferred binding often
|
|
|
|
* causes run time problems. Adding BIND_NONFATAL to BIND_IMMEDIATE
|
|
|
|
* still allows unresolved references in situations like this.]
|
|
|
|
* BIND_NOSTART - Do not call the initializer for the shared library when the
|
|
|
|
* library is loaded, nor on a future call to shl_unload().
|
|
|
|
* BIND_VERBOSE - Print verbose messages concerning possible unsatisfied symbols.
|
|
|
|
*
|
|
|
|
* hp9000s700/hp9000s800:
|
|
|
|
* BIND_RESTRICTED - Restrict symbols visible by the library to those present at
|
|
|
|
* library load time.
|
|
|
|
* DYNAMIC_PATH - Allow the loader to dynamically search for the library specified
|
|
|
|
* by the path argument.
|
|
|
|
*/
|
1999-01-10 04:05:55 +08:00
|
|
|
|
1998-12-25 18:39:59 +08:00
|
|
|
#ifndef DYNAMIC_PATH
|
|
|
|
#define DYNAMIC_PATH 0
|
|
|
|
#endif /* DYNAMIC_PATH */
|
|
|
|
#ifndef BIND_RESTRICTED
|
|
|
|
#define BIND_RESTRICTED 0
|
|
|
|
#endif /* BIND_RESTRICTED */
|
|
|
|
|
1999-01-14 05:39:14 +08:00
|
|
|
#define LTDL_BIND_FLAGS (BIND_IMMEDIATE | BIND_NONFATAL | BIND_VERBOSE | DYNAMIC_PATH)
|
1998-12-25 18:39:59 +08:00
|
|
|
|
1998-11-24 05:26:38 +08:00
|
|
|
static int
|
* ltmain.in (libobjs_save, oldobjs): when building an
old-fashioned archive, use a copy of libobjs saved before
convenience libraries are appended
* libltdl/ltdl.h (_LTDLL_EXPORT, _LTDLL_IMPORT): use cygwin or
unix library import/export primitives; this may be convenient for
people willing to create DLLs
(_LTDLL_EXTERN): select _LTDLL_EXPORT or _LTDLL_IMPORT depending
on _LTDL_COMPILE_
* libltdl/ltdl.h, libltdl/ltdl.c (lt_dlpreopen): new function,
that replaces the current preloaded_symbols list with its
argument, and returns the old value, initially NULL
(dldpre_init): don't refer to dld_preloaded_symbols any more
(dldpre_open, dldpre_sym): search preloaded_symbols
(lt_dlpreopen_default): call lt_dlpreopen with
dld_preloaded_symbols, that is declared as extern; it should be
called from the main program or from some static library without
-no-undefined
(lt_dlerror): new function, that returns the error message for the
last error occurred; the error message is kept in the static
variable last_error
* libltdl/configure.in (enable-ltdl-install): moved back from
enable-install; other packages might use enable-install already,
better have fine grained control over this.
* libltdl/Makefile.am (libltdls.la): discarded
1999-01-06 07:13:44 +08:00
|
|
|
shl_init ()
|
1998-11-24 05:26:38 +08:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
* ltmain.in (libobjs_save, oldobjs): when building an
old-fashioned archive, use a copy of libobjs saved before
convenience libraries are appended
* libltdl/ltdl.h (_LTDLL_EXPORT, _LTDLL_IMPORT): use cygwin or
unix library import/export primitives; this may be convenient for
people willing to create DLLs
(_LTDLL_EXTERN): select _LTDLL_EXPORT or _LTDLL_IMPORT depending
on _LTDL_COMPILE_
* libltdl/ltdl.h, libltdl/ltdl.c (lt_dlpreopen): new function,
that replaces the current preloaded_symbols list with its
argument, and returns the old value, initially NULL
(dldpre_init): don't refer to dld_preloaded_symbols any more
(dldpre_open, dldpre_sym): search preloaded_symbols
(lt_dlpreopen_default): call lt_dlpreopen with
dld_preloaded_symbols, that is declared as extern; it should be
called from the main program or from some static library without
-no-undefined
(lt_dlerror): new function, that returns the error message for the
last error occurred; the error message is kept in the static
variable last_error
* libltdl/configure.in (enable-ltdl-install): moved back from
enable-install; other packages might use enable-install already,
better have fine grained control over this.
* libltdl/Makefile.am (libltdls.la): discarded
1999-01-06 07:13:44 +08:00
|
|
|
shl_exit ()
|
1998-11-18 15:29:36 +08:00
|
|
|
{
|
1998-11-24 05:26:38 +08:00
|
|
|
return 0;
|
1998-11-18 15:29:36 +08:00
|
|
|
}
|
|
|
|
|
1998-11-24 05:26:38 +08:00
|
|
|
static int
|
1998-12-20 03:30:30 +08:00
|
|
|
shl_open (handle, filename)
|
|
|
|
lt_dlhandle handle;
|
|
|
|
const char *filename;
|
1998-11-18 15:29:36 +08:00
|
|
|
{
|
1999-01-14 05:39:14 +08:00
|
|
|
handle->handle = shl_load(filename, LTDL_BIND_FLAGS, 0L);
|
1999-01-10 04:05:55 +08:00
|
|
|
if (!handle->handle) {
|
|
|
|
last_error = unknown_error;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
1998-11-18 15:29:36 +08:00
|
|
|
}
|
|
|
|
|
1998-11-24 05:26:38 +08:00
|
|
|
static int
|
1998-12-20 03:30:30 +08:00
|
|
|
shl_close (handle)
|
|
|
|
lt_dlhandle handle;
|
1998-11-18 15:29:36 +08:00
|
|
|
{
|
1999-01-10 04:05:55 +08:00
|
|
|
if (shl_unload((shl_t) (handle->handle)) != 0) {
|
|
|
|
last_error = unknown_error;
|
|
|
|
return 1;
|
|
|
|
}
|
1998-11-24 05:26:38 +08:00
|
|
|
return 0;
|
1998-11-18 15:29:36 +08:00
|
|
|
}
|
|
|
|
|
1998-12-19 06:23:51 +08:00
|
|
|
static lt_ptr_t
|
1998-12-20 03:30:30 +08:00
|
|
|
shl_sym (handle, symbol)
|
|
|
|
lt_dlhandle handle;
|
|
|
|
const char *symbol;
|
1998-11-18 15:29:36 +08:00
|
|
|
{
|
1999-01-10 04:05:55 +08:00
|
|
|
lt_ptr_t address;
|
1998-12-25 18:39:59 +08:00
|
|
|
|
1999-01-14 05:39:14 +08:00
|
|
|
if (shl_findsym((shl_t) (handle->handle), symbol, TYPE_UNDEFINED,
|
1999-01-10 04:05:55 +08:00
|
|
|
&address) != 0 || !(handle->handle) || !address) {
|
|
|
|
last_error = unknown_error;
|
1998-12-25 18:39:59 +08:00
|
|
|
return 0;
|
1999-01-10 04:05:55 +08:00
|
|
|
}
|
|
|
|
return address;
|
1998-11-18 15:29:36 +08:00
|
|
|
}
|
|
|
|
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
static
|
|
|
|
lt_dltype_t
|
1999-01-15 00:31:23 +08:00
|
|
|
shl = { LT_DLTYPE_TOP, 0, shl_init, shl_exit,
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
shl_open, shl_close, shl_sym };
|
|
|
|
|
|
|
|
#undef LT_DLTYPE_TOP
|
|
|
|
#define LT_DLTYPE_TOP &shl
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAVE_DLD
|
1998-11-18 15:29:36 +08:00
|
|
|
|
|
|
|
/* dynamic linking with dld */
|
|
|
|
|
1998-11-24 05:26:38 +08:00
|
|
|
static int
|
* ltmain.in (libobjs_save, oldobjs): when building an
old-fashioned archive, use a copy of libobjs saved before
convenience libraries are appended
* libltdl/ltdl.h (_LTDLL_EXPORT, _LTDLL_IMPORT): use cygwin or
unix library import/export primitives; this may be convenient for
people willing to create DLLs
(_LTDLL_EXTERN): select _LTDLL_EXPORT or _LTDLL_IMPORT depending
on _LTDL_COMPILE_
* libltdl/ltdl.h, libltdl/ltdl.c (lt_dlpreopen): new function,
that replaces the current preloaded_symbols list with its
argument, and returns the old value, initially NULL
(dldpre_init): don't refer to dld_preloaded_symbols any more
(dldpre_open, dldpre_sym): search preloaded_symbols
(lt_dlpreopen_default): call lt_dlpreopen with
dld_preloaded_symbols, that is declared as extern; it should be
called from the main program or from some static library without
-no-undefined
(lt_dlerror): new function, that returns the error message for the
last error occurred; the error message is kept in the static
variable last_error
* libltdl/configure.in (enable-ltdl-install): moved back from
enable-install; other packages might use enable-install already,
better have fine grained control over this.
* libltdl/Makefile.am (libltdls.la): discarded
1999-01-06 07:13:44 +08:00
|
|
|
dld_init ()
|
1998-11-18 15:29:36 +08:00
|
|
|
{
|
1998-11-24 05:26:38 +08:00
|
|
|
return 0;
|
1998-11-18 15:29:36 +08:00
|
|
|
}
|
|
|
|
|
1998-11-24 05:26:38 +08:00
|
|
|
static int
|
* ltmain.in (libobjs_save, oldobjs): when building an
old-fashioned archive, use a copy of libobjs saved before
convenience libraries are appended
* libltdl/ltdl.h (_LTDLL_EXPORT, _LTDLL_IMPORT): use cygwin or
unix library import/export primitives; this may be convenient for
people willing to create DLLs
(_LTDLL_EXTERN): select _LTDLL_EXPORT or _LTDLL_IMPORT depending
on _LTDL_COMPILE_
* libltdl/ltdl.h, libltdl/ltdl.c (lt_dlpreopen): new function,
that replaces the current preloaded_symbols list with its
argument, and returns the old value, initially NULL
(dldpre_init): don't refer to dld_preloaded_symbols any more
(dldpre_open, dldpre_sym): search preloaded_symbols
(lt_dlpreopen_default): call lt_dlpreopen with
dld_preloaded_symbols, that is declared as extern; it should be
called from the main program or from some static library without
-no-undefined
(lt_dlerror): new function, that returns the error message for the
last error occurred; the error message is kept in the static
variable last_error
* libltdl/configure.in (enable-ltdl-install): moved back from
enable-install; other packages might use enable-install already,
better have fine grained control over this.
* libltdl/Makefile.am (libltdls.la): discarded
1999-01-06 07:13:44 +08:00
|
|
|
dld_exit ()
|
1998-11-18 15:29:36 +08:00
|
|
|
{
|
1998-11-24 05:26:38 +08:00
|
|
|
return 0;
|
1998-11-18 15:29:36 +08:00
|
|
|
}
|
|
|
|
|
1998-11-24 05:26:38 +08:00
|
|
|
static int
|
1998-12-20 03:30:30 +08:00
|
|
|
dld_open (handle, filename)
|
|
|
|
lt_dlhandle handle;
|
|
|
|
const char *filename;
|
1998-11-18 15:29:36 +08:00
|
|
|
{
|
1999-01-13 04:42:47 +08:00
|
|
|
handle->handle = strdup(filename);
|
|
|
|
if (!handle->handle) {
|
|
|
|
last_error = no_memory_error;
|
|
|
|
return 1;
|
|
|
|
}
|
1999-01-10 04:05:55 +08:00
|
|
|
if (dld_link(filename) != 0) {
|
|
|
|
last_error = unknown_error;
|
1999-01-13 04:42:47 +08:00
|
|
|
free(handle->handle);
|
1998-11-24 05:26:38 +08:00
|
|
|
return 1;
|
1999-01-10 04:05:55 +08:00
|
|
|
}
|
1998-11-24 05:26:38 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1998-12-20 03:30:30 +08:00
|
|
|
dld_close (handle)
|
|
|
|
lt_dlhandle handle;
|
1998-11-24 05:26:38 +08:00
|
|
|
{
|
1999-01-10 04:05:55 +08:00
|
|
|
if (dld_unlink_by_file((char*)(handle->handle), 1) != 0) {
|
|
|
|
last_error = unknown_error;
|
|
|
|
return 1;
|
|
|
|
}
|
1998-12-19 06:23:51 +08:00
|
|
|
free(handle->filename);
|
1998-11-24 05:26:38 +08:00
|
|
|
return 0;
|
1998-11-18 15:29:36 +08:00
|
|
|
}
|
|
|
|
|
1998-12-19 06:23:51 +08:00
|
|
|
static lt_ptr_t
|
1998-12-20 03:30:30 +08:00
|
|
|
dld_sym (handle, symbol)
|
|
|
|
lt_dlhandle handle;
|
|
|
|
const char *symbol;
|
1998-11-18 15:29:36 +08:00
|
|
|
{
|
1999-01-10 04:05:55 +08:00
|
|
|
lt_ptr_t address = dld_get_func(symbol);
|
|
|
|
|
|
|
|
if (!address)
|
|
|
|
last_error = unknown_error;
|
|
|
|
return address;
|
1998-11-18 15:29:36 +08:00
|
|
|
}
|
|
|
|
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
static
|
|
|
|
lt_dltype_t
|
1999-01-15 00:31:23 +08:00
|
|
|
dld = { LT_DLTYPE_TOP, 0, dld_init, dld_exit,
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
dld_open, dld_close, dld_sym };
|
|
|
|
|
|
|
|
#undef LT_DLTYPE_TOP
|
|
|
|
#define LT_DLTYPE_TOP &dld
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
1998-11-18 15:29:36 +08:00
|
|
|
#ifdef _WIN32
|
|
|
|
|
|
|
|
/* dynamic linking for Win32 */
|
|
|
|
|
* ltmain.in (libobjs_save, oldobjs): when building an
old-fashioned archive, use a copy of libobjs saved before
convenience libraries are appended
* libltdl/ltdl.h (_LTDLL_EXPORT, _LTDLL_IMPORT): use cygwin or
unix library import/export primitives; this may be convenient for
people willing to create DLLs
(_LTDLL_EXTERN): select _LTDLL_EXPORT or _LTDLL_IMPORT depending
on _LTDL_COMPILE_
* libltdl/ltdl.h, libltdl/ltdl.c (lt_dlpreopen): new function,
that replaces the current preloaded_symbols list with its
argument, and returns the old value, initially NULL
(dldpre_init): don't refer to dld_preloaded_symbols any more
(dldpre_open, dldpre_sym): search preloaded_symbols
(lt_dlpreopen_default): call lt_dlpreopen with
dld_preloaded_symbols, that is declared as extern; it should be
called from the main program or from some static library without
-no-undefined
(lt_dlerror): new function, that returns the error message for the
last error occurred; the error message is kept in the static
variable last_error
* libltdl/configure.in (enable-ltdl-install): moved back from
enable-install; other packages might use enable-install already,
better have fine grained control over this.
* libltdl/Makefile.am (libltdls.la): discarded
1999-01-06 07:13:44 +08:00
|
|
|
#include <windows.h>
|
1998-11-18 15:29:36 +08:00
|
|
|
|
1998-11-24 05:26:38 +08:00
|
|
|
static int
|
* ltmain.in (libobjs_save, oldobjs): when building an
old-fashioned archive, use a copy of libobjs saved before
convenience libraries are appended
* libltdl/ltdl.h (_LTDLL_EXPORT, _LTDLL_IMPORT): use cygwin or
unix library import/export primitives; this may be convenient for
people willing to create DLLs
(_LTDLL_EXTERN): select _LTDLL_EXPORT or _LTDLL_IMPORT depending
on _LTDL_COMPILE_
* libltdl/ltdl.h, libltdl/ltdl.c (lt_dlpreopen): new function,
that replaces the current preloaded_symbols list with its
argument, and returns the old value, initially NULL
(dldpre_init): don't refer to dld_preloaded_symbols any more
(dldpre_open, dldpre_sym): search preloaded_symbols
(lt_dlpreopen_default): call lt_dlpreopen with
dld_preloaded_symbols, that is declared as extern; it should be
called from the main program or from some static library without
-no-undefined
(lt_dlerror): new function, that returns the error message for the
last error occurred; the error message is kept in the static
variable last_error
* libltdl/configure.in (enable-ltdl-install): moved back from
enable-install; other packages might use enable-install already,
better have fine grained control over this.
* libltdl/Makefile.am (libltdls.la): discarded
1999-01-06 07:13:44 +08:00
|
|
|
wll_init ()
|
1998-11-18 15:29:36 +08:00
|
|
|
{
|
1998-11-24 05:26:38 +08:00
|
|
|
return 0;
|
1998-11-18 15:29:36 +08:00
|
|
|
}
|
|
|
|
|
1998-11-24 05:26:38 +08:00
|
|
|
static int
|
* ltmain.in (libobjs_save, oldobjs): when building an
old-fashioned archive, use a copy of libobjs saved before
convenience libraries are appended
* libltdl/ltdl.h (_LTDLL_EXPORT, _LTDLL_IMPORT): use cygwin or
unix library import/export primitives; this may be convenient for
people willing to create DLLs
(_LTDLL_EXTERN): select _LTDLL_EXPORT or _LTDLL_IMPORT depending
on _LTDL_COMPILE_
* libltdl/ltdl.h, libltdl/ltdl.c (lt_dlpreopen): new function,
that replaces the current preloaded_symbols list with its
argument, and returns the old value, initially NULL
(dldpre_init): don't refer to dld_preloaded_symbols any more
(dldpre_open, dldpre_sym): search preloaded_symbols
(lt_dlpreopen_default): call lt_dlpreopen with
dld_preloaded_symbols, that is declared as extern; it should be
called from the main program or from some static library without
-no-undefined
(lt_dlerror): new function, that returns the error message for the
last error occurred; the error message is kept in the static
variable last_error
* libltdl/configure.in (enable-ltdl-install): moved back from
enable-install; other packages might use enable-install already,
better have fine grained control over this.
* libltdl/Makefile.am (libltdls.la): discarded
1999-01-06 07:13:44 +08:00
|
|
|
wll_exit ()
|
1998-11-18 15:29:36 +08:00
|
|
|
{
|
1998-11-24 05:26:38 +08:00
|
|
|
return 0;
|
1998-11-18 15:29:36 +08:00
|
|
|
}
|
|
|
|
|
1998-11-24 05:26:38 +08:00
|
|
|
static int
|
1998-12-20 03:30:30 +08:00
|
|
|
wll_open (handle, filename)
|
|
|
|
lt_dlhandle handle;
|
|
|
|
const char *filename;
|
1998-11-18 15:29:36 +08:00
|
|
|
{
|
1998-11-24 05:26:38 +08:00
|
|
|
handle->handle = LoadLibrary(filename);
|
1999-01-10 04:05:55 +08:00
|
|
|
if (!handle->handle) {
|
|
|
|
last_error = unknown_error;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
1998-11-24 05:26:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1998-12-20 03:30:30 +08:00
|
|
|
wll_close (handle)
|
|
|
|
lt_dlhandle handle;
|
1998-11-24 05:26:38 +08:00
|
|
|
{
|
1999-01-10 04:05:55 +08:00
|
|
|
if (FreeLibrary(handle->handle) != 0) {
|
|
|
|
last_error = unknown_error;
|
|
|
|
return 1;
|
|
|
|
}
|
1998-11-24 05:26:38 +08:00
|
|
|
return 0;
|
1998-11-18 15:29:36 +08:00
|
|
|
}
|
|
|
|
|
1998-12-19 06:23:51 +08:00
|
|
|
static lt_ptr_t
|
1998-12-20 03:30:30 +08:00
|
|
|
wll_sym (handle, symbol)
|
|
|
|
lt_dlhandle handle;
|
|
|
|
const char *symbol;
|
1998-11-18 15:29:36 +08:00
|
|
|
{
|
1999-01-10 04:05:55 +08:00
|
|
|
lt_ptr_t address = GetProcAddress(handle->handle, symbol);
|
|
|
|
|
|
|
|
if (!address)
|
|
|
|
last_error = unknown_error;
|
|
|
|
return address;
|
1998-11-18 15:29:36 +08:00
|
|
|
}
|
|
|
|
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
static
|
|
|
|
lt_dltype_t
|
1999-01-15 00:31:23 +08:00
|
|
|
wll = { LT_DLTYPE_TOP, 0, wll_init, wll_exit,
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
wll_open, wll_close, wll_sym };
|
1998-11-18 15:29:36 +08:00
|
|
|
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
#undef LT_DLTYPE_TOP
|
|
|
|
#define LT_DLTYPE_TOP &wll
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAVE_DLPREOPEN
|
|
|
|
|
1999-01-14 05:39:14 +08:00
|
|
|
/* emulate dynamic linking using preloaded_symbols */
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
|
1999-01-13 04:42:47 +08:00
|
|
|
typedef struct lt_dlsymlists_t {
|
|
|
|
struct lt_dlsymlists_t *next;
|
1999-01-14 05:39:14 +08:00
|
|
|
const lt_dlsymlist *syms;
|
1999-01-13 04:42:47 +08:00
|
|
|
} lt_dlsymlists_t;
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
|
1999-01-15 00:31:23 +08:00
|
|
|
static const lt_dlsymlist *default_preloaded_symbols = 0;
|
1999-01-14 02:37:25 +08:00
|
|
|
static lt_dlsymlists_t *preloaded_symbols = 0;
|
1998-11-18 15:29:36 +08:00
|
|
|
|
1998-11-24 05:26:38 +08:00
|
|
|
static int
|
1999-01-14 05:39:14 +08:00
|
|
|
presym_init ()
|
1998-11-18 15:29:36 +08:00
|
|
|
{
|
1999-01-15 00:31:23 +08:00
|
|
|
preloaded_symbols = 0;
|
|
|
|
if (default_preloaded_symbols)
|
|
|
|
return lt_dlpreopen(default_preloaded_symbols);
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
return 0;
|
1998-11-18 15:29:36 +08:00
|
|
|
}
|
|
|
|
|
1999-01-13 04:42:47 +08:00
|
|
|
static void
|
1999-01-14 05:39:14 +08:00
|
|
|
presym_free_symlists ()
|
1999-01-13 04:42:47 +08:00
|
|
|
{
|
|
|
|
lt_dlsymlists_t *lists = preloaded_symbols;
|
|
|
|
|
|
|
|
while (lists) {
|
|
|
|
lt_dlsymlists_t *tmp = lists;
|
|
|
|
|
|
|
|
lists = lists->next;
|
|
|
|
free(tmp);
|
|
|
|
}
|
|
|
|
preloaded_symbols = 0;
|
|
|
|
}
|
|
|
|
|
1998-11-24 05:26:38 +08:00
|
|
|
static int
|
1999-01-14 05:39:14 +08:00
|
|
|
presym_exit ()
|
1998-11-18 15:29:36 +08:00
|
|
|
{
|
1999-01-15 00:31:23 +08:00
|
|
|
presym_free_symlists();
|
1999-01-13 04:42:47 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1999-01-14 05:39:14 +08:00
|
|
|
presym_add_symlist (preloaded)
|
|
|
|
const lt_dlsymlist *preloaded;
|
1999-01-13 04:42:47 +08:00
|
|
|
{
|
|
|
|
lt_dlsymlists_t *tmp;
|
|
|
|
lt_dlsymlists_t *lists = preloaded_symbols;
|
|
|
|
|
|
|
|
while (lists) {
|
|
|
|
if (lists->syms == preloaded)
|
|
|
|
return 0;
|
|
|
|
lists = lists->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp = (lt_dlsymlists_t*) malloc(sizeof(lt_dlsymlists_t));
|
|
|
|
if (!tmp) {
|
|
|
|
last_error = memory_error;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
tmp->syms = preloaded;
|
|
|
|
tmp->next = 0;
|
|
|
|
if (!preloaded_symbols)
|
|
|
|
preloaded_symbols = tmp;
|
|
|
|
else {
|
|
|
|
/* append to the end */
|
|
|
|
lists = preloaded_symbols;
|
|
|
|
while (lists->next)
|
|
|
|
lists = lists->next;
|
|
|
|
lists->next = tmp;
|
|
|
|
}
|
1998-11-21 15:45:20 +08:00
|
|
|
return 0;
|
1998-11-18 15:29:36 +08:00
|
|
|
}
|
|
|
|
|
1998-11-24 05:26:38 +08:00
|
|
|
static int
|
1999-01-14 05:39:14 +08:00
|
|
|
presym_open (handle, filename)
|
1998-12-20 03:30:30 +08:00
|
|
|
lt_dlhandle handle;
|
|
|
|
const char *filename;
|
1998-11-24 05:26:38 +08:00
|
|
|
{
|
1999-01-13 04:42:47 +08:00
|
|
|
lt_dlsymlists_t *lists = preloaded_symbols;
|
* ltmain.in (libobjs_save, oldobjs): when building an
old-fashioned archive, use a copy of libobjs saved before
convenience libraries are appended
* libltdl/ltdl.h (_LTDLL_EXPORT, _LTDLL_IMPORT): use cygwin or
unix library import/export primitives; this may be convenient for
people willing to create DLLs
(_LTDLL_EXTERN): select _LTDLL_EXPORT or _LTDLL_IMPORT depending
on _LTDL_COMPILE_
* libltdl/ltdl.h, libltdl/ltdl.c (lt_dlpreopen): new function,
that replaces the current preloaded_symbols list with its
argument, and returns the old value, initially NULL
(dldpre_init): don't refer to dld_preloaded_symbols any more
(dldpre_open, dldpre_sym): search preloaded_symbols
(lt_dlpreopen_default): call lt_dlpreopen with
dld_preloaded_symbols, that is declared as extern; it should be
called from the main program or from some static library without
-no-undefined
(lt_dlerror): new function, that returns the error message for the
last error occurred; the error message is kept in the static
variable last_error
* libltdl/configure.in (enable-ltdl-install): moved back from
enable-install; other packages might use enable-install already,
better have fine grained control over this.
* libltdl/Makefile.am (libltdls.la): discarded
1999-01-06 07:13:44 +08:00
|
|
|
|
1999-01-10 04:05:55 +08:00
|
|
|
if (!filename) {
|
|
|
|
last_error = file_not_found_error;
|
* ltmain.in (libobjs_save, oldobjs): when building an
old-fashioned archive, use a copy of libobjs saved before
convenience libraries are appended
* libltdl/ltdl.h (_LTDLL_EXPORT, _LTDLL_IMPORT): use cygwin or
unix library import/export primitives; this may be convenient for
people willing to create DLLs
(_LTDLL_EXTERN): select _LTDLL_EXPORT or _LTDLL_IMPORT depending
on _LTDL_COMPILE_
* libltdl/ltdl.h, libltdl/ltdl.c (lt_dlpreopen): new function,
that replaces the current preloaded_symbols list with its
argument, and returns the old value, initially NULL
(dldpre_init): don't refer to dld_preloaded_symbols any more
(dldpre_open, dldpre_sym): search preloaded_symbols
(lt_dlpreopen_default): call lt_dlpreopen with
dld_preloaded_symbols, that is declared as extern; it should be
called from the main program or from some static library without
-no-undefined
(lt_dlerror): new function, that returns the error message for the
last error occurred; the error message is kept in the static
variable last_error
* libltdl/configure.in (enable-ltdl-install): moved back from
enable-install; other packages might use enable-install already,
better have fine grained control over this.
* libltdl/Makefile.am (libltdls.la): discarded
1999-01-06 07:13:44 +08:00
|
|
|
return 1;
|
1999-01-10 04:05:55 +08:00
|
|
|
}
|
1999-01-13 04:42:47 +08:00
|
|
|
if (!lists) {
|
1999-01-10 04:05:55 +08:00
|
|
|
last_error = no_symbols_error;
|
|
|
|
return 1;
|
|
|
|
}
|
1999-01-13 04:42:47 +08:00
|
|
|
while (lists) {
|
1999-01-14 05:39:14 +08:00
|
|
|
const lt_dlsymlist *syms = lists->syms;
|
1999-01-13 04:42:47 +08:00
|
|
|
|
|
|
|
while (syms->name) {
|
|
|
|
if (!syms->address &&
|
|
|
|
strcmp(syms->name, filename) == 0) {
|
1999-01-14 05:39:14 +08:00
|
|
|
handle->handle = (lt_ptr_t) syms;
|
1999-01-13 04:42:47 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
syms++;
|
|
|
|
}
|
|
|
|
lists = lists->next;
|
1999-01-10 04:05:55 +08:00
|
|
|
}
|
1999-01-13 04:42:47 +08:00
|
|
|
last_error = file_not_found_error;
|
|
|
|
return 1;
|
1998-11-24 05:26:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1999-01-14 05:39:14 +08:00
|
|
|
presym_close (handle)
|
1998-12-20 03:30:30 +08:00
|
|
|
lt_dlhandle handle;
|
1998-11-18 15:29:36 +08:00
|
|
|
{
|
1998-11-24 05:26:38 +08:00
|
|
|
return 0;
|
1998-11-18 15:29:36 +08:00
|
|
|
}
|
|
|
|
|
1998-12-19 06:23:51 +08:00
|
|
|
static lt_ptr_t
|
1999-01-14 05:39:14 +08:00
|
|
|
presym_sym (handle, symbol)
|
1998-12-20 03:30:30 +08:00
|
|
|
lt_dlhandle handle;
|
|
|
|
const char *symbol;
|
1998-11-18 15:29:36 +08:00
|
|
|
{
|
1999-01-13 04:42:47 +08:00
|
|
|
lt_dlsymlist *syms = (lt_dlsymlist*)(handle->handle);
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
|
1999-01-13 04:42:47 +08:00
|
|
|
syms++;
|
|
|
|
while (syms->address) {
|
|
|
|
if (syms->address && strcmp(syms->name, symbol) == 0)
|
|
|
|
return syms->address;
|
|
|
|
syms++;
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
}
|
1999-01-10 04:05:55 +08:00
|
|
|
last_error = symbol_error;
|
1998-11-21 15:45:20 +08:00
|
|
|
return 0;
|
1998-11-18 15:29:36 +08:00
|
|
|
}
|
|
|
|
|
* ltmain.in (libobjs_save, oldobjs): when building an
old-fashioned archive, use a copy of libobjs saved before
convenience libraries are appended
* libltdl/ltdl.h (_LTDLL_EXPORT, _LTDLL_IMPORT): use cygwin or
unix library import/export primitives; this may be convenient for
people willing to create DLLs
(_LTDLL_EXTERN): select _LTDLL_EXPORT or _LTDLL_IMPORT depending
on _LTDL_COMPILE_
* libltdl/ltdl.h, libltdl/ltdl.c (lt_dlpreopen): new function,
that replaces the current preloaded_symbols list with its
argument, and returns the old value, initially NULL
(dldpre_init): don't refer to dld_preloaded_symbols any more
(dldpre_open, dldpre_sym): search preloaded_symbols
(lt_dlpreopen_default): call lt_dlpreopen with
dld_preloaded_symbols, that is declared as extern; it should be
called from the main program or from some static library without
-no-undefined
(lt_dlerror): new function, that returns the error message for the
last error occurred; the error message is kept in the static
variable last_error
* libltdl/configure.in (enable-ltdl-install): moved back from
enable-install; other packages might use enable-install already,
better have fine grained control over this.
* libltdl/Makefile.am (libltdls.la): discarded
1999-01-06 07:13:44 +08:00
|
|
|
static
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
lt_dltype_t
|
1999-01-15 00:31:23 +08:00
|
|
|
presym = { LT_DLTYPE_TOP, 0, presym_init, presym_exit,
|
1999-01-14 05:39:14 +08:00
|
|
|
presym_open, presym_close, presym_sym };
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
|
|
|
|
#undef LT_DLTYPE_TOP
|
1999-01-14 05:39:14 +08:00
|
|
|
#define LT_DLTYPE_TOP &presym
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
|
1998-11-18 15:29:36 +08:00
|
|
|
#endif
|
|
|
|
|
1998-11-24 05:26:38 +08:00
|
|
|
static lt_dlhandle handles;
|
|
|
|
static int initialized = 0;
|
|
|
|
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
static lt_dltype types = LT_DLTYPE_TOP;
|
|
|
|
#undef LT_DLTYPE_TOP
|
|
|
|
|
1998-11-24 05:26:38 +08:00
|
|
|
int
|
* ltmain.in (libobjs_save, oldobjs): when building an
old-fashioned archive, use a copy of libobjs saved before
convenience libraries are appended
* libltdl/ltdl.h (_LTDLL_EXPORT, _LTDLL_IMPORT): use cygwin or
unix library import/export primitives; this may be convenient for
people willing to create DLLs
(_LTDLL_EXTERN): select _LTDLL_EXPORT or _LTDLL_IMPORT depending
on _LTDL_COMPILE_
* libltdl/ltdl.h, libltdl/ltdl.c (lt_dlpreopen): new function,
that replaces the current preloaded_symbols list with its
argument, and returns the old value, initially NULL
(dldpre_init): don't refer to dld_preloaded_symbols any more
(dldpre_open, dldpre_sym): search preloaded_symbols
(lt_dlpreopen_default): call lt_dlpreopen with
dld_preloaded_symbols, that is declared as extern; it should be
called from the main program or from some static library without
-no-undefined
(lt_dlerror): new function, that returns the error message for the
last error occurred; the error message is kept in the static
variable last_error
* libltdl/configure.in (enable-ltdl-install): moved back from
enable-install; other packages might use enable-install already,
better have fine grained control over this.
* libltdl/Makefile.am (libltdls.la): discarded
1999-01-06 07:13:44 +08:00
|
|
|
lt_dlinit ()
|
1998-11-18 15:29:36 +08:00
|
|
|
{
|
1998-12-20 03:30:30 +08:00
|
|
|
/* initialize libltdl */
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
lt_dltype *type = &types;
|
|
|
|
int typecount = 0;
|
|
|
|
|
1998-11-24 05:26:38 +08:00
|
|
|
if (initialized) { /* Initialize only at first call. */
|
|
|
|
initialized++;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
handles = 0;
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
|
|
|
|
while (*type) {
|
|
|
|
if ((*type)->mod_init())
|
|
|
|
*type = (*type)->next; /* Remove it from the list */
|
|
|
|
else {
|
|
|
|
type = &(*type)->next; /* Keep it */
|
1998-12-20 03:30:30 +08:00
|
|
|
typecount++;
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
}
|
|
|
|
}
|
1999-01-10 04:05:55 +08:00
|
|
|
if (typecount == 0) {
|
1999-01-13 04:42:47 +08:00
|
|
|
last_error = dlopen_not_supported_error;
|
1998-11-24 05:26:38 +08:00
|
|
|
return 1;
|
1999-01-10 04:05:55 +08:00
|
|
|
}
|
|
|
|
last_error = 0;
|
1998-11-24 05:26:38 +08:00
|
|
|
initialized = 1;
|
|
|
|
return 0;
|
1998-11-18 15:29:36 +08:00
|
|
|
}
|
|
|
|
|
1999-01-13 04:42:47 +08:00
|
|
|
int
|
* ltmain.in (libobjs_save, oldobjs): when building an
old-fashioned archive, use a copy of libobjs saved before
convenience libraries are appended
* libltdl/ltdl.h (_LTDLL_EXPORT, _LTDLL_IMPORT): use cygwin or
unix library import/export primitives; this may be convenient for
people willing to create DLLs
(_LTDLL_EXTERN): select _LTDLL_EXPORT or _LTDLL_IMPORT depending
on _LTDL_COMPILE_
* libltdl/ltdl.h, libltdl/ltdl.c (lt_dlpreopen): new function,
that replaces the current preloaded_symbols list with its
argument, and returns the old value, initially NULL
(dldpre_init): don't refer to dld_preloaded_symbols any more
(dldpre_open, dldpre_sym): search preloaded_symbols
(lt_dlpreopen_default): call lt_dlpreopen with
dld_preloaded_symbols, that is declared as extern; it should be
called from the main program or from some static library without
-no-undefined
(lt_dlerror): new function, that returns the error message for the
last error occurred; the error message is kept in the static
variable last_error
* libltdl/configure.in (enable-ltdl-install): moved back from
enable-install; other packages might use enable-install already,
better have fine grained control over this.
* libltdl/Makefile.am (libltdls.la): discarded
1999-01-06 07:13:44 +08:00
|
|
|
lt_dlpreopen (preloaded)
|
1999-01-14 05:39:14 +08:00
|
|
|
const lt_dlsymlist *preloaded;
|
* ltmain.in (libobjs_save, oldobjs): when building an
old-fashioned archive, use a copy of libobjs saved before
convenience libraries are appended
* libltdl/ltdl.h (_LTDLL_EXPORT, _LTDLL_IMPORT): use cygwin or
unix library import/export primitives; this may be convenient for
people willing to create DLLs
(_LTDLL_EXTERN): select _LTDLL_EXPORT or _LTDLL_IMPORT depending
on _LTDL_COMPILE_
* libltdl/ltdl.h, libltdl/ltdl.c (lt_dlpreopen): new function,
that replaces the current preloaded_symbols list with its
argument, and returns the old value, initially NULL
(dldpre_init): don't refer to dld_preloaded_symbols any more
(dldpre_open, dldpre_sym): search preloaded_symbols
(lt_dlpreopen_default): call lt_dlpreopen with
dld_preloaded_symbols, that is declared as extern; it should be
called from the main program or from some static library without
-no-undefined
(lt_dlerror): new function, that returns the error message for the
last error occurred; the error message is kept in the static
variable last_error
* libltdl/configure.in (enable-ltdl-install): moved back from
enable-install; other packages might use enable-install already,
better have fine grained control over this.
* libltdl/Makefile.am (libltdls.la): discarded
1999-01-06 07:13:44 +08:00
|
|
|
{
|
|
|
|
#if HAVE_DLPREOPEN
|
1999-01-13 04:42:47 +08:00
|
|
|
if (preloaded)
|
1999-01-14 05:39:14 +08:00
|
|
|
return presym_add_symlist(preloaded);
|
1999-01-13 04:42:47 +08:00
|
|
|
else {
|
1999-01-14 05:39:14 +08:00
|
|
|
presym_free_symlists();
|
1999-01-15 00:31:23 +08:00
|
|
|
if (default_preloaded_symbols)
|
|
|
|
return lt_dlpreopen(default_preloaded_symbols);
|
1999-01-13 04:42:47 +08:00
|
|
|
return 0;
|
|
|
|
}
|
* ltmain.in (libobjs_save, oldobjs): when building an
old-fashioned archive, use a copy of libobjs saved before
convenience libraries are appended
* libltdl/ltdl.h (_LTDLL_EXPORT, _LTDLL_IMPORT): use cygwin or
unix library import/export primitives; this may be convenient for
people willing to create DLLs
(_LTDLL_EXTERN): select _LTDLL_EXPORT or _LTDLL_IMPORT depending
on _LTDL_COMPILE_
* libltdl/ltdl.h, libltdl/ltdl.c (lt_dlpreopen): new function,
that replaces the current preloaded_symbols list with its
argument, and returns the old value, initially NULL
(dldpre_init): don't refer to dld_preloaded_symbols any more
(dldpre_open, dldpre_sym): search preloaded_symbols
(lt_dlpreopen_default): call lt_dlpreopen with
dld_preloaded_symbols, that is declared as extern; it should be
called from the main program or from some static library without
-no-undefined
(lt_dlerror): new function, that returns the error message for the
last error occurred; the error message is kept in the static
variable last_error
* libltdl/configure.in (enable-ltdl-install): moved back from
enable-install; other packages might use enable-install already,
better have fine grained control over this.
* libltdl/Makefile.am (libltdls.la): discarded
1999-01-06 07:13:44 +08:00
|
|
|
#else
|
1999-01-13 04:42:47 +08:00
|
|
|
last_error = dlpreopen_not_supported_error;
|
|
|
|
return 1;
|
* ltmain.in (libobjs_save, oldobjs): when building an
old-fashioned archive, use a copy of libobjs saved before
convenience libraries are appended
* libltdl/ltdl.h (_LTDLL_EXPORT, _LTDLL_IMPORT): use cygwin or
unix library import/export primitives; this may be convenient for
people willing to create DLLs
(_LTDLL_EXTERN): select _LTDLL_EXPORT or _LTDLL_IMPORT depending
on _LTDL_COMPILE_
* libltdl/ltdl.h, libltdl/ltdl.c (lt_dlpreopen): new function,
that replaces the current preloaded_symbols list with its
argument, and returns the old value, initially NULL
(dldpre_init): don't refer to dld_preloaded_symbols any more
(dldpre_open, dldpre_sym): search preloaded_symbols
(lt_dlpreopen_default): call lt_dlpreopen with
dld_preloaded_symbols, that is declared as extern; it should be
called from the main program or from some static library without
-no-undefined
(lt_dlerror): new function, that returns the error message for the
last error occurred; the error message is kept in the static
variable last_error
* libltdl/configure.in (enable-ltdl-install): moved back from
enable-install; other packages might use enable-install already,
better have fine grained control over this.
* libltdl/Makefile.am (libltdls.la): discarded
1999-01-06 07:13:44 +08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
1999-01-15 00:31:23 +08:00
|
|
|
int
|
1999-01-17 12:15:06 +08:00
|
|
|
lt_dlpreopen_default_ (preloaded)
|
1999-01-15 00:31:23 +08:00
|
|
|
const lt_dlsymlist *preloaded;
|
|
|
|
{
|
|
|
|
#if HAVE_DLPREOPEN
|
|
|
|
default_preloaded_symbols = preloaded;
|
|
|
|
return 0;
|
|
|
|
#else
|
|
|
|
last_error = dlpreopen_not_supported_error;
|
|
|
|
return 1;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
1998-11-24 05:26:38 +08:00
|
|
|
int
|
* ltmain.in (libobjs_save, oldobjs): when building an
old-fashioned archive, use a copy of libobjs saved before
convenience libraries are appended
* libltdl/ltdl.h (_LTDLL_EXPORT, _LTDLL_IMPORT): use cygwin or
unix library import/export primitives; this may be convenient for
people willing to create DLLs
(_LTDLL_EXTERN): select _LTDLL_EXPORT or _LTDLL_IMPORT depending
on _LTDL_COMPILE_
* libltdl/ltdl.h, libltdl/ltdl.c (lt_dlpreopen): new function,
that replaces the current preloaded_symbols list with its
argument, and returns the old value, initially NULL
(dldpre_init): don't refer to dld_preloaded_symbols any more
(dldpre_open, dldpre_sym): search preloaded_symbols
(lt_dlpreopen_default): call lt_dlpreopen with
dld_preloaded_symbols, that is declared as extern; it should be
called from the main program or from some static library without
-no-undefined
(lt_dlerror): new function, that returns the error message for the
last error occurred; the error message is kept in the static
variable last_error
* libltdl/configure.in (enable-ltdl-install): moved back from
enable-install; other packages might use enable-install already,
better have fine grained control over this.
* libltdl/Makefile.am (libltdls.la): discarded
1999-01-06 07:13:44 +08:00
|
|
|
lt_dlexit ()
|
1998-11-18 15:29:36 +08:00
|
|
|
{
|
1998-12-20 03:30:30 +08:00
|
|
|
/* shut down libltdl */
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
lt_dltype type = types;
|
1998-12-23 21:28:28 +08:00
|
|
|
int errors;
|
1998-11-24 05:26:38 +08:00
|
|
|
|
1999-01-10 04:05:55 +08:00
|
|
|
if (!initialized) {
|
|
|
|
last_error = shutdown_error;
|
|
|
|
return 1;
|
|
|
|
}
|
1998-12-20 03:30:30 +08:00
|
|
|
if (initialized != 1) { /* shut down only at last call. */
|
1998-11-24 05:26:38 +08:00
|
|
|
initialized--;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* close all modules */
|
1998-12-23 21:28:28 +08:00
|
|
|
errors = 0;
|
* ltmain.in (libobjs_save, oldobjs): when building an
old-fashioned archive, use a copy of libobjs saved before
convenience libraries are appended
* libltdl/ltdl.h (_LTDLL_EXPORT, _LTDLL_IMPORT): use cygwin or
unix library import/export primitives; this may be convenient for
people willing to create DLLs
(_LTDLL_EXTERN): select _LTDLL_EXPORT or _LTDLL_IMPORT depending
on _LTDL_COMPILE_
* libltdl/ltdl.h, libltdl/ltdl.c (lt_dlpreopen): new function,
that replaces the current preloaded_symbols list with its
argument, and returns the old value, initially NULL
(dldpre_init): don't refer to dld_preloaded_symbols any more
(dldpre_open, dldpre_sym): search preloaded_symbols
(lt_dlpreopen_default): call lt_dlpreopen with
dld_preloaded_symbols, that is declared as extern; it should be
called from the main program or from some static library without
-no-undefined
(lt_dlerror): new function, that returns the error message for the
last error occurred; the error message is kept in the static
variable last_error
* libltdl/configure.in (enable-ltdl-install): moved back from
enable-install; other packages might use enable-install already,
better have fine grained control over this.
* libltdl/Makefile.am (libltdls.la): discarded
1999-01-06 07:13:44 +08:00
|
|
|
while (handles) {
|
1998-12-23 21:28:28 +08:00
|
|
|
/* FIXME: what if a module depends on another one? */
|
* ltmain.in (libobjs_save, oldobjs): when building an
old-fashioned archive, use a copy of libobjs saved before
convenience libraries are appended
* libltdl/ltdl.h (_LTDLL_EXPORT, _LTDLL_IMPORT): use cygwin or
unix library import/export primitives; this may be convenient for
people willing to create DLLs
(_LTDLL_EXTERN): select _LTDLL_EXPORT or _LTDLL_IMPORT depending
on _LTDL_COMPILE_
* libltdl/ltdl.h, libltdl/ltdl.c (lt_dlpreopen): new function,
that replaces the current preloaded_symbols list with its
argument, and returns the old value, initially NULL
(dldpre_init): don't refer to dld_preloaded_symbols any more
(dldpre_open, dldpre_sym): search preloaded_symbols
(lt_dlpreopen_default): call lt_dlpreopen with
dld_preloaded_symbols, that is declared as extern; it should be
called from the main program or from some static library without
-no-undefined
(lt_dlerror): new function, that returns the error message for the
last error occurred; the error message is kept in the static
variable last_error
* libltdl/configure.in (enable-ltdl-install): moved back from
enable-install; other packages might use enable-install already,
better have fine grained control over this.
* libltdl/Makefile.am (libltdls.la): discarded
1999-01-06 07:13:44 +08:00
|
|
|
if (lt_dlclose(handles))
|
1998-12-23 21:28:28 +08:00
|
|
|
errors++;
|
* ltmain.in (libobjs_save, oldobjs): when building an
old-fashioned archive, use a copy of libobjs saved before
convenience libraries are appended
* libltdl/ltdl.h (_LTDLL_EXPORT, _LTDLL_IMPORT): use cygwin or
unix library import/export primitives; this may be convenient for
people willing to create DLLs
(_LTDLL_EXTERN): select _LTDLL_EXPORT or _LTDLL_IMPORT depending
on _LTDL_COMPILE_
* libltdl/ltdl.h, libltdl/ltdl.c (lt_dlpreopen): new function,
that replaces the current preloaded_symbols list with its
argument, and returns the old value, initially NULL
(dldpre_init): don't refer to dld_preloaded_symbols any more
(dldpre_open, dldpre_sym): search preloaded_symbols
(lt_dlpreopen_default): call lt_dlpreopen with
dld_preloaded_symbols, that is declared as extern; it should be
called from the main program or from some static library without
-no-undefined
(lt_dlerror): new function, that returns the error message for the
last error occurred; the error message is kept in the static
variable last_error
* libltdl/configure.in (enable-ltdl-install): moved back from
enable-install; other packages might use enable-install already,
better have fine grained control over this.
* libltdl/Makefile.am (libltdls.la): discarded
1999-01-06 07:13:44 +08:00
|
|
|
}
|
1998-11-24 05:26:38 +08:00
|
|
|
initialized = 0;
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
while (type) {
|
|
|
|
if (type->mod_exit())
|
1998-12-23 21:28:28 +08:00
|
|
|
errors++;
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
type = type->next;
|
|
|
|
}
|
1998-12-23 21:28:28 +08:00
|
|
|
return errors;
|
1998-11-18 15:29:36 +08:00
|
|
|
}
|
|
|
|
|
1998-11-24 05:26:38 +08:00
|
|
|
static void
|
1998-12-20 03:30:30 +08:00
|
|
|
trim (dest, s)
|
|
|
|
char *dest;
|
|
|
|
const char *s;
|
1998-11-24 05:26:38 +08:00
|
|
|
{
|
1998-12-02 21:05:23 +08:00
|
|
|
char *i = strrchr(s, '\'');
|
1998-11-24 05:26:38 +08:00
|
|
|
int len = strlen(s);
|
|
|
|
|
|
|
|
if (len > 3 && s[0] == '\'') {
|
|
|
|
strncpy(dest, &s[1], (i - s) - 1);
|
|
|
|
dest[len-3] = '\0';
|
|
|
|
} else
|
|
|
|
*dest = '\0';
|
|
|
|
}
|
1998-11-18 15:29:36 +08:00
|
|
|
|
1998-12-20 03:30:30 +08:00
|
|
|
static int
|
1998-12-23 21:28:28 +08:00
|
|
|
tryall_dlopen (handle, filename)
|
|
|
|
lt_dlhandle *handle;
|
|
|
|
const char *filename;
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
{
|
1998-12-23 21:28:28 +08:00
|
|
|
lt_dlhandle cur;
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
lt_dltype type = types;
|
1999-01-10 04:05:55 +08:00
|
|
|
const char *saved_error = last_error;
|
1998-12-23 21:28:28 +08:00
|
|
|
|
|
|
|
/* check whether the module was already opened */
|
|
|
|
cur = handles;
|
|
|
|
while (cur && strcmp(cur->filename, filename))
|
|
|
|
cur = cur->next;
|
|
|
|
if (cur) {
|
|
|
|
cur->usage++;
|
|
|
|
free(*handle);
|
|
|
|
*handle = cur;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1999-01-13 04:42:47 +08:00
|
|
|
(*handle)->filename = strdup(filename);
|
|
|
|
if (!(*handle)->filename)
|
|
|
|
return 1;
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
while (type) {
|
1998-12-23 21:28:28 +08:00
|
|
|
if (type->lib_open(*handle, filename) == 0)
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
break;
|
|
|
|
type = type->next;
|
|
|
|
}
|
1999-01-13 04:42:47 +08:00
|
|
|
if (!type) {
|
|
|
|
free((*handle)->filename);
|
1999-01-10 04:05:55 +08:00
|
|
|
return 1;
|
1999-01-13 04:42:47 +08:00
|
|
|
}
|
1998-12-23 21:28:28 +08:00
|
|
|
(*handle)->type = type;
|
1999-01-10 04:05:55 +08:00
|
|
|
last_error = saved_error;
|
|
|
|
return 0;
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
}
|
|
|
|
|
1999-01-13 04:42:47 +08:00
|
|
|
/* max. filename length */
|
1999-01-11 03:15:01 +08:00
|
|
|
#ifndef FILENAME_MAX
|
|
|
|
#define FILENAME_MAX 1024
|
|
|
|
#endif
|
1998-12-20 03:30:30 +08:00
|
|
|
|
|
|
|
static int
|
1998-12-23 21:28:28 +08:00
|
|
|
find_module (handle, dir, libdir, dlname, old_name)
|
* ltmain.in (libobjs_save, oldobjs): when building an
old-fashioned archive, use a copy of libobjs saved before
convenience libraries are appended
* libltdl/ltdl.h (_LTDLL_EXPORT, _LTDLL_IMPORT): use cygwin or
unix library import/export primitives; this may be convenient for
people willing to create DLLs
(_LTDLL_EXTERN): select _LTDLL_EXPORT or _LTDLL_IMPORT depending
on _LTDL_COMPILE_
* libltdl/ltdl.h, libltdl/ltdl.c (lt_dlpreopen): new function,
that replaces the current preloaded_symbols list with its
argument, and returns the old value, initially NULL
(dldpre_init): don't refer to dld_preloaded_symbols any more
(dldpre_open, dldpre_sym): search preloaded_symbols
(lt_dlpreopen_default): call lt_dlpreopen with
dld_preloaded_symbols, that is declared as extern; it should be
called from the main program or from some static library without
-no-undefined
(lt_dlerror): new function, that returns the error message for the
last error occurred; the error message is kept in the static
variable last_error
* libltdl/configure.in (enable-ltdl-install): moved back from
enable-install; other packages might use enable-install already,
better have fine grained control over this.
* libltdl/Makefile.am (libltdls.la): discarded
1999-01-06 07:13:44 +08:00
|
|
|
lt_dlhandle *handle;
|
|
|
|
const char *dir;
|
1998-12-20 03:30:30 +08:00
|
|
|
const char *libdir;
|
|
|
|
const char *dlname;
|
|
|
|
const char *old_name;
|
|
|
|
{
|
1999-01-11 03:15:01 +08:00
|
|
|
char fullname[FILENAME_MAX];
|
1998-12-20 03:30:30 +08:00
|
|
|
|
1999-01-17 12:15:06 +08:00
|
|
|
/* search for old library first; if it was dlpreopened, we
|
|
|
|
want the preopened version of it, even if a dlopenable
|
|
|
|
module is available */
|
|
|
|
if (*old_name && tryall_dlopen(handle, old_name) == 0)
|
|
|
|
return 0;
|
|
|
|
|
1998-12-20 03:30:30 +08:00
|
|
|
/* search a module */
|
|
|
|
if (*dlname) {
|
|
|
|
/* try to open the installed module */
|
1999-01-11 03:15:01 +08:00
|
|
|
if (strlen(libdir)+strlen(dlname)+1 < FILENAME_MAX) {
|
1999-01-09 17:51:44 +08:00
|
|
|
strcpy(fullname, libdir);
|
|
|
|
strcat(fullname, "/");
|
|
|
|
strcat(fullname, dlname);
|
|
|
|
if (tryall_dlopen(handle, fullname) == 0)
|
|
|
|
return 0;
|
|
|
|
}
|
1998-12-20 03:30:30 +08:00
|
|
|
/* try to open the not-installed module */
|
1999-01-11 03:15:01 +08:00
|
|
|
if (strlen(dir)+strlen(dlname)+6 < FILENAME_MAX) {
|
1999-01-09 17:51:44 +08:00
|
|
|
strcpy(fullname, dir);
|
|
|
|
strcat(fullname, ".libs/");
|
|
|
|
strcat(fullname, dlname);
|
|
|
|
if (tryall_dlopen(handle, fullname) == 0)
|
|
|
|
return 0;
|
|
|
|
}
|
1999-01-11 03:15:01 +08:00
|
|
|
if (strlen(dir)+strlen(dlname) < FILENAME_MAX) {
|
1999-01-09 17:51:44 +08:00
|
|
|
strcpy(fullname, dir);
|
|
|
|
strcat(fullname, dlname);
|
|
|
|
if (tryall_dlopen(handle, fullname) == 0)
|
|
|
|
return 0;
|
|
|
|
}
|
1998-12-20 03:30:30 +08:00
|
|
|
}
|
1999-01-13 04:42:47 +08:00
|
|
|
last_error = file_not_found_error;
|
1998-12-20 03:30:30 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
1999-01-13 04:42:47 +08:00
|
|
|
static int
|
|
|
|
find_library (handle, filename, have_dir, basename, search_path)
|
|
|
|
lt_dlhandle *handle;
|
|
|
|
const char *filename;
|
|
|
|
int have_dir;
|
|
|
|
const char *basename;
|
|
|
|
const char *search_path;
|
|
|
|
{
|
|
|
|
char dir[FILENAME_MAX], fullname[FILENAME_MAX];
|
|
|
|
const char *p, *next;
|
|
|
|
|
1999-01-14 05:39:14 +08:00
|
|
|
if (have_dir || !search_path) {
|
1999-01-13 04:42:47 +08:00
|
|
|
last_error = file_not_found_error;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
/* try other directories */
|
|
|
|
|
|
|
|
/* search_path is a colon-separated
|
|
|
|
list of search directories */
|
|
|
|
p = search_path;
|
|
|
|
while (p) {
|
|
|
|
next = strchr(p, ':');
|
|
|
|
if (next) {
|
|
|
|
if (next - p + 1 >= FILENAME_MAX) {
|
|
|
|
last_error = buffer_overflow_error;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
strncpy(dir, p, next - p);
|
|
|
|
dir[next - p] = '\0';
|
|
|
|
p = next+1;
|
|
|
|
} else {
|
|
|
|
if (strlen(p)+1 >= FILENAME_MAX) {
|
|
|
|
last_error = buffer_overflow_error;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
strcpy(dir, p);
|
|
|
|
p = 0;
|
|
|
|
}
|
|
|
|
if (!*dir)
|
|
|
|
continue;
|
|
|
|
strcat(dir, "/");
|
|
|
|
if (strlen(dir)+strlen(basename) < FILENAME_MAX) {
|
|
|
|
strcpy(fullname, dir);
|
|
|
|
strcat(fullname, basename);
|
|
|
|
if (tryall_dlopen(handle, fullname) == 0)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
last_error = file_not_found_error;
|
|
|
|
return 1;
|
|
|
|
}
|
1998-12-20 03:30:30 +08:00
|
|
|
|
1999-01-13 04:42:47 +08:00
|
|
|
#undef READTEXT_MODE
|
|
|
|
/* fopen() mode flags for reading a text file */
|
1998-12-20 03:30:30 +08:00
|
|
|
#ifdef _WIN32
|
|
|
|
#define READTEXT_MODE "rt"
|
|
|
|
#else
|
|
|
|
#define READTEXT_MODE "r"
|
|
|
|
#endif
|
|
|
|
|
1999-01-13 04:42:47 +08:00
|
|
|
static FILE *
|
|
|
|
find_file (filename, basename, have_dir, search_path)
|
|
|
|
const char *filename;
|
|
|
|
int have_dir;
|
|
|
|
const char *basename;
|
|
|
|
const char *search_path;
|
|
|
|
{
|
|
|
|
char dir[FILENAME_MAX], fullname[FILENAME_MAX];
|
|
|
|
const char *p, *next;
|
|
|
|
FILE *file;
|
|
|
|
|
1999-01-14 05:39:14 +08:00
|
|
|
if (have_dir || !search_path) {
|
1999-01-13 04:42:47 +08:00
|
|
|
last_error = file_not_found_error;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* try other directories */
|
|
|
|
|
|
|
|
/* search_path is a colon-separated
|
|
|
|
list of search directories */
|
|
|
|
p = search_path;
|
|
|
|
while (p) {
|
|
|
|
next = strchr(p, ':');
|
|
|
|
if (next) {
|
|
|
|
if (next - p + 1 >= FILENAME_MAX) {
|
|
|
|
last_error = buffer_overflow_error;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
strncpy(dir, p, next - p);
|
|
|
|
dir[next - p] = '\0';
|
|
|
|
p = next+1;
|
|
|
|
} else {
|
|
|
|
if (strlen(p)+1 >= FILENAME_MAX) {
|
|
|
|
last_error = buffer_overflow_error;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
strcpy(dir, p);
|
|
|
|
p = 0;
|
|
|
|
}
|
|
|
|
if (!*dir)
|
|
|
|
continue;
|
|
|
|
strcat(dir, "/");
|
|
|
|
if (strlen(dir)+strlen(basename) < FILENAME_MAX) {
|
|
|
|
strcpy(fullname, dir);
|
|
|
|
strcat(fullname, basename);
|
|
|
|
file = fopen(fullname, READTEXT_MODE);
|
|
|
|
if (file)
|
|
|
|
return file;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
last_error = file_not_found_error;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
load_deplibs(handle, deplibs)
|
|
|
|
lt_dlhandle *handle;
|
|
|
|
const char *deplibs;
|
|
|
|
{
|
|
|
|
/* FIXME: load deplibs */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
unload_deplibs(handle)
|
|
|
|
lt_dlhandle *handle;
|
|
|
|
{
|
|
|
|
/* FIXME: unload deplibs */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1998-11-24 05:26:38 +08:00
|
|
|
lt_dlhandle
|
1998-12-20 03:30:30 +08:00
|
|
|
lt_dlopen (filename)
|
|
|
|
const char *filename;
|
1998-11-18 15:29:36 +08:00
|
|
|
{
|
1998-12-23 21:28:28 +08:00
|
|
|
lt_dlhandle handle;
|
1999-01-13 04:42:47 +08:00
|
|
|
char dir[FILENAME_MAX];
|
1998-12-20 03:30:30 +08:00
|
|
|
const char *basename, *ext, *search_path;
|
1999-01-14 02:37:25 +08:00
|
|
|
#ifdef LTDL_SHLIBPATH_VAR
|
1999-01-15 00:31:23 +08:00
|
|
|
const char *sys_search_path;
|
1999-01-14 02:37:25 +08:00
|
|
|
#endif
|
1999-01-10 04:05:55 +08:00
|
|
|
const char *saved_error = last_error;
|
1998-11-24 05:26:38 +08:00
|
|
|
|
1998-12-02 21:05:23 +08:00
|
|
|
basename = strrchr(filename, '/');
|
1998-11-24 05:26:38 +08:00
|
|
|
if (basename)
|
|
|
|
basename++;
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
else
|
|
|
|
basename = filename;
|
1999-01-11 03:15:01 +08:00
|
|
|
if (basename - filename >= FILENAME_MAX) {
|
1999-01-10 04:05:55 +08:00
|
|
|
last_error = buffer_overflow_error;
|
1999-01-09 17:51:44 +08:00
|
|
|
return 0;
|
1999-01-10 04:05:55 +08:00
|
|
|
}
|
1998-11-24 05:26:38 +08:00
|
|
|
strncpy(dir, filename, basename - filename);
|
|
|
|
dir[basename - filename] = '\0';
|
1998-12-20 03:30:30 +08:00
|
|
|
search_path = getenv("LTDL_LIBRARY_PATH"); /* get the search path */
|
1999-01-14 02:37:25 +08:00
|
|
|
#ifdef LTDL_SHLIBPATH_VAR
|
1999-01-15 00:31:23 +08:00
|
|
|
sys_search_path = getenv(LTDL_SHLIBPATH_VAR);
|
1999-01-14 02:37:25 +08:00
|
|
|
#endif
|
1998-11-24 05:26:38 +08:00
|
|
|
/* check whether we open a libtool module (.la extension) */
|
1998-12-02 21:05:23 +08:00
|
|
|
ext = strrchr(basename, '.');
|
1998-11-24 05:26:38 +08:00
|
|
|
if (ext && strcmp(ext, ".la") == 0) {
|
1999-01-11 03:15:01 +08:00
|
|
|
char dlname[FILENAME_MAX], old_name[FILENAME_MAX];
|
1999-01-13 04:42:47 +08:00
|
|
|
char libdir[FILENAME_MAX], deplibs[FILENAME_MAX];
|
|
|
|
char tmp[FILENAME_MAX];
|
|
|
|
char *name;
|
|
|
|
FILE *file;
|
1998-12-19 06:23:51 +08:00
|
|
|
int i;
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
|
1999-01-13 04:42:47 +08:00
|
|
|
dlname[0] = old_name[0] = libdir[0] = deplibs[0] = '\0';
|
1998-12-23 21:28:28 +08:00
|
|
|
|
1999-01-13 04:42:47 +08:00
|
|
|
/* extract the module name from the file name */
|
|
|
|
if (strlen(basename) >= FILENAME_MAX) {
|
|
|
|
last_error = buffer_overflow_error;
|
|
|
|
return 0;
|
1998-12-23 21:28:28 +08:00
|
|
|
}
|
1999-01-13 04:42:47 +08:00
|
|
|
strcpy(tmp, basename);
|
|
|
|
tmp[ext - basename] = '\0';
|
|
|
|
/* canonicalize the module name */
|
|
|
|
for (i = 0; i < ext - basename; i++)
|
|
|
|
if (!isalnum(tmp[i]))
|
|
|
|
tmp[i] = '_';
|
|
|
|
name = strdup(tmp);
|
|
|
|
if (!name) {
|
|
|
|
last_error = memory_error;
|
|
|
|
return 0;
|
|
|
|
}
|
1999-01-15 00:31:23 +08:00
|
|
|
file = fopen(filename, READTEXT_MODE);
|
|
|
|
if (!file)
|
|
|
|
file = find_file(filename, *dir, basename,
|
|
|
|
usr_search_path);
|
|
|
|
if (!file)
|
|
|
|
file = find_file(filename, *dir, basename,
|
|
|
|
search_path);
|
1999-01-14 02:37:25 +08:00
|
|
|
#ifdef LTDL_SHLIBPATH_VAR
|
|
|
|
if (!file)
|
|
|
|
file = find_file(filename, *dir, basename,
|
1999-01-15 00:31:23 +08:00
|
|
|
sys_search_path);
|
1999-01-14 02:37:25 +08:00
|
|
|
#endif
|
1999-01-10 04:05:55 +08:00
|
|
|
if (!file) {
|
1999-01-13 04:42:47 +08:00
|
|
|
free(name);
|
1999-01-14 02:37:25 +08:00
|
|
|
handle = (lt_dlhandle)0;
|
|
|
|
#ifdef LTDL_SHLIB_EXT
|
|
|
|
/* Try with the shared library extension */
|
|
|
|
name = malloc(strlen(filename) -
|
|
|
|
3 /*i.e., strlen(".la") */
|
|
|
|
+ strlen(LTDL_SHLIB_EXT)
|
|
|
|
+ 1 /* '\0' */);
|
|
|
|
if (name) {
|
|
|
|
strcpy(name, filename);
|
|
|
|
strcpy(name + strlen(filename) - 3,
|
|
|
|
LTDL_SHLIB_EXT);
|
|
|
|
handle = lt_dlopen(name);
|
|
|
|
free(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return handle;
|
1999-01-10 04:05:55 +08:00
|
|
|
}
|
1998-11-24 05:26:38 +08:00
|
|
|
while (!feof(file)) {
|
1999-01-11 03:15:01 +08:00
|
|
|
if (!fgets(tmp, FILENAME_MAX, file))
|
1998-11-24 05:26:38 +08:00
|
|
|
break;
|
|
|
|
if (strncmp(tmp, "dlname=", 7) == 0)
|
|
|
|
trim(dlname, &tmp[7]);
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
else
|
|
|
|
if (strncmp(tmp, "old_library=", 12) == 0)
|
|
|
|
trim(old_name, &tmp[12]);
|
1998-12-23 21:28:28 +08:00
|
|
|
else
|
|
|
|
if (strncmp(tmp, "libdir=", 7) == 0)
|
|
|
|
trim(libdir, &tmp[7]);
|
|
|
|
else
|
1999-01-13 04:42:47 +08:00
|
|
|
if (strncmp(tmp, "dl_dependency_libs=", 20) == 0)
|
|
|
|
trim(deplibs, &tmp[20]);
|
1998-11-24 05:26:38 +08:00
|
|
|
}
|
|
|
|
fclose(file);
|
1998-12-23 21:28:28 +08:00
|
|
|
|
1999-01-09 17:51:44 +08:00
|
|
|
handle = (lt_dlhandle) malloc(sizeof(lt_dlhandle_t));
|
1999-01-10 04:05:55 +08:00
|
|
|
if (!handle) {
|
|
|
|
last_error = memory_error;
|
1999-01-13 04:42:47 +08:00
|
|
|
free(name);
|
1999-01-09 17:51:44 +08:00
|
|
|
return 0;
|
1999-01-10 04:05:55 +08:00
|
|
|
}
|
1999-01-13 04:42:47 +08:00
|
|
|
if (load_deplibs(handle, deplibs)) {
|
1998-11-24 05:26:38 +08:00
|
|
|
free(handle);
|
1999-01-13 04:42:47 +08:00
|
|
|
free(name);
|
1998-11-24 05:26:38 +08:00
|
|
|
return 0;
|
|
|
|
}
|
1999-01-13 04:42:47 +08:00
|
|
|
if (find_module(&handle, dir, libdir, dlname, old_name)) {
|
|
|
|
unload_deplibs(handle);
|
|
|
|
free(handle);
|
|
|
|
free(name);
|
1999-01-09 17:51:44 +08:00
|
|
|
return 0;
|
1999-01-10 04:05:55 +08:00
|
|
|
}
|
1999-01-13 04:42:47 +08:00
|
|
|
handle->name = name;
|
1998-11-24 05:26:38 +08:00
|
|
|
} else {
|
|
|
|
/* not a libtool module */
|
1999-01-09 17:51:44 +08:00
|
|
|
handle = (lt_dlhandle) malloc(sizeof(lt_dlhandle_t));
|
1999-01-10 04:05:55 +08:00
|
|
|
if (!handle) {
|
|
|
|
last_error = memory_error;
|
1999-01-09 17:51:44 +08:00
|
|
|
return 0;
|
1999-01-10 04:05:55 +08:00
|
|
|
}
|
1999-01-15 00:31:23 +08:00
|
|
|
if (tryall_dlopen(&handle, filename)
|
|
|
|
&& find_library(&handle, filename, *dir,
|
|
|
|
basename, usr_search_path)
|
|
|
|
&& find_library(&handle, filename, *dir,
|
|
|
|
basename, search_path)
|
1999-01-14 02:37:25 +08:00
|
|
|
#ifdef LTDL_SHLIBPATH_VAR
|
|
|
|
&& find_library(&handle, filename, *dir,
|
1999-01-15 00:31:23 +08:00
|
|
|
basename, sys_search_path)
|
1999-01-14 02:37:25 +08:00
|
|
|
#endif
|
|
|
|
) {
|
1999-01-13 04:42:47 +08:00
|
|
|
free(handle);
|
|
|
|
return 0;
|
1998-11-24 05:26:38 +08:00
|
|
|
}
|
|
|
|
handle->name = 0;
|
|
|
|
}
|
|
|
|
handle->usage = 1;
|
|
|
|
handle->next = handles;
|
|
|
|
handles = handle;
|
1999-01-10 04:05:55 +08:00
|
|
|
last_error = saved_error;
|
1998-11-24 05:26:38 +08:00
|
|
|
return handle;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1998-12-20 03:30:30 +08:00
|
|
|
lt_dlclose (handle)
|
|
|
|
lt_dlhandle handle;
|
1998-11-24 05:26:38 +08:00
|
|
|
{
|
|
|
|
lt_dlhandle cur, last;
|
|
|
|
|
|
|
|
/* check whether the handle is valid */
|
|
|
|
last = cur = handles;
|
|
|
|
while (cur && handle != cur) {
|
|
|
|
last = cur;
|
|
|
|
cur = cur->next;
|
|
|
|
}
|
1999-01-10 04:05:55 +08:00
|
|
|
if (!cur) {
|
|
|
|
last_error = invalid_handle_error;
|
|
|
|
return 1;
|
|
|
|
}
|
1998-11-24 05:26:38 +08:00
|
|
|
handle->usage--;
|
|
|
|
if (!handle->usage) {
|
|
|
|
int error;
|
|
|
|
|
|
|
|
if (handle != handles)
|
|
|
|
last->next = handle->next;
|
|
|
|
else
|
|
|
|
handles = handle->next;
|
* ltmain.in (-force-static, force_static): removed
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening. Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list. Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release! Fix bug when filename did not
contain slashes; should we check for `\\' too? Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test. However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly
1998-12-16 13:42:23 +08:00
|
|
|
error = handle->type->lib_close(handle);
|
1999-01-13 04:42:47 +08:00
|
|
|
error += unload_deplibs(handle);
|
1998-11-24 05:26:38 +08:00
|
|
|
free(handle->filename);
|
|
|
|
if (handle->name)
|
|
|
|
free(handle->name);
|
|
|
|
free(handle);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
return 0;
|
1998-11-18 15:29:36 +08:00
|
|
|
}
|
|
|
|
|
1999-01-11 03:15:01 +08:00
|
|
|
#undef LT_SYMBOL_LENGTH
|
|
|
|
/* This is the maximum symbol size that won't require malloc/free */
|
|
|
|
#define LT_SYMBOL_LENGTH 256
|
|
|
|
|
|
|
|
#undef LT_SYMBOL_OVERHEAD
|
1999-01-15 00:31:23 +08:00
|
|
|
/* This accounts for the _LTX_ separator and the string terminator */
|
1999-01-13 04:42:47 +08:00
|
|
|
#define LT_SYMBOL_OVERHEAD 7
|
1999-01-09 17:51:44 +08:00
|
|
|
|
1998-12-19 06:23:51 +08:00
|
|
|
lt_ptr_t
|
1998-12-20 03:30:30 +08:00
|
|
|
lt_dlsym (handle, symbol)
|
|
|
|
lt_dlhandle handle;
|
|
|
|
const char *symbol;
|
1998-11-18 15:29:36 +08:00
|
|
|
{
|
1999-01-15 00:31:23 +08:00
|
|
|
int lensym;
|
1999-01-13 04:42:47 +08:00
|
|
|
char lsym[LT_SYMBOL_LENGTH];
|
|
|
|
char *sym;
|
1998-12-19 06:23:51 +08:00
|
|
|
lt_ptr_t address;
|
1998-11-24 05:26:38 +08:00
|
|
|
|
1999-01-13 04:42:47 +08:00
|
|
|
if (!handle) {
|
|
|
|
last_error = invalid_handle_error;
|
|
|
|
return 0;
|
|
|
|
}
|
1999-01-14 05:39:14 +08:00
|
|
|
if (!symbol) {
|
|
|
|
last_error = symbol_error;
|
|
|
|
return 0;
|
|
|
|
}
|
1999-01-13 04:42:47 +08:00
|
|
|
lensym = strlen(symbol);
|
1999-01-15 00:31:23 +08:00
|
|
|
if (handle->type->sym_prefix)
|
|
|
|
lensym += strlen(handle->type->sym_prefix);
|
1999-01-13 04:42:47 +08:00
|
|
|
if (handle->name)
|
1999-01-15 00:31:23 +08:00
|
|
|
lensym += strlen(handle->name);
|
|
|
|
if (lensym + LT_SYMBOL_OVERHEAD < LT_SYMBOL_LENGTH)
|
1999-01-13 04:42:47 +08:00
|
|
|
sym = lsym;
|
|
|
|
else
|
1999-01-15 00:31:23 +08:00
|
|
|
sym = malloc(lensym + LT_SYMBOL_OVERHEAD);
|
1999-01-13 04:42:47 +08:00
|
|
|
if (!sym) {
|
1999-01-10 04:05:55 +08:00
|
|
|
last_error = buffer_overflow_error;
|
|
|
|
return 0;
|
|
|
|
}
|
1999-01-13 04:42:47 +08:00
|
|
|
if (handle->name) {
|
|
|
|
/* this is a libtool module */
|
1999-01-15 00:31:23 +08:00
|
|
|
if (handle->type->sym_prefix) {
|
|
|
|
strcpy(sym, handle->type->sym_prefix);
|
|
|
|
strcat(sym, handle->name);
|
|
|
|
} else
|
|
|
|
strcpy(sym, handle->name);
|
1999-01-13 04:42:47 +08:00
|
|
|
strcat(sym, "_LTX_");
|
|
|
|
strcat(sym, symbol);
|
|
|
|
/* try "modulename_LTX_symbol" */
|
|
|
|
address = handle->type->find_sym(handle, sym);
|
|
|
|
if (address) {
|
|
|
|
if (sym != lsym)
|
|
|
|
free(sym);
|
|
|
|
return address;
|
|
|
|
}
|
1998-11-24 05:26:38 +08:00
|
|
|
}
|
|
|
|
/* otherwise try "symbol" */
|
1999-01-15 00:31:23 +08:00
|
|
|
if (handle->type->sym_prefix) {
|
|
|
|
strcpy(sym, handle->type->sym_prefix);
|
1999-01-17 12:15:06 +08:00
|
|
|
strcat(sym, symbol);
|
1999-01-15 00:31:23 +08:00
|
|
|
} else
|
1999-01-17 12:15:06 +08:00
|
|
|
strcpy(sym, symbol);
|
1999-01-11 03:15:01 +08:00
|
|
|
address = handle->type->find_sym(handle, sym);
|
|
|
|
if (sym != lsym)
|
|
|
|
free(sym);
|
|
|
|
return address;
|
1998-11-18 15:29:36 +08:00
|
|
|
}
|
* ltmain.in (libobjs_save, oldobjs): when building an
old-fashioned archive, use a copy of libobjs saved before
convenience libraries are appended
* libltdl/ltdl.h (_LTDLL_EXPORT, _LTDLL_IMPORT): use cygwin or
unix library import/export primitives; this may be convenient for
people willing to create DLLs
(_LTDLL_EXTERN): select _LTDLL_EXPORT or _LTDLL_IMPORT depending
on _LTDL_COMPILE_
* libltdl/ltdl.h, libltdl/ltdl.c (lt_dlpreopen): new function,
that replaces the current preloaded_symbols list with its
argument, and returns the old value, initially NULL
(dldpre_init): don't refer to dld_preloaded_symbols any more
(dldpre_open, dldpre_sym): search preloaded_symbols
(lt_dlpreopen_default): call lt_dlpreopen with
dld_preloaded_symbols, that is declared as extern; it should be
called from the main program or from some static library without
-no-undefined
(lt_dlerror): new function, that returns the error message for the
last error occurred; the error message is kept in the static
variable last_error
* libltdl/configure.in (enable-ltdl-install): moved back from
enable-install; other packages might use enable-install already,
better have fine grained control over this.
* libltdl/Makefile.am (libltdls.la): discarded
1999-01-06 07:13:44 +08:00
|
|
|
|
|
|
|
const char *
|
|
|
|
lt_dlerror ()
|
|
|
|
{
|
1999-01-10 04:05:55 +08:00
|
|
|
const char *error = last_error;
|
|
|
|
|
|
|
|
last_error = 0;
|
|
|
|
return error;
|
* ltmain.in (libobjs_save, oldobjs): when building an
old-fashioned archive, use a copy of libobjs saved before
convenience libraries are appended
* libltdl/ltdl.h (_LTDLL_EXPORT, _LTDLL_IMPORT): use cygwin or
unix library import/export primitives; this may be convenient for
people willing to create DLLs
(_LTDLL_EXTERN): select _LTDLL_EXPORT or _LTDLL_IMPORT depending
on _LTDL_COMPILE_
* libltdl/ltdl.h, libltdl/ltdl.c (lt_dlpreopen): new function,
that replaces the current preloaded_symbols list with its
argument, and returns the old value, initially NULL
(dldpre_init): don't refer to dld_preloaded_symbols any more
(dldpre_open, dldpre_sym): search preloaded_symbols
(lt_dlpreopen_default): call lt_dlpreopen with
dld_preloaded_symbols, that is declared as extern; it should be
called from the main program or from some static library without
-no-undefined
(lt_dlerror): new function, that returns the error message for the
last error occurred; the error message is kept in the static
variable last_error
* libltdl/configure.in (enable-ltdl-install): moved back from
enable-install; other packages might use enable-install already,
better have fine grained control over this.
* libltdl/Makefile.am (libltdls.la): discarded
1999-01-06 07:13:44 +08:00
|
|
|
}
|
1999-01-15 00:31:23 +08:00
|
|
|
|
|
|
|
const char *
|
|
|
|
lt_dlsearchpath (search_path)
|
|
|
|
const char *search_path;
|
|
|
|
{
|
|
|
|
const char *old_path = usr_search_path;
|
|
|
|
|
|
|
|
usr_search_path = search_path;
|
|
|
|
return old_path;
|
|
|
|
}
|