comparison lwlink/output.c @ 523:1744f2d1a821

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.
author William Astle <lost@l-w.ca>
date Mon, 24 Jan 2022 13:55:40 -0700
parents 9f0448022f1f
children cde1a5a48636
comparison
equal deleted inserted replaced
522:01bdad2118aa 523:1744f2d1a821
34 #define writebytes(s, l, c, f) do { (void)(fwrite((s), (l), (c), (f)) && 1); } while (0) 34 #define writebytes(s, l, c, f) do { (void)(fwrite((s), (l), (c), (f)) && 1); } while (0)
35 35
36 void do_output_os9(FILE *of); 36 void do_output_os9(FILE *of);
37 void do_output_decb(FILE *of); 37 void do_output_decb(FILE *of);
38 void do_output_raw(FILE *of); 38 void do_output_raw(FILE *of);
39 void do_output_raw2(FILE *of);
39 void do_output_lwex0(FILE *of); 40 void do_output_lwex0(FILE *of);
40 void do_output_srec(FILE *of); 41 void do_output_srec(FILE *of);
41 42
42 void do_output(void) 43 void do_output(void)
43 { 44 {
57 do_output_decb(of); 58 do_output_decb(of);
58 break; 59 break;
59 60
60 case OUTPUT_RAW: 61 case OUTPUT_RAW:
61 do_output_raw(of); 62 do_output_raw(of);
63 break;
64
65 case OUTPUT_RAW2:
66 do_output_raw2(of);
62 break; 67 break;
63 68
64 case OUTPUT_LWEX0: 69 case OUTPUT_LWEX0:
65 do_output_lwex0(of); 70 do_output_lwex0(of);
66 break; 71 break;
143 writebytes(buf, 1, 5, of); 148 writebytes(buf, 1, 5, of);
144 } 149 }
145 150
146 void do_output_raw(FILE *of) 151 void do_output_raw(FILE *of)
147 { 152 {
153 int sn;
154
155
156 for (sn = 0; sn < nsects; sn++)
157 {
158 if (sectlist[sn].ptr -> flags & SECTION_BSS)
159 {
160 // no output for a BSS section
161 continue;
162 }
163 writebytes(sectlist[sn].ptr -> code, 1, sectlist[sn].ptr -> codesize, of);
164 }
165 }
166
167 void do_output_raw2(FILE *of)
168 {
148 int nskips = 0; // used to output blanks for BSS inline 169 int nskips = 0; // used to output blanks for BSS inline
149 int sn; 170 int sn;
171
150 172
151 for (sn = 0; sn < nsects; sn++) 173 for (sn = 0; sn < nsects; sn++)
152 { 174 {
153 if (sectlist[sn].ptr -> flags & SECTION_BSS) 175 if (sectlist[sn].ptr -> flags & SECTION_BSS)
154 { 176 {