summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2018-06-21 09:50:26 -0400
committermidipix <writeonce@midipix.org>2018-06-21 10:37:49 -0400
commit2baf1cc107ba6041a3856b77d33140ac876ad6f0 (patch)
tree78d2eaec68e175f8c6505f17b839a36d4f79c839 /src
parent2900877604e4fac83e49ed98536b0fcdf01055a8 (diff)
downloadslibtool-2baf1cc107ba6041a3856b77d33140ac876ad6f0.tar.bz2
slibtool-2baf1cc107ba6041a3856b77d33140ac876ad6f0.tar.xz
link mode: --disable-{shared|static}: use differently-named placeholders.
Diffstat (limited to 'src')
-rw-r--r--src/internal/slibtool_symlink_impl.c44
-rw-r--r--src/internal/slibtool_symlink_impl.h2
-rw-r--r--src/logic/slbt_exec_install.c8
-rw-r--r--src/logic/slbt_exec_link.c4
4 files changed, 46 insertions, 12 deletions
diff --git a/src/internal/slibtool_symlink_impl.c b/src/internal/slibtool_symlink_impl.c
index 72d693a..b5b9b28 100644
--- a/src/internal/slibtool_symlink_impl.c
+++ b/src/internal/slibtool_symlink_impl.c
@@ -11,6 +11,7 @@
#include "slibtool_errinfo_impl.h"
#include "slibtool_symlink_impl.h"
+#include "slibtool_readlink_impl.h"
#define SLBT_DEV_NULL_FLAGS (SLBT_DRIVER_ALL_STATIC \
| SLBT_DRIVER_DISABLE_SHARED \
@@ -29,19 +30,29 @@ int slbt_create_symlink(
char * dotdot;
char tmplnk [PATH_MAX];
char lnkarg [PATH_MAX];
+ char alnkarg[PATH_MAX];
char atarget[PATH_MAX];
+ char * suffix = 0;
- /* atarget */
+ /* symlink is a placeholder? */
if ((dctx->cctx->drvflags & SLBT_DEV_NULL_FLAGS)
- && !strcmp(target,"/dev/null"))
- slash = target;
- else if ((slash = strrchr(target,'/')))
+ && !strcmp(target,"/dev/null")) {
+ slash = target;
+ suffix = ".disabled";
+
+ /* symlink target contains a dirname? */
+ } else if ((slash = strrchr(target,'/'))) {
slash++;
- else
+
+ /* symlink target is a basename */
+ } else {
slash = target;
+ }
+ /* .la wrapper? */
dotdot = flawrapper ? "../" : "";
+ /* atarget */
if ((size_t)snprintf(atarget,sizeof(atarget),"%s%s",
dotdot,slash) >= sizeof(atarget))
return SLBT_BUFFER_ERROR(dctx);
@@ -51,6 +62,12 @@ int slbt_create_symlink(
lnkname) >= sizeof(tmplnk))
return SLBT_BUFFER_ERROR(dctx);
+ /* placeholder? */
+ if (suffix) {
+ sprintf(alnkarg,"%s%s",lnkname,suffix);
+ lnkname = alnkarg;
+ }
+
/* lnkarg */
strcpy(lnkarg,lnkname);
@@ -90,3 +107,20 @@ int slbt_create_symlink(
? SLBT_SYSTEM_ERROR(dctx)
: 0;
}
+
+int slbt_symlink_is_a_placeholder(char * lnkpath)
+{
+ size_t len;
+ char slink [PATH_MAX];
+ char target[PATH_MAX];
+ const char suffix[] = ".disabled";
+
+ if ((sizeof(slink)-sizeof(suffix)) < (len=strlen(lnkpath)))
+ return 0;
+
+ memcpy(slink,lnkpath,len);
+ memcpy(&slink[len],suffix,sizeof(suffix));
+
+ return (!slbt_readlink(slink,target,sizeof(target)))
+ && (!strcmp(target,"/dev/null"));
+}
diff --git a/src/internal/slibtool_symlink_impl.h b/src/internal/slibtool_symlink_impl.h
index 63a74a8..b96fdb9 100644
--- a/src/internal/slibtool_symlink_impl.h
+++ b/src/internal/slibtool_symlink_impl.h
@@ -13,3 +13,5 @@ int slbt_create_symlink(
const char * target,
const char * lnkname,
bool flawrapper);
+
+int slbt_symlink_is_a_placeholder(char * lnkpath);
diff --git a/src/logic/slbt_exec_install.c b/src/logic/slbt_exec_install.c
index ea795e3..2d98881 100644
--- a/src/logic/slbt_exec_install.c
+++ b/src/logic/slbt_exec_install.c
@@ -424,6 +424,10 @@ static int slbt_exec_install_entry(
/* source (build) symlink target */
if (slbt_readlink(slnkname,target,sizeof(target)) < 0) {
+ /* -all-static? */
+ if (slbt_symlink_is_a_placeholder(slnkname))
+ return 0;
+
/* -avoid-version? */
if (stat(slnkname,&st))
return SLBT_SYSTEM_ERROR(dctx);
@@ -447,10 +451,6 @@ static int slbt_exec_install_entry(
return 0;
}
- /* -all-static? */
- if (!strcmp(target,"/dev/null"))
- return 0;
-
/* srcfile: .libs/libfoo.so.x.y.z */
slash = strrchr(srcfile,'/');
strcpy(++slash,target);
diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c
index 542448c..5cf3355 100644
--- a/src/logic/slbt_exec_link.c
+++ b/src/logic/slbt_exec_link.c
@@ -200,7 +200,6 @@ static int slbt_adjust_linker_argument(
char * slash;
char * dot;
char base[PATH_MAX];
- char slnk[PATH_MAX];
if (*arg == '-')
return 0;
@@ -229,8 +228,7 @@ static int slbt_adjust_linker_argument(
if (fpic) {
sprintf(dot,"%s",dsosuffix);
- if (!slbt_readlink(arg,slnk,sizeof(slnk))
- && !(strcmp(slnk,"/dev/null")))
+ if (slbt_symlink_is_a_placeholder(arg))
sprintf(dot,"%s",arsuffix);
else if ((fdlib = open(arg,O_RDONLY)) >= 0)
close(fdlib);