ID: 19937 Updated by: [EMAIL PROTECTED] Reported By: ryan dot smith at openwave dot com Status: Feedback Bug Type: Dynamic loading Operating System: AIX 5.1 PHP Version: 4.3.0-dev New Comment:
Here's an url to it: http://www.php.net/~jani/dlopen_patch.txt Previous Comments: ------------------------------------------------------------------------ [2003-07-10 18:05:55] [EMAIL PROTECTED] Could you try this patch: Index: zend.h =================================================================== RCS file: /repository/Zend/Attic/zend.h,v retrieving revision 1.164.2.8 diff -u -r1.164.2.8 zend.h --- zend.h 31 May 2003 01:37:43 -0000 1.164.2.8 +++ zend.h 10 Jul 2003 23:05:38 -0000 @@ -89,7 +89,11 @@ # define RTLD_GLOBAL 0 # endif -# define DL_LOAD(libname) dlopen(libname, RTLD_LAZY | RTLD_GLOBAL) +# ifndef RTLD_PARENT +# define RTLD_PARENT 0 +# endif + +# define DL_LOAD(libname) dlopen(libname, RTLD_LAZY | RTLD_GLOBAL | RTLD_PARENT) # define DL_UNLOAD dlclose # if DLSYM_NEEDS_UNDERSCORE # define DL_FETCH_SYMBOL(h,s) dlsym((h), "_" s) ------------------------------------------------------------------------ [2003-05-02 06:51:16] francois dot turi at globecast dot com The following patch should fix problem of loading extension under AIX 4.3.3 like the java extension. Under AIX, shared object are different from shared library. The default library construction (as in the construction of the JAVA extension) doesnt work correctly as it relies on dynamic linking from a library when only a shared object is given. An exception appear as illegal instruction. The following configuration are missing: First of all: ============= one should construct correctly the export definition of libphp4.so. In configure the following line should be changed: ******************************** diff configure configure.orig (sorry no -b available under AIX) 78084,78086c78084 < # FTU export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | sed '\''s/.* //'\'' | sort | uniq > $export_symbols' < export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | sed '\''s/.* //'\'' | sort | uniq|awk -vlib=$SOHOME/$soname '\''BEGIN{printf "#!%s\n",lib}{print \$0}'\'' > $export_symbols' < echo "FTU export_symbols_cmds=$export_symbols_cmds" --- > export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | sed '\''s/.* //'\'' | sort | uniq > $export_symbols' *************************** I added awk -vlib=$SOHOME/$soname '\''BEGIN{printf "#!%s\n",lib}{print \$0}'\'' To the pipe so the first line will be read as: #!/your/path/to/your/libphp4.so And the rest is identical. Before compiling your library you should setup the SOHOME variable as the path where your shared object (libphp4.so.0) will be running: ************ export SOHOME=/s00/opendata/build/SSOD/php.430/current ************ Second important point: ======================== Refer the export file of php shared object in the construction of the java extension: When compiling the JAVA extension you have to setup the following environement VARIABLE ***************** export JAVA_SHARED_LIBADD="-Wl,-bI:.libs/libphp4.exp" ***************** That line state that in the linking process (ld), the java extension will use the libphp4.exp file to find undefined function or global variable. By defaut such function will be resolve as running time. On AIX such binding doesnt work because the libphp4.so is not a shared library (doesnt appear in the genmkd listing) but a share object. You have to specify the full path to your share object while linking it to make him resolve correctly the reference to the Zend API. Nota: the default exemple given to make an extension doesnt have that problem because it doesnt call any Zend API function stored in the libphp4.so. External reference: The followings redbooks explain the subtle difference between share objects and shared library under AIX: Understanding C and C++ development on AIX chapter 3 Compiling and Linking original http://www.redbooks.ibm.com/pubs/pdfs/redbooks/sg245674.pdf latest draft (for 5.L) http://www.redbooks.ibm.com/redpieces/pdfs/sg245674.pdf Last point: =========== The extension java should be rename after construction to cp -p libjava.so.0 libphp_java.so to work correctly. About libtool: ============== The first line in configure change the libtool which is in charge of creating the dynamic library. I cannot figure out if the bug is a php bug or a libtool bug. ------------------------------------------------------------------------ [2002-10-21 10:28:00] ryan dot smith at openwave dot com By specifying an extension path and then the extension: extension_dir=/usr/HTTPServer/libexec extension=libldap.so If you (or anyone) has a PHP setup that does demonstrate that this functionality works, I'd like to know. ------------------------------------------------------------------------ [2002-10-19 10:48:08] [EMAIL PROTECTED] How exactly did you configure the loading of the extension in php.ini ? ------------------------------------------------------------------------ [2002-10-18 17:53:48] ryan dot smith at openwave dot com I just tried the latest snapshot, and it fails in the same way. Note that I am using the ldap extension to test this, so my configuration differs slight - it has --with-ldap=shared,/users/rysmith/apache/openldap-2.0.25_AIX ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/19937 -- Edit this bug report at http://bugs.php.net/?id=19937&edit=1
