From 644d623d314f0c6fa62b6ca3031ae8c658c803fc Mon Sep 17 00:00:00 2001
From: Greg King <gregdk@users.sf.net>
Date: Sat, 18 May 2019 12:16:52 -0400
Subject: [PATCH] Reset the name of the "current bss segment" before writing
 bss variables into the output Assembly file.

Then, cc65 can notice a single "#pragma bss-name()" at the beginning of the variables list.
---
 src/cc65/compile.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/cc65/compile.c b/src/cc65/compile.c
index 9cc7f9641..bf9ada833 100644
--- a/src/cc65/compile.c
+++ b/src/cc65/compile.c
@@ -38,6 +38,7 @@
 
 /* common */
 #include "debugflag.h"
+#include "segnames.h"
 #include "version.h"
 #include "xmalloc.h"
 #include "xsprintf.h"
@@ -419,6 +420,11 @@ void FinishCompile (void)
 {
     SymEntry* Entry;
 
+    /* Reset the BSS segment name to its default; so that the below strcmp()
+    ** will work as expected, at the beginning of the list of variables
+    */
+    SetSegName (SEG_BSS, SEGNAME_BSS);
+
     /* Walk over all global symbols:
     ** - for functions, do clean-up and optimizations
     ** - generate code for uninitialized global variables