# HG changeset patch # User Michael Spacefalcon # Date 1395787671 0 # Node ID 590396e27e96b0ceff60ba1869b8d4f454a70d9f # Parent 7a0559016b680dd69e69cf28ad5f9a95c921961a tiobjd: basics dump streamlined diff -r 7a0559016b68 -r 590396e27e96 ticoff/Makefile --- 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} diff -r 7a0559016b68 -r 590396e27e96 ticoff/basics.c --- 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); +} diff -r 7a0559016b68 -r 590396e27e96 ticoff/main.c --- 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 #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} }; diff -r 7a0559016b68 -r 590396e27e96 ticoff/symtab.c --- /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 +#include +#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); +}