diff --git a/src/cc65/compile.c b/src/cc65/compile.c index d914afb97..ef66d38d2 100644 --- a/src/cc65/compile.c +++ b/src/cc65/compile.c @@ -453,7 +453,7 @@ void FinishCompile (void) } /* Output the literal pool */ - OutputLiteralPool (); + OutputGlobalLiteralPool (); /* Emit debug infos if enabled */ EmitDebugInfo (); diff --git a/src/cc65/function.c b/src/cc65/function.c index 3256d7541..8da084ac1 100644 --- a/src/cc65/function.c +++ b/src/cc65/function.c @@ -582,6 +582,11 @@ void NewFunc (SymEntry* Func) /* Restore the old literal pool, remembering the one for the function */ Func->V.F.LitPool = PopLiteralPool (); + /* If --local-strings was given, output the literals now */ + if (IS_Get (&LocalStrings)) { + OutputLocalLiteralPool (Func->V.F.LitPool); + } + /* Switch back to the old segments */ PopSegments (); diff --git a/src/cc65/litpool.c b/src/cc65/litpool.c index c427310d9..eb31c7ecc 100644 --- a/src/cc65/litpool.c +++ b/src/cc65/litpool.c @@ -147,18 +147,6 @@ Literal* UseLiteral (Literal* L) /* Increase the reference count */ ++L->RefCount; - /* If --local-strings was given, immediately output the literal */ - if (IS_Get (&LocalStrings)) { - /* Switch to the proper data segment */ - if (IS_Get (&WritableStrings)) { - g_usedata (); - } else { - g_userodata (); - } - /* Output the literal */ - OutputLiteral (L); - } - /* Return the literal */ return L; } @@ -454,12 +442,20 @@ static void OutputReadOnlyLiterals (Collection* Literals) -void OutputLiteralPool (void) -/* Output the global literal pool */ +void OutputLocalLiteralPool (LiteralPool* Pool) +/* Output the local literal pool */ { /* Output both sorts of literals */ - OutputWritableLiterals (&GlobalPool->WritableLiterals); - OutputReadOnlyLiterals (&GlobalPool->ReadOnlyLiterals); + OutputWritableLiterals (&Pool->WritableLiterals); + OutputReadOnlyLiterals (&Pool->ReadOnlyLiterals); +} + + + +void OutputGlobalLiteralPool (void) +/* Output the global literal pool */ +{ + OutputLocalLiteralPool (GlobalPool); } diff --git a/src/cc65/litpool.h b/src/cc65/litpool.h index 6efdfb089..78f432138 100644 --- a/src/cc65/litpool.h +++ b/src/cc65/litpool.h @@ -113,8 +113,11 @@ void MoveLiteralPool (LiteralPool* LocalPool); ** function will free LocalPool after moving the used string literals. */ -void OutputLiteralPool (void); -/* Output the literal pool */ +void OutputLocalLiteralPool (LiteralPool* Pool); +/* Output the local literal pool */ + +void OutputGlobalLiteralPool (void); +/* Output the global literal pool */ Literal* AddLiteral (const char* S); /* Add a literal string to the literal pool. Return the literal. */