diff options
author | midipix <writeonce@midipix.org> | 2016-09-14 18:48:21 -0400 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-09-14 18:50:43 -0400 |
commit | 2f9f52a1648cc5da9a4dbb8eb06d0cc1ea55a82c (patch) | |
tree | c51ed8a0d7a67c86716548c7e08bc1abea987f0a /src | |
parent | 8f07c59b89632f15559720c95e994d512219a0ff (diff) | |
download | slibtool-2f9f52a1648cc5da9a4dbb8eb06d0cc1ea55a82c.tar.bz2 slibtool-2f9f52a1648cc5da9a4dbb8eb06d0cc1ea55a82c.tar.xz |
link mode: soname: properly handle -module when output begins with dso prefix.
Diffstat (limited to 'src')
-rw-r--r-- | src/logic/slbt_exec_ctx.c | 20 | ||||
-rw-r--r-- | src/logic/slbt_exec_link.c | 32 |
2 files changed, 33 insertions, 19 deletions
diff --git a/src/logic/slbt_exec_ctx.c b/src/logic/slbt_exec_ctx.c index 6b66f12..6141410 100644 --- a/src/logic/slbt_exec_ctx.c +++ b/src/logic/slbt_exec_ctx.c @@ -18,6 +18,7 @@ struct slbt_exec_ctx_impl { int argc; char * args; char * shadow; + char * dsoprefix; size_t size; struct slbt_exec_ctx ctx; char * vbuffer[]; @@ -104,6 +105,7 @@ static struct slbt_exec_ctx_impl * slbt_exec_ctx_alloc( + strlen(dctx->cctx->settings.arsuffix) + 1 + strlen(dctx->cctx->settings.dsoprefix) + 1 + strlen(dctx->cctx->settings.dsoprefix) + 1 + + strlen(dctx->cctx->settings.dsoprefix) + 1 + strlen(dctx->cctx->settings.exeprefix) + 1 + strlen(dctx->cctx->settings.exeprefix) + 1 + strlen(dctx->cctx->settings.impprefix) + 1 @@ -151,6 +153,7 @@ int slbt_get_exec_ctx( char * slash; const char * arprefix; const char * dsoprefix; + const char * impprefix; const char * ref; int i; @@ -270,6 +273,13 @@ int slbt_get_exec_ctx( slbt_reset_placeholders(&ictx->ctx); + /* dsoprefix */ + if (dctx->cctx->settings.dsoprefix) { + ictx->dsoprefix = ch; + strcpy(ch,dctx->cctx->settings.dsoprefix); + ch += strlen(ch) + 1; + } + /* output file name */ if (ref && ((dctx->cctx->mode == SLBT_MODE_COMPILE))) { *ictx->ctx.lout[0] = "-o"; @@ -301,11 +311,15 @@ int slbt_get_exec_ctx( if (dctx->cctx->mode == SLBT_MODE_LINK && dctx->cctx->libname) { /* arprefix, dsoprefix */ if (dctx->cctx->drvflags & SLBT_DRIVER_MODULE) { + ictx->ctx.sonameprefix = ""; arprefix = ""; dsoprefix = ""; + impprefix = ""; } else { + ictx->ctx.sonameprefix = ictx->dsoprefix; arprefix = dctx->cctx->settings.arprefix; dsoprefix = dctx->cctx->settings.dsoprefix; + impprefix = dctx->cctx->settings.impprefix; } /* arfilename */ @@ -368,7 +382,7 @@ int slbt_get_exec_ctx( ictx->ctx.dimpfilename = ch; ch += sprintf(ch,"%s%s%s%s", ictx->ctx.ldirname, - dctx->cctx->settings.impprefix, + impprefix, dctx->cctx->libname, dctx->cctx->settings.impsuffix); ch++; @@ -378,7 +392,7 @@ int slbt_get_exec_ctx( ictx->ctx.pimpfilename = ch; ch += sprintf(ch,"%s%s%s.%d%s", ictx->ctx.ldirname, - dctx->cctx->settings.impprefix, + impprefix, dctx->cctx->libname, dctx->cctx->verinfo.major, dctx->cctx->settings.impsuffix); @@ -388,7 +402,7 @@ int slbt_get_exec_ctx( ictx->ctx.vimpfilename = ch; ch += sprintf(ch,"%s%s%s.%d.%d.%d%s", ictx->ctx.ldirname, - dctx->cctx->settings.impprefix, + impprefix, dctx->cctx->libname, dctx->cctx->verinfo.major, dctx->cctx->verinfo.minor, diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c index be46fab..178335a 100644 --- a/src/logic/slbt_exec_link.c +++ b/src/logic/slbt_exec_link.c @@ -912,7 +912,7 @@ static int slbt_exec_link_create_library( (void)0; } else if (!(dctx->cctx->drvflags & SLBT_DRIVER_AVOID_VERSION)) { if ((size_t)snprintf(soname,sizeof(soname),"-Wl,%s%s%s.%d", - dctx->cctx->settings.dsoprefix, + ectx->sonameprefix, dctx->cctx->libname, dctx->cctx->settings.dsosuffix, dctx->cctx->verinfo.major) @@ -923,7 +923,7 @@ static int slbt_exec_link_create_library( *ectx->lsoname = soname; } else if (relfilename) { if ((size_t)snprintf(soname,sizeof(soname),"-Wl,%s%s-%s%s", - dctx->cctx->settings.dsoprefix, + ectx->sonameprefix, dctx->cctx->libname, dctx->cctx->release, dctx->cctx->settings.dsosuffix) @@ -1240,29 +1240,37 @@ int slbt_exec_link( if (dctx->cctx->drvflags & SLBT_DRIVER_DRY_RUN) return 0; + /* context */ + if (ectx) + actx = 0; + else if ((ret = slbt_get_exec_ctx(dctx,&ectx))) + return SLBT_NESTED_ERROR(dctx); + else + actx = ectx; + /* libfoo.so.x.y.z */ if ((size_t)snprintf(soxyz,sizeof(soxyz),"%s%s%s.%d.%d.%d", - dctx->cctx->settings.dsoprefix, + ectx->sonameprefix, dctx->cctx->libname, dctx->cctx->settings.dsosuffix, dctx->cctx->verinfo.major, dctx->cctx->verinfo.minor, dctx->cctx->verinfo.revision) - >= sizeof(soxyz)) + >= sizeof(soxyz)) { + slbt_free_exec_ctx(actx); return SLBT_BUFFER_ERROR(dctx); + } /* libfoo.so.x */ sprintf(soname,"%s%s%s.%d", - dctx->cctx->settings.dsoprefix, + ectx->sonameprefix, dctx->cctx->libname, dctx->cctx->settings.dsosuffix, dctx->cctx->verinfo.major); /* libfoo.so */ sprintf(solnk,"%s%s%s", - (dctx->cctx->drvflags & SLBT_DRIVER_MODULE) - ? "" - : dctx->cctx->settings.dsoprefix, + ectx->sonameprefix, dctx->cctx->libname, dctx->cctx->settings.dsosuffix); @@ -1272,14 +1280,6 @@ int slbt_exec_link( dctx->cctx->libname, dctx->cctx->settings.arsuffix); - /* context */ - if (ectx) - actx = 0; - else if ((ret = slbt_get_exec_ctx(dctx,&ectx))) - return SLBT_NESTED_ERROR(dctx); - else - actx = ectx; - /* output suffix */ output = dctx->cctx->output; dot = strrchr(output,'.'); |