FreeCalypso > hg > freecalypso-reveng
changeset 80:da103b9377e3
tiobjd: preparation for symbol sorting
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Wed, 26 Mar 2014 02:44:19 +0000 |
parents | 8f4996bff904 |
children | 192da19c7506 |
files | ticoff/intstruct.h ticoff/symtab.c ticoff/tables.c |
diffstat | 3 files changed, 20 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/ticoff/intstruct.h Wed Mar 26 02:00:44 2014 +0000 +++ b/ticoff/intstruct.h Wed Mar 26 02:44:19 2014 +0000 @@ -12,6 +12,8 @@ unsigned nreloc; unsigned nlineent; unsigned flags; + unsigned nsymbols; + struct internal_syment **sorted_symbols; }; struct internal_syment { @@ -21,4 +23,5 @@ int type; int class; u_char *aux; + struct internal_scnhdr *section; };
--- a/ticoff/symtab.c Wed Mar 26 02:00:44 2014 +0000 +++ b/ticoff/symtab.c Wed Mar 26 02:44:19 2014 +0000 @@ -72,8 +72,8 @@ sym = symtab[n]; if (!sym) continue; - if (sym->scnum >= 1 && (unsigned)sym->scnum <= nsections) - sec = sections[sym->scnum - 1].name; + if (sym->section) + sec = sym->section->name; else { sprintf(secstr, "%d", sym->scnum); sec = secstr; @@ -115,7 +115,7 @@ printf("%s defines:\n\n", heading); defs_started = 1; } - printf("%s (%s)\n", sym->name, sections[sym->scnum - 1].name); + printf("%s (%s)\n", sym->name, sym->section->name); } if (defs_started) putchar('\n');
--- 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) {