FreeCalypso > hg > freecalypso-reveng
annotate leo-obj/tool/main.c @ 333:f8a4a330d0e6
frbl/reconst/serial.c: 0x200 static function reconstructed
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 07 Mar 2020 02:10:27 +0000 |
parents | 069b79b36228 |
children |
rev | line source |
---|---|
70 | 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 | |
77
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
75
diff
changeset
|
12 extern int cmd_basics(); |
184
069b79b36228
tiobjd: chararray extraction command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
145
diff
changeset
|
13 extern int cmd_chararray(); |
145
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
14 extern int cmd_ctypes(); |
111
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
110
diff
changeset
|
15 extern int cmd_disasm(); |
143
fbdb7686a9e9
tiobjd: raw dump of line number records implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
130
diff
changeset
|
16 extern int cmd_ln(); |
81
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
79
diff
changeset
|
17 extern int cmd_nm(); |
79
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
18 extern int cmd_profile(); |
82
c20dc315a9d4
tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
81
diff
changeset
|
19 extern int cmd_rawrel(); |
110
e650fdc743fe
tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
82
diff
changeset
|
20 extern int cmd_reloc(); |
71
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
70
diff
changeset
|
21 extern int cmd_sechdr(); |
77
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
75
diff
changeset
|
22 extern int cmd_symtab(); |
70 | 23 extern int dump_filehdr_info(); |
24 | |
25 static struct cmdtab { | |
26 char *cmd; | |
27 int (*func)(); | |
28 } cmdtab[] = { | |
77
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
75
diff
changeset
|
29 {"basics", cmd_basics}, |
184
069b79b36228
tiobjd: chararray extraction command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
145
diff
changeset
|
30 {"chararray", cmd_chararray}, |
145
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
31 {"ctypes", cmd_ctypes}, |
111
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
110
diff
changeset
|
32 {"disasm", cmd_disasm}, |
77
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
75
diff
changeset
|
33 {"dumpsym", cmd_symtab}, /* backward compat */ |
70 | 34 {"hdr", dump_filehdr_info}, |
143
fbdb7686a9e9
tiobjd: raw dump of line number records implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
130
diff
changeset
|
35 {"ln", cmd_ln}, |
81
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
79
diff
changeset
|
36 {"nm", cmd_nm}, |
79
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
37 {"profile", cmd_profile}, |
82
c20dc315a9d4
tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
81
diff
changeset
|
38 {"rawrel", cmd_rawrel}, |
110
e650fdc743fe
tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
82
diff
changeset
|
39 {"reloc", cmd_reloc}, |
71
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
70
diff
changeset
|
40 {"sechdr", cmd_sechdr}, |
77
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
75
diff
changeset
|
41 {"symtab", cmd_symtab}, |
70 | 42 {0, 0} |
43 }; | |
44 | |
45 main(argc, argv) | |
46 char **argv; | |
47 { | |
48 struct cmdtab *tp; | |
49 | |
126
2c6b1319383b
tiobjd: first preparations for adding disasm hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
111
diff
changeset
|
50 if (argc < 3) { |
2c6b1319383b
tiobjd: first preparations for adding disasm hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
111
diff
changeset
|
51 fprintf(stderr, "usage: %s <objfile> <op> [args]\n", argv[0]); |
70 | 52 exit(1); |
53 } | |
54 objfilename = argv[1]; | |
55 mmap_objfile(); | |
56 initial_parse_hdr(); | |
57 for (tp = cmdtab; tp->cmd; tp++) | |
58 if (!strcmp(tp->cmd, argv[2])) | |
59 break; | |
60 if (!tp->func) { | |
61 fprintf(stderr, "\"%s\": unknown or unimplemented command\n", | |
62 argv[2]); | |
63 exit(1); | |
64 } | |
126
2c6b1319383b
tiobjd: first preparations for adding disasm hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
111
diff
changeset
|
65 return tp->func(argc - 2, argv + 2); |
70 | 66 } |