FreeCalypso > hg > freecalypso-reveng
changeset 77:590396e27e96
tiobjd: basics dump streamlined
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Tue, 25 Mar 2014 22:47:51 +0000 |
parents | 7a0559016b68 |
children | c2445afce514 |
files | ticoff/Makefile ticoff/basics.c ticoff/main.c ticoff/symtab.c |
diffstat | 4 files changed, 66 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/ticoff/Makefile Tue Mar 25 20:39:44 2014 +0000 +++ b/ticoff/Makefile Tue Mar 25 22:47:51 2014 +0000 @@ -1,7 +1,7 @@ CC= gcc CFLAGS= -O2 PROG= tiobjd -OBJS= basics.o globals.o lowlevel.o main.o tables.o +OBJS= basics.o globals.o lowlevel.o main.o symtab.o tables.o HDRS= filestruct.h globals.h intstruct.h all: ${PROG}
--- a/ticoff/basics.c Tue Mar 25 20:39:44 2014 +0000 +++ b/ticoff/basics.c Tue Mar 25 22:47:51 2014 +0000 @@ -27,12 +27,11 @@ return(0); } -cmd_sechdr() +dump_sechdr() { unsigned n; struct internal_scnhdr *inf; - get_int_section_table(); for (n = 0; n < nsections; n++) { inf = sections + n; printf("#%d: %s size=%u, flags=0x%x\n", n, inf->name, @@ -40,32 +39,36 @@ printf("\t%u reloc, %u line entries\n", inf->nreloc, inf->nlineent); } + return(0); +} + +cmd_sechdr() +{ + get_int_section_table(); + dump_sechdr(); exit(0); } -cmd_dumpsym() +cmd_symtab() { - unsigned n; - struct internal_syment *sym; - char *sec, secstr[8]; - get_int_section_table(); get_int_symbol_table(); - printf("%-5s %-24s %-4s %-5s %-12s %-8s\n", - "Num", "Name", "Type", "Class", "Section", "Value"); - for (n = 0; n < nsymtab; n++) { - sym = symtab[n]; - if (!sym) - continue; - if (sym->scnum >= 1 && (unsigned)sym->scnum <= nsections) - sec = sections[sym->scnum - 1].name; - else { - sprintf(secstr, "%d", sym->scnum); - sec = secstr; - } - printf("%-5u %-24s %04X %-5d %-12s %08X%s\n", - n, sym->name, sym->type, sym->class, - sec, sym->value, sym->aux ? " Aux" : ""); - } + dump_symtab(); exit(0); } + +cmd_basics() +{ + printf("%s:\n", objfilename); + dump_filehdr_info(); + putchar('\n'); + get_int_section_table(); + printf("Sections:\n\n"); + dump_sechdr(); + putchar('\n'); + get_int_symbol_table(); + printf("Symbol table:\n\n"); + dump_symtab(); + putchar('\n'); + exit(0); +}
--- a/ticoff/main.c Tue Mar 25 20:39:44 2014 +0000 +++ b/ticoff/main.c Tue Mar 25 22:47:51 2014 +0000 @@ -9,17 +9,20 @@ #include <strings.h> #include "globals.h" -extern int cmd_dumpsym(); +extern int cmd_basics(); extern int cmd_sechdr(); +extern int cmd_symtab(); extern int dump_filehdr_info(); static struct cmdtab { char *cmd; int (*func)(); } cmdtab[] = { - {"dumpsym", cmd_dumpsym}, + {"basics", cmd_basics}, + {"dumpsym", cmd_symtab}, /* backward compat */ {"hdr", dump_filehdr_info}, {"sechdr", cmd_sechdr}, + {"symtab", cmd_symtab}, {0, 0} };
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ticoff/symtab.c Tue Mar 25 22:47:51 2014 +0000 @@ -0,0 +1,34 @@ +/* + * Code for working with the symbol table + */ + +#include <sys/types.h> +#include <stdio.h> +#include "filestruct.h" +#include "intstruct.h" +#include "globals.h" + +dump_symtab() +{ + unsigned n; + struct internal_syment *sym; + char *sec, secstr[8]; + + printf("%-5s %-24s %-4s %-5s %-12s %-8s\n", + "Num", "Name", "Type", "Class", "Section", "Value"); + for (n = 0; n < nsymtab; n++) { + sym = symtab[n]; + if (!sym) + continue; + if (sym->scnum >= 1 && (unsigned)sym->scnum <= nsections) + sec = sections[sym->scnum - 1].name; + else { + sprintf(secstr, "%d", sym->scnum); + sec = secstr; + } + printf("%-5u %-24s %04X %-5d %-12s %08X%s\n", + n, sym->name, sym->type, sym->class, + sec, sym->value, sym->aux ? " Aux" : ""); + } + return(0); +}