Skip to content

Commit f9f4226

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: add --enable-rtld-now in upgrade info use DL_LOAD in litespeed add --enable-rtld-now build option to change dlopen behavior
2 parents 5bf6562 + 99ee5db commit f9f4226

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

Zend/zend_portability.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,18 @@
139139
# define RTLD_GLOBAL 0
140140
# endif
141141

142+
# ifdef PHP_USE_RTLD_NOW
143+
# define PHP_RTLD_MODE RTLD_NOW
144+
# else
145+
# define PHP_RTLD_MODE RTLD_LAZY
146+
# endif
147+
142148
# if defined(RTLD_GROUP) && defined(RTLD_WORLD) && defined(RTLD_PARENT)
143-
# define DL_LOAD(libname) dlopen(libname, RTLD_LAZY | RTLD_GLOBAL | RTLD_GROUP | RTLD_WORLD | RTLD_PARENT)
149+
# define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL | RTLD_GROUP | RTLD_WORLD | RTLD_PARENT)
144150
# elif defined(RTLD_DEEPBIND) && !defined(__SANITIZE_ADDRESS__)
145-
# define DL_LOAD(libname) dlopen(libname, RTLD_LAZY | RTLD_GLOBAL | RTLD_DEEPBIND)
151+
# define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL | RTLD_DEEPBIND)
146152
# else
147-
# define DL_LOAD(libname) dlopen(libname, RTLD_LAZY | RTLD_GLOBAL)
153+
# define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL)
148154
# endif
149155
# define DL_UNLOAD dlclose
150156
# if defined(DLSYM_NEEDS_UNDERSCORE)

configure.ac

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,17 @@ else
928928
ZEND_DEBUG=no
929929
fi
930930

931+
PHP_ARG_ENABLE([rtld-now],
932+
[whether to dlopen extensions with RTLD_NOW instead of RTLD_LAZY],
933+
[AS_HELP_STRING([--enable-rtld-now],
934+
[Use dlopen with RTLD_NOW instead of RTLD_LAZY])],
935+
[no],
936+
[no])
937+
938+
if test "$PHP_RTLD_NOW" = "yes"; then
939+
AC_DEFINE(PHP_USE_RTLD_NOW, 1, [ Use dlopen with RTLD_NOW instead of RTLD_LAZY ])
940+
fi
941+
931942
PHP_ARG_WITH([layout],
932943
[layout of installed files],
933944
[AS_HELP_STRING([--with-layout=TYPE],

sapi/litespeed/lsapilib.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9292
#define uint32 uint32_t
9393
#endif
9494

95+
#include <Zend/zend_portability.h>
96+
9597
struct lsapi_MD5Context {
9698
uint32 buf[4];
9799
uint32 bits[2];
@@ -767,7 +769,7 @@ static int (*fp_lve_leave)(struct liblve *, uint32_t *) = NULL;
767769
static int (*fp_lve_jail)( struct passwd *, char *) = NULL;
768770
static int lsapi_load_lve_lib(void)
769771
{
770-
s_liblve = dlopen("liblve.so.0", RTLD_LAZY);
772+
s_liblve = DL_LOAD("liblve.so.0");
771773
if (s_liblve)
772774
{
773775
fp_lve_is_available = dlsym(s_liblve, "lve_is_available");

sapi/litespeed/lscriu.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8888
#include <unistd.h>
8989
#include "lscriu.h"
9090

91+
#include <Zend/zend_portability.h>
92+
9193
#define LSCRIU_PATH 256
9294

9395
// Begin CRIU inclusion
@@ -262,8 +264,8 @@ static int LSCRIU_load_liblscapi(void)
262264
int error = 1;
263265
char *last;
264266

265-
if (!(lib_handle = dlopen(last = "liblscapi.so", RTLD_LAZY)) /*||
266-
!(pthread_lib_handle = dlopen(last = "libpthread.so", RTLD_LAZY))*/)
267+
if (!(lib_handle = DL_LOAD(last = "liblscapi.so")) /*||
268+
!(pthread_lib_handle = DL_LOAD(last = "libpthread.so"))*/)
267269
fprintf(stderr, "LSCRIU (%d): failed to dlopen %s: %s - ignore CRIU\n",
268270
s_pid, last, dlerror());
269271
else if (!(s_lscapi_dump_me = dlsym(lib_handle, last = "lscapi_dump_me")) ||

0 commit comments

Comments
 (0)