comparison leo-obj/tool/basics.c @ 130:87b82398a08b

leo-obj project subtree started, tiobjd tool moved into it
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 06 Apr 2014 22:14:39 +0000
parents ticoff/basics.c@590396e27e96
children ed533d469838
comparison
equal deleted inserted replaced
129:597143ba1c37 130:87b82398a08b
1 /*
2 * This C module implements some "basic" dump commands
3 */
4
5 #include <sys/types.h>
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <time.h>
9 #include "filestruct.h"
10 #include "intstruct.h"
11 #include "globals.h"
12
13 extern unsigned get_u16(), get_u32();
14
15 dump_filehdr_info()
16 {
17 time_t timestamp;
18 struct tm *timedec;
19
20 timestamp = get_u32(filehdr_struct->f_timdat);
21 timedec = gmtime(&timestamp);
22 printf("timestamp: %d-%02d-%02dT%02d:%02d:%02dZ\n",
23 timedec->tm_year + 1900, timedec->tm_mon + 1, timedec->tm_mday,
24 timedec->tm_hour, timedec->tm_min, timedec->tm_sec);
25 printf("file flags: 0x%x\n", get_u16(filehdr_struct->f_flags));
26 printf("%u sections, %u symtab entries\n", nsections, nsymtab);
27 return(0);
28 }
29
30 dump_sechdr()
31 {
32 unsigned n;
33 struct internal_scnhdr *inf;
34
35 for (n = 0; n < nsections; n++) {
36 inf = sections + n;
37 printf("#%d: %s size=%u, flags=0x%x\n", n, inf->name,
38 inf->size, inf->flags);
39 printf("\t%u reloc, %u line entries\n",
40 inf->nreloc, inf->nlineent);
41 }
42 return(0);
43 }
44
45 cmd_sechdr()
46 {
47 get_int_section_table();
48 dump_sechdr();
49 exit(0);
50 }
51
52 cmd_symtab()
53 {
54 get_int_section_table();
55 get_int_symbol_table();
56 dump_symtab();
57 exit(0);
58 }
59
60 cmd_basics()
61 {
62 printf("%s:\n", objfilename);
63 dump_filehdr_info();
64 putchar('\n');
65 get_int_section_table();
66 printf("Sections:\n\n");
67 dump_sechdr();
68 putchar('\n');
69 get_int_symbol_table();
70 printf("Symbol table:\n\n");
71 dump_symtab();
72 putchar('\n');
73 exit(0);
74 }