summaryrefslogtreecommitdiffhomepage
path: root/src/archive
diff options
context:
space:
mode:
Diffstat (limited to 'src/archive')
-rw-r--r--src/archive/mdso_argen_common.c62
1 files changed, 8 insertions, 54 deletions
diff --git a/src/archive/mdso_argen_common.c b/src/archive/mdso_argen_common.c
index 5b534cf..a2553c0 100644
--- a/src/archive/mdso_argen_common.c
+++ b/src/archive/mdso_argen_common.c
@@ -51,14 +51,11 @@ static void mdso_write_big_endian_long(unsigned char * ch, uint32_t val)
int mdso_argen_common(
const struct mdso_driver_ctx * dctx,
const char ** symv,
- const int * stype,
struct mdso_object * vobj)
{
int ret;
const char ** psym;
- int nsym;
- int nobj;
- int ndata;
+ intptr_t nobj;
uint32_t objlen;
uint32_t hdrlen;
uint32_t mapstrsnum;
@@ -78,16 +75,16 @@ int mdso_argen_common(
/* init */
memset(sobj,0,sizeof(sobj));
- for (nsym=0,ndata=0,psym=symv; *psym; psym++,nsym++)
- ndata += (stype[psym-symv] == MDSO_SYMBOL_TYPE_DATA);
+ for (psym=symv; *psym; psym++)
+ (void)0;
- if ((nobj = 1 + (2*nsym) - ndata) < 256)
+ if ((nobj = psym - symv) < 255)
aobj = sobj;
else if (nobj > 1024*1024)
return MDSO_CUSTOM_ERROR(dctx,MDSO_ERR_INVALID_VECTOR);
- else if (!(aobj = calloc(1,nobj*sizeof(*aobj))))
+ else if (!(aobj = calloc(1,++nobj*sizeof(*aobj))))
return MDSO_SYSTEM_ERROR(dctx);
/* objlen: archive signature, index header */
@@ -107,24 +104,9 @@ int mdso_argen_common(
mapstrslen = aobj->mapstrslen;
mapstrsnum = aobj->mapstrsnum;
- /* objlen: symfn, symentry */
+ /* objlen: symentry */
for (psym=symv,pobj=&aobj[1]; *psym && !ret; psym++) {
- if (stype[psym-symv] == MDSO_SYMBOL_TYPE_CODE) {
- ret = mdso_objgen_symfn(dctx,*psym,pobj);
-
- pobj->size += 1;
- pobj->size |= 1;
- pobj->size ^= 1;
-
- objlen += pobj->size;
- objlen += sizeof(struct pe_raw_archive_common_hdr);
-
- mapstrslen += pobj->mapstrslen;
- mapstrsnum += pobj->mapstrsnum;
- pobj++;
- }
-
- ret |= mdso_objgen_symentry(dctx,*psym,pobj);
+ ret = mdso_objgen_symentry(dctx,*psym,pobj);
pobj->size += 1;
pobj->size |= 1;
@@ -221,36 +203,8 @@ int mdso_argen_common(
mark += aobj->arhdrlen + aobj->size;
mapstrs += aobj->mapstrslen;
- /* archive symfn and symentry objects */
+ /* archive symentry objects */
for (psym=symv,pobj=&aobj[1]; *psym && !ret; psym++) {
- /* symfn object */
- if (stype[psym-symv] == MDSO_SYMBOL_TYPE_CODE) {
- pobj->mapstrs = mapstrs;
- pobj->arhdrpos = (uint32_t)(mark - ar);
- pobj->arhdrlen = sizeof(struct pe_raw_archive_common_hdr);
- pobj->addr = &mark[pobj->arhdrlen];
-
- for (symidx=0; symidx<pobj->mapstrsnum; symidx++) {
- mdso_write_big_endian_long(idx,pobj->arhdrpos);
- idx += sizeof(uint32_t);
- }
-
- ret = mdso_objgen_symfn(dctx,*psym,pobj);
-
- sprintf(
- objname,"f%06zu.o",
- psym - symv);
-
- mdso_argen_common_hdr(
- (struct pe_raw_archive_common_hdr *)mark,
- objname,pobj->size);
-
- mark += pobj->arhdrlen + pobj->size;
- mapstrs += pobj->mapstrslen;
- pobj++;
- }
-
-
/* symentry object */
pobj->mapstrs = mapstrs;
pobj->arhdrpos = (uint32_t)(mark - ar);