[BACK]Return to patch-gmodule_gmodule-dl.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / pkgsrc / devel / glib2 / patches

File: [cvs.NetBSD.org] / pkgsrc / devel / glib2 / patches / Attic / patch-gmodule_gmodule-dl.c (download)

Revision 1.1, Mon Oct 8 10:12:06 2018 UTC (5 years, 6 months ago) by prlw1
Branch: MAIN
CVS Tags: pkgsrc-2019Q4-base, pkgsrc-2019Q4, pkgsrc-2019Q3-base, pkgsrc-2019Q3, pkgsrc-2019Q2-base, pkgsrc-2019Q2, pkgsrc-2019Q1-base, pkgsrc-2019Q1, pkgsrc-2018Q4-base, pkgsrc-2018Q4

glib2's gobject subsystem is essentially a wrapper for dlopen. In
view of comments in PR lib/49791 which can be summarised as
"RTLD_GLOBAL is a bug", make gobject use RTLD_DEFAULT instead.

$NetBSD: patch-gmodule_gmodule-dl.c,v 1.1 2018/10/08 10:12:06 prlw1 Exp $

RTLD_GLOBAL is a bug.
https://gitlab.gnome.org/GNOME/glib/issues/19

--- gmodule/gmodule-dl.c.orig	2018-01-08 21:34:19.000000000 +0000
+++ gmodule/gmodule-dl.c
@@ -106,46 +106,13 @@ _g_module_open (const gchar *file_name,
 static gpointer
 _g_module_self (void)
 {
-  gpointer handle;
-  
-  /* to query symbols from the program itself, special link options
-   * are required on some systems.
-   */
-
-  /* On Android 32 bit (i.e. not __LP64__), dlopen(NULL)
-   * does not work reliable and generally no symbols are found
-   * at all. RTLD_DEFAULT works though.
-   * On Android 64 bit, dlopen(NULL) seems to work but dlsym(handle)
-   * always returns 'undefined symbol'. Only if RTLD_DEFAULT or 
-   * NULL is given, dlsym returns an appropriate pointer.
-   */
-#if defined(__BIONIC__)
-  handle = RTLD_DEFAULT;
-#else
-  handle = dlopen (NULL, RTLD_GLOBAL | RTLD_LAZY);
-#endif
-  if (!handle)
-    g_module_set_error (fetch_dlerror (TRUE));
-  
-  return handle;
+  return RTLD_DEFAULT;
 }
 
 static void
-_g_module_close (gpointer handle,
-		 gboolean is_unref)
+_g_module_close (gpointer handle)
 {
-  /* are there any systems out there that have dlopen()/dlclose()
-   * without a reference count implementation?
-   *
-   * See above for the Android special case
-   */
-#if defined(__BIONIC__)
-  is_unref = (handle != RTLD_DEFAULT);
-#else
-  is_unref |= 1;
-#endif
-
-  if (is_unref)
+  if (handle != RTLD_DEFAULT)
     {
       if (dlclose (handle) != 0)
 	g_module_set_error (fetch_dlerror (TRUE));