Mercurial > hg-old > index.cgi
changeset 306:be1abc4ac114
Corrected errors with parsing script and object files
author | lost |
---|---|
date | Fri, 23 Jan 2009 04:03:37 +0000 |
parents | 10cc87f4b16c |
children | 87c4e65074f0 |
files | src/link.c src/readfiles.c src/script.c |
diffstat | 3 files changed, 11 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/link.c Thu Jan 22 02:14:52 2009 +0000 +++ b/src/link.c Fri Jan 23 04:03:37 2009 +0000 @@ -231,7 +231,7 @@ lw_expr_stack_free(s); } - for (sn = 0; nsects; sn++) + for (sn = 0; sn < nsects; sn++) { for (rl = sectlist[sn].ptr -> incompletes; rl; rl = rl -> next) {
--- a/src/readfiles.c Thu Jan 22 02:14:52 2009 +0000 +++ b/src/readfiles.c Fri Jan 23 04:03:37 2009 +0000 @@ -88,9 +88,9 @@ // this macro is used to bail out if we run off the end of the file data // while parsing - it keeps the code below cleaner -#define NEXTBYTE() do { cc++; if (cc >= fn -> filesize) { fprintf(stderr, "%s: invalid file format\n", fn -> filename); exit(1); } } while (0) +#define NEXTBYTE() do { cc++; if (cc > fn -> filesize) { fprintf(stderr, "%s: invalid file format\n", fn -> filename); exit(1); } } while (0) // this macro is used to refer to the current byte in the stream -#define CURBYTE() (fn -> filedata[cc]) +#define CURBYTE() (fn -> filedata[cc < fn -> filesize ? cc : fn -> filesize - 1]) // this one will leave the input pointer past the trailing NUL #define CURSTR() read_lwobj16v0_str(&cc, fn) unsigned char *read_lwobj16v0_str(long *cc1, fileinfo_t *fn) @@ -185,7 +185,9 @@ se -> sym = fp; se -> offset = val; } - + // skip terminating NUL + NEXTBYTE(); + // now parse the exported symbol table while (CURBYTE()) { @@ -205,6 +207,8 @@ se -> sym = fp; se -> offset = val; } + // skip terminating NUL + NEXTBYTE(); // now parse the incomplete references and make a list of // external references that need resolution @@ -269,7 +273,7 @@ lw_expr_term_free(term); } } - // skip the NUL terminatin + // skip the NUL terminating the relocations NEXTBYTE(); // now set code location and size and verify that the file
--- a/src/script.c Thu Jan 22 02:14:52 2009 +0000 +++ b/src/script.c Fri Jan 23 04:03:37 2009 +0000 @@ -35,7 +35,7 @@ // the built-in DECB target linker script static char *decb_script = - "section init load at 2000\n" + "section init load 2000\n" "section code\n" "section *,!bss\n" "section *,bss\n" @@ -44,7 +44,7 @@ // the built-in RAW target linker script static char *raw_script = - "section init load at 0000\n" + "section init load 0000\n" "section code\n" "section *,!bss\n" "section *,bss\n"