Skip to content

Commit 08052c7

Browse files
committed
Add the flag RTLD_GLOBAL to the dlopen() options.
This exports symbols defined by the loaded extension to other extensions (loaded later). (I'm not quite sure about this but suppose it can't hurt...)
1 parent c425d2f commit 08052c7

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

Python/importdl.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ typedef void (*dl_funcptr)();
171171
#ifndef RTLD_LAZY
172172
#define RTLD_LAZY 1
173173
#endif
174+
#ifndef RTLD_GLOBAL
175+
#define RTLD_GLOBAL 0
176+
#endif
174177
#define SHORT_EXT ".so"
175178
#define LONG_EXT "module.so"
176179
#endif /* USE_SHLIB */
@@ -362,12 +365,13 @@ _PyImport_LoadDynamicModule(name, pathname, fp)
362365
#ifdef RTLD_NOW
363366
/* RTLD_NOW: resolve externals now
364367
(i.e. core dump now if some are missing) */
365-
void *handle = dlopen(pathname, RTLD_NOW);
368+
void *handle = dlopen(pathname, RTLD_NOW | RTLD_GLOBAL);
366369
#else
367370
void *handle;
368371
if (Py_VerboseFlag)
369-
printf("dlopen(\"%s\", %d);\n", pathname, RTLD_LAZY);
370-
handle = dlopen(pathname, RTLD_LAZY);
372+
printf("dlopen(\"%s\", %d);\n", pathname,
373+
RTLD_LAZY | RTLD_GLOBAL);
374+
handle = dlopen(pathname, RTLD_LAZY | RTLD_GLOBAL);
371375
#endif /* RTLD_NOW */
372376
if (handle == NULL) {
373377
PyErr_SetString(PyExc_ImportError, dlerror());

0 commit comments

Comments
 (0)