FreeCalypso > hg > freecalypso-reveng
view leo-obj/tool/basics.c @ 367:6dd0fc53bcba
pirelli/battery: battery icon experiments
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 21 Oct 2020 22:40:28 +0000 |
parents | ed533d469838 |
children |
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); } dump_sechdr() { unsigned n; struct internal_scnhdr *inf; 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); } return(0); } cmd_sechdr() { get_int_section_table(); dump_sechdr(); exit(0); } cmd_symtab(argc, argv) char **argv; { int c, show_aux = 0; while ((c = getopt(argc, argv, "a")) != EOF) switch (c) { case 'a': show_aux++; continue; default: /* error msg already printed */ exit(1); } get_int_section_table(); get_int_symbol_table(); dump_symtab(show_aux); 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(0); putchar('\n'); exit(0); }