FreeCalypso > hg > freecalypso-reveng
annotate ticoff/main.c @ 121:d88f2f40e3ae
tiobjd: handling of symbol-less relocs
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Fri, 04 Apr 2014 07:19:15 +0000 |
parents | 0f94d17899b3 |
children | 2c6b1319383b |
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(); |
111
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
110
diff
changeset
|
13 extern int cmd_disasm(); |
81
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
79
diff
changeset
|
14 extern int cmd_nm(); |
79
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
15 extern int cmd_profile(); |
82
c20dc315a9d4
tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
81
diff
changeset
|
16 extern int cmd_rawrel(); |
110
e650fdc743fe
tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
82
diff
changeset
|
17 extern int cmd_reloc(); |
71
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
70
diff
changeset
|
18 extern int cmd_sechdr(); |
77
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
75
diff
changeset
|
19 extern int cmd_symtab(); |
70 | 20 extern int dump_filehdr_info(); |
21 | |
22 static struct cmdtab { | |
23 char *cmd; | |
24 int (*func)(); | |
25 } cmdtab[] = { | |
77
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
75
diff
changeset
|
26 {"basics", cmd_basics}, |
111
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
110
diff
changeset
|
27 {"disasm", cmd_disasm}, |
77
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
75
diff
changeset
|
28 {"dumpsym", cmd_symtab}, /* backward compat */ |
70 | 29 {"hdr", dump_filehdr_info}, |
81
192da19c7506
tiobjd: symbol sorting implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
79
diff
changeset
|
30 {"nm", cmd_nm}, |
79
8f4996bff904
tiobjd: profile operation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
31 {"profile", cmd_profile}, |
82
c20dc315a9d4
tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
81
diff
changeset
|
32 {"rawrel", cmd_rawrel}, |
110
e650fdc743fe
tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
82
diff
changeset
|
33 {"reloc", cmd_reloc}, |
71
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
70
diff
changeset
|
34 {"sechdr", cmd_sechdr}, |
77
590396e27e96
tiobjd: basics dump streamlined
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
75
diff
changeset
|
35 {"symtab", cmd_symtab}, |
70 | 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>\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(); | |
60 } |