summaryrefslogtreecommitdiff
path: root/gmodule
diff options
context:
space:
mode:
authorTim Janik <timj@gtk.org>2004-02-20 01:41:00 +0000
committerTim Janik <timj@src.gnome.org>2004-02-20 01:41:00 +0000
commitdefca980e4c4c899f18d8a8c17b629306abfe41c (patch)
tree3f742451c610641276d12c3a7da28a5e8c23f0f8 /gmodule
parentfb464bde99ee62a4c1f36eaa05426be151a37406 (diff)
applied patch from David Schleef <ds@schleef.org> which implements a
Fri Feb 20 02:39:03 2004 Tim Janik <timj@gtk.org> * applied patch from David Schleef <ds@schleef.org> which implements a G_MODULE_BIND_LOCAL flag to g_module_open() to disable global symbol registration.
Diffstat (limited to 'gmodule')
-rw-r--r--gmodule/gmodule-beos.c6
-rw-r--r--gmodule/gmodule-dl.c6
-rw-r--r--gmodule/gmodule-dld.c14
-rw-r--r--gmodule/gmodule-dyld.c7
-rw-r--r--gmodule/gmodule-os2.c6
-rw-r--r--gmodule/gmodule-win32.c3
-rw-r--r--gmodule/gmodule.c9
-rw-r--r--gmodule/gmodule.h3
8 files changed, 41 insertions, 13 deletions
diff --git a/gmodule/gmodule-beos.c b/gmodule/gmodule-beos.c
index edd6b893f..159bc985a 100644
--- a/gmodule/gmodule-beos.c
+++ b/gmodule/gmodule-beos.c
@@ -48,6 +48,9 @@
* different image_id's. While this means that we don't have to worry about
* reference counts, it could lead to problems in the future....
* richard.
+ *
+ * load_add_on() apparently does not support lazy or local binding. Need
+ * to confirm that the actual behavior is non-lazy/local. --ds
*/
#include <Errors.h>
@@ -56,7 +59,8 @@
/* --- functions --- */
static gpointer
_g_module_open (const gchar *file_name,
- gboolean bind_lazy)
+ gboolean bind_lazy,
+ gboolean bind_local)
{
image_id handle;
diff --git a/gmodule/gmodule-dl.c b/gmodule/gmodule-dl.c
index 28dc8a903..08f87f3b2 100644
--- a/gmodule/gmodule-dl.c
+++ b/gmodule/gmodule-dl.c
@@ -90,11 +90,13 @@ fetch_dlerror (gboolean replace_null)
static gpointer
_g_module_open (const gchar *file_name,
- gboolean bind_lazy)
+ gboolean bind_lazy,
+ gboolean bind_local)
{
gpointer handle;
- handle = dlopen (file_name, RTLD_GLOBAL | (bind_lazy ? RTLD_LAZY : RTLD_NOW));
+ handle = dlopen (file_name,
+ (bind_local ? 0 : RTLD_GLOBAL) | (bind_lazy ? RTLD_LAZY : RTLD_NOW));
if (!handle)
g_module_set_error (fetch_dlerror (TRUE));
diff --git a/gmodule/gmodule-dld.c b/gmodule/gmodule-dld.c
index 997c197d4..913ac453b 100644
--- a/gmodule/gmodule-dld.c
+++ b/gmodule/gmodule-dld.c
@@ -67,9 +67,21 @@
/* --- functions --- */
+
+/*
+ * shl_load() does not appear to support making symbols invisible to
+ * the global namespace. However, the default is to put the library
+ * last in the search order, which is approximately what we want,
+ * since it will cause symbols that conflict with existing symbols to
+ * be invisible. It is unclear if BIND_FIRST should be used when
+ * bind_local==0, since it may cause the loaded symbols to be used
+ * preferentially to the application's symbols, which is Almost
+ * Always Wrong. --ds
+ */
static gpointer
_g_module_open (const gchar *file_name,
- gboolean bind_lazy)
+ gboolean bind_lazy,
+ gboolean bind_local)
{
shl_t shl_handle;
diff --git a/gmodule/gmodule-dyld.c b/gmodule/gmodule-dyld.c
index 93bfc7771..3a96017d1 100644
--- a/gmodule/gmodule-dyld.c
+++ b/gmodule/gmodule-dyld.c
@@ -26,7 +26,8 @@ static gpointer self_module = GINT_TO_POINTER (1);
static gpointer
_g_module_open (const gchar *file_name,
- gboolean bind_lazy)
+ gboolean bind_lazy,
+ gboolean bind_local)
{
NSObjectFileImage image;
NSObjectFileImageReturnCode ret;
@@ -66,7 +67,9 @@ _g_module_open (const gchar *file_name,
return NULL;
}
- options = NSLINKMODULE_OPTION_RETURN_ON_ERROR | NSLINKMODULE_OPTION_PRIVATE;
+ options = NSLINKMODULE_OPTION_RETURN_ON_ERROR;
+ if (bind_local)
+ options |= NSLINKMODULE_OPTION_PRIVATE;
if (!bind_lazy)
options |= NSLINKMODULE_OPTION_BINDNOW;
module = NSLinkModule (image, file_name, options);
diff --git a/gmodule/gmodule-os2.c b/gmodule/gmodule-os2.c
index 49d7351b4..4dd0404d7 100644
--- a/gmodule/gmodule-os2.c
+++ b/gmodule/gmodule-os2.c
@@ -68,11 +68,13 @@
/* --- functions --- */
static gpointer
_g_module_open (const gchar *file_name,
- gboolean bind_lazy)
+ gboolean bind_lazy,
+ gboolean bind_local)
{
gpointer handle;
- handle = dlopen (file_name, RTLD_GLOBAL | (bind_lazy ? RTLD_LAZY : RTLD_NOW));
+ handle = dlopen (file_name,
+ (bind_local ? 0 : RTLD_GLOBAL) | (bind_lazy ? RTLD_LAZY : RTLD_NOW));
if (!handle)
g_module_set_error (dlerror ());
diff --git a/gmodule/gmodule-win32.c b/gmodule/gmodule-win32.c
index ebf0cbb55..882ee7b0a 100644
--- a/gmodule/gmodule-win32.c
+++ b/gmodule/gmodule-win32.c
@@ -52,7 +52,8 @@ set_error (void)
/* --- functions --- */
static gpointer
_g_module_open (const gchar *file_name,
- gboolean bind_lazy)
+ gboolean bind_lazy,
+ gboolean bind_local)
{
HINSTANCE handle;
#ifdef G_WITH_CYGWIN
diff --git a/gmodule/gmodule.c b/gmodule/gmodule.c
index 25a463e50..1429a3283 100644
--- a/gmodule/gmodule.c
+++ b/gmodule/gmodule.c
@@ -68,7 +68,8 @@ struct _GModule
/* --- prototypes --- */
static gpointer _g_module_open (const gchar *file_name,
- gboolean bind_lazy);
+ gboolean bind_lazy,
+ gboolean bind_local);
static void _g_module_close (gpointer handle,
gboolean is_unref);
static gpointer _g_module_self (void);
@@ -153,7 +154,8 @@ g_module_set_error (const gchar *error)
"not supported by this system"); return rv; }
static gpointer
_g_module_open (const gchar *file_name,
- gboolean bind_lazy)
+ gboolean bind_lazy,
+ gboolean bind_local)
{
return NULL;
}
@@ -384,7 +386,8 @@ g_module_open (const gchar *file_name,
name = real_name;
}
if (name)
- handle = _g_module_open (name, (flags & G_MODULE_BIND_LAZY) != 0);
+ handle = _g_module_open (name, (flags & G_MODULE_BIND_LAZY) != 0,
+ (flags & G_MODULE_BIND_LOCAL) != 0);
}
else
g_module_set_error_unduped (g_strdup_printf ("unable to access file \"%s\"", file_name));
diff --git a/gmodule/gmodule.h b/gmodule/gmodule.h
index 819ba1086..75de322cb 100644
--- a/gmodule/gmodule.h
+++ b/gmodule/gmodule.h
@@ -44,7 +44,8 @@ G_BEGIN_DECLS
typedef enum
{
G_MODULE_BIND_LAZY = 1 << 0,
- G_MODULE_BIND_MASK = 0x01
+ G_MODULE_BIND_LOCAL = 1 << 1,
+ G_MODULE_BIND_MASK = 0x03
} GModuleFlags;
typedef struct _GModule GModule;