diff options
author | midipix <writeonce@midipix.org> | 2018-06-29 01:00:36 -0400 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2018-06-29 01:37:44 -0400 |
commit | 9706faf3b18a3fe231bff70e6d8acd62aaae99df (patch) | |
tree | 4bd85493b914dd8565c36776ec85814009c7532b /src/logic/slbt_exec_link.c | |
parent | c178e3616873d4bb6d94d6fb68633497a4df0ef5 (diff) | |
download | slibtool-9706faf3b18a3fe231bff70e6d8acd62aaae99df.tar.bz2 slibtool-9706faf3b18a3fe231bff70e6d8acd62aaae99df.tar.xz |
execution context: generated wrapper: replaced the stream with a pure fd.
Diffstat (limited to 'src/logic/slbt_exec_link.c')
-rw-r--r-- | src/logic/slbt_exec_link.c | 24 |
1 files changed, 15 insertions, 9 deletions
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 <slibtool/slibtool.h> #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, |