Blame SOURCES/apr-1.4.8-deepbind.patch

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