diff options
-rw-r--r-- | CHANGES | 1 | ||||
-rw-r--r-- | output/outas86.c | 22 |
2 files changed, 20 insertions, 3 deletions
@@ -1,5 +1,6 @@ 0.98.39 ------- +* fix outas86's .bss handling * "make spotless" no longer deletes config.h.in. * %(el)if(n)idn insensitivity to string quotes difference (#809300). * (nasm.c) __OUTPUT_FORMAT__ changed to string value instead of symbol. diff --git a/output/outas86.c b/output/outas86.c index 3026ad9e..fa1514c4 100644 --- a/output/outas86.c +++ b/output/outas86.c @@ -395,7 +395,7 @@ static void as86_write(void) fwritelong (0x000186A3L, as86fp); fputc (0x2A, as86fp); fwritelong (27+symlen+seglen+strslen, as86fp); /* header length */ - fwritelong (stext.len+sdata.len, as86fp); + fwritelong (stext.len+sdata.len+bsslen, as86fp); fwriteshort (strslen, as86fp); fwriteshort (0, as86fp); /* class = revision = 0 */ fwritelong (0x55555555L, as86fp); /* segment max sizes: always this */ @@ -405,9 +405,9 @@ static void as86_write(void) else fwriteshort (stext.len, as86fp); if (segsize & 0x40000000L) - fwritelong (sdata.len, as86fp); + fwritelong (sdata.len+bsslen, as86fp); else - fwriteshort (sdata.len, as86fp); + fwriteshort (sdata.len+bsslen, as86fp); fwriteshort (nsyms, as86fp); /* @@ -437,6 +437,22 @@ static void as86_write(void) as86_reloc_size = -1; as86_write_section (&stext, SECT_TEXT); as86_write_section (&sdata, SECT_DATA); + /* + * Append the BSS section to the .data section + */ + if (bsslen > 65535L) { + fputc (0x13, as86fp); + fwritelong (bsslen, as86fp); + } + else if (bsslen > 255) { + fputc (0x12, as86fp); + fwriteshort (bsslen, as86fp); + } + else if (bsslen) { + fputc (0x11, as86fp); + fputc (bsslen, as86fp); + } + fputc (0, as86fp); /* termination */ } |