From b48cb77c5fe44e3392ecb9f4335c6a9b7401c89d Mon Sep 17 00:00:00 2001 From: midipix Date: Wed, 13 Mar 2024 21:33:14 +0000 Subject: link mode: properly interpret -static when output is an executable program. --- include/slibtool/slibtool.h | 3 +++ src/driver/slbt_driver_ctx.c | 2 ++ src/logic/linkcmd/slbt_linkcmd_executable.c | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/slibtool/slibtool.h b/include/slibtool/slibtool.h index bf0bf32..bb1fc84 100644 --- a/include/slibtool/slibtool.h +++ b/include/slibtool/slibtool.h @@ -78,6 +78,9 @@ extern "C" { #define SLBT_DRIVER_MODE_AR_CHECK SLBT_DRIVER_XFLAG(0x020000) #define SLBT_DRIVER_MODE_AR_MERGE SLBT_DRIVER_XFLAG(0x040000) +#define SLBT_DRIVER_PREFER_SHARED SLBT_DRIVER_XFLAG(0x100000) +#define SLBT_DRIVER_PREFER_STATIC SLBT_DRIVER_XFLAG(0x200000) + #define SLBT_DRIVER_DLOPEN_SELF SLBT_DRIVER_XFLAG(0x10000000) #define SLBT_DRIVER_DLOPEN_FORCE SLBT_DRIVER_XFLAG(0x20000000) #define SLBT_DRIVER_DLPREOPEN_SELF SLBT_DRIVER_XFLAG(0x40000000) diff --git a/src/driver/slbt_driver_ctx.c b/src/driver/slbt_driver_ctx.c index 6737815..9479e54 100644 --- a/src/driver/slbt_driver_ctx.c +++ b/src/driver/slbt_driver_ctx.c @@ -788,10 +788,12 @@ int slbt_lib_get_driver_ctx( case TAG_SHARED: cmdshared = entry; + cctx.drvflags |= SLBT_DRIVER_PREFER_SHARED; break; case TAG_STATIC: cmdstatic = entry; + cctx.drvflags |= SLBT_DRIVER_PREFER_STATIC; break; case TAG_WEAK: diff --git a/src/logic/linkcmd/slbt_linkcmd_executable.c b/src/logic/linkcmd/slbt_linkcmd_executable.c index 76c0b1d..a1f8b1c 100644 --- a/src/logic/linkcmd/slbt_linkcmd_executable.c +++ b/src/logic/linkcmd/slbt_linkcmd_executable.c @@ -100,7 +100,8 @@ slbt_hidden int slbt_exec_link_create_executable( fdcwd = slbt_driver_fdcwd(dctx); /* fpic */ - fpic = (dctx->cctx->drvflags & SLBT_DRIVER_SHARED); + fpic = (dctx->cctx->drvflags & SLBT_DRIVER_SHARED); + fpic &= !(dctx->cctx->drvflags & SLBT_DRIVER_PREFER_STATIC); /* input argument adjustment */ for (parg=ectx->cargv; *parg; parg++) -- cgit v1.2.3