Blame SOURCES/apr-1.4.8-deepbind.patch

555547
555547
Add $APR_DEEPBIND to enable use of RTLD_DEEPBIND in apr_dso_open().
555547
301a8f
--- apr-1.4.8/dso/unix/dso.c.deepbind
301a8f
+++ apr-1.4.8/dso/unix/dso.c
301a8f
@@ -38,6 +38,8 @@
301a8f
 #define DYLD_LIBRARY_HANDLE (void *)-1
301a8f
 #endif
301a8f
 
301a8f
+static int use_deepbind; /* 0 = unset, 1 = use DEEPBIND, -1, don't use DEEPBIND */
301a8f
+
301a8f
 APR_DECLARE(apr_status_t) apr_os_dso_handle_put(apr_dso_handle_t **aprdso,
301a8f
                                                 apr_os_dso_handle_t osdso,
301a8f
                                                 apr_pool_t *pool)
301a8f
@@ -125,6 +127,12 @@
301a8f
 #else
301a8f
     int flags = RTLD_NOW | RTLD_GLOBAL;
301a8f
     void *os_handle;
301a8f
+
301a8f
+    if (use_deepbind == 0)
301a8f
+        use_deepbind = getenv("APR_DEEPBIND") != NULL ? 1 : -1;
301a8f
+    if (use_deepbind == 1)
301a8f
+        flags |= RTLD_DEEPBIND;
301a8f
+
301a8f
 #ifdef _AIX
301a8f
     if (strchr(path + 1, '(') && path[strlen(path) - 1] == ')')
301a8f
     {
555547
--- apr-1.7.0/README.deepbind.deepbind
555547
+++ apr-1.7.0/README.deepbind
555547
@@ -0,0 +1,30 @@
555547
+This distribution of APR contains a modification of the behaviour of
555547
+the apr_dso_open() function which allows users enable the
555547
+"RTLD_DEEPBIND" flag when dlopen() is called.
555547
+
555547
+If the "APR_DEEPBIND" environment variable is set at runtime, the
555547
+RTLD_DEEPBIND flag is always added to the flags passed to dlopen().
555547
+
555547
+With normal use of dlopen(), dynamically loaded objects will use
555547
+global symbols in preference to any symbols defined within the object.
555547
+Using RTLD_DEEPBIND reverses this binding order.  See the dlopen(3)
555547
+man page for more information.
555547
+
555547
+This can be useful with Apache httpd, where two different modules are
555547
+loaded like:
555547
+
555547
+1. mod_foo.so uses library "libfoo.so"
555547
+   libfoo.so defines a function "SomeSym"
555547
+2. mod_bar.so uses library "libbar.so"
555547
+   libbar.so defines a different "SomeSym" function
555547
+
555547
+By default, mod_bar or mod_foo would use the "SomeSym" definition from
555547
+the "wrong" library depending on the load order.  If RTLD_DEEPBIND is
555547
+used, the "SomeSym" definition will always be mapped to the definition
555547
+from the corresponding dependent library.  This can avoid symbol
555547
+conflicts.
555547
+
555547
+There are some risks with using RTLD_DEEPBIND, in particular potential
555547
+issues with modules written in C++.  It is not recommended to enable
555547
+$APR_DEEPBIND unless it solves a specific problem and after thorough
555547
+testing of the configuration.