From ff7fb8ff0eda9757e3395577ef2943ded893fadb Mon Sep 17 00:00:00 2001 From: midipix Date: Thu, 10 Sep 2020 02:06:41 +0000 Subject: link mode: slbt_exec_link(): properly handle .la targets built with -module. --- src/logic/slbt_exec_link.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c index 88efff2..ff406f9 100644 --- a/src/logic/slbt_exec_link.c +++ b/src/logic/slbt_exec_link.c @@ -1261,6 +1261,8 @@ static int slbt_exec_link_create_library( char ** parg; char ** xarg; char * ccwrap; + const char * laout; + const char * dot; char cwd [PATH_MAX]; char output [PATH_MAX]; char soname [PATH_MAX]; @@ -1303,10 +1305,15 @@ static int slbt_exec_link_create_library( *ectx->noundef = "-Wl,--no-undefined"; /* -soname */ + dot = strrchr(dctx->cctx->output,'.'); + laout = (dot && !strcmp(dot,".la")) + ? dctx->cctx->output + : 0; + if ((dctx->cctx->drvflags & SLBT_DRIVER_IMAGE_MACHO)) { (void)0; - } else if (dctx->cctx->drvflags & SLBT_DRIVER_MODULE) { + } else if (!laout && (dctx->cctx->drvflags & SLBT_DRIVER_MODULE)) { if ((size_t)snprintf(soname,sizeof(soname),"-Wl,%s", dctx->cctx->output) >= sizeof(soname)) @@ -1377,7 +1384,7 @@ static int slbt_exec_link_create_library( } /* output */ - if (dctx->cctx->drvflags & SLBT_DRIVER_MODULE) { + if (!laout && dctx->cctx->drvflags & SLBT_DRIVER_MODULE) { strcpy(output,dctx->cctx->output); } else if (relfilename) { strcpy(output,relfilename); @@ -1802,17 +1809,19 @@ int slbt_exec_link( /* 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)) { + if (!dot || strcmp(dot,".la")) { + 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 SLBT_NESTED_ERROR(dctx); + return 0; } - - slbt_free_exec_ctx(actx); - return 0; } /* dynamic library */ -- cgit v1.2.3