summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2024-03-02 17:04:49 +0000
committermidipix <writeonce@midipix.org>2024-03-02 22:01:19 +0000
commit9da20229476b0de4fa1e5460b9ade35775a02165 (patch)
treea473f75bddd8d9e11710b648016c02d0e32665d7
parent55d6e3a7c7780bfd254f13e0a090adbf91aa3f68 (diff)
downloadslibtool-9da20229476b0de4fa1e5460b9ade35775a02165.tar.bz2
slibtool-9da20229476b0de4fa1e5460b9ade35775a02165.tar.xz
driver: create a vector of -dlpreopen libraries.
-rw-r--r--src/driver/slbt_driver_ctx.c41
-rw-r--r--src/driver/slbt_split_argv.c6
-rw-r--r--src/internal/slibtool_driver_impl.h2
3 files changed, 46 insertions, 3 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,
diff --git a/src/driver/slbt_split_argv.c b/src/driver/slbt_split_argv.c
index db4693a..bdde474 100644
--- a/src/driver/slbt_split_argv.c
+++ b/src/driver/slbt_split_argv.c
@@ -503,7 +503,11 @@ slbt_hidden int slbt_split_argv(
*targv++ = argv[i];
} else if (!(strcmp("dlpreopen",&argv[i][1]))) {
- (void)0;
+ *cargv++ = argv[i];
+ *targv++ = argv[i++];
+
+ *cargv++ = argv[i];
+ *targv++ = argv[i];
} else {
for (popt=optout; popt[0] && popt[0]->long_name; popt++)
diff --git a/src/internal/slibtool_driver_impl.h b/src/internal/slibtool_driver_impl.h
index 052daf2..b540e6a 100644
--- a/src/internal/slibtool_driver_impl.h
+++ b/src/internal/slibtool_driver_impl.h
@@ -149,6 +149,8 @@ struct slbt_driver_ctx_impl {
struct slbt_map_info lconf;
struct slbt_txtfile_ctx * lconfctx;
struct slbt_obj_list * objlistv;
+ const char ** dlopenv;
+ size_t ndlopen;
const struct slbt_archive_ctx * arctx;
const char * arpath;