diff options
author | midipix <writeonce@midipix.org> | 2024-03-02 17:04:49 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2024-03-02 22:01:19 +0000 |
commit | 9da20229476b0de4fa1e5460b9ade35775a02165 (patch) | |
tree | a473f75bddd8d9e11710b648016c02d0e32665d7 /src/driver/slbt_driver_ctx.c | |
parent | 55d6e3a7c7780bfd254f13e0a090adbf91aa3f68 (diff) | |
download | slibtool-9da20229476b0de4fa1e5460b9ade35775a02165.tar.bz2 slibtool-9da20229476b0de4fa1e5460b9ade35775a02165.tar.xz |
driver: create a vector of -dlpreopen libraries.
Diffstat (limited to 'src/driver/slbt_driver_ctx.c')
-rw-r--r-- | src/driver/slbt_driver_ctx.c | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/src/driver/slbt_driver_ctx.c b/src/driver/slbt_driver_ctx.c index c9cbdd6..5fed282 100644 --- a/src/driver/slbt_driver_ctx.c +++ b/src/driver/slbt_driver_ctx.c @@ -232,7 +232,8 @@ static struct slbt_driver_ctx_impl * slbt_driver_ctx_alloc( const struct slbt_common_ctx * cctx, struct slbt_split_vector * sargv, struct slbt_obj_list * objlistv, - char ** envp) + char ** envp, + size_t ndlopen) { struct slbt_driver_ctx_alloc * ictx; size_t size; @@ -245,6 +246,16 @@ static struct slbt_driver_ctx_impl * slbt_driver_ctx_alloc( return 0; } + if (ndlopen) { + if (!(ictx->ctx.dlopenv = calloc(ndlopen+1,sizeof(char *)))) { + free(ictx); + slbt_free_argv_buffer(sargv,objlistv); + return 0; + } + + ictx->ctx.ndlopen = ndlopen; + } + ictx->ctx.dargs = sargv->dargs; ictx->ctx.dargv = sargv->dargv; ictx->ctx.targv = sargv->targv; @@ -394,6 +405,8 @@ int slbt_lib_get_driver_ctx( const char * program; const char * lconf; uint64_t lflags; + size_t ndlopen; + const char ** dlopenv; const char * cfgmeta_host; const char * cfgmeta_ar; const char * cfgmeta_as; @@ -414,6 +427,7 @@ int slbt_lib_get_driver_ctx( sargv.targv = 0; sargv.cargv = 0; objlistv = 0; + ndlopen = 0; switch (slbt_split_argv(argv,flags,&sargv,&objlistv,fdctx->fderr,fdctx->fdcwd)) { case SLBT_OK: @@ -710,6 +724,10 @@ int slbt_lib_get_driver_ctx( case TAG_DLOPEN: break; + case TAG_DLPREOPEN: + ndlopen++; + break; + case TAG_STATIC_LIBTOOL_LIBS: cctx.drvflags |= SLBT_DRIVER_STATIC_LIBTOOL_LIBS; break; @@ -870,7 +888,7 @@ int slbt_lib_get_driver_ctx( cctx.tag = SLBT_TAG_CC; /* driver context */ - if (!(ctx = slbt_driver_ctx_alloc(fdctx,&cctx,&sargv,objlistv,envp))) + if (!(ctx = slbt_driver_ctx_alloc(fdctx,&cctx,&sargv,objlistv,envp,ndlopen))) return slbt_lib_get_driver_ctx_fail(0,meta); /* ctx */ @@ -988,6 +1006,22 @@ int slbt_lib_get_driver_ctx( if (slbt_init_link_params(ctx)) return slbt_lib_get_driver_ctx_fail(&ctx->ctx,0); + /* dlpreopen */ + if ((dlopenv = ctx->dlopenv)) { + for (entry=meta->entries; entry->fopt || entry->arg; entry++) { + if (entry->fopt) { + switch (entry->tag) { + case TAG_DLPREOPEN: + *dlopenv++ = entry->arg; + + default: + break; + } + } + } + } + + /* all ready */ *pctx = &ctx->ctx; return 0; @@ -1010,6 +1044,9 @@ static void slbt_lib_free_driver_ctx_impl(struct slbt_driver_ctx_alloc * ictx) if (ictx->ctx.libname) free(ictx->ctx.libname); + if (ictx->ctx.dlopenv) + free(ictx->ctx.dlopenv); + if (ictx->ctx.lconf.addr) munmap( ictx->ctx.lconf.addr, |