|
|
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 |
|
|
|
a3e2cf |
static void mdso_init_object(struct mdso_object * obj, const char * objname)
|
|
|
a3e2cf |
{
|
|
|
a3e2cf |
memset(obj,0,sizeof(*obj));
|
|
|
a3e2cf |
obj->name = objname;
|
|
|
a3e2cf |
}
|
|
|
a3e2cf |
|
|
|
a3e2cf |
int mdso_create_implib_objects(const struct mdso_driver_ctx * dctx)
|
|
|
3e55ee |
{
|
|
|
3e55ee |
const char ** unit;
|
|
|
a3e2cf |
struct mdso_unit_ctx * uctx;
|
|
|
a3e2cf |
struct mdso_object obj;
|
|
|
3e55ee |
const char * const * sym;
|
|
|
a3e2cf |
char objname[PATH_MAX];
|
|
|
3e55ee |
|
|
|
1c23fb |
/* symentry, symfn */
|
|
|
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);
|
|
|
a3e2cf |
mdso_init_object(&obj,objname);
|
|
|
3e55ee |
|
|
|
a3e2cf |
if (mdso_objgen_symentry(dctx,*sym,&obj) < 0)
|
|
|
3e55ee |
return MDSO_NESTED_ERROR(dctx);
|
|
|
3e55ee |
|
|
|
02e881 |
if (uctx->stype[sym-uctx->syms] == MDSO_SYMBOL_TYPE_CODE) {
|
|
|
02e881 |
mdso_init_objname(objname,".%s_symfn.o",*sym);
|
|
|
a3e2cf |
mdso_init_object(&obj,objname);
|
|
|
3e55ee |
|
|
|
a3e2cf |
if (mdso_objgen_symfn(dctx,*sym,&obj) < 0)
|
|
|
02e881 |
return MDSO_NESTED_ERROR(dctx);
|
|
|
02e881 |
}
|
|
|
3e55ee |
}
|
|
|
3e55ee |
|
|
|
3e55ee |
mdso_free_unit_ctx(uctx);
|
|
|
3e55ee |
}
|
|
|
3e55ee |
|
|
|
1c23fb |
/* dsometa */
|
|
|
1c23fb |
mdso_init_objname(objname,".dsometa_%s.o",dctx->cctx->libname);
|
|
|
a3e2cf |
mdso_init_object(&obj,objname);
|
|
|
1c23fb |
|
|
|
a3e2cf |
if (mdso_objgen_dsometa(dctx,&obj) < 0)
|
|
|
1c23fb |
return MDSO_NESTED_ERROR(dctx);
|
|
|
1c23fb |
|
|
|
a3e2cf |
return 0;
|
|
|
3e55ee |
}
|