summaryrefslogtreecommitdiffhomepage
path: root/src/logic
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2020-09-08 02:29:46 +0000
committermidipix <writeonce@midipix.org>2020-09-08 02:29:46 +0000
commit712060650be4ca4ba6fd84fc4670a12a6cef79b7 (patch)
tree58e275e26a351a9113c4c573f5310c0ca4895707 /src/logic
parent1394543be7df6171ceac2d5eadef48ca4e302efa (diff)
downloadslibtool-712060650be4ca4ba6fd84fc4670a12a6cef79b7.tar.bz2
slibtool-712060650be4ca4ba6fd84fc4670a12a6cef79b7.tar.xz
driver, link mode: properly implement the -module semantics.
Prior to this commit, -module was not respected when the specified output name happened to end with the platform's shared library suffix. In addition, the logic for generating shared libraries with -module in effect has been incomplete and partially also incorrect.
Diffstat (limited to 'src/logic')
-rw-r--r--src/logic/slbt_exec_link.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c
index 5f94038..88efff2 100644
--- a/src/logic/slbt_exec_link.c
+++ b/src/logic/slbt_exec_link.c
@@ -1306,6 +1306,15 @@ static int slbt_exec_link_create_library(
if ((dctx->cctx->drvflags & SLBT_DRIVER_IMAGE_MACHO)) {
(void)0;
+ } else if (dctx->cctx->drvflags & SLBT_DRIVER_MODULE) {
+ if ((size_t)snprintf(soname,sizeof(soname),"-Wl,%s",
+ dctx->cctx->output)
+ >= sizeof(soname))
+ return SLBT_BUFFER_ERROR(dctx);
+
+ *ectx->soname = "-Wl,-soname";
+ *ectx->lsoname = soname;
+
} else if (relfilename && dctx->cctx->verinfo.verinfo) {
if ((size_t)snprintf(soname,sizeof(soname),"-Wl,%s%s-%s%s.%d%s",
ectx->sonameprefix,
@@ -1368,7 +1377,9 @@ static int slbt_exec_link_create_library(
}
/* output */
- if (relfilename) {
+ if (dctx->cctx->drvflags & SLBT_DRIVER_MODULE) {
+ strcpy(output,dctx->cctx->output);
+ } else if (relfilename) {
strcpy(output,relfilename);
} else if (dctx->cctx->drvflags & SLBT_DRIVER_AVOID_VERSION) {
strcpy(output,dsofilename);
@@ -1789,6 +1800,21 @@ int slbt_exec_link(
false))
return SLBT_NESTED_ERROR(dctx);
+ /* dynaic library via -module */
+ if (dctx->cctx->drvflags & SLBT_DRIVER_MODULE) {
+ if (slbt_exec_link_create_library(
+ dctx,ectx,
+ ectx->dsobasename,
+ ectx->dsofilename,
+ ectx->relfilename)) {
+ slbt_free_exec_ctx(actx);
+ return SLBT_NESTED_ERROR(dctx);
+ }
+
+ slbt_free_exec_ctx(actx);
+ return 0;
+ }
+
/* dynamic library */
if (dot && !strcmp(dot,".la") && dctx->cctx->rpath && !fstaticonly) {
/* linking: libfoo.so.x.y.z */