int main(int argc, char **argv) { FILE *f; FILE_HEADER filehead; size_t symtab_off; u32 i; if (argc != 2) { fprintf(stderr, "Usage: %s <xdf>\n", argv[0]); return EXIT_FAILURE; } f = fopen(argv[1], "rb"); if (!f) { fprintf(stderr, "Could not open `%s'\n", argv[1]); return EXIT_FAILURE; } fread(&filehead.f_magic, sizeof(filehead.f_magic), 1, f); fread(&filehead.f_nsect, sizeof(filehead.f_nsect), 1, f); fread(&filehead.f_nsyms, sizeof(filehead.f_nsyms), 1, f); fread(&filehead.f_size, sizeof(filehead.f_size), 1, f); if (filehead.f_magic != XDF_MAGIC) { fprintf(stderr, "Magic number mismatch (expected %08X, got %08X\n", XDF_MAGIC, filehead.f_magic); return EXIT_FAILURE; } print_file_header(&filehead); symtab_off = FILE_HEADER_SIZE+filehead.f_nsect*SECTION_HEADER_SIZE; for (i=0; i<filehead.f_nsect; i++) { SECTION_HEADER secthead; fread(§head.s_name_idx, sizeof(secthead.s_name_idx), 1, f); fread(§head.s_addr, sizeof(secthead.s_addr), 1, f); fread(§head.s_vaddr, sizeof(secthead.s_vaddr), 1, f); fread(§head.s_align, sizeof(secthead.s_align), 1, f); fread(§head.s_flags, sizeof(secthead.s_flags), 1, f); fread(§head.s_data_off, sizeof(secthead.s_data_off), 1, f); fread(§head.s_data_size, sizeof(secthead.s_data_size), 1, f); fread(§head.s_reltab_off, sizeof(secthead.s_reltab_off), 1, f); fread(§head.s_num_reloc, sizeof(secthead.s_num_reloc), 1, f); print_section(§head, f, symtab_off); } printf("Symbol Table:\n"); for (i=0; i<filehead.f_nsyms; i++) { SYMBOL_ENTRY syment; read_syment(&syment, f); print_symbol(&syment, f, symtab_off, sizeof(FILE_HEADER)); } return EXIT_SUCCESS; }
static void process_file(FILE *f, FILE *output, FILE* outputHeader) { process_header(f); print_file_header(output, outputHeader); process_content(f, output, outputHeader); print_codepage_tables(output); print_dictionary_table(output, outputHeader); }