Fix tcc -ar c symbol header size

tcc -ar t failed sometimes because the header size was not correct.
This commit is contained in:
herman ten brugge 2022-12-28 07:38:39 +01:00
parent d15dec711d
commit 20a22cf3d6

View File

@ -70,11 +70,11 @@ ST_FUNC int tcc_tool_ar(TCCState *s1, int argc, char **argv)
{ {
static const ArHdr arhdr_init = { static const ArHdr arhdr_init = {
"/ ", "/ ",
" ", "0 ",
"0 ", "0 ",
"0 ", "0 ",
"0 ", "0 ",
" ", "0 ",
ARFMAG ARFMAG
}; };
@ -308,7 +308,7 @@ finish:
ret = 0; ret = 0;
goto the_end; goto the_end;
} }
sprintf(stmp, "%-10d", (int)(strpos + (funccnt+1) * sizeof(int))); sprintf(stmp, "%-10d", (int)(strpos + (funccnt+1) * sizeof(int)) + fpos);
memcpy(&arhdr.ar_size, stmp, 10); memcpy(&arhdr.ar_size, stmp, 10);
fwrite(&arhdr, sizeof(arhdr), 1, fh); fwrite(&arhdr, sizeof(arhdr), 1, fh);
afpos[0] = le2belong(funccnt); afpos[0] = le2belong(funccnt);