From c2bf1b9ba4eaf37b40b6b283531754268783032f Mon Sep 17 00:00:00 2001 From: uz Date: Mon, 29 Aug 2011 20:30:57 +0000 Subject: [PATCH] Some code cleanup. git-svn-id: svn://svn.cc65.org/cc65/trunk@5282 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/ld65/dbgsyms.c | 58 +++++++++++++++++++++++++++------------------- src/ld65/dbgsyms.h | 7 +----- src/ld65/mapfile.c | 16 ++----------- 3 files changed, 37 insertions(+), 44 deletions(-) diff --git a/src/ld65/dbgsyms.c b/src/ld65/dbgsyms.c index 89f4080d1..fb90e4e3a 100644 --- a/src/ld65/dbgsyms.c +++ b/src/ld65/dbgsyms.c @@ -213,7 +213,7 @@ DbgSym* ReadDbgSym (FILE* F, ObjData* O, unsigned Id) -void ClearDbgSymTable (void) +static void ClearDbgSymTable (void) /* Clear the debug symbol table */ { unsigned I; @@ -349,39 +349,49 @@ void PrintDbgSyms (FILE* F) -void PrintDbgSymLabels (ObjData* O, FILE* F) +void PrintDbgSymLabels (FILE* F) /* Print the debug symbols in a VICE label file */ { - unsigned I; + unsigned I, J; - /* Walk through all debug symbols in this module */ - for (I = 0; I < CollCount (&O->DbgSyms); ++I) { + /* Clear the symbol table */ + ClearDbgSymTable (); - long Val; + /* Create labels from all modules we have linked into the output file */ + for (I = 0; I < CollCount (&ObjDataList); ++I) { - /* Get the next debug symbol */ - DbgSym* D = CollAt (&O->DbgSyms, I); + /* Get the object file */ + ObjData* O = CollAtUnchecked (&ObjDataList, I); - /* Emit this symbol only if it is a label (ignore equates and imports) */ - if (SYM_IS_EQUATE (D->Type) || SYM_IS_IMPORT (D->Type)) { - continue; - } + /* Walk through all debug symbols in this module */ + for (J = 0; J < CollCount (&O->DbgSyms); ++J) { - /* Get the symbol value */ - Val = GetDbgSymVal (D); + long Val; - /* Lookup this symbol in the table. If it is found in the table, it was - * already written to the file, so don't emit it twice. If it is not in - * the table, insert and output it. - */ - if (GetDbgSym (D, Val) == 0) { + /* Get the next debug symbol */ + DbgSym* D = CollAt (&O->DbgSyms, J); + + /* Emit this symbol only if it is a label (ignore equates and imports) */ + if (SYM_IS_EQUATE (D->Type) || SYM_IS_IMPORT (D->Type)) { + continue; + } + + /* Get the symbol value */ + Val = GetDbgSymVal (D); - /* Emit the VICE label line */ - fprintf (F, "al %06lX .%s\n", Val, GetString (D->Name)); + /* Lookup this symbol in the table. If it is found in the table, it was + * already written to the file, so don't emit it twice. If it is not in + * the table, insert and output it. + */ + if (GetDbgSym (D, Val) == 0) { + + /* Emit the VICE label line */ + fprintf (F, "al %06lX .%s\n", Val, GetString (D->Name)); - /* Insert the symbol into the table */ - InsertDbgSym (D, Val); - } + /* Insert the symbol into the table */ + InsertDbgSym (D, Val); + } + } } } diff --git a/src/ld65/dbgsyms.h b/src/ld65/dbgsyms.h index fd6b9a37d..2922cb6c1 100644 --- a/src/ld65/dbgsyms.h +++ b/src/ld65/dbgsyms.h @@ -72,15 +72,10 @@ typedef struct DbgSym DbgSym; DbgSym* ReadDbgSym (FILE* F, ObjData* Obj, unsigned Id); /* Read a debug symbol from a file, insert and return it */ -void ClearDbgSymTable (void); -/* Clear the debug symbol table. Must be called before outputting debug syms - * or debug labels the first time. - */ - void PrintDbgSyms (FILE* F); /* Print the debug symbols in a debug file */ -void PrintDbgSymLabels (ObjData* O, FILE* F); +void PrintDbgSymLabels (FILE* F); /* Print the debug symbols in a VICE label file */ diff --git a/src/ld65/mapfile.c b/src/ld65/mapfile.c index c9aad3f56..ff7ee0f84 100644 --- a/src/ld65/mapfile.c +++ b/src/ld65/mapfile.c @@ -132,29 +132,17 @@ void CreateMapFile (int ShortMap) void CreateLabelFile (void) /* Create a label file */ { - unsigned I; - /* Open the label file */ FILE* F = fopen (LabelFileName, "w"); if (F == 0) { Error ("Cannot create label file `%s': %s", LabelFileName, strerror (errno)); } - /* Clear the debug sym table (used to detect duplicates) */ - ClearDbgSymTable (); - /* Print the labels for the export symbols */ PrintExportLabels (F); - /* Create labels from all modules we have linked into the output file */ - for (I = 0; I < CollCount (&ObjDataList); ++I) { - - /* Get the object file */ - ObjData* O = CollAtUnchecked (&ObjDataList, I); - - /* Output the labels */ - PrintDbgSymLabels (O, F); - } + /* Output the labels */ + PrintDbgSymLabels (F); /* Close the file */ if (fclose (F) != 0) { -- 2.39.5