# HG changeset patch # User William Astle # Date 1643057740 25200 # Node ID 1744f2d1a82146f3fe22a7fc58a2cba6c197198b # Parent 01bdad2118aa33afedab1664c8a864ed936de1c7 Change behaviour of --format=raw; old behaviour kept for --format=raw2 Make the default --format=raw output just ignore BSS flagged sections. If you put any in the middle of your code, your output file will break. Don't do dumb things like that. If you really need the old behaviour, change to --format=raw2 Neither behaviour is really ideal but doing the "right" thing is a boatload more complicated and is still going to do the wrong thing from time to time. Most situations will likely load the BSS sections with separate link script directives anyway or be assembling directly to raw without using the linker. diff -r 01bdad2118aa -r 1744f2d1a821 lwlink/lwlink.h --- a/lwlink/lwlink.h Sun Jan 02 00:59:21 2022 -0700 +++ b/lwlink/lwlink.h Mon Jan 24 13:55:40 2022 -0700 @@ -27,10 +27,11 @@ #include "expr.h" #define OUTPUT_DECB 0 // DECB multirecord format -#define OUTPUT_RAW 1 // raw sequence of bytes +#define OUTPUT_RAW 1 // raw sequence of bytes; BSS is just not included #define OUTPUT_LWEX0 2 // LWOS LWEX binary version 0 #define OUTPUT_OS9 3 // OS9 object code module #define OUTPUT_SREC 4 // motorola SREC format +#define OUTPUT_RAW2 5 // raw sequence of bytes, BSS converted to NULs typedef struct symtab_s symtab_t; struct symtab_s diff -r 01bdad2118aa -r 1744f2d1a821 lwlink/main.c --- a/lwlink/main.c Sun Jan 02 00:59:21 2022 -0700 +++ b/lwlink/main.c Mon Jan 24 13:55:40 2022 -0700 @@ -84,6 +84,8 @@ outformat = OUTPUT_DECB; else if (!strcasecmp(arg, "raw")) outformat = OUTPUT_RAW; + else if (!strcasecmp(arg, "raw2")) + outformat = OUTPUT_RAW2; else if (!strcasecmp(arg, "lwex0") || !strcasecmp(arg, "lwex")) outformat = OUTPUT_LWEX0; else if (!strcasecmp(arg, "os9")) diff -r 01bdad2118aa -r 1744f2d1a821 lwlink/output.c --- a/lwlink/output.c Sun Jan 02 00:59:21 2022 -0700 +++ b/lwlink/output.c Mon Jan 24 13:55:40 2022 -0700 @@ -36,6 +36,7 @@ void do_output_os9(FILE *of); void do_output_decb(FILE *of); void do_output_raw(FILE *of); +void do_output_raw2(FILE *of); void do_output_lwex0(FILE *of); void do_output_srec(FILE *of); @@ -61,6 +62,10 @@ do_output_raw(of); break; + case OUTPUT_RAW2: + do_output_raw2(of); + break; + case OUTPUT_LWEX0: do_output_lwex0(of); break; @@ -145,8 +150,25 @@ void do_output_raw(FILE *of) { + int sn; + + + for (sn = 0; sn < nsects; sn++) + { + if (sectlist[sn].ptr -> flags & SECTION_BSS) + { + // no output for a BSS section + continue; + } + writebytes(sectlist[sn].ptr -> code, 1, sectlist[sn].ptr -> codesize, of); + } +} + +void do_output_raw2(FILE *of) +{ int nskips = 0; // used to output blanks for BSS inline int sn; + for (sn = 0; sn < nsects; sn++) {