summaryrefslogtreecommitdiff
path: root/src/logic
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2018-08-03 07:53:34 +0000
committermidipix <writeonce@midipix.org>2018-08-03 21:13:30 -0400
commit18a091990a2de49fb0c9d85b0ae8e86825f2104f (patch)
treebd01adba7687618857a1866790c3ed4f9346f319 /src/logic
parent3d38ce6b746e9d6f4e0b7dc251d88dba78fb0a47 (diff)
downloadmdso-18a091990a2de49fb0c9d85b0ae8e86825f2104f.tar.bz2
mdso-18a091990a2de49fb0c9d85b0ae8e86825f2104f.tar.xz
library interfaces: asm source generation: re-implement w. pure fdio and fdctx.
Diffstat (limited to 'src/logic')
-rw-r--r--src/logic/mdso_asmgen_dsometa.c19
-rw-r--r--src/logic/mdso_asmgen_symentry.c17
-rw-r--r--src/logic/mdso_asmgen_symfn.c7
3 files changed, 23 insertions, 20 deletions
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;