Skip to content

Commit d633cba

Browse files
committed
add --enable-rtld-now build option to change dlopen behavior
1 parent b003e0a commit d633cba

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
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
@@ -927,6 +927,17 @@ else
927927
ZEND_DEBUG=no
928928
fi
929929

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

0 commit comments

Comments
 (0)