annotate leo-obj/tool/main.c @ 381:ca75ac283888

compal/audio: analysis of handheld mode omr readouts made by Das Signal
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 09 Nov 2021 18:49:09 +0000
parents 069b79b36228
children
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();
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
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 extern int dump_filehdr_info();
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 static struct cmdtab {
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 char *cmd;
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 int (*func)();
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
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
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
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
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42 {0, 0}
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
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 main(argc, argv)
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 char **argv;
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47 {
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 struct cmdtab *tp;
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
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
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
52 exit(1);
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
53 }
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54 objfilename = argv[1];
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55 mmap_objfile();
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56 initial_parse_hdr();
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
57 for (tp = cmdtab; tp->cmd; tp++)
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
58 if (!strcmp(tp->cmd, argv[2]))
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
59 break;
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
60 if (!tp->func) {
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
61 fprintf(stderr, "\"%s\": unknown or unimplemented command\n",
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
62 argv[2]);
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
63 exit(1);
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
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
6799a5c57a49 tiobjd started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
66 }