summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2021-05-06 04:26:10 +0000
committermidipix <writeonce@midipix.org>2021-05-06 05:40:34 +0000
commitc7981ca306e4dfa2d8a5524b3b2063be8a7a6584 (patch)
tree5f4c459658830bb47bec24ab26132f7787fb965a /src
parent465de6c0f42fe777f8023fc79f41440d5ec8e365 (diff)
downloadslibtool-c7981ca306e4dfa2d8a5524b3b2063be8a7a6584.tar.bz2
slibtool-c7981ca306e4dfa2d8a5524b3b2063be8a7a6584.tar.xz
link mode: always create libfoo.so.def.{host|flavor} and related tags.
Diffstat (limited to 'src')
-rw-r--r--src/internal/slibtool_symlink_impl.c7
-rw-r--r--src/internal/slibtool_symlink_impl.h1
-rw-r--r--src/logic/slbt_exec_install.c2
-rw-r--r--src/logic/slbt_exec_link.c106
4 files changed, 74 insertions, 42 deletions
diff --git a/src/internal/slibtool_symlink_impl.c b/src/internal/slibtool_symlink_impl.c
index 0b1daa0..bb67623 100644
--- a/src/internal/slibtool_symlink_impl.c
+++ b/src/internal/slibtool_symlink_impl.c
@@ -28,6 +28,7 @@ int slbt_create_symlink(
int fdcwd;
int fliteral;
int fwrapper;
+ int fdevnull;
char ** oargv;
const char * slash;
char * ln[5];
@@ -41,9 +42,13 @@ int slbt_create_symlink(
/* options */
fliteral = (options & SLBT_SYMLINK_LITERAL);
fwrapper = (options & SLBT_SYMLINK_WRAPPER);
+ fdevnull = (options & SLBT_SYMLINK_DEVNULL);
/* symlink is a placeholder? */
- if ((dctx->cctx->drvflags & SLBT_DEV_NULL_FLAGS)
+ if (fliteral && fdevnull) {
+ slash = target;
+
+ } else if ((dctx->cctx->drvflags & SLBT_DEV_NULL_FLAGS)
&& !strcmp(target,"/dev/null")) {
slash = target;
suffix = ".disabled";
diff --git a/src/internal/slibtool_symlink_impl.h b/src/internal/slibtool_symlink_impl.h
index 5619e75..fc4c708 100644
--- a/src/internal/slibtool_symlink_impl.h
+++ b/src/internal/slibtool_symlink_impl.h
@@ -7,6 +7,7 @@
#define SLBT_SYMLINK_DEFAULT 0x0000
#define SLBT_SYMLINK_LITERAL 0x0001
#define SLBT_SYMLINK_WRAPPER 0x0002
+#define SLBT_SYMLINK_DEVNULL 0x0004
int slbt_create_symlink(
const struct slbt_driver_ctx * dctx,
diff --git a/src/logic/slbt_exec_install.c b/src/logic/slbt_exec_install.c
index 124c44d..3f04e66 100644
--- a/src/logic/slbt_exec_install.c
+++ b/src/logic/slbt_exec_install.c
@@ -479,7 +479,7 @@ static int slbt_exec_install_entry(
slnkname) >= sizeof(dstfile))
return SLBT_BUFFER_ERROR(dctx);
- fpe = fstatat(fdcwd,dstfile,&st,0) ? false : true;
+ fpe = !strcmp(dctx->cctx->asettings.imagefmt,"pe");
/* basename */
if ((base = strrchr(slnkname,'/')))
diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c
index f61c5db..c271e7e 100644
--- a/src/logic/slbt_exec_link.c
+++ b/src/logic/slbt_exec_link.c
@@ -1138,54 +1138,60 @@ static int slbt_exec_link_create_dep_file(
return 0;
}
-static int slbt_exec_link_create_import_library(
+static int slbt_exec_link_create_host_tag(
const struct slbt_driver_ctx * dctx,
struct slbt_exec_ctx * ectx,
- char * impfilename,
- char * deffilename,
- char * soname,
- bool ftag)
+ char * deffilename)
{
- int fmdso;
- char * slash;
- char * eargv[8];
- char program[PATH_MAX];
+ char * slash;
char hosttag[PATH_MAX];
char hostlnk[PATH_MAX];
/* libfoo.so.def.{flavor} */
- if (ftag) {
- if ((size_t)snprintf(hosttag,sizeof(hosttag),"%s.%s",
- deffilename,
- dctx->cctx->host.flavor) >= sizeof(hosttag))
- return SLBT_BUFFER_ERROR(dctx);
+ if ((size_t)snprintf(hosttag,sizeof(hosttag),"%s.%s",
+ deffilename,
+ dctx->cctx->host.flavor) >= sizeof(hosttag))
+ return SLBT_BUFFER_ERROR(dctx);
- if ((size_t)snprintf(hostlnk,sizeof(hostlnk),"%s.host",
- deffilename) >= sizeof(hostlnk))
- return SLBT_BUFFER_ERROR(dctx);
+ if ((size_t)snprintf(hostlnk,sizeof(hostlnk),"%s.host",
+ deffilename) >= sizeof(hostlnk))
+ return SLBT_BUFFER_ERROR(dctx);
- /* libfoo.so.def is under .libs/ */
- if (!(slash = strrchr(deffilename,'/')))
- return SLBT_CUSTOM_ERROR(dctx,SLBT_ERR_LINK_FLOW);
+ /* libfoo.so.def is under .libs/ */
+ if (!(slash = strrchr(deffilename,'/')))
+ return SLBT_CUSTOM_ERROR(dctx,SLBT_ERR_LINK_FLOW);
- if (slbt_create_symlink(
- dctx,ectx,
- deffilename,
- hosttag,
- SLBT_SYMLINK_DEFAULT))
- return SLBT_NESTED_ERROR(dctx);
+ if (slbt_create_symlink(
+ dctx,ectx,
+ deffilename,
+ hosttag,
+ SLBT_SYMLINK_DEFAULT))
+ return SLBT_NESTED_ERROR(dctx);
- /* libfoo.so.def.{flavor} is under .libs/ */
- if (!(slash = strrchr(hosttag,'/')))
- return SLBT_CUSTOM_ERROR(dctx,SLBT_ERR_LINK_FLOW);
+ /* libfoo.so.def.{flavor} is under .libs/ */
+ if (!(slash = strrchr(hosttag,'/')))
+ return SLBT_CUSTOM_ERROR(dctx,SLBT_ERR_LINK_FLOW);
- if (slbt_create_symlink(
- dctx,ectx,
- ++slash,
- hostlnk,
- SLBT_SYMLINK_DEFAULT))
- return SLBT_NESTED_ERROR(dctx);
- }
+ if (slbt_create_symlink(
+ dctx,ectx,
+ ++slash,
+ hostlnk,
+ SLBT_SYMLINK_DEFAULT))
+ return SLBT_NESTED_ERROR(dctx);
+
+ return 0;
+}
+
+static int slbt_exec_link_create_import_library(
+ const struct slbt_driver_ctx * dctx,
+ struct slbt_exec_ctx * ectx,
+ char * impfilename,
+ char * deffilename,
+ char * soname)
+{
+ int fmdso;
+ char * eargv[8];
+ char program[PATH_MAX];
/* dlltool or mdso? */
if (dctx->cctx->drvflags & SLBT_DRIVER_IMPLIB_DSOMETA)
@@ -1925,6 +1931,14 @@ int slbt_exec_link(
fpic = false;
}
+ /* libfoo.so.def.{flavor} */
+ if (dctx->cctx->libname) {
+ if (slbt_exec_link_create_host_tag(
+ dctx,ectx,
+ ectx->deffilename))
+ return SLBT_NESTED_ERROR(dctx);
+ }
+
/* pic libfoo.a */
if (dot && !strcmp(dot,".la"))
if (slbt_exec_link_create_archive(
@@ -1963,6 +1977,13 @@ int slbt_exec_link(
SLBT_SYMLINK_DEFAULT))
return SLBT_NESTED_ERROR(dctx);
}
+
+ if (slbt_create_symlink(
+ dctx,ectx,
+ "/dev/null",
+ ectx->deffilename,
+ SLBT_SYMLINK_LITERAL|SLBT_SYMLINK_DEVNULL))
+ return SLBT_NESTED_ERROR(dctx);
}
/* -all-static library */
@@ -2086,8 +2107,7 @@ int slbt_exec_link(
dctx,ectx,
ectx->pimpfilename,
ectx->deffilename,
- soname,
- true))
+ soname))
return SLBT_NESTED_ERROR(dctx);
/* symlink: libfoo.lib.a --> libfoo.x.lib.a */
@@ -2103,8 +2123,14 @@ int slbt_exec_link(
dctx,ectx,
ectx->vimpfilename,
ectx->deffilename,
- soxyz,
- false))
+ soxyz))
+ return SLBT_NESTED_ERROR(dctx);
+ } else {
+ if (slbt_create_symlink(
+ dctx,ectx,
+ "/dev/null",
+ ectx->deffilename,
+ SLBT_SYMLINK_LITERAL|SLBT_SYMLINK_DEVNULL))
return SLBT_NESTED_ERROR(dctx);
}
}