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