|
|
c70c0a |
/****************************************************************/
|
|
|
c70c0a |
/* mdso: midipix dso scavenger */
|
|
|
d5fc3d |
/* Copyright (C) 2015--2021 SysDeer Technologies, LLC */
|
|
|
c70c0a |
/* Released under GPLv2 and GPLv3; see COPYING.MDSO. */
|
|
|
c70c0a |
/****************************************************************/
|
|
|
c70c0a |
|
|
|
c70c0a |
#include <stdint.h>
|
|
|
c70c0a |
#include <stdio.h>
|
|
|
c70c0a |
#include <stdlib.h>
|
|
|
c70c0a |
#include <string.h>
|
|
|
c70c0a |
|
|
|
c70c0a |
#include <mdso/mdso.h>
|
|
|
c70c0a |
#include "mdso_errinfo_impl.h"
|
|
|
c70c0a |
|
|
|
a6209c |
static void mdso_free_uctx_vector(
|
|
|
a6209c |
struct mdso_unit_ctx ** uctxv,
|
|
|
8535b6 |
const char ** symv)
|
|
|
c70c0a |
{
|
|
|
c70c0a |
struct mdso_unit_ctx ** puctx;
|
|
|
c70c0a |
|
|
|
a6209c |
if (symv)
|
|
|
a6209c |
free(symv);
|
|
|
a6209c |
|
|
|
c70c0a |
for (puctx=uctxv; *puctx; puctx++)
|
|
|
c70c0a |
mdso_free_unit_ctx(*puctx);
|
|
|
c70c0a |
|
|
|
c70c0a |
free(uctxv);
|
|
|
c70c0a |
}
|
|
|
c70c0a |
|
|
|
c70c0a |
int mdso_create_implib_archive(const struct mdso_driver_ctx * dctx)
|
|
|
c70c0a |
{
|
|
|
c70c0a |
size_t nsym;
|
|
|
c70c0a |
struct mdso_unit_ctx ** uctxv;
|
|
|
c70c0a |
struct mdso_unit_ctx ** puctx;
|
|
|
2f4c03 |
struct mdso_object obj;
|
|
|
c70c0a |
const char * const * dsym;
|
|
|
c70c0a |
const char ** unit;
|
|
|
c70c0a |
const char ** psym;
|
|
|
c70c0a |
const char ** symv;
|
|
|
c70c0a |
|
|
|
c70c0a |
if (!dctx->cctx->implib)
|
|
|
c70c0a |
return MDSO_CUSTOM_ERROR(dctx,MDSO_ERR_INVALID_NAME);
|
|
|
c70c0a |
|
|
|
c70c0a |
for (unit=dctx->units; *unit; unit++)
|
|
|
c70c0a |
(void)0;
|
|
|
c70c0a |
|
|
|
c70c0a |
if (!(uctxv = calloc(++unit - dctx->units,sizeof(*uctxv))))
|
|
|
c70c0a |
return MDSO_SYSTEM_ERROR(dctx);
|
|
|
c70c0a |
|
|
|
c70c0a |
for (puctx=uctxv,unit=dctx->units; *unit; unit++) {
|
|
|
d1416c |
if (mdso_get_unit_ctx(dctx,*unit,puctx++)) {
|
|
|
8535b6 |
mdso_free_uctx_vector(uctxv,0);
|
|
|
c70c0a |
return MDSO_NESTED_ERROR(dctx);
|
|
|
c70c0a |
}
|
|
|
c70c0a |
}
|
|
|
c70c0a |
|
|
|
c70c0a |
for (nsym=0,puctx=uctxv; *puctx; puctx++)
|
|
|
c70c0a |
for (dsym=puctx[0]->syms; *dsym; dsym++)
|
|
|
c70c0a |
nsym++;
|
|
|
c70c0a |
|
|
|
a6209c |
if (!(symv = calloc(nsym+1,sizeof(const char *)))) {
|
|
|
8535b6 |
mdso_free_uctx_vector(uctxv,0);
|
|
|
c70c0a |
return MDSO_SYSTEM_ERROR(dctx);
|
|
|
c70c0a |
}
|
|
|
c70c0a |
|
|
|
a6209c |
for (psym=symv,puctx=uctxv; *puctx; puctx++) {
|
|
|
8535b6 |
for (dsym=puctx[0]->syms; *dsym; dsym++)
|
|
|
c70c0a |
*psym++ = *dsym;
|
|
|
a6209c |
}
|
|
|
c70c0a |
|
|
|
2f4c03 |
memset(&obj,0,sizeof(obj));
|
|
|
2f4c03 |
obj.name = dctx->cctx->implib;
|
|
|
2f4c03 |
|
|
|
8535b6 |
if (mdso_argen_common(dctx,symv,&obj) < 0) {
|
|
|
8535b6 |
mdso_free_uctx_vector(uctxv,symv);
|
|
|
2f4c03 |
return MDSO_NESTED_ERROR(dctx);
|
|
|
2f4c03 |
}
|
|
|
c70c0a |
|
|
|
2f4c03 |
return 0;
|
|
|
c70c0a |
}
|