FreeCalypso > hg > freecalypso-reveng
diff ticoff/tables.c @ 80:da103b9377e3
tiobjd: preparation for symbol sorting
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Wed, 26 Mar 2014 02:44:19 +0000 |
parents | 1a23ff9a81de |
children | e650fdc743fe |
line wrap: on
line diff
--- a/ticoff/tables.c Wed Mar 26 02:00:44 2014 +0000 +++ b/ticoff/tables.c Wed Mar 26 02:44:19 2014 +0000 @@ -75,6 +75,8 @@ fprintf(stderr, "warning: section #%u (%s): some nonzero value in s_page bytes\n", n, sections[n].name); + sections[n].nsymbols = 0; + sections[n].sorted_symbols = 0; } } @@ -98,11 +100,20 @@ in->name = get_secorsym_name(symtab_raw[n].e_name); in->value = get_u32(symtab_raw[n].e_value); in->scnum = get_s16(symtab_raw[n].e_scnum); - if (in->scnum < -2 || in->scnum > (int)nsections) { + if (in->scnum > 0) { + if (in->scnum > nsections) { + fprintf(stderr, + "symtab entry #%u: scnum too big\n", n); + exit(1); + } + in->section = sections + in->scnum - 1; + in->section->nsymbols++; + } else if (in->scnum < -2) { fprintf(stderr, - "symtab entry #%u: scnum out of range\n", n); + "symtab entry #%u: scnum < -2\n", n); exit(1); - } + } else + in->section = 0; in->type = get_u16(symtab_raw[n].e_type); in->class = symtab_raw[n].e_sclass; switch (symtab_raw[n++].e_numaux) {