comparison leo-obj/tool/main.c @ 130:87b82398a08b

leo-obj project subtree started, tiobjd tool moved into it
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 06 Apr 2014 22:14:39 +0000
parents ticoff/main.c@2c6b1319383b
children fbdb7686a9e9
comparison
equal deleted inserted replaced
129:597143ba1c37 130:87b82398a08b
1 /*
2 * tiobjd main() function and command dispatch
3 */
4
5 #include <sys/types.h>
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <strings.h>
10 #include "globals.h"
11
12 extern int cmd_basics();
13 extern int cmd_disasm();
14 extern int cmd_nm();
15 extern int cmd_profile();
16 extern int cmd_rawrel();
17 extern int cmd_reloc();
18 extern int cmd_sechdr();
19 extern int cmd_symtab();
20 extern int dump_filehdr_info();
21
22 static struct cmdtab {
23 char *cmd;
24 int (*func)();
25 } cmdtab[] = {
26 {"basics", cmd_basics},
27 {"disasm", cmd_disasm},
28 {"dumpsym", cmd_symtab}, /* backward compat */
29 {"hdr", dump_filehdr_info},
30 {"nm", cmd_nm},
31 {"profile", cmd_profile},
32 {"rawrel", cmd_rawrel},
33 {"reloc", cmd_reloc},
34 {"sechdr", cmd_sechdr},
35 {"symtab", cmd_symtab},
36 {0, 0}
37 };
38
39 main(argc, argv)
40 char **argv;
41 {
42 struct cmdtab *tp;
43
44 if (argc < 3) {
45 fprintf(stderr, "usage: %s <objfile> <op> [args]\n", argv[0]);
46 exit(1);
47 }
48 objfilename = argv[1];
49 mmap_objfile();
50 initial_parse_hdr();
51 for (tp = cmdtab; tp->cmd; tp++)
52 if (!strcmp(tp->cmd, argv[2]))
53 break;
54 if (!tp->func) {
55 fprintf(stderr, "\"%s\": unknown or unimplemented command\n",
56 argv[2]);
57 exit(1);
58 }
59 return tp->func(argc - 2, argv + 2);
60 }