summaryrefslogtreecommitdiff
path: root/src/logic
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-04-02 11:42:02 -0400
committermidipix <writeonce@midipix.org>2016-04-02 11:42:02 -0400
commite7ddb294b84a2f012019d11f9fa5fad90dc304e5 (patch)
tree09ecd90947d59864f08c4f79dbb245d935f321fa /src/logic
parent54d0a583ef6f40697f860b85c6d01b2540217f20 (diff)
downloadslibtool-e7ddb294b84a2f012019d11f9fa5fad90dc304e5.tar.bz2
slibtool-e7ddb294b84a2f012019d11f9fa5fad90dc304e5.tar.xz
slbt_reset_arguments(): initial implementation and integration.
Diffstat (limited to 'src/logic')
-rw-r--r--src/logic/slbt_exec_ctx.c32
-rw-r--r--src/logic/slbt_exec_link.c3
2 files changed, 33 insertions, 2 deletions
diff --git a/src/logic/slbt_exec_ctx.c b/src/logic/slbt_exec_ctx.c
index 1fbcca3..3eec822 100644
--- a/src/logic/slbt_exec_ctx.c
+++ b/src/logic/slbt_exec_ctx.c
@@ -16,6 +16,8 @@
struct slbt_exec_ctx_impl {
int argc;
char * args;
+ char * shadow;
+ size_t size;
struct slbt_exec_ctx ctx;
char * vbuffer[];
};
@@ -57,8 +59,10 @@ static struct slbt_exec_ctx_impl * slbt_exec_ctx_alloc(
{
struct slbt_exec_ctx_impl * ictx;
size_t size;
+ size_t vsize;
int argc;
char * args;
+ char * shadow;
char * csrc;
char ** parg;
@@ -102,16 +106,25 @@ static struct slbt_exec_ctx_impl * slbt_exec_ctx_alloc(
if (!(args = malloc(size)))
return 0;
- size = sizeof(*ictx) + (2*(argc+1)+SLBT_ARGV_SPARE_PTRS)*sizeof(char *);
+ if (!(shadow = malloc(size))) {
+ free(args);
+ return 0;
+ }
+
+ vsize = sizeof(*ictx) + (2*(argc+1)+SLBT_ARGV_SPARE_PTRS)*sizeof(char *);
- if (!(ictx = calloc(1,size))) {
+ if (!(ictx = calloc(1,vsize))) {
free(args);
+ free(shadow);
return 0;
}
ictx->args = args;
ictx->argc = argc;
+ ictx->size = size;
+ ictx->shadow = shadow;
+
ictx->ctx.csrc = csrc;
return ictx;
@@ -269,6 +282,9 @@ int slbt_get_exec_ctx(
+ sizeof('\0');
}
+ /* argument strings shadow copy */
+ memcpy(ictx->shadow,ictx->args,ictx->size);
+
*ectx = &ictx->ctx;
return 0;
}
@@ -279,6 +295,7 @@ static int slbt_free_exec_ctx_impl(
int status)
{
free(ictx->args);
+ free(ictx->shadow);
free (ictx);
return status;
}
@@ -297,6 +314,17 @@ void slbt_free_exec_ctx(struct slbt_exec_ctx * ctx)
}
+void slbt_reset_arguments(struct slbt_exec_ctx * ectx)
+{
+ struct slbt_exec_ctx_impl * ictx;
+ uintptr_t addr;
+
+ addr = (uintptr_t)ectx - offsetof(struct slbt_exec_ctx_impl,ctx);
+ ictx = (struct slbt_exec_ctx_impl *)addr;
+ memcpy(ictx->args,ictx->shadow,ictx->size);
+}
+
+
void slbt_reset_placeholders(struct slbt_exec_ctx * ectx)
{
*ectx->dpic = "-USLIBTOOL_PLACEHOLDER_DPIC";
diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c
index 1739c63..9c07517 100644
--- a/src/logic/slbt_exec_link.c
+++ b/src/logic/slbt_exec_link.c
@@ -58,6 +58,9 @@ static int slbt_exec_link_static_archive(
char program[PATH_MAX];
char output [PATH_MAX];
+ /* initial state */
+ slbt_reset_arguments(ectx);
+
/* placeholders */
slbt_reset_placeholders(ectx);