summaryrefslogtreecommitdiff
path: root/src/logic
diff options
context:
space:
mode:
Diffstat (limited to 'src/logic')
-rw-r--r--src/logic/slbt_exec_ctx.c10
-rw-r--r--src/logic/slbt_exec_link.c18
2 files changed, 21 insertions, 7 deletions
diff --git a/src/logic/slbt_exec_ctx.c b/src/logic/slbt_exec_ctx.c
index 230dd7f..baddab7 100644
--- a/src/logic/slbt_exec_ctx.c
+++ b/src/logic/slbt_exec_ctx.c
@@ -110,8 +110,13 @@ static struct slbt_exec_ctx_impl * slbt_exec_ctx_alloc(
return 0;
}
+ /* ictx, argv, xargv */
+ vsize = sizeof(*ictx);
+ vsize += sizeof(char *) * (argc + 1);
+ vsize += sizeof(char *) * (argc + 1);
+
/* altv: duplicate set, -Wl,--whole-archive, -Wl,--no-whole-archive */
- vsize = sizeof(*ictx) + 4*(argc+1)*sizeof(char *);
+ vsize += sizeof(char *) * (argc + 1) * 3;
if (!(ictx = calloc(1,vsize))) {
free(args);
@@ -155,7 +160,8 @@ int slbt_get_exec_ctx(
/* init with guard for later .lo check */
ch = ictx->args + strlen(".lo");
ictx->ctx.argv = ictx->vbuffer;
- ictx->ctx.altv = &ictx->vbuffer[ictx->argc + 1];
+ ictx->ctx.xargv = &ictx->ctx.argv [ictx->argc + 1];
+ ictx->ctx.altv = &ictx->ctx.xargv[ictx->argc + 1];
/* <compiler> */
ictx->ctx.compiler = dctx->cctx->cargv[0];
diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c
index 53fcd83..4f422d2 100644
--- a/src/logic/slbt_exec_link.c
+++ b/src/logic/slbt_exec_link.c
@@ -193,6 +193,7 @@ static bool slbt_adjust_input_argument(
static int slbt_adjust_linker_argument(
const struct slbt_driver_ctx * dctx,
char * arg,
+ char ** xarg,
bool fpic,
const char * dsosuffix,
const char * arsuffix,
@@ -209,8 +210,10 @@ static int slbt_adjust_linker_argument(
if (!(dot = strrchr(arg,'.')))
return 0;
- if (!(strcmp(dot,arsuffix)))
+ if (!(strcmp(dot,arsuffix))) {
+ *xarg = arg;
return slbt_get_deps_meta(dctx,arg,1,depsmeta);
+ }
if (!(strcmp(dot,dsosuffix)))
return slbt_get_deps_meta(dctx,arg,1,depsmeta);
@@ -350,6 +353,9 @@ static int slbt_exec_link_adjust_argument_vector(
} else if (!(dot = strrchr(*carg,'.'))) {
*aarg++ = *carg++;
+ } else if (ectx->xargv[carg - ectx->cargv]) {
+ *aarg++ = *carg++;
+
} else if (!(strcmp(dot,".a"))) {
if (flibrary && !fwholearchive)
*aarg++ = "-Wl,--whole-archive";
@@ -1120,6 +1126,7 @@ static int slbt_exec_link_create_library(
const char * relfilename)
{
char ** parg;
+ char ** xarg;
char cwd [PATH_MAX];
char output [PATH_MAX];
char soname [PATH_MAX];
@@ -1145,10 +1152,10 @@ static int slbt_exec_link_create_library(
SLBT_NESTED_ERROR(dctx));
/* linker argument adjustment */
- for (parg=ectx->cargv; *parg; parg++)
+ for (parg=ectx->cargv, xarg=ectx->xargv; *parg; parg++, xarg++)
if (slbt_adjust_linker_argument(
dctx,
- *parg,true,
+ *parg,xarg,true,
dctx->cctx->settings.dsosuffix,
dctx->cctx->settings.arsuffix,
&depsmeta) < 0)
@@ -1287,6 +1294,7 @@ static int slbt_exec_link_create_executable(
int fdcwd;
int fdwrap;
char ** parg;
+ char ** xarg;
char * base;
char cwd [PATH_MAX];
char output [PATH_MAX];
@@ -1314,10 +1322,10 @@ static int slbt_exec_link_create_executable(
slbt_adjust_input_argument(*parg,".lo",".o",fpic);
/* linker argument adjustment */
- for (parg=ectx->cargv; *parg; parg++)
+ for (parg=ectx->cargv, xarg=ectx->xargv; *parg; parg++, xarg++)
if (slbt_adjust_linker_argument(
dctx,
- *parg,true,
+ *parg,xarg,true,
dctx->cctx->settings.dsosuffix,
dctx->cctx->settings.arsuffix,
&depsmeta) < 0)