diff options
author | midipix <writeonce@midipix.org> | 2025-03-30 23:27:59 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2025-03-31 02:30:49 +0000 |
commit | 9e90beda5fd3fd4f93eac229e41bb5f3b9f86982 (patch) | |
tree | f5d3274582d4753ac7df5b146f6312425942d9d8 | |
parent | d2b130bdd92c2bee08c8a7f20766bd014ad4a362 (diff) | |
download | slibtool-9e90beda5fd3fd4f93eac229e41bb5f3b9f86982.tar.bz2 slibtool-9e90beda5fd3fd4f93eac229e41bb5f3b9f86982.tar.xz |
driver: --prefer-sltdl: implementation and link-mode integration.
-rw-r--r-- | include/slibtool/slibtool.h | 1 | ||||
-rw-r--r-- | src/driver/slbt_driver_ctx.c | 4 | ||||
-rw-r--r-- | src/internal/slibtool_driver_impl.h | 2 | ||||
-rw-r--r-- | src/logic/linkcmd/slbt_linkcmd_argv.c | 16 | ||||
-rw-r--r-- | src/logic/slbt_exec_ctx.c | 8 | ||||
-rw-r--r-- | src/skin/slbt_skin_default.c | 6 |
6 files changed, 37 insertions, 0 deletions
diff --git a/include/slibtool/slibtool.h b/include/slibtool/slibtool.h index 9336728..0642e9c 100644 --- a/include/slibtool/slibtool.h +++ b/include/slibtool/slibtool.h @@ -89,6 +89,7 @@ extern "C" { #define SLBT_DRIVER_PREFER_SHARED SLBT_DRIVER_XFLAG(0x100000) #define SLBT_DRIVER_PREFER_STATIC SLBT_DRIVER_XFLAG(0x200000) +#define SLBT_DRIVER_PREFER_SLTDL SLBT_DRIVER_XFLAG(0x400000) #define SLBT_DRIVER_STOOLIE_COPY SLBT_DRIVER_XFLAG(0x01000000) #define SLBT_DRIVER_STOOLIE_FORCE SLBT_DRIVER_XFLAG(0x02000000) diff --git a/src/driver/slbt_driver_ctx.c b/src/driver/slbt_driver_ctx.c index 09adb68..d8970d0 100644 --- a/src/driver/slbt_driver_ctx.c +++ b/src/driver/slbt_driver_ctx.c @@ -810,6 +810,10 @@ int slbt_lib_get_driver_ctx( cctx.drvflags |= SLBT_DRIVER_NO_UNDEFINED; break; + case TAG_PREFER_SLTDL: + cctx.drvflags |= SLBT_DRIVER_PREFER_SLTDL; + break; + case TAG_MODULE: cctx.drvflags |= SLBT_DRIVER_MODULE; break; diff --git a/src/internal/slibtool_driver_impl.h b/src/internal/slibtool_driver_impl.h index 7b6114d..83c7ad9 100644 --- a/src/internal/slibtool_driver_impl.h +++ b/src/internal/slibtool_driver_impl.h @@ -90,6 +90,7 @@ enum app_tags { TAG_DISABLE_STATIC, TAG_DISABLE_SHARED, TAG_NO_UNDEFINED, + TAG_PREFER_SLTDL, TAG_MODULE, TAG_AVOID_VERSION, TAG_COMPILER_FLAG, @@ -209,6 +210,7 @@ struct slbt_exec_ctx_impl { char * args; char * shadow; char * dsoprefix; + char * lsltdl; size_t size; size_t exts; int fdwrapper; diff --git a/src/logic/linkcmd/slbt_linkcmd_argv.c b/src/logic/linkcmd/slbt_linkcmd_argv.c index 013317f..546c8d5 100644 --- a/src/logic/linkcmd/slbt_linkcmd_argv.c +++ b/src/logic/linkcmd/slbt_linkcmd_argv.c @@ -1027,6 +1027,22 @@ slbt_hidden int slbt_exec_link_finalize_argument_vector( } } + /* replace -lltdl with -lsltdl as needed */ + if (dctx->cctx->drvflags & SLBT_DRIVER_PREFER_SLTDL) { + struct slbt_exec_ctx_impl * ictx; + + ictx = slbt_get_exec_ictx(ectx); + + for (src=ectx->argv; *src; src++) + if ((src[0][0] == '-') && (src[0][1] == 'l')) + if ((src[0][2] == 'l') + && (src[0][3] == 't') + && (src[0][4] == 'd') + && (src[0][5] == 'l')) + if (!src[0][6]) + *src = ictx->lsltdl; + } + /* properly null-terminate argv, accounting for redundant -l arguments */ *dst = 0; diff --git a/src/logic/slbt_exec_ctx.c b/src/logic/slbt_exec_ctx.c index 223be17..f76990a 100644 --- a/src/logic/slbt_exec_ctx.c +++ b/src/logic/slbt_exec_ctx.c @@ -131,6 +131,9 @@ static struct slbt_exec_ctx_impl * slbt_exec_ctx_alloc( size += exts * SLBT_ECTX_LIB_EXTRAS; } + /* -lsltdl (--prefer-sltdl impl.) */ + size += 8; + /* string buffers: args, shadow */ if (!(args = malloc(size))) return 0; @@ -629,6 +632,11 @@ int slbt_ectx_get_exec_ctx( } + /* -lsltdl (--prefer-sltdl impl.) */ + ictx->lsltdl = ch; + strcpy(ch,"-lsltdl"); + ch += 8; + /* dlopen, dlpreopen */ if ((dlopenv = idctx->dlopenv), (dlactxv = ictx->dlactxv)) { if (slbt_ar_get_varchive_ctx(dctx,dlactxv) < 0) diff --git a/src/skin/slbt_skin_default.c b/src/skin/slbt_skin_default.c index 8ae0833..6a2ab6a 100644 --- a/src/skin/slbt_skin_default.c +++ b/src/skin/slbt_skin_default.c @@ -333,6 +333,12 @@ const slbt_hidden struct argv_option slbt_default_options[] = { "statically link libtool libraries " "[currently a no-op]"}, + {"prefer-sltdl", 0,TAG_PREFER_SLTDL,ARGV_OPTARG_NONE, + 0,0,0, + "prefer the use of libsltdl over the system's " + "ltdl library, specifically by substituting " + "-lltdl linker arguments with -lsltdl ones."}, + {"Wc", 0,TAG_COMPILER_FLAG,ARGV_OPTARG_REQUIRED, ARGV_OPTION_HYBRID_ONLY|ARGV_OPTION_HYBRID_COMMA, 0,"<flag>[,<flag]...", |