annotate vos_prog_info.c @ 1044:1625555e346e

Properly handle redundant prefixes
author Michael Pavone <pavone@retrodev.com>
date Mon, 25 Jul 2016 23:16:04 -0700
parents de6f00204fa2
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
631
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
1 #include <stdio.h>
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
2 #include "vos_program_module.h"
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
3
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
4 int main(int argc, char ** argv)
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
5 {
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
6 vos_program_module header;
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
7 FILE * f = fopen(argv[1], "rb");
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
8 vos_read_header(f, &header);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
9 vos_read_alloc_module_map(f, &header);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
10 vos_read_alloc_external_vars(f, &header);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
11
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
12 printf("Version: %d\n", header.version);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
13 printf("Binder Version: %s\n", header.binder_version.str);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
14 printf("Binder Options: %s\n", header.binder_options.str);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
15 printf("System name: %s\n", header.system_name.str);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
16 printf("User name: %s\n", header.user_name.str);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
17 printf("Date bound: %d\n", header.date_bound);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
18 printf("Code addresss: 0x%X, Static address: 0x%X\n",
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
19 header.main_entry_link.code_address, header.main_entry_link.static_address);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
20 printf("User boundary: 0x%X\n", header.user_boundary);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
21 printf("Num modules: %d\n", header.n_modules);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
22 printf("Num extern vars: %d\n", header.n_external_vars);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
23 printf("Num link names: %d\n", header.n_link_names);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
24 printf("Num unsapped links: %d\n", header.n_unsnapped_links);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
25 printf("Num VM pages: %d\n", header.n_vm_pages);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
26 printf("Num header pages: %d\n", header.n_header_pages);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
27 for (int i = 0; i < 3; i++) {
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
28 for (int j = 0; j < 4; j++) {
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
29 printf("Info %d:%d\n\tAddress: 0x%X\n\tLength: 0x%X\n",
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
30 i, j, header.info[i][j].address, header.info[i][j].len);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
31 }
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
32 }
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
33 printf("Module map address: 0x%X\n", header.module_map_address);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
34 printf("Module map length: 0x%X\n", header.module_map_len);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
35 printf("External vars map address: 0x%X\n", header.external_vars_map_address);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
36 printf("External vars map length: 0x%X\n", header.external_vars_map_len);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
37 printf("Link names map address: 0x%X\n", header.link_names_map_address);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
38 printf("Link names map length: 0x%X\n", header.link_names_map_len);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
39 printf("Header address: 0x%X\n", header.header_address);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
40 printf("Header length: 0x%X\n", header.header_len);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
41 //printf("Access Info: 0x%X\n", header.header_address);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
42 printf("Flags: 0x%X\n", header.flags);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
43 printf("Num tasks: %d\n", header.n_tasks);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
44 printf("Stack Size: 0x%X\n", header.stack_len);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
45 printf("Num entries: %d\n", header.n_entries);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
46 printf("Entry map address: 0x%X\n", header.entry_map_address);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
47 printf("Entry map length: 0x%X\n", header.entry_map_len);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
48 printf("Pop Version: %d\n", header.pop_version);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
49 printf("Processor: %d\n", header.processor);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
50 printf("Processor family: %d\n", header.processor_family);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
51 printf("Release name: %s\n", header.release_name.str);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
52 printf("Relocation info:\n\tMap Addres: 0x%X\n\tMap Length: 0x%X\n\tNum Relocations: %d\n",
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
53 header.relocation_info.map_address, header.relocation_info.map_len,
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
54 header.relocation_info.n_relocations);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
55 printf("High water mark: 0x%X\n", header.high_water_mark);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
56 printf("Copyright notice: %s\n", header.program_name.str);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
57 printf("String pool address: 0x%X\n", header.string_pool_address);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
58 printf("String pool length: 0x%X\n", header.string_pool_len);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
59 printf("Object dir map address: 0x%X\n", header.obj_dir_map_address);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
60 printf("Object dir map length: 0x%X\n", header.obj_dir_map_len);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
61 puts("Global offset table addresses:");
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
62 for (int i = 0; i < 3; i++) {
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
63 printf("\t%d: 0x%X\n", i, header.global_offset_table_address[i]);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
64 }
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
65 for (int i = 0; i < 3; i++) {
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
66 printf("Block map info %d\n\tAddress: 0x%X\n\tLength: 0x%X\n",
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
67 i, header.block_map_info[i].address, header.block_map_info[i].len);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
68 }
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
69 printf("Secton map file address: 0x%X\n", header.section_map_file_address);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
70 printf("Secton map address: 0x%X\n", header.section_map_address);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
71 printf("Secton map length: 0x%X\n", header.section_map_len);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
72 printf("Num sections: %d\n", header.n_sections);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
73 printf("Max heap size: 0x%X\n", header.max_heap_size);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
74 printf("Max program size: 0x%X\n", header.max_program_size);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
75 printf("Max stack size: 0x%X\n", header.max_stack_size);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
76 printf("Stack fence size: 0x%X\n", header.stack_fence_size);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
77
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
78 puts("\nModules");
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
79 for (int i = 0; i < header.n_modules; i++) {
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
80 printf("\t%s:\n\t\tCode Address: 0x%X, Length: 0x%X\n",
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
81 header.module_map_entries[i].name.str,
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
82 header.module_map_entries[i].code_address,
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
83 header.module_map_entries[i].code_length);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
84 printf("\t\tFoo Address: 0x%X, Length: 0x%X\n",
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
85 header.module_map_entries[i].foo_address,
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
86 header.module_map_entries[i].foo_length);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
87 printf("\t\tBar Address: 0x%X, Length: 0x%X\n",
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
88 header.module_map_entries[i].bar_address,
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
89 header.module_map_entries[i].bar_length);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
90 }
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
91
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
92 puts("\nExtrnal Vars");
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
93 for (int i = 0; i < header.n_external_vars; i++) {
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
94 printf("\t%s: 0x%X\n",
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
95 header.external_vars[i].name.str, header.external_vars[i].address);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
96 }
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
97
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
98 vos_header_cleanup(&header);
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
99 return 0;
de6f00204fa2 Add support for disassembling VOS program modules
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
100 }