diff options
-rw-r--r-- | include/mdso/mdso.h | 8 | ||||
-rw-r--r-- | src/helper/mdso_create_output.c | 6 | ||||
-rw-r--r-- | src/logic/mdso_asmgen_dsometa.c | 19 | ||||
-rw-r--r-- | src/logic/mdso_asmgen_symentry.c | 17 | ||||
-rw-r--r-- | src/logic/mdso_asmgen_symfn.c | 7 | ||||
-rw-r--r-- | src/util/mdso_create_implib_sources.c | 29 |
6 files changed, 45 insertions, 41 deletions
diff --git a/include/mdso/mdso.h b/include/mdso/mdso.h index a2ac094..a0ecb0e 100644 --- a/include/mdso/mdso.h +++ b/include/mdso/mdso.h @@ -158,7 +158,7 @@ mdso_api int mdso_set_driver_fdctx (struct mdso_driver_ctx *, const struct /* helper api */ mdso_api FILE*mdso_create_archive (const struct mdso_driver_ctx *, const char * arname); -mdso_api FILE*mdso_create_asmsrc (const struct mdso_driver_ctx *, const char * asmname); +mdso_api int mdso_create_asmsrc (const struct mdso_driver_ctx *, const char * asmname); mdso_api FILE*mdso_create_object (const struct mdso_driver_ctx *, const char * objname); /* utility api */ @@ -181,9 +181,9 @@ mdso_api int mdso_unmap_input (struct mdso_input *); mdso_api uint32_t mdso_crc32_mbstr (const unsigned char *, size_t *); mdso_api uint64_t mdso_crc64_mbstr (const unsigned char *, size_t *); -mdso_api int mdso_asmgen_dsometa (const struct mdso_driver_ctx *, FILE *); -mdso_api int mdso_asmgen_symentry (const struct mdso_driver_ctx *, const char *, FILE *); -mdso_api int mdso_asmgen_symfn (const struct mdso_driver_ctx *, const char *, FILE *); +mdso_api int mdso_asmgen_dsometa (const struct mdso_driver_ctx *, int); +mdso_api int mdso_asmgen_symentry (const struct mdso_driver_ctx *, const char *, int); +mdso_api int mdso_asmgen_symfn (const struct mdso_driver_ctx *, const char *, int); mdso_api int mdso_objgen_dsometa (const struct mdso_driver_ctx *, FILE *, struct mdso_object *); mdso_api int mdso_objgen_symentry (const struct mdso_driver_ctx *, const char *, FILE *, struct mdso_object *); diff --git a/src/helper/mdso_create_output.c b/src/helper/mdso_create_output.c index f94524b..24ed757 100644 --- a/src/helper/mdso_create_output.c +++ b/src/helper/mdso_create_output.c @@ -58,13 +58,13 @@ FILE * mdso_create_archive( return mdso_create_output_stream(dctx,arname); } -FILE * mdso_create_asmsrc( +int mdso_create_asmsrc( const struct mdso_driver_ctx * dctx, const char * asmname) { return dctx->cctx->dstdir - ? mdso_create_output_stream(dctx,asmname) - : stdout; + ? mdso_create_output(dctx,asmname) + : mdso_driver_fdout(dctx); } FILE * mdso_create_object( diff --git a/src/logic/mdso_asmgen_dsometa.c b/src/logic/mdso_asmgen_dsometa.c index 4643e98..7c0b5ba 100644 --- a/src/logic/mdso_asmgen_dsometa.c +++ b/src/logic/mdso_asmgen_dsometa.c @@ -9,6 +9,7 @@ #include <mdso/mdso.h> #include <mdso/mdso_specs.h> +#include "mdso_dprintf_impl.h" #include "mdso_errinfo_impl.h" static const char * const asm_hdr_lines[] = { @@ -40,7 +41,7 @@ static const char * const asm_libname_fmt = int mdso_asmgen_dsometa( const struct mdso_driver_ctx * dctx, - FILE * fout) + int fdout) { const char * const * line; const char * alignstr; @@ -55,29 +56,29 @@ int mdso_asmgen_dsometa( } for (line=asm_hdr_lines; *line; line++) - if ((fprintf(fout,*line,dctx->cctx->libname)) < 0) + if ((mdso_dprintf(fdout,*line,dctx->cctx->libname)) < 0) return MDSO_FILE_ERROR(dctx); - if ((fputs(alignstr,fout)) < 0) + if (mdso_dprintf(fdout,alignstr) < 0) return MDSO_FILE_ERROR(dctx); - if ((fprintf(fout,".dsometa_%s:\n",dctx->cctx->libname)) < 0) + if ((mdso_dprintf(fdout,".dsometa_%s:\n",dctx->cctx->libname)) < 0) return MDSO_FILE_ERROR(dctx); - if ((fprintf(fout,"\t%s\t%d\t\t# base\n",ptrsize,0)) < 0) + if ((mdso_dprintf(fdout,"\t%s\t%d\t\t# base\n",ptrsize,0)) < 0) return MDSO_FILE_ERROR(dctx); - if ((fprintf(fout,"\t%s\t%s\t# name\n",ptrsize,".libname")) < 0) + if ((mdso_dprintf(fdout,"\t%s\t%s\t# name\n",ptrsize,".libname")) < 0) return MDSO_FILE_ERROR(dctx); - if ((fprintf(fout,"\t%s\t%u\t\t# flags\n",".long",dctx->cctx->dsoflags)) < 0) + if ((mdso_dprintf(fdout,"\t%s\t%u\t\t# flags\n",".long",dctx->cctx->dsoflags)) < 0) return MDSO_FILE_ERROR(dctx); for (line=asm_meta_lines; *line; line++) - if ((fprintf(fout,*line,ptrsize)) < 0) + if ((mdso_dprintf(fdout,*line,ptrsize)) < 0) return MDSO_FILE_ERROR(dctx); - if (fprintf(fout,asm_libname_fmt,dctx->cctx->libname) < 0) + if (mdso_dprintf(fdout,asm_libname_fmt,dctx->cctx->libname) < 0) return MDSO_FILE_ERROR(dctx); return 0; diff --git a/src/logic/mdso_asmgen_symentry.c b/src/logic/mdso_asmgen_symentry.c index 2b1541f..67ea686 100644 --- a/src/logic/mdso_asmgen_symentry.c +++ b/src/logic/mdso_asmgen_symentry.c @@ -9,6 +9,7 @@ #include <mdso/mdso.h> #include <mdso/mdso_specs.h> +#include "mdso_dprintf_impl.h" #include "mdso_errinfo_impl.h" static const char * const asm_lines[] = { @@ -22,14 +23,14 @@ static const char * const asm_lines[] = { int mdso_asmgen_symentry( const struct mdso_driver_ctx * dctx, const char * sym, - FILE * fout) + int fdout) { const char * const * line; const char * alignstr; const char * ptrsize; const char * uscore; - if (fprintf(fout,"\t.file \".%s_symentry.s\"\n",sym) < 0) + if (mdso_dprintf(fdout,"\t.file \".%s_symentry.s\"\n",sym) < 0) return MDSO_FILE_ERROR(dctx); if (dctx->cctx->drvflags & MDSO_DRIVER_QUAD_PTR) { @@ -43,22 +44,22 @@ int mdso_asmgen_symentry( } for (line=asm_lines; *line; line++) - if ((fprintf(fout,*line,sym)) < 0) + if ((mdso_dprintf(fdout,*line,sym)) < 0) return MDSO_FILE_ERROR(dctx); - if (fprintf(fout,"\t.globl __imp_%s%s\n",uscore,sym) < 0) + if (mdso_dprintf(fdout,"\t.globl __imp_%s%s\n",uscore,sym) < 0) return MDSO_FILE_ERROR(dctx); - if ((fputs(alignstr,fout)) < 0) + if (mdso_dprintf(fdout,alignstr) < 0) return MDSO_FILE_ERROR(dctx); - if ((fprintf(fout,"__imp_%s%s:\n",uscore,sym)) < 0) + if ((mdso_dprintf(fdout,"__imp_%s%s:\n",uscore,sym)) < 0) return MDSO_FILE_ERROR(dctx); - if ((fprintf(fout,"\t%s\t.symstr\n",ptrsize)) < 0) + if ((mdso_dprintf(fdout,"\t%s\t.symstr\n",ptrsize)) < 0) return MDSO_FILE_ERROR(dctx); - if ((fprintf(fout,"\t%s\t.dsometa_%s\n",ptrsize,dctx->cctx->libname)) < 0) + if ((mdso_dprintf(fdout,"\t%s\t.dsometa_%s\n",ptrsize,dctx->cctx->libname)) < 0) return MDSO_FILE_ERROR(dctx); return 0; diff --git a/src/logic/mdso_asmgen_symfn.c b/src/logic/mdso_asmgen_symfn.c index e9484af..e63ec5d 100644 --- a/src/logic/mdso_asmgen_symfn.c +++ b/src/logic/mdso_asmgen_symfn.c @@ -8,6 +8,7 @@ #include <stdio.h> #include <mdso/mdso.h> +#include "mdso_dprintf_impl.h" #include "mdso_errinfo_impl.h" static const char * const asm_lines[] = { @@ -23,19 +24,19 @@ static const char * const asm_lines[] = { int mdso_asmgen_symfn( const struct mdso_driver_ctx * dctx, const char * sym, - FILE * fout) + int fdout) { const char * const * line; const char * uscore; - if (fprintf(fout,"\t.file \".%s_symfn.s\"\n",sym) < 0) + if (mdso_dprintf(fdout,"\t.file \".%s_symfn.s\"\n",sym) < 0) return MDSO_FILE_ERROR(dctx); uscore = (dctx->cctx->drvflags & MDSO_DRIVER_QUAD_PTR) ? "" : "_"; for (line=asm_lines; *line; line++) - if (fprintf(fout,*line,uscore,sym) < 0) + if (mdso_dprintf(fdout,*line,uscore,sym) < 0) return MDSO_FILE_ERROR(dctx); return 0; diff --git a/src/util/mdso_create_implib_sources.c b/src/util/mdso_create_implib_sources.c index 5c320eb..1ee647d 100644 --- a/src/util/mdso_create_implib_sources.c +++ b/src/util/mdso_create_implib_sources.c @@ -9,6 +9,7 @@ #include <string.h> #include <mdso/mdso.h> +#include "mdso_driver_impl.h" #include "mdso_errinfo_impl.h" static void mdso_init_asmname(char * buf, const char * fmt, const char * str) @@ -24,11 +25,11 @@ static void mdso_init_asmname(char * buf, const char * fmt, const char * str) sprintf(buf,fmt,str); } -mdso_api int mdso_create_implib_sources(const struct mdso_driver_ctx * dctx) +int mdso_create_implib_sources(const struct mdso_driver_ctx * dctx) { struct mdso_unit_ctx * uctx; const char ** unit; - FILE * fout; + int fdout; char asmname[PATH_MAX]; const char * const * sym; int ret; @@ -42,13 +43,13 @@ mdso_api int mdso_create_implib_sources(const struct mdso_driver_ctx * dctx) for (sym=uctx->syms; *sym; sym++) { mdso_init_asmname(asmname,".%s_symentry.s",*sym); - if (!(fout = mdso_create_asmsrc(dctx,asmname))) + if ((fdout = mdso_create_asmsrc(dctx,asmname)) < 0) return MDSO_NESTED_ERROR(dctx); - ret = mdso_asmgen_symentry(dctx,*sym,fout); + ret = mdso_asmgen_symentry(dctx,*sym,fdout); - if (fout != stdout) - fclose(fout); + if (fdout != mdso_driver_fdout(dctx)) + close(fdout); if (ret < 0) return MDSO_NESTED_ERROR(dctx); @@ -56,13 +57,13 @@ mdso_api int mdso_create_implib_sources(const struct mdso_driver_ctx * dctx) if (uctx->stype[sym-uctx->syms] == MDSO_SYMBOL_TYPE_CODE) { mdso_init_asmname(asmname,".%s_symfn.s",*sym); - if (!(fout = mdso_create_asmsrc(dctx,asmname))) + if ((fdout = mdso_create_asmsrc(dctx,asmname)) < 0) return MDSO_NESTED_ERROR(dctx); - ret = mdso_asmgen_symfn(dctx,*sym,fout); + ret = mdso_asmgen_symfn(dctx,*sym,fdout); - if (fout != stdout) - fclose(fout); + if (fdout != mdso_driver_fdout(dctx)) + close(fdout); if (ret < 0) return MDSO_NESTED_ERROR(dctx); @@ -75,13 +76,13 @@ mdso_api int mdso_create_implib_sources(const struct mdso_driver_ctx * dctx) /* dsometa */ mdso_init_asmname(asmname,".dsometa_%s.s",dctx->cctx->libname); - if (!(fout = mdso_create_asmsrc(dctx,asmname))) + if ((fdout = mdso_create_asmsrc(dctx,asmname)) < 0) return MDSO_NESTED_ERROR(dctx); - ret = mdso_asmgen_dsometa(dctx,fout); + ret = mdso_asmgen_dsometa(dctx,fdout); - if (fout != stdout) - fclose(fout); + if (fdout != mdso_driver_fdout(dctx)) + close(fdout); return (ret < 0) ? MDSO_NESTED_ERROR(dctx) : 0; } |