|
|
3e55ee |
/****************************************************************/
|
|
|
3e55ee |
/* mdso: midipix dso scavenger */
|
|
|
3e55ee |
/* Copyright (C) 2015--2017 Z. Gilboa */
|
|
|
3e55ee |
/* Released under GPLv2 and GPLv3; see COPYING.MDSO. */
|
|
|
3e55ee |
/****************************************************************/
|
|
|
3e55ee |
|
|
|
3e55ee |
#include <stdint.h>
|
|
|
3e55ee |
#include <stdio.h>
|
|
|
3e55ee |
#include <string.h>
|
|
|
3e55ee |
|
|
|
3e55ee |
#include <mdso/mdso.h>
|
|
|
3e55ee |
#include "mdso_errinfo_impl.h"
|
|
|
3e55ee |
|
|
|
3e55ee |
static void mdso_init_objname(char * buf, const char * fmt, const char * str)
|
|
|
3e55ee |
{
|
|
|
3e55ee |
char hexstr[24];
|
|
|
3e55ee |
long long unsigned int crc64;
|
|
|
3e55ee |
|
|
|
3e55ee |
if (strlen(str) + strlen(fmt) > (PATH_MAX - 1)) {
|
|
|
3e55ee |
crc64 = mdso_crc64_mbstr((const unsigned char *)str,0);
|
|
|
3e55ee |
sprintf(hexstr,"%llx",crc64);
|
|
|
3e55ee |
sprintf(buf,fmt,hexstr);
|
|
|
3e55ee |
} else
|
|
|
3e55ee |
sprintf(buf,fmt,str);
|
|
|
3e55ee |
}
|
|
|
3e55ee |
|
|
|
3e55ee |
mdso_api int mdso_create_implib_objects(const struct mdso_driver_ctx * dctx)
|
|
|
3e55ee |
{
|
|
|
3e55ee |
struct mdso_unit_ctx * uctx;
|
|
|
3e55ee |
const char ** unit;
|
|
|
3e55ee |
FILE * fout;
|
|
|
3e55ee |
char objname[PATH_MAX];
|
|
|
3e55ee |
const char * const * sym;
|
|
|
3e55ee |
int ret;
|
|
|
3e55ee |
|
|
|
3e55ee |
mdso_init_objname(objname,".dsometa_%s.o",dctx->cctx->libname);
|
|
|
3e55ee |
|
|
|
3e55ee |
if (!(fout = mdso_create_object(dctx,objname)))
|
|
|
3e55ee |
return MDSO_NESTED_ERROR(dctx);
|
|
|
3e55ee |
|
|
|
3e55ee |
ret = mdso_objgen_dsometa(dctx,fout,0);
|
|
|
3e55ee |
fclose(fout);
|
|
|
3e55ee |
|
|
|
3e55ee |
if (ret < 0)
|
|
|
3e55ee |
return MDSO_NESTED_ERROR(dctx);
|
|
|
3e55ee |
|
|
|
3e55ee |
for (unit=dctx->units; *unit; unit++) {
|
|
|
3e55ee |
if (mdso_get_unit_ctx(dctx,*unit,&uctx))
|
|
|
3e55ee |
return MDSO_NESTED_ERROR(dctx);
|
|
|
3e55ee |
|
|
|
3e55ee |
for (sym=uctx->syms; *sym; sym++) {
|
|
|
3e55ee |
mdso_init_objname(objname,".%s_symentry.o",*sym);
|
|
|
3e55ee |
|
|
|
3e55ee |
if (!(fout = mdso_create_object(dctx,objname)))
|
|
|
3e55ee |
return MDSO_NESTED_ERROR(dctx);
|
|
|
3e55ee |
|
|
|
3e55ee |
ret = mdso_objgen_symentry(dctx,*sym,fout,0);
|
|
|
3e55ee |
fclose(fout);
|
|
|
3e55ee |
|
|
|
3e55ee |
if (ret < 0)
|
|
|
3e55ee |
return MDSO_NESTED_ERROR(dctx);
|
|
|
3e55ee |
|
|
|
3e55ee |
mdso_init_objname(objname,".%s_symfn.o",*sym);
|
|
|
3e55ee |
|
|
|
3e55ee |
if (!(fout = mdso_create_object(dctx,objname)))
|
|
|
3e55ee |
return MDSO_NESTED_ERROR(dctx);
|
|
|
3e55ee |
|
|
|
3e55ee |
ret = mdso_objgen_symfn(dctx,*sym,fout,0);
|
|
|
3e55ee |
fclose(fout);
|
|
|
3e55ee |
|
|
|
3e55ee |
if (ret < 0)
|
|
|
3e55ee |
return MDSO_NESTED_ERROR(dctx);
|
|
|
3e55ee |
}
|
|
|
3e55ee |
|
|
|
3e55ee |
mdso_free_unit_ctx(uctx);
|
|
|
3e55ee |
}
|
|
|
3e55ee |
|
|
|
3e55ee |
return 0;
|
|
|
3e55ee |
}
|