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