annotate objgrep/dumpmatch.c @ 171:ddbfc1a1a811

objgrep: -s implemented
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Fri, 04 Jul 2014 03:07:09 +0000
parents
children 452baa748747
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
171
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * objgrep: output on matches
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 */
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 #include <sys/types.h>
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <stdio.h>
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <stdint.h>
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <stdlib.h>
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 #include <string.h>
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 #include <strings.h>
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 #include "intstruct.h"
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 #include "coffconst.h"
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 #include "globals.h"
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 extern unsigned get_u16(), get_u32();
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 dump_symtab_on_match()
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 {
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 unsigned n;
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 struct internal_syment *sym;
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 printf("\nThis source section's symbols:\n\n");
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 for (n = 0; n < nsymtab; n++) {
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 sym = symtab[n];
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 if (!sym)
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 continue;
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 if (sym->section != grep_section)
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 continue;
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 switch (sym->class) {
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 case C_EXT:
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 printf("%s = %08X\n", sym->name,
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 sym->value + match_offset);
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 continue;
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 case C_STAT:
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 printf("%s:%s = %08X\n", objfilename, sym->name,
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 sym->value + match_offset);
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 continue;
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 }
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 }
ddbfc1a1a811 objgrep: -s implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40 }