diff options
author | Ezequiel Garcia <ezequiel@vanguardiasur.com.ar> | 2017-04-29 23:06:22 +0300 |
---|---|---|
committer | Refael Ackermann <refack@gmail.com> | 2017-09-09 00:14:03 +0300 |
commit | 5f223759229a112af41508c470d683152523c6e3 (patch) | |
tree | b4788ac6a406a36d0f0649f48beda1993682f960 /src/node_constants.cc | |
parent | aa76ce943b618c3b6d5b86c89f69aa4817ca783d (diff) |
src: add support to pass flags to dlopen
* add constants for dlopen flags, which are needed
for dlopen's flag passing.
* introduce an optional parameter for process.dlopen(),
allowing to pass dlopen flags (using values from os.constants.dlopen).
If no flags are passed, the default behavior is to load the library
with RTLD_LAZY (perform lazy binding) and RTLD_LOCAL (symbols are
available only locally).
PR-URL: https://github.com/nodejs/node/pull/12794
Refs: https://github.com/nodejs/node/pull/4105
Refs: https://github.com/libuv/libuv/pull/1331
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Diffstat (limited to 'src/node_constants.cc')
-rw-r--r-- | src/node_constants.cc | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/node_constants.cc b/src/node_constants.cc index f8055f01e6d..b8b97b21f9e 100644 --- a/src/node_constants.cc +++ b/src/node_constants.cc @@ -44,6 +44,10 @@ # endif // !OPENSSL_NO_ENGINE #endif +#if defined(__POSIX__) +#include <dlfcn.h> +#endif + namespace node { using v8::Local; @@ -1238,6 +1242,28 @@ void DefineZlibConstants(Local<Object> target) { NODE_DEFINE_CONSTANT(target, Z_DEFAULT_LEVEL); } +void DefineDLOpenConstants(Local<Object> target) { +#ifdef RTLD_LAZY + NODE_DEFINE_CONSTANT(target, RTLD_LAZY); +#endif + +#ifdef RTLD_NOW + NODE_DEFINE_CONSTANT(target, RTLD_NOW); +#endif + +#ifdef RTLD_GLOBAL + NODE_DEFINE_CONSTANT(target, RTLD_GLOBAL); +#endif + +#ifdef RTLD_LOCAL + NODE_DEFINE_CONSTANT(target, RTLD_LOCAL); +#endif + +#ifdef RTLD_DEEPBIND + NODE_DEFINE_CONSTANT(target, RTLD_DEEPBIND); +#endif +} + } // anonymous namespace void DefineConstants(v8::Isolate* isolate, Local<Object> target) { @@ -1267,6 +1293,10 @@ void DefineConstants(v8::Isolate* isolate, Local<Object> target) { CHECK(zlib_constants->SetPrototype(env->context(), Null(env->isolate())).FromJust()); + Local<Object> dlopen_constants = Object::New(isolate); + CHECK(dlopen_constants->SetPrototype(env->context(), + Null(env->isolate())).FromJust()); + DefineErrnoConstants(err_constants); DefineWindowsErrorConstants(err_constants); DefineSignalConstants(sig_constants); @@ -1274,11 +1304,13 @@ void DefineConstants(v8::Isolate* isolate, Local<Object> target) { DefineOpenSSLConstants(crypto_constants); DefineCryptoConstants(crypto_constants); DefineZlibConstants(zlib_constants); + DefineDLOpenConstants(dlopen_constants); // Define libuv constants. NODE_DEFINE_CONSTANT(os_constants, UV_UDP_REUSEADDR); NODE_DEFINE_CONSTANT(fs_constants, UV_FS_COPYFILE_EXCL); + os_constants->Set(OneByteString(isolate, "dlopen"), dlopen_constants); os_constants->Set(OneByteString(isolate, "errno"), err_constants); os_constants->Set(OneByteString(isolate, "signals"), sig_constants); target->Set(OneByteString(isolate, "os"), os_constants); |