diff --git a/include/slibtool/slibtool.h b/include/slibtool/slibtool.h index ebd0794..b9327f4 100644 --- a/include/slibtool/slibtool.h +++ b/include/slibtool/slibtool.h @@ -82,6 +82,10 @@ struct slbt_exec_ctx { char * program; char ** argv; char ** envp; + char ** dpic; + char ** fpic; + char ** cass; + char ** lout[2]; char * csrc; char * ldirname; char * lbasename; @@ -131,6 +135,7 @@ slbt_api void slbt_free_unit_ctx (struct slbt_unit_ctx *); slbt_api int slbt_get_exec_ctx (const struct slbt_driver_ctx *, struct slbt_exec_ctx **); slbt_api void slbt_free_exec_ctx (struct slbt_exec_ctx *); +slbt_api void slbt_reset_placeholders (struct slbt_exec_ctx *); slbt_api int slbt_map_input (int fd, const char * path, int prot, struct slbt_input *); slbt_api int slbt_unmap_input (struct slbt_input *); diff --git a/src/logic/slbt_exec_ctx.c b/src/logic/slbt_exec_ctx.c index e191585..cfa7434 100644 --- a/src/logic/slbt_exec_ctx.c +++ b/src/logic/slbt_exec_ctx.c @@ -183,20 +183,19 @@ int slbt_get_exec_ctx( } } - if (dctx->cctx->mode == SLBT_MODE_COMPILE) { - if (dctx->cctx->drvflags & SLBT_DRIVER_SHARED) { - ictx->ctx.argv[i++] = "-DPIC"; - ictx->ctx.argv[i++] = "-fPIC"; - } + /* placeholders for -DPIC, -fPIC, -c, -o, */ + ictx->ctx.dpic = &ictx->ctx.argv[i++]; + ictx->ctx.fpic = &ictx->ctx.argv[i++]; + ictx->ctx.cass = &ictx->ctx.argv[i++]; - ictx->ctx.argv[i++] = "-c"; - } + ictx->ctx.lout[0] = &ictx->ctx.argv[i++]; + ictx->ctx.lout[1] = &ictx->ctx.argv[i++]; /* output file name */ if (ref) { - ictx->ctx.argv[i++] = "-o"; - ictx->ctx.argv[i++] = ch; - ictx->ctx.lobjname = ch; + *ictx->ctx.lout[0] = "-o"; + *ictx->ctx.lout[1] = ch; + ictx->ctx.lobjname = ch; sprintf(ch,"%s%s", ictx->ctx.ldirname, @@ -229,3 +228,14 @@ void slbt_free_exec_ctx(struct slbt_exec_ctx * ctx) slbt_free_exec_ctx_impl(ictx,0); } } + + +void slbt_reset_placeholders(struct slbt_exec_ctx * ectx) +{ + *ectx->dpic = "-DSLIBTOOL_PLACEHOLDER_DPIC"; + *ectx->fpic = "-DSLIBTOOL_PLACEHOLDER_FPIC"; + *ectx->cass = "-DSLIBTOOL_PLACEHOLDER_COMPILE_ASSEMBLE"; + + *ectx->lout[0] = "-DSLIBTOOL_PLACEHOLDER_OUTPUT_SWITCH"; + *ectx->lout[1] = "-DSLIBTOOL_PLACEHOLDER_OUTPUT_FILE"; +}