diff options
author | midipix <writeonce@midipix.org> | 2025-06-21 09:17:15 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2025-06-21 09:17:15 +0000 |
commit | 8c3ccc38e7c0bde90d2b1009539267a4935b16fc (patch) | |
tree | 1e1153cd4ad102dba2b87974ab7e9ab2e6e4bcbe /src | |
parent | 01192f444c3f2ab07b25c488b4b9d2d9fb8c80d2 (diff) | |
download | sltdl-8c3ccc38e7c0bde90d2b1009539267a4935b16fc.tar.bz2 sltdl-8c3ccc38e7c0bde90d2b1009539267a4935b16fc.tar.xz |
lt_dlopen_locked(): support symbol tables in addition to module path arguments.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/lt_path.c | 30 | ||||
-rw-r--r-- | src/internal/sltdl_module.h | 1 |
2 files changed, 20 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; } diff --git a/src/internal/sltdl_module.h b/src/internal/sltdl_module.h index 26e47e3..c567e02 100644 --- a/src/internal/sltdl_module.h +++ b/src/internal/sltdl_module.h @@ -2,6 +2,7 @@ #define SLTDL_MODULE_H struct lt_modctx { + const struct lt_symdef *symtbl; struct lt_modctx * mnext; void * maddr; char * mpath; |