comparison 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
comparison
equal deleted inserted replaced
77:590396e27e96 78:c2445afce514
4 4
5 #include <sys/types.h> 5 #include <sys/types.h>
6 #include <stdio.h> 6 #include <stdio.h>
7 #include "filestruct.h" 7 #include "filestruct.h"
8 #include "intstruct.h" 8 #include "intstruct.h"
9 #include "coffconst.h"
9 #include "globals.h" 10 #include "globals.h"
11
12 static struct classmap {
13 int code;
14 char *str;
15 } classtab[] = {
16 {C_NULL, "NULL"},
17 {C_AUTO, "AUTO"},
18 {C_EXT, "EXT"},
19 {C_STAT, "STAT"},
20 {C_REG, "REG"},
21 {C_EXTREF, "EXTREF"},
22 {C_LABEL, "LABEL"},
23 {C_ULABEL, "ULABEL"},
24 {C_MOS, "MOS"},
25 {C_ARG, "ARG"},
26 {C_STRTAG, "STRTAG"},
27 {C_MOU, "MOU"},
28 {C_UNTAG, "UNTAG"},
29 {C_TPDEF, "TPDEF"},
30 {C_USTATIC, "USTATIC"},
31 {C_ENTAG, "ENTAG"},
32 {C_MOE, "MOE"},
33 {C_REGPARM, "REGPARM"},
34 {C_FIELD, "FIELD"},
35 {C_UEXT, "UEXT"},
36 {C_STATLAB, "STATLAB"},
37 {C_EXTLAB, "EXTLAB"},
38 {C_SYSTEM, "SYSTEM"},
39 {C_VARARG, "VARARG"},
40 {C_BLOCK, "BLOCK"},
41 {C_FCN, "FCN"},
42 {C_EOS, "EOS"},
43 {C_FILE, "FILE"},
44 {C_LINE, "LINE"},
45 {0, 0}
46 };
47
48 char *
49 storage_class_to_string(code, numbuf)
50 char *numbuf;
51 {
52 struct classmap *tp;
53
54 for (tp = classtab; tp->str; tp++)
55 if (tp->code == code)
56 return(tp->str);
57 sprintf(numbuf, "%d", code);
58 return(numbuf);
59 }
10 60
11 dump_symtab() 61 dump_symtab()
12 { 62 {
13 unsigned n; 63 unsigned n;
14 struct internal_syment *sym; 64 struct internal_syment *sym;
15 char *sec, secstr[8]; 65 char *sec, secstr[8];
66 char *class, classbuf[8];
16 67
17 printf("%-5s %-24s %-4s %-5s %-12s %-8s\n", 68 printf("%-5s %-30s %-4s %-7s %-12s %-8s\n",
18 "Num", "Name", "Type", "Class", "Section", "Value"); 69 "Num", "Name", "Type", "Class", "Section", "Value");
19 for (n = 0; n < nsymtab; n++) { 70 for (n = 0; n < nsymtab; n++) {
20 sym = symtab[n]; 71 sym = symtab[n];
21 if (!sym) 72 if (!sym)
22 continue; 73 continue;
24 sec = sections[sym->scnum - 1].name; 75 sec = sections[sym->scnum - 1].name;
25 else { 76 else {
26 sprintf(secstr, "%d", sym->scnum); 77 sprintf(secstr, "%d", sym->scnum);
27 sec = secstr; 78 sec = secstr;
28 } 79 }
29 printf("%-5u %-24s %04X %-5d %-12s %08X%s\n", 80 class = storage_class_to_string(sym->class, classbuf);
30 n, sym->name, sym->type, sym->class, 81 printf("%-5u %-30s %04X %-7s %-12s %08X%s\n",
82 n, sym->name, sym->type, class,
31 sec, sym->value, sym->aux ? " Aux" : ""); 83 sec, sym->value, sym->aux ? " Aux" : "");
32 } 84 }
33 return(0); 85 return(0);
34 } 86 }