|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-10-16 12:25 UTC] ryan dot smith at openwave dot com
Attempting to dynamically load a module fails under AIX. The error message is: PHP Warning: Unable to load dynamic library '/usr/HTTPServer/libexec/firstmod.so' - Invalid argument in Unknown on line 0 This indicates that the failure occurs during the DL_LOAD. The module does exist, and can be loaded with dlopen() in a test program. PHP is being loaded as a dynamic module within the IBM HTTP server (based on Apache 1.3.12). PHP was configured with: CC='cc_r' \ CXX='xlC_r -E' \ './configure' \ '--enable-c9x-inline' \ '--enable-shared' \ '--with-apxs=/usr/HTTPServer/bin/apxs' \ '--without-mysql' \ '--with-ldap=/users/rysmith/apache/openldap-2.0.25_AIX' I've tried compiling the module in many ways: (Simple) cc -c test2.c cc -G -o firstmod.so test2.o (from sample IBM DSO makefile) xlC_r -c -I /users/rysmith/apache/php-4.2.3/Zend -I /users/rysmith/apache/php-4.2.3 -I/users/rysmith/apache/php-4.2.3/main -I/users/rysmith/apache/php-4.2.3/TSRM -DAIX=42 -U__STR__ -DAIX_BIND_PROCESSOR -DUSE_HSREGEX -O2 -DSHARED_MODULE firstmod.c && mv firstmod.o firstmod.lo ld -H512 -T512 -bhalt:4 -bM:SRE -bnoentry -bI:/users/rysmith/apache/php-4.2.3/ext/ryan/libphp4.exp -bE:`echo firstmod.so|sed -e 's:\.so$:.exp:'` -lc -o firstmod.so firstmod.lo Attempting to load the module from within a PHP script also fails in the same way. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 07 17:00:02 2025 UTC |
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.