annotate ticoff/symtab.c @ 77:590396e27e96

tiobjd: basics dump streamlined
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Tue, 25 Mar 2014 22:47:51 +0000
parents
children c2445afce514
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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"
590396e27e96 tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 #include "globals.h"
590396e27e96 tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10
590396e27e96 tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 dump_symtab()
590396e27e96 tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 {
590396e27e96 tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 unsigned n;
590396e27e96 tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 struct internal_syment *sym;
590396e27e96 tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 char *sec, secstr[8];
590396e27e96 tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16
590396e27e96 tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 printf("%-5s %-24s %-4s %-5s %-12s %-8s\n",
590396e27e96 tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 "Num", "Name", "Type", "Class", "Section", "Value");
590396e27e96 tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 for (n = 0; n < nsymtab; n++) {
590396e27e96 tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 sym = symtab[n];
590396e27e96 tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 if (!sym)
590396e27e96 tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 continue;
590396e27e96 tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 if (sym->scnum >= 1 && (unsigned)sym->scnum <= nsections)
590396e27e96 tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 sec = sections[sym->scnum - 1].name;
590396e27e96 tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 else {
590396e27e96 tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 sprintf(secstr, "%d", sym->scnum);
590396e27e96 tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 sec = secstr;
590396e27e96 tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 }
590396e27e96 tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 printf("%-5u %-24s %04X %-5d %-12s %08X%s\n",
590396e27e96 tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 n, sym->name, sym->type, sym->class,
590396e27e96 tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 sec, sym->value, sym->aux ? " Aux" : "");
590396e27e96 tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 }
590396e27e96 tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 return(0);
590396e27e96 tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 }