FreeCalypso > hg > freecalypso-reveng
annotate ticoff/symtab.c @ 112:61a58677dc68
tiobjd disasm: beginning of reloc handling
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Thu, 03 Apr 2014 05:54:59 +0000 |
parents | 192da19c7506 |
children | 5f4141ee175b |
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> |
79
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
7 #include <stdlib.h> |
77
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 #include "filestruct.h" |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 #include "intstruct.h" |
78
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
10 #include "coffconst.h" |
77
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 #include "globals.h" |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 |
78
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
13 static struct classmap { |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
14 int code; |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
15 char *str; |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
16 } classtab[] = { |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
17 {C_NULL, "NULL"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
18 {C_AUTO, "AUTO"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
19 {C_EXT, "EXT"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
20 {C_STAT, "STAT"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
21 {C_REG, "REG"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
22 {C_EXTREF, "EXTREF"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
23 {C_LABEL, "LABEL"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
24 {C_ULABEL, "ULABEL"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
25 {C_MOS, "MOS"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
26 {C_ARG, "ARG"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
27 {C_STRTAG, "STRTAG"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
28 {C_MOU, "MOU"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
29 {C_UNTAG, "UNTAG"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
30 {C_TPDEF, "TPDEF"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
31 {C_USTATIC, "USTATIC"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
32 {C_ENTAG, "ENTAG"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
33 {C_MOE, "MOE"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
34 {C_REGPARM, "REGPARM"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
35 {C_FIELD, "FIELD"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
36 {C_UEXT, "UEXT"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
37 {C_STATLAB, "STATLAB"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
38 {C_EXTLAB, "EXTLAB"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
39 {C_SYSTEM, "SYSTEM"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
40 {C_VARARG, "VARARG"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
41 {C_BLOCK, "BLOCK"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
42 {C_FCN, "FCN"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
43 {C_EOS, "EOS"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
44 {C_FILE, "FILE"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
45 {C_LINE, "LINE"}, |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
46 {0, 0} |
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 |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
49 char * |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
50 storage_class_to_string(code, numbuf) |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
51 char *numbuf; |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
52 { |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
53 struct classmap *tp; |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
54 |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
55 for (tp = classtab; tp->str; tp++) |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
56 if (tp->code == code) |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
57 return(tp->str); |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
58 sprintf(numbuf, "%d", code); |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
59 return(numbuf); |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
60 } |
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
61 |
77
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 dump_symtab() |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 { |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
64 unsigned n; |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
65 struct internal_syment *sym; |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
66 char *sec, secstr[8]; |
78
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
67 char *class, classbuf[8]; |
77
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
68 |
78
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
69 printf("%-5s %-30s %-4s %-7s %-12s %-8s\n", |
77
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
70 "Num", "Name", "Type", "Class", "Section", "Value"); |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
71 for (n = 0; n < nsymtab; n++) { |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
72 sym = symtab[n]; |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
73 if (!sym) |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 continue; |
80
da103b9377e3
tiobjd: preparation for symbol sorting
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
79
diff
changeset
|
75 if (sym->section) |
da103b9377e3
tiobjd: preparation for symbol sorting
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
79
diff
changeset
|
76 sec = sym->section->name; |
77
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
77 else { |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
78 sprintf(secstr, "%d", sym->scnum); |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
79 sec = secstr; |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
80 } |
78
c2445afce514
tiobjd: symbol storage classes decoded into mnemonics
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
81 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
|
82 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
|
83 n, sym->name, sym->type, class, |
77
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
84 sec, sym->value, sym->aux ? " Aux" : ""); |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
85 } |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
86 return(0); |
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
87 } |
79
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
88 |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
89 extern_profile_report(heading) |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
90 char *heading; |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
91 { |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
92 unsigned n; |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
93 int first_extern = -1, last_extern; |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
94 struct internal_syment *sym; |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
95 int defs_started = 0; |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
96 |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
97 for (n = 0; n < nsymtab; n++) { |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
98 sym = symtab[n]; |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
99 if (!sym) |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
100 continue; |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
101 if (sym->class != C_EXT) |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
102 continue; |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
103 if (sym->scnum < 0) { |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
104 fprintf(stderr, |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
105 "symbol entry #%u: unexpected negative scnum for C_EXT\n", n); |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
106 exit(1); |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
107 } |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
108 if (sym->scnum == 0) { /* undef external ref */ |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
109 if (first_extern < 0) |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
110 first_extern = n; |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
111 last_extern = n; |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
112 continue; |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
113 } |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
114 if (!defs_started) { |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
115 printf("%s defines:\n\n", heading); |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
116 defs_started = 1; |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
117 } |
80
da103b9377e3
tiobjd: preparation for symbol sorting
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
79
diff
changeset
|
118 printf("%s (%s)\n", sym->name, sym->section->name); |
79
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
119 } |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
120 if (defs_started) |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
121 putchar('\n'); |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
122 if (first_extern < 0) |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
123 return(0); |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
124 printf("%s references:\n\n", heading); |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
125 for (n = first_extern; n <= last_extern; n++) { |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
126 sym = symtab[n]; |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
127 if (!sym) |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
128 continue; |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
129 if (sym->class != C_EXT || sym->scnum) |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
130 continue; |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
131 printf("%s\n", sym->name); |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
132 } |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
133 putchar('\n'); |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
134 return(0); |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
135 } |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
136 |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
137 cmd_profile() |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
138 { |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
139 get_int_section_table(); |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
140 get_int_symbol_table(); |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
141 extern_profile_report(objfilename); |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
142 exit(0); |
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
78
diff
changeset
|
143 } |
81
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
144 |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
145 static void |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
146 initial_fill_for_sort(sec) |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
147 struct internal_scnhdr *sec; |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
148 { |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
149 unsigned n, m; |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
150 struct internal_syment *sym; |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
151 |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
152 m = 0; |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
153 for (n = 0; n < nsymtab; n++) { |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
154 sym = symtab[n]; |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
155 if (!sym) |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
156 continue; |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
157 if (sym->section != sec) |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
158 continue; |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
159 sec->sorted_symbols[m++] = sym; |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
160 } |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
161 } |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
162 |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
163 static int |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
164 compare_for_sort(p1, p2) |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
165 struct internal_syment **p1, **p2; |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
166 { |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
167 if ((*p1)->value < (*p2)->value) |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
168 return(-1); |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
169 if ((*p1)->value > (*p2)->value) |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
170 return(1); |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
171 else |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
172 return(0); |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
173 } |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
174 |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
175 void |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
176 sort_symbols_of_sec(sec) |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
177 struct internal_scnhdr *sec; |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
178 { |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
179 if (sec->sorted_symbols) |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
180 return; |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
181 if (!sec->nsymbols) { |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
182 fprintf(stderr, |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
183 "BUG: sort_symbols_of_sec() called for section \"%s\" w/o symbols\n", |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
184 sec->name); |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
185 exit(1); |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
186 } |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
187 sec->sorted_symbols = malloc(sizeof(void *) * sec->nsymbols); |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
188 if (!sec->sorted_symbols) { |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
189 perror("malloc"); |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
190 exit(1); |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
191 } |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
192 initial_fill_for_sort(sec); |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
193 qsort(sec->sorted_symbols, sec->nsymbols, sizeof(void *), |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
194 compare_for_sort); |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
195 } |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
196 |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
197 cmd_nm() |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
198 { |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
199 unsigned n, m; |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
200 struct internal_scnhdr *sec; |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
201 struct internal_syment *sym; |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
202 char classbuf[8]; |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
203 |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
204 get_int_section_table(); |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
205 get_int_symbol_table(); |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
206 for (n = 0; n < nsections; n++) { |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
207 sec = sections + n; |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
208 if (!sec->nsymbols) |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
209 continue; |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
210 printf("%s:\n\n", sec->name); |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
211 sort_symbols_of_sec(sec); |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
212 for (m = 0; m < sec->nsymbols; m++) { |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
213 sym = sec->sorted_symbols[m]; |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
214 printf("%08X %-7s %s\n", sym->value, |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
215 storage_class_to_string(sym->class, classbuf), |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
216 sym->name); |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
217 } |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
218 putchar('\n'); |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
219 } |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
220 exit(0); |
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
221 } |