FreeCalypso > hg > freecalypso-reveng
annotate ticoff/symtab.c @ 78:c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Wed, 26 Mar 2014 01:24:17 +0000 |
parents | 590396e27e96 |
children | 8f4996bff904 |
rev | line source |
---|---|
77
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * Code for working with the symbol table |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 */ |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 #include <sys/types.h> |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include <stdio.h> |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 #include "filestruct.h" |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 #include "intstruct.h" |
78
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
9 #include "coffconst.h" |
77
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 #include "globals.h" |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 |
78
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
12 static struct classmap { |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
13 int code; |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
14 char *str; |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
15 } classtab[] = { |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
16 {C_NULL, "NULL"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
17 {C_AUTO, "AUTO"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
18 {C_EXT, "EXT"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
19 {C_STAT, "STAT"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
20 {C_REG, "REG"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
21 {C_EXTREF, "EXTREF"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
22 {C_LABEL, "LABEL"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
23 {C_ULABEL, "ULABEL"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
24 {C_MOS, "MOS"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
25 {C_ARG, "ARG"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
26 {C_STRTAG, "STRTAG"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
27 {C_MOU, "MOU"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
28 {C_UNTAG, "UNTAG"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
29 {C_TPDEF, "TPDEF"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
30 {C_USTATIC, "USTATIC"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
31 {C_ENTAG, "ENTAG"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
32 {C_MOE, "MOE"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
33 {C_REGPARM, "REGPARM"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
34 {C_FIELD, "FIELD"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
35 {C_UEXT, "UEXT"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
36 {C_STATLAB, "STATLAB"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
37 {C_EXTLAB, "EXTLAB"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
38 {C_SYSTEM, "SYSTEM"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
39 {C_VARARG, "VARARG"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
40 {C_BLOCK, "BLOCK"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
41 {C_FCN, "FCN"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
42 {C_EOS, "EOS"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
43 {C_FILE, "FILE"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
44 {C_LINE, "LINE"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
45 {0, 0} |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
46 }; |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
47 |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
48 char * |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
49 storage_class_to_string(code, numbuf) |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
50 char *numbuf; |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
51 { |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
52 struct classmap *tp; |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
53 |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
54 for (tp = classtab; tp->str; tp++) |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
55 if (tp->code == code) |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
56 return(tp->str); |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
57 sprintf(numbuf, "%d", code); |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
58 return(numbuf); |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
59 } |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
60 |
77
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 dump_symtab() |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 { |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 unsigned n; |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
64 struct internal_syment *sym; |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
65 char *sec, secstr[8]; |
78
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
66 char *class, classbuf[8]; |
77
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
67 |
78
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
68 printf("%-5s %-30s %-4s %-7s %-12s %-8s\n", |
77
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
69 "Num", "Name", "Type", "Class", "Section", "Value"); |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
70 for (n = 0; n < nsymtab; n++) { |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
71 sym = symtab[n]; |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
72 if (!sym) |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
73 continue; |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 if (sym->scnum >= 1 && (unsigned)sym->scnum <= nsections) |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
75 sec = sections[sym->scnum - 1].name; |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
76 else { |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
77 sprintf(secstr, "%d", sym->scnum); |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
78 sec = secstr; |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
79 } |
78
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
80 class = storage_class_to_string(sym->class, classbuf); |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
81 printf("%-5u %-30s %04X %-7s %-12s %08X%s\n", |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
82 n, sym->name, sym->type, class, |
77
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
83 sec, sym->value, sym->aux ? " Aux" : ""); |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
84 } |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
85 return(0); |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
86 } |