From 9706faf3b18a3fe231bff70e6d8acd62aaae99df Mon Sep 17 00:00:00 2001 From: midipix Date: Fri, 29 Jun 2018 01:00:36 -0400 Subject: execution context: generated wrapper: replaced the stream with a pure fd. --- src/logic/slbt_exec_link.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'src/logic/slbt_exec_link.c') diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c index 8ad1af3..c9f62e4 100644 --- a/src/logic/slbt_exec_link.c +++ b/src/logic/slbt_exec_link.c @@ -15,6 +15,7 @@ #include #include "slibtool_spawn_impl.h" #include "slibtool_mkdir_impl.h" +#include "slibtool_driver_impl.h" #include "slibtool_dprintf_impl.h" #include "slibtool_errinfo_impl.h" #include "slibtool_mapfile_impl.h" @@ -242,6 +243,7 @@ static int slbt_exec_link_adjust_argument_vector( bool flibrary) { int fd; + int fdwrap; char ** carg; char ** aarg; char * ldir; @@ -383,10 +385,10 @@ static int slbt_exec_link_adjust_argument_vector( mark = strrchr(*carg,'/'); *mark = 0; - if (ectx->fwrapper) { + if ((fdwrap = slbt_exec_get_fdwrapper(ectx)) >= 0) { *slash = 0; - if (fprintf(ectx->fwrapper, + if (slbt_dprintf(fdwrap, "DL_PATH=\"$DL_PATH$COLON%s/%s\"\n" "COLON=':'\n\n", cwd,arg) < 0) @@ -1259,6 +1261,7 @@ static int slbt_exec_link_create_executable( struct slbt_exec_ctx * ectx, const char * exefilename) { + int fdwrap; char ** parg; char * base; char cwd [PATH_MAX]; @@ -1297,18 +1300,22 @@ static int slbt_exec_link_create_executable( if (dctx->cctx->drvflags & SLBT_DRIVER_NO_UNDEFINED) *ectx->noundef = "-Wl,--no-undefined"; - /* executable wrapper: header */ - if ((size_t)snprintf(wrapper,sizeof(wrapper),"%s.wrapper.tmp", + /* executable wrapper: create */ + if ((size_t)snprintf(wrapper,sizeof(wrapper), + "%s.wrapper.tmp", dctx->cctx->output) >= sizeof(wrapper)) return SLBT_BUFFER_ERROR(dctx); - if (!(ectx->fwrapper = fopen(wrapper,"w"))) + if ((fdwrap = openat(AT_FDCWD,wrapper,O_RDWR|O_CREAT|O_TRUNC,0644)) < 0) return SLBT_SYSTEM_ERROR(dctx); + slbt_exec_set_fdwrapper(ectx,fdwrap); + + /* executable wrapper: header */ verinfo = slbt_source_version(); - if (fprintf(ectx->fwrapper, + if (slbt_dprintf(fdwrap, "#!/bin/sh\n" "# libtool compatible executable wrapper\n" "# Generated by %s (slibtool %d.%d.%d)\n" @@ -1372,7 +1379,7 @@ static int slbt_exec_link_create_executable( /* executable wrapper: footer */ fabspath = (exefilename[0] == '/'); - if (fprintf(ectx->fwrapper, + if (slbt_dprintf(fdwrap, "DL_PATH=\"$DL_PATH$LCOLON$%s\"\n\n" "export %s=$DL_PATH\n\n" "if [ `basename \"$0\"` = \"%s\" ]; then\n" @@ -1407,8 +1414,7 @@ static int slbt_exec_link_create_executable( SLBT_SPAWN_ERROR(dctx)); /* executable wrapper: finalize */ - fclose(ectx->fwrapper); - ectx->fwrapper = 0; + slbt_exec_close_fdwrapper(ectx); if (slbt_create_symlink( dctx,ectx, -- cgit v1.2.3