comparison ticoff/symtab.c @ 79:8f4996bff904

tiobjd: profile operation implemented
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Wed, 26 Mar 2014 02:00:44 +0000
parents c2445afce514
children da103b9377e3
comparison
equal deleted inserted replaced
78:c2445afce514 79:8f4996bff904
2 * Code for working with the symbol table 2 * Code for working with the symbol table
3 */ 3 */
4 4
5 #include <sys/types.h> 5 #include <sys/types.h>
6 #include <stdio.h> 6 #include <stdio.h>
7 #include <stdlib.h>
7 #include "filestruct.h" 8 #include "filestruct.h"
8 #include "intstruct.h" 9 #include "intstruct.h"
9 #include "coffconst.h" 10 #include "coffconst.h"
10 #include "globals.h" 11 #include "globals.h"
11 12
82 n, sym->name, sym->type, class, 83 n, sym->name, sym->type, class,
83 sec, sym->value, sym->aux ? " Aux" : ""); 84 sec, sym->value, sym->aux ? " Aux" : "");
84 } 85 }
85 return(0); 86 return(0);
86 } 87 }
88
89 extern_profile_report(heading)
90 char *heading;
91 {
92 unsigned n;
93 int first_extern = -1, last_extern;
94 struct internal_syment *sym;
95 int defs_started = 0;
96
97 for (n = 0; n < nsymtab; n++) {
98 sym = symtab[n];
99 if (!sym)
100 continue;
101 if (sym->class != C_EXT)
102 continue;
103 if (sym->scnum < 0) {
104 fprintf(stderr,
105 "symbol entry #%u: unexpected negative scnum for C_EXT\n", n);
106 exit(1);
107 }
108 if (sym->scnum == 0) { /* undef external ref */
109 if (first_extern < 0)
110 first_extern = n;
111 last_extern = n;
112 continue;
113 }
114 if (!defs_started) {
115 printf("%s defines:\n\n", heading);
116 defs_started = 1;
117 }
118 printf("%s (%s)\n", sym->name, sections[sym->scnum - 1].name);
119 }
120 if (defs_started)
121 putchar('\n');
122 if (first_extern < 0)
123 return(0);
124 printf("%s references:\n\n", heading);
125 for (n = first_extern; n <= last_extern; n++) {
126 sym = symtab[n];
127 if (!sym)
128 continue;
129 if (sym->class != C_EXT || sym->scnum)
130 continue;
131 printf("%s\n", sym->name);
132 }
133 putchar('\n');
134 return(0);
135 }
136
137 cmd_profile()
138 {
139 get_int_section_table();
140 get_int_symbol_table();
141 extern_profile_report(objfilename);
142 exit(0);
143 }