From 8ef9e14afc6d97e6cf2da17995c3278f7309cf25 Mon Sep 17 00:00:00 2001 From: midipix Date: Tue, 5 Mar 2024 00:14:03 +0000 Subject: driver: finalized support of -`-dlpreopen self` and `-dlpreopen force`. --- src/driver/slbt_driver_ctx.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src/driver/slbt_driver_ctx.c') diff --git a/src/driver/slbt_driver_ctx.c b/src/driver/slbt_driver_ctx.c index 5fed282..0e4ebda 100644 --- a/src/driver/slbt_driver_ctx.c +++ b/src/driver/slbt_driver_ctx.c @@ -1012,7 +1012,15 @@ int slbt_lib_get_driver_ctx( if (entry->fopt) { switch (entry->tag) { case TAG_DLPREOPEN: - *dlopenv++ = entry->arg; + if (!strcmp(entry->arg,"self")) { + ctx->cctx.drvflags |= SLBT_DRIVER_DLPREOPEN_SELF; + + } else if (!strcmp(entry->arg,"force")) { + ctx->cctx.drvflags |= SLBT_DRIVER_DLPREOPEN_FORCE; + + } else { + *dlopenv++ = entry->arg; + } default: break; @@ -1021,6 +1029,22 @@ int slbt_lib_get_driver_ctx( } } + /* -dlopen & -dlpreopen semantic validation */ + uint64_t fmask; + + fmask = SLBT_DRIVER_DLOPEN_SELF | SLBT_DRIVER_DLPREOPEN_SELF; + fmask |= SLBT_DRIVER_DLOPEN_FORCE | SLBT_DRIVER_DLPREOPEN_FORCE; + + if (ctx->cctx.libname && (cctx.drvflags & fmask)) { + slbt_dprintf(ctx->fdctx.fderr, + "%s: error: -dlopen/-dlpreopen: " + "the special 'self' and 'force' arguments " + "may only be used when linking a program.\n", + ctx->ctx.program); + + return slbt_lib_get_driver_ctx_fail(&ctx->ctx,0); + } + /* all ready */ *pctx = &ctx->ctx; -- cgit v1.2.3