annotate ticoff/main.c @ 103:a10acb1688e0

thumbdis: buglet in the decoding of sub-from-sp
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Mon, 31 Mar 2014 01:59:28 +0000
parents c20dc315a9d4
children e650fdc743fe
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
70
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * tiobjd main() function and command dispatch
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 */
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 #include <sys/types.h>
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <stdio.h>
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <stdlib.h>
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <string.h>
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 #include <strings.h>
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 #include "globals.h"
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11
77
590396e27e96 tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 75
diff changeset
12 extern int cmd_basics();
81
192da19c7506 tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 79
diff changeset
13 extern int cmd_nm();
79
8f4996bff904 tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
14 extern int cmd_profile();
82
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 81
diff changeset
15 extern int cmd_rawrel();
71
c15cd3d695c0 tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 70
diff changeset
16 extern int cmd_sechdr();
77
590396e27e96 tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 75
diff changeset
17 extern int cmd_symtab();
70
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 extern int dump_filehdr_info();
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 static struct cmdtab {
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 char *cmd;
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 int (*func)();
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 } cmdtab[] = {
77
590396e27e96 tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 75
diff changeset
24 {"basics", cmd_basics},
590396e27e96 tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 75
diff changeset
25 {"dumpsym", cmd_symtab}, /* backward compat */
70
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 {"hdr", dump_filehdr_info},
81
192da19c7506 tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 79
diff changeset
27 {"nm", cmd_nm},
79
8f4996bff904 tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 77
diff changeset
28 {"profile", cmd_profile},
82
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 81
diff changeset
29 {"rawrel", cmd_rawrel},
71
c15cd3d695c0 tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 70
diff changeset
30 {"sechdr", cmd_sechdr},
77
590396e27e96 tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 75
diff changeset
31 {"symtab", cmd_symtab},
70
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 {0, 0}
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 };
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 main(argc, argv)
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 char **argv;
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 {
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 struct cmdtab *tp;
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40 if (argc != 3) {
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41 fprintf(stderr, "usage: %s <objfile> <op>\n", argv[0]);
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42 exit(1);
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 }
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 objfilename = argv[1];
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 mmap_objfile();
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 initial_parse_hdr();
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47 for (tp = cmdtab; tp->cmd; tp++)
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 if (!strcmp(tp->cmd, argv[2]))
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 break;
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50 if (!tp->func) {
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51 fprintf(stderr, "\"%s\": unknown or unimplemented command\n",
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
52 argv[2]);
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
53 exit(1);
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54 }
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55 return tp->func();
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56 }