summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2018-08-03 20:56:45 +0000
committermidipix <writeonce@midipix.org>2018-08-03 21:13:30 -0400
commita3e2cfa926e49bb4f63557bd990f83b8f4685734 (patch)
tree3edaf363a11a1fe1050780de272309ca0ac40db8 /src/util
parent18a091990a2de49fb0c9d85b0ae8e86825f2104f (diff)
downloadmdso-a3e2cfa926e49bb4f63557bd990f83b8f4685734.tar.bz2
mdso-a3e2cfa926e49bb4f63557bd990f83b8f4685734.tar.xz
library interfaces: object file generation: simplify, re-implement with mmap.
Diffstat (limited to 'src/util')
-rw-r--r--src/util/mdso_create_implib_objects.c42
1 files changed, 17 insertions, 25 deletions
diff --git a/src/util/mdso_create_implib_objects.c b/src/util/mdso_create_implib_objects.c
index 5740109..43f79ee 100644
--- a/src/util/mdso_create_implib_objects.c
+++ b/src/util/mdso_create_implib_objects.c
@@ -24,14 +24,19 @@ static void mdso_init_objname(char * buf, const char * fmt, const char * str)
sprintf(buf,fmt,str);
}
-mdso_api int mdso_create_implib_objects(const struct mdso_driver_ctx * dctx)
+static void mdso_init_object(struct mdso_object * obj, const char * objname)
+{
+ memset(obj,0,sizeof(*obj));
+ obj->name = objname;
+}
+
+int mdso_create_implib_objects(const struct mdso_driver_ctx * dctx)
{
- struct mdso_unit_ctx * uctx;
const char ** unit;
- FILE * fout;
- char objname[PATH_MAX];
+ struct mdso_unit_ctx * uctx;
+ struct mdso_object obj;
const char * const * sym;
- int ret;
+ char objname[PATH_MAX];
/* symentry, symfn */
for (unit=dctx->units; *unit; unit++) {
@@ -40,26 +45,16 @@ mdso_api int mdso_create_implib_objects(const struct mdso_driver_ctx * dctx)
for (sym=uctx->syms; *sym; sym++) {
mdso_init_objname(objname,".%s_symentry.o",*sym);
+ mdso_init_object(&obj,objname);
- if (!(fout = mdso_create_object(dctx,objname)))
- return MDSO_NESTED_ERROR(dctx);
-
- ret = mdso_objgen_symentry(dctx,*sym,fout,0);
- fclose(fout);
-
- if (ret < 0)
+ if (mdso_objgen_symentry(dctx,*sym,&obj) < 0)
return MDSO_NESTED_ERROR(dctx);
if (uctx->stype[sym-uctx->syms] == MDSO_SYMBOL_TYPE_CODE) {
mdso_init_objname(objname,".%s_symfn.o",*sym);
+ mdso_init_object(&obj,objname);
- if (!(fout = mdso_create_object(dctx,objname)))
- return MDSO_NESTED_ERROR(dctx);
-
- ret = mdso_objgen_symfn(dctx,*sym,fout,0);
- fclose(fout);
-
- if (ret < 0)
+ if (mdso_objgen_symfn(dctx,*sym,&obj) < 0)
return MDSO_NESTED_ERROR(dctx);
}
}
@@ -69,13 +64,10 @@ mdso_api int mdso_create_implib_objects(const struct mdso_driver_ctx * dctx)
/* dsometa */
mdso_init_objname(objname,".dsometa_%s.o",dctx->cctx->libname);
+ mdso_init_object(&obj,objname);
- if (!(fout = mdso_create_object(dctx,objname)))
+ if (mdso_objgen_dsometa(dctx,&obj) < 0)
return MDSO_NESTED_ERROR(dctx);
- ret = mdso_objgen_dsometa(dctx,fout,0);
- fclose(fout);
-
- return (ret < 0) ? MDSO_NESTED_ERROR(dctx) : 0;
-
+ return 0;
}