From 87b0f785dbe71aa6c19fbe7daeef9834798478d3 Mon Sep 17 00:00:00 2001 From: midipix Date: Sun, 21 Mar 2021 21:18:42 +0000 Subject: install mode: slbt_exec_install_entry(): added -shrext support. --- src/logic/slbt_exec_install.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/logic/slbt_exec_install.c b/src/logic/slbt_exec_install.c index 4a24b87..3cf0e12 100644 --- a/src/logic/slbt_exec_install.c +++ b/src/logic/slbt_exec_install.c @@ -329,6 +329,8 @@ static int slbt_exec_install_entry( char * base; char * slash; char * suffix; + char * dsosuffix; + char sobuf [64]; char target [PATH_MAX]; char srcfile [PATH_MAX]; char dstfile [PATH_MAX]; @@ -338,6 +340,7 @@ static int slbt_exec_install_entry( bool fexe = false; bool fpe; bool frelease; + size_t slen; struct stat st; /* executable wrapper? */ @@ -367,6 +370,27 @@ static int slbt_exec_install_entry( } else sprintf(srcfile,".libs/%s",lasource); + /* -shrext, dsosuffix */ + strcpy(sobuf,dctx->cctx->settings.dsosuffix); + dsosuffix = sobuf; + + if ((size_t)snprintf(slnkname,sizeof(slnkname),"%s.shrext", + srcfile) >= sizeof(slnkname)) + return SLBT_BUFFER_ERROR(dctx); + + if (!stat(slnkname,&st)) { + if (slbt_readlink(slnkname,target,sizeof(target)) < 0) + return SLBT_SYSTEM_ERROR(dctx,slnkname); + + if (strncmp(lasource,target,(slen = strlen(lasource)))) + return SLBT_CUSTOM_ERROR(dctx,SLBT_ERR_INSTALL_FLOW); + + if (strncmp(&target[slen],".shrext",7)) + return SLBT_CUSTOM_ERROR(dctx,SLBT_ERR_INSTALL_FLOW); + + strcpy(sobuf,&target[slen+7]); + } + /* executable? ordinary file? */ if (fexe || !dot || strcmp(dot,".la")) { *src = fexe ? srcfile : (char *)entry->arg; @@ -406,11 +430,11 @@ static int slbt_exec_install_entry( dot = strrchr(slnkname,'.'); /* libfoo.a --> libfoo.so.release */ - sprintf(dot,"%s.release",dctx->cctx->settings.dsosuffix); + sprintf(dot,"%s.release",dsosuffix); frelease = stat(slnkname,&st) ? false : true; /* libfoo.a --> libfoo.so */ - strcpy(dot,dctx->cctx->settings.dsosuffix); + strcpy(dot,dsosuffix); /* PE support: does .libs/libfoo.so.def exist? */ if ((size_t)snprintf(dstfile,sizeof(dstfile),"%s.def", -- cgit v1.2.3