FreeCalypso > hg > freecalypso-reveng
annotate 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 |
rev | line source |
---|---|
70 | 1 /* |
74
2eef88395908
tiobjd: a little refactoring
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
73
diff
changeset
|
2 * This C module implements some "basic" dump commands |
70 | 3 */ |
4 | |
5 #include <sys/types.h> | |
6 #include <stdio.h> | |
7 #include <stdlib.h> | |
8 #include <time.h> | |
9 #include "filestruct.h" | |
74
2eef88395908
tiobjd: a little refactoring
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
73
diff
changeset
|
10 #include "intstruct.h" |
70 | 11 #include "globals.h" |
12 | |
74
2eef88395908
tiobjd: a little refactoring
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
73
diff
changeset
|
13 extern unsigned get_u16(), get_u32(); |
70 | 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(×tamp); | |
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 } | |
74
2eef88395908
tiobjd: a little refactoring
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
73
diff
changeset
|
29 |
2eef88395908
tiobjd: a little refactoring
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
73
diff
changeset
|
30 cmd_sechdr() |
2eef88395908
tiobjd: a little refactoring
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
73
diff
changeset
|
31 { |
2eef88395908
tiobjd: a little refactoring
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
73
diff
changeset
|
32 unsigned n; |
2eef88395908
tiobjd: a little refactoring
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
73
diff
changeset
|
33 struct internal_scnhdr *inf; |
2eef88395908
tiobjd: a little refactoring
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
73
diff
changeset
|
34 |
2eef88395908
tiobjd: a little refactoring
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
73
diff
changeset
|
35 get_int_section_table(); |
2eef88395908
tiobjd: a little refactoring
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
73
diff
changeset
|
36 for (n = 0; n < nsections; n++) { |
2eef88395908
tiobjd: a little refactoring
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
73
diff
changeset
|
37 inf = sections + n; |
2eef88395908
tiobjd: a little refactoring
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
73
diff
changeset
|
38 printf("#%d: %s size=%u, flags=0x%x\n", n, inf->name, |
2eef88395908
tiobjd: a little refactoring
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
73
diff
changeset
|
39 inf->size, inf->flags); |
2eef88395908
tiobjd: a little refactoring
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
73
diff
changeset
|
40 printf("\t%u reloc, %u line entries\n", |
2eef88395908
tiobjd: a little refactoring
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
73
diff
changeset
|
41 inf->nreloc, inf->nlineent); |
2eef88395908
tiobjd: a little refactoring
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
73
diff
changeset
|
42 } |
2eef88395908
tiobjd: a little refactoring
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
73
diff
changeset
|
43 exit(0); |
2eef88395908
tiobjd: a little refactoring
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
73
diff
changeset
|
44 } |
75
1a23ff9a81de
tiobjd: dumpsym implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
45 |
1a23ff9a81de
tiobjd: dumpsym implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
46 cmd_dumpsym() |
1a23ff9a81de
tiobjd: dumpsym implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
47 { |
1a23ff9a81de
tiobjd: dumpsym implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
48 unsigned n; |
1a23ff9a81de
tiobjd: dumpsym implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
49 struct internal_syment *sym; |
1a23ff9a81de
tiobjd: dumpsym implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
50 char *sec, secstr[8]; |
1a23ff9a81de
tiobjd: dumpsym implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
51 |
1a23ff9a81de
tiobjd: dumpsym implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
52 get_int_section_table(); |
1a23ff9a81de
tiobjd: dumpsym implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
53 get_int_symbol_table(); |
1a23ff9a81de
tiobjd: dumpsym implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
54 printf("%-5s %-24s %-4s %-5s %-12s %-8s\n", |
1a23ff9a81de
tiobjd: dumpsym implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
55 "Num", "Name", "Type", "Class", "Section", "Value"); |
1a23ff9a81de
tiobjd: dumpsym implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
56 for (n = 0; n < nsymtab; n++) { |
1a23ff9a81de
tiobjd: dumpsym implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
57 sym = symtab[n]; |
1a23ff9a81de
tiobjd: dumpsym implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
58 if (!sym) |
1a23ff9a81de
tiobjd: dumpsym implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
59 continue; |
1a23ff9a81de
tiobjd: dumpsym implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
60 if (sym->scnum >= 1 && (unsigned)sym->scnum <= nsections) |
1a23ff9a81de
tiobjd: dumpsym implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
61 sec = sections[sym->scnum - 1].name; |
1a23ff9a81de
tiobjd: dumpsym implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
62 else { |
1a23ff9a81de
tiobjd: dumpsym implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
63 sprintf(secstr, "%d", sym->scnum); |
1a23ff9a81de
tiobjd: dumpsym implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
64 sec = secstr; |
1a23ff9a81de
tiobjd: dumpsym implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
65 } |
1a23ff9a81de
tiobjd: dumpsym implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
66 printf("%-5u %-24s %04X %-5d %-12s %08X%s\n", |
1a23ff9a81de
tiobjd: dumpsym implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
67 n, sym->name, sym->type, sym->class, |
1a23ff9a81de
tiobjd: dumpsym implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
68 sec, sym->value, sym->aux ? " Aux" : ""); |
1a23ff9a81de
tiobjd: dumpsym implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
69 } |
1a23ff9a81de
tiobjd: dumpsym implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
70 exit(0); |
1a23ff9a81de
tiobjd: dumpsym implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
71 } |