--- trunk/src/file.c 2007/10/08 16:18:11 6 +++ trunk/src/file.c 2007/10/08 16:18:27 10 @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * - * $Id: file.c,v 1.96 2005/06/02 12:31:39 debug Exp $ + * $Id: file.c,v 1.99 2005/06/26 09:21:28 debug Exp $ * * This file contains functions which load executable images into (emulated) * memory. File formats recognized so far: @@ -165,7 +165,7 @@ symbsize = 0; fseek(f, 0, SEEK_END); /* This is of course wrong, but should work anyway: */ - textsize = ftell(f) - 512; + textsize = ftello(f) - 512; datasize = 0; fseek(f, 512, SEEK_SET); } else { @@ -226,7 +226,7 @@ char *string_symbols; off_t oldpos; - debug("symbols: %i bytes @ 0x%x\n", symbsize, (int)ftell(f)); + debug("symbols: %i bytes @ 0x%x\n", symbsize, (int)ftello(f)); syms = malloc(symbsize); if (syms == NULL) { fprintf(stderr, "out of memory\n"); @@ -239,11 +239,11 @@ exit(1); } - oldpos = ftell(f); + oldpos = ftello(f); fseek(f, 0, SEEK_END); - strings_len = ftell(f) - oldpos; + strings_len = ftello(f) - oldpos; fseek(f, oldpos, SEEK_SET); - debug("strings: %i bytes @ 0x%x\n", strings_len, (int)ftell(f)); + debug("strings: %i bytes @ 0x%x\n", strings_len,(int)ftello(f)); string_symbols = malloc(strings_len); if (string_symbols == NULL) { fprintf(stderr, "out of memory\n"); @@ -474,7 +474,7 @@ if (s_scnptr != 0 && s_size != 0 && s_vaddr != 0 && !(s_flags & 0x02)) { /* Remember the current file offset: */ - oldpos = ftell(f); + oldpos = ftello(f); /* Load the section into emulated memory: */ fseek(f, s_scnptr, SEEK_SET); @@ -900,7 +900,7 @@ } debug("RAW: 0x%llx bytes @ 0x%08llx", - (long long) (ftell(f) - skip), (long long)loadaddr); + (long long) (ftello(f) - skip), (long long)loadaddr); if (skip != 0) debug(" (0x%llx bytes of header skipped)", (long long)skip); debug("\n"); @@ -1211,13 +1211,10 @@ debug(" len=0x%llx\n", (long long)p_memsz); - if (p_vaddr != p_paddr) { - fprintf(stderr, "%s: vaddr != paddr. TODO: " - "how to handle this? vaddr=%016llx paddr" - "=%016llx\n", filename, (long long)p_vaddr, - (long long)p_paddr); - exit(1); - } + if (p_vaddr != p_paddr) + fatal("WARNING! vaddr (0x%llx) and paddr " + "(0x%llx) differ; using vaddr\n", + (long long)p_vaddr, (long long)p_paddr); if (p_memsz < p_filesz) { fprintf(stderr, "%s: memsz < filesz. TODO: how" @@ -1580,7 +1577,7 @@ } fseek(f, 0, SEEK_END); - size = ftell(f); + size = ftello(f); fseek(f, 0, SEEK_SET); memset(buf, 0, sizeof(buf));