summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/driver/slbt_driver_ctx.c22
-rw-r--r--src/logic/slbt_exec_link.c28
2 files changed, 41 insertions, 9 deletions
diff --git a/src/driver/slbt_driver_ctx.c b/src/driver/slbt_driver_ctx.c
index ab28c44..78058aa 100644
--- a/src/driver/slbt_driver_ctx.c
+++ b/src/driver/slbt_driver_ctx.c
@@ -1139,7 +1139,8 @@ static int slbt_init_link_params(struct slbt_driver_ctx_impl * ctx)
/* executable? */
if (!(dot = strrchr(ctx->cctx.output,'.')))
- return 0;
+ if (!(ctx->cctx.drvflags & SLBT_DRIVER_MODULE))
+ return 0;
/* todo: archive? library? wrapper? inlined function, avoid repetition */
if ((base = strrchr(ctx->cctx.output,'/')))
@@ -1148,7 +1149,7 @@ static int slbt_init_link_params(struct slbt_driver_ctx_impl * ctx)
base = ctx->cctx.output;
/* archive? */
- if (!strcmp(dot,ctx->cctx.settings.arsuffix)) {
+ if (dot && !strcmp(dot,ctx->cctx.settings.arsuffix)) {
prefix = ctx->cctx.settings.arprefix;
if (!strncmp(prefix,base,strlen(prefix)))
@@ -1165,12 +1166,17 @@ static int slbt_init_link_params(struct slbt_driver_ctx_impl * ctx)
}
/* library? */
- else if (!strcmp(dot,ctx->cctx.settings.dsosuffix)) {
+ else if (dot && !strcmp(dot,ctx->cctx.settings.dsosuffix)) {
prefix = ctx->cctx.settings.dsoprefix;
- if (!strncmp(prefix,base,strlen(prefix)))
+ if (!strncmp(prefix,base,strlen(prefix))) {
libname = base;
- else {
+
+ } else if (ctx->cctx.drvflags & SLBT_DRIVER_MODULE) {
+ libname = base;
+ fmodule = true;
+
+ } else {
if (ctx->cctx.drvflags & SLBT_DRIVER_VERBOSITY_ERRORS)
slbt_dprintf(fderr,
"%s: error: output file prefix does "
@@ -1182,7 +1188,7 @@ static int slbt_init_link_params(struct slbt_driver_ctx_impl * ctx)
}
/* wrapper? */
- else if (!strcmp(dot,".la")) {
+ else if (dot && !strcmp(dot,".la")) {
prefix = ctx->cctx.settings.dsoprefix;
if (!strncmp(prefix,base,strlen(prefix))) {
@@ -1210,8 +1216,8 @@ static int slbt_init_link_params(struct slbt_driver_ctx_impl * ctx)
if (!(ctx->libname = strdup(libname)))
return -1;
- dot = strrchr(ctx->libname,'.');
- *dot = 0;
+ if ((dot = strrchr(ctx->libname,'.')))
+ *dot = 0;
ctx->cctx.libname = ctx->libname;
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 */