From 94ae747d1e600883992c26349e39fea05bdc16c4 Mon Sep 17 00:00:00 2001 From: midipix Date: Thu, 21 Apr 2016 19:26:48 -0400 Subject: link mode: account for archives that were created via direct ar(1) invocation. --- src/logic/slbt_exec_link.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c index 141229d..267e292 100644 --- a/src/logic/slbt_exec_link.c +++ b/src/logic/slbt_exec_link.c @@ -223,6 +223,7 @@ static int slbt_exec_link_adjust_argument_vector( char * dot; FILE * fdeps; char * dpath; + bool freqd; int argc; char arg[PATH_MAX]; char lib[PATH_MAX]; @@ -246,6 +247,7 @@ static int slbt_exec_link_adjust_argument_vector( for (; *carg; ) { dpath = 0; + freqd = false; if (!strcmp(*carg,"-Wl,--whole-archive")) fwholearchive = true; @@ -279,6 +281,7 @@ static int slbt_exec_link_adjust_argument_vector( *aarg++ = *carg++; } else { dpath = lib; + freqd = true; sprintf(lib,"%s.slibtool.deps",*carg); /* account for {'-','L','-','l'} */ @@ -319,25 +322,25 @@ static int slbt_exec_link_adjust_argument_vector( if (dpath) { *aarg = darg; - if (!(fdeps = fopen(dpath,"r"))) { - free(depsmeta->altv); - free(depsmeta->args); - return -1; - } - - while (fscanf(fdeps,"%s\n",darg) == 1) { - *aarg++ = darg; - darg += strlen(darg); - darg++; - } + if ((fdeps = fopen(dpath,"r"))) { + while (fscanf(fdeps,"%s\n",darg) == 1) { + *aarg++ = darg; + darg += strlen(darg); + darg++; + } - if (ferror(fdeps)) { + if (ferror(fdeps)) { + free(depsmeta->altv); + free(depsmeta->args); + fclose(fdeps); + return -1; + } else { + fclose(fdeps); + } + } else if (freqd) { free(depsmeta->altv); free(depsmeta->args); - fclose(fdeps); return -1; - } else { - fclose(fdeps); } } } -- cgit v1.2.3