FreeCalypso > hg > freecalypso-reveng
view ticoff/basics.c @ 75:1a23ff9a81de
tiobjd: dumpsym implemented
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Tue, 25 Mar 2014 20:38:31 +0000 |
parents | 2eef88395908 |
children | 590396e27e96 |
line wrap: on
line source
/* * This C module implements some "basic" dump commands */ #include <sys/types.h> #include <stdio.h> #include <stdlib.h> #include <time.h> #include "filestruct.h" #include "intstruct.h" #include "globals.h" extern unsigned get_u16(), get_u32(); dump_filehdr_info() { time_t timestamp; struct tm *timedec; timestamp = get_u32(filehdr_struct->f_timdat); timedec = gmtime(×tamp); printf("timestamp: %d-%02d-%02dT%02d:%02d:%02dZ\n", timedec->tm_year + 1900, timedec->tm_mon + 1, timedec->tm_mday, timedec->tm_hour, timedec->tm_min, timedec->tm_sec); printf("file flags: 0x%x\n", get_u16(filehdr_struct->f_flags)); printf("%u sections, %u symtab entries\n", nsections, nsymtab); return(0); } cmd_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, inf->size, inf->flags); printf("\t%u reloc, %u line entries\n", inf->nreloc, inf->nlineent); } exit(0); } cmd_dumpsym() { 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" : ""); } exit(0); }