# HG changeset patch # User lost # Date 1237655022 0 # Node ID 302b8db5fd895844bc948b4c861c9ef7f263f418 # Parent 833d392fec82ffbbdf59b965530d54a94470b4aa modified lwlink to merge contiguous sections in the DECB output file to avoid the explosion of preambles diff -r 833d392fec82 -r 302b8db5fd89 ChangeLog --- a/ChangeLog Fri Mar 06 01:35:40 2009 +0000 +++ b/ChangeLog Sat Mar 21 17:03:42 2009 +0000 @@ -7,6 +7,7 @@ [+] new feature [-] feature removed [b] minor bugfix +[ ] general improvement Also, the software affected may follow in []. @@ -17,6 +18,10 @@ LWLINK (they get prepended to the built in link script) [b] arranged for output files for lwasm/lwlink to be removed if the assembly or linking fails +[ ] DECB output of LWLINK now collapses contiguous output blocks into single + single blocks in the output file; this eliminates the explosion of + preambles that previously occurred + Version 2.2 diff -r 833d392fec82 -r 302b8db5fd89 lwlink/output.c --- a/lwlink/output.c Fri Mar 06 01:35:40 2009 +0000 +++ b/lwlink/output.c Sat Mar 21 17:03:42 2009 +0000 @@ -70,7 +70,8 @@ void do_output_decb(FILE *of) { - int sn; + int sn, sn2; + int cloc, olen; unsigned char buf[5]; for (sn = 0; sn < nsects; sn++) @@ -85,14 +86,40 @@ // don't generate output for a zero size section continue; } + + // calculate the length of this output block + cloc = sectlist[sn].ptr -> loadaddress; + olen = 0; + for (sn2 = sn; sn2 < nsects; sn2++) + { + // ignore BSS sections + if (sectlist[sn2].ptr -> flags & SECTION_BSS) + continue; + // ignore zero length sections + if (sectlist[sn2].ptr -> codesize == 0) + continue; + if (cloc != sectlist[sn2].ptr -> loadaddress) + break; + olen += sectlist[sn2].ptr -> codesize; + cloc += sectlist[sn2].ptr -> codesize; + } + // write a preamble buf[0] = 0x00; - buf[1] = sectlist[sn].ptr -> codesize >> 8; - buf[2] = sectlist[sn].ptr -> codesize & 0xff; + buf[1] = olen >> 8; + buf[2] = olen & 0xff; buf[3] = sectlist[sn].ptr -> loadaddress >> 8; buf[4] = sectlist[sn].ptr -> loadaddress & 0xff; writebytes(buf, 1, 5, of); - writebytes(sectlist[sn].ptr -> code, 1, sectlist[sn].ptr -> codesize, of); + for (; sn < sn2; sn++) + { + if (sectlist[sn].ptr -> flags & SECTION_BSS) + continue; + if (sectlist[sn].ptr -> codesize == 0) + continue; + writebytes(sectlist[sn].ptr -> code, 1, sectlist[sn].ptr -> codesize, of); + } + sn--; } // write a postamble buf[0] = 0xff;