diff options
Diffstat (limited to 'src/core/lt_path.c')
-rw-r--r-- | src/core/lt_path.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/src/core/lt_path.c b/src/core/lt_path.c index 3609d2c..6103119 100644 --- a/src/core/lt_path.c +++ b/src/core/lt_path.c @@ -358,6 +358,7 @@ int lt_dlpathopen(const char * module, const char ** extv) } static struct lt_modctx * lt_dlopen_locked( + const struct lt_symdef * symtbl, const char * module, const char ** extv, int mode) @@ -368,11 +369,17 @@ static struct lt_modctx * lt_dlopen_locked( struct lt_modctx * modctx; struct lt_modctx * modctx_buf; - /* path open */ - if ((fdmod = lt_dlpathopen_locked(module,extv,&mpath)) < 0) - return 0; + /* init */ + mpath = 0; + maddr = 0; + + /* path open (module) */ + if (module) { + if ((fdmod = lt_dlpathopen_locked(module,extv,&mpath)) < 0) + return 0; - close(fdmod); + close(fdmod); + } /* entry alloc */ if (lt_modv_next == lt_modv_cap) { @@ -386,15 +393,15 @@ static struct lt_modctx * lt_dlopen_locked( lt_modv_cap = <_modv_next[64]; } - /* dlopen */ - if (!(maddr = dlopen(mpath,mode))) { + /* dlopen (module) */ + if (module && !(maddr = dlopen(mpath,mode))) { free(mpath); lt_setstatus(0,SLTDL_ERR_DLFCN_ERROR); return 0; } - /* already dlopen'ed? */ - for (modctx=lt_modv_head; modctx; modctx=modctx->mnext) { + /* module already dlopen'ed? */ + for (modctx=lt_modv_head; module && modctx; modctx=modctx->mnext) { if (!strcmp(modctx->mpath,mpath)) { free(mpath); modctx->mrefs++; @@ -402,8 +409,9 @@ static struct lt_modctx * lt_dlopen_locked( } } - /* module entry */ + /* module or symtbl entry */ modctx = lt_modv_next; + modctx->symtbl = symtbl; modctx->maddr = maddr; modctx->mpath = mpath; modctx->mrefs = 1; @@ -447,7 +455,7 @@ struct lt_modctx * lt_dlopen(const char * module) strcpy(dot,OS_LIB_SUFFIX); module = dsobuf; - modctx = lt_dlopen_locked(module,extv,RTLD_NOW); + modctx = lt_dlopen_locked(0,module,extv,RTLD_NOW); lt_sunlock(0,lt_status); return modctx; } @@ -458,7 +466,7 @@ struct lt_modctx * lt_dlopenext(const char * module) const char * extv[3] = {"",OS_LIB_SUFFIX,0}; lt_slock(); - modctx = lt_dlopen_locked(module,extv,RTLD_NOW); + modctx = lt_dlopen_locked(0,module,extv,RTLD_NOW); lt_sunlock(0,lt_status); return modctx; } |