# HG changeset patch # User lost # Date 1259383569 0 # Node ID 4dc2a10997a63fa43e8a14d9e41028e2a7c3ed70 # Parent f6af5791472c0920e1a230683cd20ac81c03654e Fixed LWEX binary output when BSS size > 0 diff -r f6af5791472c -r 4dc2a10997a6 ChangeLog --- a/ChangeLog Fri Nov 27 22:04:05 2009 +0000 +++ b/ChangeLog Sat Nov 28 04:46:09 2009 +0000 @@ -30,6 +30,7 @@ [LWASM] [b] Fixed default linkscript for LWEX0 format to include the .ctors, .dtors, and related section [LWLINK] +[!] Fixed problem outputting LWEX0 binaries with non-zero BSS size [LWLINK] Version 2.5 diff -r f6af5791472c -r 4dc2a10997a6 lwlink/output.c --- a/lwlink/output.c Fri Nov 27 22:04:05 2009 +0000 +++ b/lwlink/output.c Sat Nov 28 04:46:09 2009 +0000 @@ -162,11 +162,14 @@ int nskips = 0; // used to output blanks for BSS inline int sn; int codedatasize = 0; + int coffs; unsigned char buf[32]; - + int fsize = 0; + // calculate items for the file header for (sn = 0; sn < nsects; sn++) { +// fprintf(stderr, "Counting: %s (%s) at %04X (%04X bytes), calc total = %04X\n", sectlist[sn].ptr -> name, sectlist[sn].ptr -> file -> filename, sectlist[sn].ptr -> loadaddress, sectlist[sn].ptr -> codesize, codedatasize); if (sectlist[sn].ptr -> flags & SECTION_BSS) { // no output for a BSS section @@ -194,16 +197,23 @@ buf[12] = linkscript.execaddr / 256; buf[13] = linkscript.execaddr & 0xff; memset(buf + 14, 0, 18); + +// fprintf(stderr, "Exec addr %04X, stacksize %04X, codesize %04X, bss size %04X\n", linkscript.execaddr, linkscript.stacksize, codedatasize, nskips); writebytes(buf, 1, 32, of); + fsize = 32; + coffs = 0x100; + nskips = 0; // output the data // NOTE: disjoint load addresses will not work correctly!!!!! for (sn = 0; sn < nsects; sn++) { +// fprintf(stderr, "Outputting: %s (%s) at %04X (%04X bytes), calc offset = %04X, file offset = %04X\n", sectlist[sn].ptr -> name, sectlist[sn].ptr -> file -> filename, sectlist[sn].ptr -> loadaddress, sectlist[sn].ptr -> codesize, coffs, fsize); if (sectlist[sn].ptr -> flags & SECTION_BSS) { // no output for a BSS section nskips += sectlist[sn].ptr -> codesize; + coffs += sectlist[sn].ptr -> codesize; continue; } while (nskips > 0) @@ -211,7 +221,10 @@ // the "" is not an error - it turns into a single NUL byte! writebytes("", 1, 1, of); nskips--; + fsize += 1; } writebytes(sectlist[sn].ptr -> code, 1, sectlist[sn].ptr -> codesize, of); + coffs += sectlist[sn].ptr -> codesize; + fsize += sectlist[sn].ptr -> codesize; } }