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
|
|
|
|
* 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 const char *last_error = "unknown error";
|
|
|
|
|
* 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;
|
|
|
|
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 */
|
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
|
|
|
|
|
1998-11-24 05:26:38 +08:00
|
|
|
#ifdef RTLD_LAZY
|
1998-11-18 15:29:36 +08:00
|
|
|
# define DLOPEN_MODE RTLD_LAZY
|
|
|
|
#else
|
* 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
|
|
|
# ifdef DL_LAZY
|
1998-11-18 15:29:36 +08:00
|
|
|
# define DLOPEN_MODE DL_LAZY
|
* 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
|
1998-11-24 05:26:38 +08:00
|
|
|
# define DLOPEN_MODE 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
|
|
|
# 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
|
|
|
{
|
|
|
|
handle->handle = dlopen(filename, DLOPEN_MODE);
|
|
|
|
return !(handle->handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1998-12-20 03:30:30 +08:00
|
|
|
dl_close (handle)
|
|
|
|
lt_dlhandle handle;
|
1998-11-18 15:29:36 +08:00
|
|
|
{
|
1998-11-24 05:26:38 +08:00
|
|
|
return dlclose(handle->handle);
|
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
|
|
|
{
|
1998-11-24 05:26:38 +08:00
|
|
|
return dlsym(handle->handle, symbol);
|
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
|
|
|
|
dl = { LT_DLTYPE_TOP, dl_init, dl_exit,
|
|
|
|
dl_open, dl_close, dl_sym };
|
|
|
|
|
|
|
|
#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
|
|
|
/* the following lines are (c) Tim Janik */
|
|
|
|
|
|
|
|
/* 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.
|
|
|
|
*/
|
|
|
|
#ifndef DYNAMIC_PATH
|
|
|
|
#define DYNAMIC_PATH 0
|
|
|
|
#endif /* DYNAMIC_PATH */
|
|
|
|
#ifndef BIND_RESTRICTED
|
|
|
|
#define BIND_RESTRICTED 0
|
|
|
|
#endif /* BIND_RESTRICTED */
|
|
|
|
|
|
|
|
#define OPT_BIND_FLAGS (BIND_IMMEDIATE | BIND_NONFATAL | BIND_VERBOSE | DYNAMIC_PATH)
|
|
|
|
|
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
|
|
|
{
|
1998-12-25 18:39:59 +08:00
|
|
|
handle->handle = shl_load (filename, OPT_BIND_FLAGS, 0L);
|
|
|
|
/* the hp-docs say we should better abort() if errno==ENOSYM ;( */
|
1998-11-24 05:26:38 +08:00
|
|
|
return !(handle->handle);
|
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
|
|
|
{
|
1998-11-24 05:26:38 +08:00
|
|
|
shl_unload((shl_t) (handle->handle));
|
|
|
|
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
|
|
|
{
|
1998-12-25 18:39:59 +08:00
|
|
|
lt_ptr_t *sym;
|
|
|
|
|
* 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 (shl_findsym ((shl_t) (handle->handle), symbol,
|
1998-12-25 18:39:59 +08:00
|
|
|
TYPE_UNDEFINED, &sym) || !(handle->handle) || !sym)
|
|
|
|
return 0;
|
|
|
|
return 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
|
|
|
static
|
|
|
|
lt_dltype_t
|
|
|
|
shl = { LT_DLTYPE_TOP, shl_init, shl_exit,
|
|
|
|
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
|
|
|
{
|
1998-11-24 05:26:38 +08:00
|
|
|
if (dld_link(filename))
|
|
|
|
return 1;
|
1998-12-19 06:23:51 +08:00
|
|
|
handle->handle = strdup(filename);
|
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
|
|
|
{
|
|
|
|
dld_unlink_by_file((char*)(handle->handle), 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
|
|
|
{
|
1998-11-24 05:26:38 +08:00
|
|
|
return dld_get_func(symbol);
|
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
|
|
|
|
dld = { LT_DLTYPE_TOP, dld_init, dld_exit,
|
|
|
|
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);
|
|
|
|
return !(handle->handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1998-12-20 03:30:30 +08:00
|
|
|
wll_close (handle)
|
|
|
|
lt_dlhandle handle;
|
1998-11-24 05:26:38 +08:00
|
|
|
{
|
|
|
|
FreeLibrary(handle->handle);
|
|
|
|
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
|
|
|
{
|
1998-11-24 05:26:38 +08:00
|
|
|
return GetProcAddress(handle->handle, symbol);
|
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
|
|
|
|
wll = { LT_DLTYPE_TOP, wll_init, wll_exit,
|
|
|
|
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
|
|
|
|
|
|
|
|
/* emulate dynamic linking using dld_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
|
|
|
struct lt_dlsymlist
|
* 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
|
|
|
{
|
|
|
|
char *name;
|
1998-12-19 06:23:51 +08:00
|
|
|
lt_ptr_t address;
|
* 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
|
|
|
};
|
|
|
|
|
* 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 struct lt_dlsymlist *preloaded_symbols;
|
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
|
|
|
dldpre_init ()
|
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
|
|
|
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
|
|
|
dldpre_exit ()
|
1998-11-18 15:29:36 +08:00
|
|
|
{
|
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
|
1998-12-20 03:30:30 +08:00
|
|
|
dldpre_open (handle, filename)
|
|
|
|
lt_dlhandle handle;
|
|
|
|
const char *filename;
|
1998-11-24 05:26:38 +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
|
|
|
struct lt_dlsymlist *s = preloaded_symbols;
|
|
|
|
|
|
|
|
if (!s)
|
|
|
|
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 (s->name) {
|
|
|
|
if (!s->address && !strcmp(s->name, filename))
|
|
|
|
break;
|
|
|
|
s++;
|
|
|
|
}
|
|
|
|
if (!s->name)
|
|
|
|
return 1;
|
|
|
|
handle->handle = s;
|
|
|
|
return 0;
|
1998-11-24 05:26:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1998-12-20 03:30:30 +08:00
|
|
|
dldpre_close (handle)
|
|
|
|
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
|
1998-12-20 03:30:30 +08:00
|
|
|
dldpre_sym (handle, symbol)
|
|
|
|
lt_dlhandle handle;
|
|
|
|
const char *symbol;
|
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
|
|
|
struct lt_dlsymlist *s = (struct 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
|
|
|
|
|
|
|
if (!s)
|
|
|
|
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
|
|
|
|
|
|
|
#if NEED_USCORE
|
|
|
|
/* lt_dlsym will have prepended a `_', but we don't need it */
|
|
|
|
++symbol;
|
|
|
|
#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
|
|
|
s++;
|
|
|
|
while (s->address) {
|
|
|
|
if (strcmp(s->name, symbol) == 0)
|
|
|
|
return s->address;
|
|
|
|
s++;
|
|
|
|
}
|
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
|
|
|
|
dldpre = { LT_DLTYPE_TOP, dldpre_init, dldpre_exit,
|
|
|
|
dldpre_open, dldpre_close, dldpre_sym };
|
|
|
|
|
|
|
|
#undef LT_DLTYPE_TOP
|
|
|
|
#define LT_DLTYPE_TOP &dldpre
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
if (typecount == 0)
|
1998-11-24 05:26:38 +08:00
|
|
|
return 1;
|
|
|
|
initialized = 1;
|
|
|
|
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
|
|
|
struct lt_dlsymlist *
|
|
|
|
lt_dlpreopen (preloaded)
|
|
|
|
struct lt_dlsymlist *preloaded;
|
|
|
|
{
|
|
|
|
#if HAVE_DLPREOPEN
|
|
|
|
struct lt_dlsymlist *prev = preloaded_symbols;
|
|
|
|
preloaded_symbols = preloaded;
|
|
|
|
return prev;
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#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
|
|
|
|
|
|
|
if (!initialized)
|
|
|
|
return 1; /* already deinitialized */
|
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;
|
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;
|
|
|
|
}
|
|
|
|
|
* 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;
|
|
|
|
}
|
1998-12-23 21:28:28 +08:00
|
|
|
(*handle)->type = type;
|
|
|
|
(*handle)->filename = strdup(filename);
|
|
|
|
return !(type);
|
* 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-20 03:30:30 +08:00
|
|
|
#undef MAX_FILENAME
|
1999-01-09 17:51:44 +08:00
|
|
|
#define MAX_FILENAME 2048
|
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-09 17:51:44 +08:00
|
|
|
char fullname[MAX_FILENAME];
|
1998-12-20 03:30:30 +08:00
|
|
|
|
|
|
|
/* search a module */
|
|
|
|
if (*dlname) {
|
|
|
|
/* try to open the installed module */
|
1999-01-09 17:51:44 +08:00
|
|
|
if (strlen(libdir)+strlen(dlname)+1 < MAX_FILENAME) {
|
|
|
|
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-09 17:51:44 +08:00
|
|
|
if (strlen(dir)+strlen(dlname)+6 < MAX_FILENAME) {
|
|
|
|
strcpy(fullname, dir);
|
|
|
|
strcat(fullname, ".libs/");
|
|
|
|
strcat(fullname, dlname);
|
|
|
|
if (tryall_dlopen(handle, fullname) == 0)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (strlen(dir)+strlen(dlname) < MAX_FILENAME) {
|
|
|
|
strcpy(fullname, dir);
|
|
|
|
strcat(fullname, dlname);
|
|
|
|
if (tryall_dlopen(handle, fullname) == 0)
|
|
|
|
return 0;
|
|
|
|
}
|
1998-12-20 03:30:30 +08:00
|
|
|
}
|
|
|
|
if (*old_name && tryall_dlopen(handle, old_name) == 0)
|
1998-12-23 21:28:28 +08:00
|
|
|
return 0;
|
1998-12-20 03:30:30 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef READTEXT_MODE
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
#define READTEXT_MODE "rt"
|
|
|
|
#else
|
|
|
|
#define READTEXT_MODE "r"
|
|
|
|
#endif
|
|
|
|
|
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;
|
1998-11-24 05:26:38 +08:00
|
|
|
FILE *file;
|
1999-01-09 17:51:44 +08:00
|
|
|
char dir[MAX_FILENAME];
|
|
|
|
char tmp[MAX_FILENAME];
|
1998-12-20 03:30:30 +08:00
|
|
|
const char *basename, *ext, *search_path;
|
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-09 17:51:44 +08:00
|
|
|
if (basename - filename >= MAX_FILENAME)
|
|
|
|
return 0;
|
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 */
|
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) {
|
1998-12-20 03:30:30 +08:00
|
|
|
char dlname[MAX_FILENAME], old_name[MAX_FILENAME];
|
1998-12-23 21:28:28 +08:00
|
|
|
char libdir[MAX_FILENAME], preload[MAX_FILENAME];
|
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
|
|
|
|
1998-12-23 21:28:28 +08:00
|
|
|
dlname[0] = old_name[0] = libdir[0] = preload[0] = '\0';
|
|
|
|
|
1998-12-20 03:30:30 +08:00
|
|
|
file = fopen(filename, READTEXT_MODE);
|
1998-12-23 21:28:28 +08:00
|
|
|
if (!file && !*dir && search_path) {
|
|
|
|
/* try other directories */
|
|
|
|
const char *p, *next;
|
|
|
|
|
1999-01-09 17:51:44 +08:00
|
|
|
/* search_path is a colon-separated
|
|
|
|
list of search directories */
|
1998-12-23 21:28:28 +08:00
|
|
|
p = search_path;
|
|
|
|
while (!file && p) {
|
|
|
|
next = strchr(p, ':');
|
|
|
|
if (next) {
|
1999-01-09 17:51:44 +08:00
|
|
|
if (next - p + 1 >= MAX_FILENAME)
|
|
|
|
return 0;
|
1998-12-23 21:28:28 +08:00
|
|
|
strncpy(dir, p, next - p);
|
|
|
|
dir[next - p] = '\0';
|
|
|
|
p = next+1;
|
|
|
|
} else {
|
1999-01-09 17:51:44 +08:00
|
|
|
if (strlen(p)+1 >= MAX_FILENAME)
|
|
|
|
return 0;
|
1998-12-23 21:28:28 +08:00
|
|
|
strcpy(dir, p);
|
|
|
|
p = 0;
|
|
|
|
}
|
|
|
|
if (!*dir)
|
|
|
|
continue;
|
|
|
|
strcat(dir, "/");
|
1999-01-09 17:51:44 +08:00
|
|
|
if (strlen(dir)+strlen(basename) < MAX_FILENAME) {
|
|
|
|
strcpy(tmp, dir);
|
|
|
|
strcat(tmp, basename);
|
|
|
|
file = fopen(tmp, READTEXT_MODE);
|
|
|
|
}
|
1998-12-23 21:28:28 +08:00
|
|
|
}
|
|
|
|
}
|
1999-01-09 17:51:44 +08:00
|
|
|
if (!file)
|
1998-11-24 05:26:38 +08:00
|
|
|
return 0;
|
|
|
|
while (!feof(file)) {
|
1998-12-20 03:30:30 +08:00
|
|
|
if (!fgets(tmp, MAX_FILENAME, 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
|
|
|
|
if (strncmp(tmp, "preload_libs=", 13) == 0)
|
|
|
|
trim(preload, &tmp[13]);
|
1998-11-24 05:26:38 +08:00
|
|
|
}
|
|
|
|
fclose(file);
|
1999-01-09 17:51:44 +08:00
|
|
|
/* FIXME: preload required libraries */
|
1998-12-23 21:28:28 +08:00
|
|
|
|
1999-01-09 17:51:44 +08:00
|
|
|
handle = (lt_dlhandle) malloc(sizeof(lt_dlhandle_t));
|
|
|
|
if (!handle)
|
|
|
|
return 0;
|
1998-12-23 21:28:28 +08:00
|
|
|
if (find_module(&handle, dir, libdir, dlname, old_name)) {
|
1998-11-24 05:26:38 +08:00
|
|
|
free(handle);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* extract the module name from the file name */
|
1999-01-09 23:35:32 +08:00
|
|
|
if (strlen(basename) >= MAX_FILENAME)
|
1999-01-09 17:51:44 +08:00
|
|
|
return 0;
|
1998-11-24 05:26:38 +08:00
|
|
|
strcpy(tmp, basename);
|
|
|
|
tmp[ext - basename] = '\0';
|
1999-01-09 23:35:32 +08:00
|
|
|
/* canonicalize the module name */
|
1998-12-19 06:23:51 +08:00
|
|
|
for (i = 0; i < ext - basename; i++)
|
|
|
|
if (!isalnum(tmp[i]))
|
|
|
|
tmp[i] = '_';
|
1998-11-24 05:26:38 +08:00
|
|
|
handle->name = strdup(tmp);
|
|
|
|
} else {
|
|
|
|
/* not a libtool module */
|
1999-01-09 17:51:44 +08:00
|
|
|
handle = (lt_dlhandle) malloc(sizeof(lt_dlhandle_t));
|
|
|
|
if (!handle)
|
|
|
|
return 0;
|
|
|
|
|
1998-12-23 21:28:28 +08:00
|
|
|
if (tryall_dlopen(*handle, filename)) {
|
|
|
|
int error = 1;
|
|
|
|
|
|
|
|
if (!*dir && search_path) {
|
|
|
|
/* try other directories */
|
|
|
|
const char *p, *next;
|
|
|
|
|
1999-01-09 17:51:44 +08:00
|
|
|
/* search_path is a colon-separated
|
|
|
|
list of search directories */
|
|
|
|
p = search_path;
|
1998-12-23 21:28:28 +08:00
|
|
|
while (error && p) {
|
|
|
|
next = strchr(p, ':');
|
|
|
|
if (next) {
|
1999-01-09 17:51:44 +08:00
|
|
|
if (next - p + 1 >= MAX_FILENAME)
|
|
|
|
return 0;
|
1998-12-23 21:28:28 +08:00
|
|
|
strncpy(dir, p, next - p);
|
|
|
|
dir[next - p] = '\0';
|
|
|
|
p = next+1;
|
|
|
|
} else {
|
1999-01-09 17:51:44 +08:00
|
|
|
if (strlen(p)+1 >= MAX_FILENAME)
|
|
|
|
return 0;
|
1998-12-23 21:28:28 +08:00
|
|
|
strcpy(dir, p);
|
|
|
|
p = 0;
|
|
|
|
}
|
|
|
|
if (!*dir)
|
|
|
|
continue;
|
|
|
|
strcat(dir, "/");
|
1999-01-09 17:51:44 +08:00
|
|
|
if (strlen(dir)+strlen(basename) < MAX_FILENAME) {
|
|
|
|
strcpy(tmp, dir);
|
|
|
|
strcat(tmp, basename);
|
|
|
|
error = tryall_dlopen(*handle, tmp);
|
|
|
|
}
|
1998-12-23 21:28:28 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (error) {
|
|
|
|
free(handle);
|
|
|
|
return 0;
|
|
|
|
}
|
1998-11-24 05:26:38 +08:00
|
|
|
}
|
|
|
|
handle->name = 0;
|
|
|
|
}
|
|
|
|
handle->usage = 1;
|
|
|
|
handle->next = handles;
|
|
|
|
handles = handle;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
if (!cur)
|
|
|
|
return 1; /* invalid handle */
|
|
|
|
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);
|
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-09 17:51:44 +08:00
|
|
|
#define MAX_SYMBOL_LENGTH 128
|
|
|
|
|
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-09 17:51:44 +08:00
|
|
|
char sym[MAX_SYMBOL_LENGTH];
|
1998-12-19 06:23:51 +08:00
|
|
|
lt_ptr_t address;
|
1998-11-24 05:26:38 +08:00
|
|
|
|
|
|
|
#ifdef NEED_USCORE
|
1999-01-09 17:51:44 +08:00
|
|
|
if (handle->name && strlen(handle->name) < MAX_SYMBOL_LENGTH-6) {
|
|
|
|
/* this is a libtool module */
|
1998-11-24 05:26:38 +08:00
|
|
|
/* prefix symbol with leading underscore */
|
|
|
|
strcpy(sym, "_");
|
|
|
|
strcat(sym, handle->name);
|
|
|
|
#else
|
1999-01-09 17:51:44 +08:00
|
|
|
if (handle->name && strlen(handle->name) < MAX_SYMBOL_LENGTH-5) {
|
|
|
|
/* this is a libtool module */
|
1998-11-24 05:26:38 +08:00
|
|
|
strcpy(sym, handle->name);
|
|
|
|
#endif
|
|
|
|
strcat(sym, "_LTX_");
|
1999-01-09 17:51:44 +08:00
|
|
|
if (strlen(sym)+strlen(symbol) < MAX_SYMBOL_LENGTH) {
|
|
|
|
strcat(sym, symbol);
|
|
|
|
/* try "modulename_LTX_symbol" */
|
|
|
|
address = handle->type->find_sym(handle, sym);
|
|
|
|
if (address)
|
|
|
|
return address;
|
|
|
|
}
|
1998-11-24 05:26:38 +08:00
|
|
|
}
|
|
|
|
/* otherwise try "symbol" */
|
|
|
|
#ifdef NEED_USCORE
|
|
|
|
/* prefix symbol with leading underscore */
|
|
|
|
strcpy(sym, "_");
|
1999-01-09 17:51:44 +08:00
|
|
|
if (strlen(symbol) >= MAX_SYMBOL_LENGTH)
|
|
|
|
return 0;
|
1998-11-24 05:26:38 +08:00
|
|
|
strcat(sym, 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
|
|
|
return handle->type->find_sym(handle, sym);
|
1998-11-24 05:26:38 +08:00
|
|
|
#else
|
* 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 handle->type->find_sym(handle, symbol);
|
1998-11-24 05:26:38 +08:00
|
|
|
#endif
|
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 ()
|
|
|
|
{
|
|
|
|
return last_error;
|
|
|
|
}
|