php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #42630 dlopen() should be preferred to NSLinkModule()
Submitted: 2007-09-11 20:27 UTC Modified: 2010-12-28 12:55 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: jdolecek at NetBSD dot org Assigned: jani (profile)
Status: Closed Package: Dynamic loading
PHP Version: 5.2.4 OS: Mac OS X 10.4
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jdolecek at NetBSD dot org
New email:
PHP Version: OS:

 

 [2007-09-11 20:27 UTC] jdolecek at NetBSD dot org
Description:
------------
PHP uses NSLinkModule()-based interface for loading dynamic extensions. Since Mac OS X 10.4, dlopen() is now available as native function and should be used in preference to older NSLinkModule()-based method, for consistency with other UNIX platforms.

Fix - if dlopen() is available, use dlopen(), otherwise fallback to NSLinkModule():

--- Zend/zend.h.orig    2007-09-05 00:16:02.000000000 +0200
+++ Zend/zend.h
@@ -80,18 +80,7 @@
 # include <dlfcn.h>
 #endif

-#if HAVE_MACH_O_DYLD_H
-#include <mach-o/dyld.h>
-
-/* MH_BUNDLE loading functions for Mac OS X / Darwin */
-void *zend_mh_bundle_load (char* bundle_path);
-int zend_mh_bundle_unload (void *bundle_handle);
-void *zend_mh_bundle_symbol(void *bundle_handle, const char *symbol_name);
-const char *zend_mh_bundle_error(void);
-
-#endif /* HAVE_MACH_O_DYLD_H */
-
-#if defined(HAVE_LIBDL) && !defined(HAVE_MACH_O_DYLD_H) && !defined(ZEND_WIN32)
+#if defined(HAVE_LIBDL) && !defined(ZEND_WIN32)

 # ifndef RTLD_LAZY
 #  define RTLD_LAZY 1    /* Solaris 1, FreeBSD's (2.1.7.1 and older) */
@@ -118,6 +107,14 @@ const char *zend_mh_bundle_error(void);
 # define DL_HANDLE                                     void *
 # define ZEND_EXTENSIONS_SUPPORT       1
 #elif defined(HAVE_MACH_O_DYLD_H)
+
+#include <mach-o/dyld.h>
+
+/* MH_BUNDLE loading functions for Mac OS X / Darwin */
+void *zend_mh_bundle_load (char* bundle_path);
+int zend_mh_bundle_unload (void *bundle_handle);
+void *zend_mh_bundle_symbol(void *bundle_handle, const char *symbol_name);
+const char *zend_mh_bundle_error(void);
 # define DL_LOAD(libname)                      zend_mh_bundle_load(libname)
 # define DL_UNLOAD                     zend_mh_bundle_unload
 # define DL_FETCH_SYMBOL(h,s) 
         zend_mh_bundle_symbol(h,s)

--- Zend/zend_extensions.c.orig 2007-09-05 00:24:04.000000000 +0200
+++ Zend/zend_extensions.c
@@ -230,7 +230,7 @@ ZEND_API zend_extension *zend_get_extens
  *
  */

-#if HAVE_MACH_O_DYLD_H
+#if defined(HAVE_MACH_O_DYLD_H) && !defined(HAVE_LIBDL)

 void *zend_mh_bundle_load(char* bundle_path)
 {
@@ -284,7 +284,7 @@ const char *zend_mh_bundle_error(void)
        return NULL;
 }

-#endif /* HAVE_MACH_O_DYLD_H */
+#endif /* HAVE_MACH_O_DYLD_H && !HAVE_LIBDL */

 /*
  * Local variables:



Reproduce code:
---------------
I've originally developed this patch as a fix to  bug #42629 to make extensions load  with RTLD_GLOBAL. However, I found simplier fix to that problem, so I'm filling this dlopen() change as a separate bug report.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-03 02:13 UTC] php at group dot apple dot com
I believe this was addressed in 5.3.1 or 5.3.2.
 [2010-12-28 12:55 UTC] jani@php.net
-Status: Open +Status: Closed -Package: Feature/Change Request +Package: Dynamic loading -Assigned To: +Assigned To: jani
 [2010-12-28 12:55 UTC] jani@php.net
No such code in trunk/PHP_5_3 anymore. Quite likely already done in 5.3.0.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 22:01:28 2024 UTC