-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
Add process.dlopenFlags #12794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add process.dlopenFlags #12794
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Let's add constants for dlopen flags, which are needed for dlopen's flag passing, implemented in next commit. Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1170,6 +1170,43 @@ The following error codes are specific to the Windows operating system: | |
| </tr> | ||
| </table> | ||
|
|
||
| ### dlopen Constants | ||
|
|
||
| If available on the operating system, the following constants | ||
| are exported in `os.constants.dlopen`. See dlopen(3) for detailed | ||
| information. | ||
|
|
||
| <table> | ||
| <tr> | ||
| <th>Constant</th> | ||
| <th>Description</th> | ||
| </tr> | ||
| <tr> | ||
| <td><code>RTLD_LAZY</code></td> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing descriptions for these constants?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought the descriptions were too detailed and complex, and was expecting the reader could refer to the manual instead? It's a 1:1 mapping of the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the idea is to refer the user to a manual, then having these as links to that manual would be ideal :-) ... still, a very brief one sentence description would be preferred (I know we're fairly inconsistent with that in the docs and we need to get better at it)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| <td>Perform lazy binding. Node.js sets this flag by default.</td> | ||
| </tr> | ||
| <tr> | ||
| <td><code>RTLD_NOW</code></td> | ||
| <td>Resolve all undefined symbols in the library before dlopen(3) | ||
| returns.</td> | ||
| </tr> | ||
| <tr> | ||
| <td><code>RTLD_GLOBAL</code></td> | ||
| <td>Symbols defined by the library will be made available for symbol | ||
| resolution of subsequently loaded libraries.</td> | ||
| </tr> | ||
| <tr> | ||
| <td><code>RTLD_LOCAL</code></td> | ||
| <td>The converse of RTLD_GLOBAL. This is the default behavior if neither | ||
| flag is specified.</td> | ||
| </tr> | ||
| <tr> | ||
| <td><code>RTLD_DEEPBIND</code></td> | ||
| <td>Make a self-contained library use its own symbols in preference to | ||
| symbols from previously loaded libraries.</td> | ||
| </tr> | ||
| </table> | ||
|
|
||
| ### libuv Constants | ||
|
|
||
| <table> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ | |
| // Deprecation Code: DEP0008 | ||
| const constants = process.binding('constants'); | ||
| Object.assign(exports, | ||
| constants.os.dlopen, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should add things to something that's already deprecated.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This has already been discussed, on this same PR-thread. I'll let you do the digging. (BTW: this is where mailing lists outpass github PRs: it's so much harder to dig discussion history).
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, in that case SGTM. Sorry about not reading through the entire thread – though in my defense it is quite long. |
||
| constants.os.errno, | ||
| constants.os.signals, | ||
| constants.fs, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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,18 +1293,24 @@ 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); | ||
| DefineSystemConstants(fs_constants); | ||
| 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); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alphabetical order
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,8 @@ assert.deepStrictEqual( | |
| ); | ||
|
|
||
| assert.deepStrictEqual( | ||
| Object.keys(constants.os).sort(), ['UV_UDP_REUSEADDR', 'errno', 'signals'] | ||
| Object.keys(constants.os).sort(), ['UV_UDP_REUSEADDR', 'dlopen', 'errno', | ||
| 'signals'] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style Nit: The second array would look better in the second line I guess. |
||
| ); | ||
|
|
||
| // Make sure all the constants objects don't inherit from Object.prototype | ||
|
|
@@ -26,5 +27,5 @@ function test(obj) { | |
|
|
||
| [ | ||
| constants, constants.crypto, constants.fs, constants.os, constants.zlib, | ||
| constants.os.errno, constants.os.signals | ||
| constants.os.dlopen, constants.os.errno, constants.os.signals | ||
| ].forEach(test); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Care to link http://man7.org/linux/man-pages/man3/dlopen.3.html?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it done automagically? I think we already discussed this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad. Yes, tools/doc/html.js will take care of this.