]> git.sur5r.net Git - cc65/commitdiff
More debug file output
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sun, 14 Sep 2003 21:08:05 +0000 (21:08 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sun, 14 Sep 2003 21:08:05 +0000 (21:08 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@2441 b7a2c559-68d2-44c3-8de9-860c34a00d81

12 files changed:
src/ld65/config.c
src/ld65/config.h
src/ld65/dbgfile.c [new file with mode: 0644]
src/ld65/dbgfile.h [new file with mode: 0644]
src/ld65/main.c
src/ld65/make/gcc.mak
src/ld65/make/watcom.mak
src/ld65/mapfile.c
src/ld65/mapfile.h
src/ld65/scanner.h
src/ld65/segments.c
src/ld65/segments.h

index a77f4c7ec3189072cd6fb9a28d93b39fa0404dbb..cf519e0468d9468e7ca352658f0bb3516e3db6b3 100644 (file)
@@ -612,8 +612,7 @@ static void ParseSegments (void)
                {   "RW",       CFGTOK_RW       },
                {   "BSS",      CFGTOK_BSS      },
        {   "ZP",       CFGTOK_ZP       },
-       {   "WP",       CFGTOK_WPROT    },
-       {   "WPROT",    CFGTOK_WPROT    },
+        {   "WPROT",    CFGTOK_RO       },      /* ### OBSOLETE */
     };
 
     unsigned Count;
@@ -706,7 +705,6 @@ static void ParseSegments (void)
                        case CFGTOK_RW:    /* Default */                    break;
                        case CFGTOK_BSS:   S->Flags |= SF_BSS;              break;
                        case CFGTOK_ZP:    S->Flags |= (SF_BSS | SF_ZP);    break;
-                       case CFGTOK_WPROT: S->Flags |= (SF_RO | SF_WPROT);  break;
                        default:           Internal ("Unexpected token: %d", CfgTok);
                    }
                    break;
@@ -1473,11 +1471,13 @@ void CfgAssignSegments (void)
                Addr = NewAddr;
            }
 
-                   /* If this is the run area, set the start address of this segment
-             * and remember if the segment is in a relocatable file or not.
+                   /* If this is the run area, set the start address of this segment,
+             * set the readonly flag in the segment and and remember if the 
+             * segment is in a relocatable file or not.
              */
            if (S->Run == M) {
                S->Seg->PC = Addr;
+                S->Seg->ReadOnly = (S->Flags & SF_RO) != 0;
                 S->Seg->Relocatable = M->Relocatable;
            }
 
index 58036d5f3cbe687d3d945d00d768ffab96e121d8..38282689f042d96304c5e69ec521c66c8d3ee0cc 100644 (file)
@@ -38,6 +38,7 @@
 
 
 
+/* ld65 */
 #include "segments.h"
 
 
@@ -111,12 +112,11 @@ extern unsigned           SegDescCount;   /* Number of entries in list */
 #define SF_RO                  0x0001          /* Read only segment */
 #define SF_BSS                 0x0002          /* Segment is BSS style segment */
 #define SF_ZP                  0x0004          /* Zeropage segment (o65 only) */
-#define SF_WPROT       0x0008          /* Write protected segment */
-#define SF_DEFINE              0x0010          /* Define start and size */
-#define SF_ALIGN       0x0020          /* Align the segment */
-#define SF_OFFSET      0x0040          /* Segment has offset in memory */
-#define SF_START       0x0080          /* Segment has fixed start address */
-#define SF_OPTIONAL     0x0100          /* Segment is optional (must not exist) */
+#define SF_DEFINE              0x0008          /* Define start and size */
+#define SF_ALIGN       0x0010          /* Align the segment */
+#define SF_OFFSET      0x0020          /* Segment has offset in memory */
+#define SF_START       0x0040          /* Segment has fixed start address */
+#define SF_OPTIONAL     0x0080          /* Segment is optional (must not exist) */
 #define SF_LOAD_AND_RUN        0x1000          /* LOAD and RUN given */
 #define SF_RUN_DEF             0x2000          /* RUN symbols already defined */
 #define SF_LOAD_DEF    0x4000          /* LOAD symbols already defined */
diff --git a/src/ld65/dbgfile.c b/src/ld65/dbgfile.c
new file mode 100644 (file)
index 0000000..9f2c20e
--- /dev/null
@@ -0,0 +1,88 @@
+/*****************************************************************************/
+/*                                                                           */
+/*                                dbgfile.c                                 */
+/*                                                                           */
+/*                  Debug file creation for the ld65 linker                  */
+/*                                                                           */
+/*                                                                           */
+/*                                                                           */
+/* (C) 2003      Ullrich von Bassewitz                                       */
+/*               Römerstrasse 52                                             */
+/*               D-70794 Filderstadt                                         */
+/* EMail:        uz@cc65.org                                                 */
+/*                                                                           */
+/*                                                                           */
+/* This software is provided 'as-is', without any expressed or implied       */
+/* warranty.  In no event will the authors be held liable for any damages    */
+/* arising from the use of this software.                                    */
+/*                                                                           */
+/* Permission is granted to anyone to use this software for any purpose,     */
+/* including commercial applications, and to alter it and redistribute it    */
+/* freely, subject to the following restrictions:                            */
+/*                                                                           */
+/* 1. The origin of this software must not be misrepresented; you must not   */
+/*    claim that you wrote the original software. If you use this software   */
+/*    in a product, an acknowledgment in the product documentation would be  */
+/*    appreciated but is not required.                                       */
+/* 2. Altered source versions must be plainly marked as such, and must not   */
+/*    be misrepresented as being the original software.                      */
+/* 3. This notice may not be removed or altered from any source              */
+/*    distribution.                                                          */
+/*                                                                           */
+/*****************************************************************************/
+
+
+
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+
+/* ld65 */
+#include "dbgfile.h"
+#include "dbginfo.h"
+#include "dbgsyms.h"
+#include "error.h"
+#include "global.h"
+#include "segments.h"
+
+
+
+/*****************************************************************************/
+/*                                  Code                                    */
+/*****************************************************************************/
+
+
+
+void CreateDbgFile (void)
+/* Create a debug info file */
+{
+    unsigned I;
+
+    /* Open the debug info file */
+    FILE* F = fopen (DbgFileName, "w");
+    if (F == 0) {
+               Error ("Cannot create debug file `%s': %s", DbgFileName, strerror (errno));
+    }
+
+    /* Output the segment info */
+    PrintDbgSegments (F);
+
+    /* Print line infos 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 debug info */
+       PrintDbgInfo (O, F);
+        PrintDbgSyms (O, F);
+    }
+
+    /* Close the file */
+    if (fclose (F) != 0) {
+       Error ("Error closing debug file `%s': %s", DbgFileName, strerror (errno));
+    }
+}
+
+
+
diff --git a/src/ld65/dbgfile.h b/src/ld65/dbgfile.h
new file mode 100644 (file)
index 0000000..ad660da
--- /dev/null
@@ -0,0 +1,57 @@
+/*****************************************************************************/
+/*                                                                           */
+/*                                dbgfile.h                                 */
+/*                                                                           */
+/*                  Debug file creation for the ld65 linker                  */
+/*                                                                           */
+/*                                                                           */
+/*                                                                           */
+/* (C) 2003      Ullrich von Bassewitz                                       */
+/*               Römerstrasse 52                                             */
+/*               D-70794 Filderstadt                                         */
+/* EMail:        uz@cc65.org                                                 */
+/*                                                                           */
+/*                                                                           */
+/* This software is provided 'as-is', without any expressed or implied       */
+/* warranty.  In no event will the authors be held liable for any damages    */
+/* arising from the use of this software.                                    */
+/*                                                                           */
+/* Permission is granted to anyone to use this software for any purpose,     */
+/* including commercial applications, and to alter it and redistribute it    */
+/* freely, subject to the following restrictions:                            */
+/*                                                                           */
+/* 1. The origin of this software must not be misrepresented; you must not   */
+/*    claim that you wrote the original software. If you use this software   */
+/*    in a product, an acknowledgment in the product documentation would be  */
+/*    appreciated but is not required.                                       */
+/* 2. Altered source versions must be plainly marked as such, and must not   */
+/*    be misrepresented as being the original software.                      */
+/* 3. This notice may not be removed or altered from any source              */
+/*    distribution.                                                          */
+/*                                                                           */
+/*****************************************************************************/
+
+
+
+#ifndef DBGFILE_H
+#define DBGFILE_H
+
+
+
+/*****************************************************************************/
+/*                                  Code                                    */
+/*****************************************************************************/
+
+
+
+void CreateDbgFile (void);
+/* Create a debug info file */
+
+
+
+/* End of dbgfile.h */
+
+#endif
+
+
+
index 146b0db783007a3d073bb77870b1429a9a5a9c8c..c5f4aec17cb24a12b2948c87e4db29c5acc0f249 100644 (file)
@@ -53,6 +53,7 @@
 #include "binfmt.h"
 #include "condes.h"
 #include "config.h"
+#include "dbgfile.h"
 #include "error.h"
 #include "exports.h"
 #include "fileio.h"
index e9fdf92e20bd5a322c020e43ea79cea6ca4bc181..241444fa2d62186935ed1e9beb6a2799d076117b 100644 (file)
@@ -23,6 +23,7 @@ OBJS =        asserts.o       \
        binfmt.o        \
        condes.o        \
        config.o        \
+        dbgfile.o       \
        dbginfo.o       \
        dbgsyms.o       \
        error.o         \
index 37b01652298702bf23acddfbb77fbd6c4558b466..4e452785e59dfde185da75e991fb4ef3701ce238 100644 (file)
@@ -48,6 +48,7 @@ OBJS =        asserts.obj     \
        binfmt.obj      \
        condes.obj      \
        config.obj      \
+        dbgfile.obj     \
        dbginfo.obj     \
        dbgsyms.obj     \
        error.obj       \
index 5fcba2b99ee9940c64be26e80f452e4a48be7c5b..22c11d492971a9ef601152f977595f7b918f9170 100644 (file)
@@ -39,7 +39,6 @@
 
 /* ld65 */
 #include "config.h"
-#include "dbginfo.h"
 #include "dbgsyms.h"
 #include "exports.h"
 #include "global.h"
@@ -155,33 +154,3 @@ void CreateLabelFile (void)
 
 
 
-void CreateDbgFile (void)
-/* Create a debug info file */
-{
-    unsigned I;
-
-    /* Open the debug info file */
-    FILE* F = fopen (DbgFileName, "w");
-    if (F == 0) {
-               Error ("Cannot create debug file `%s': %s", DbgFileName, strerror (errno));
-    }
-
-    /* Print line infos 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 debug info */
-       PrintDbgInfo (O, F);
-        PrintDbgSyms (O, F);
-    }
-
-    /* Close the file */
-    if (fclose (F) != 0) {
-       Error ("Error closing debug file `%s': %s", DbgFileName, strerror (errno));
-    }
-}
-
-
-
index 91a50f28dd121eef0802fa83211db3aec034a377..b4cc31f18e95b3cedccae5bac5677a7682a5d75e 100644 (file)
@@ -6,9 +6,9 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2001 Ullrich von Bassewitz                                       */
-/*               Wacholderweg 14                                             */
-/*               D-70597 Stuttgart                                           */
+/* (C) 1998-2003 Ullrich von Bassewitz                                       */
+/*               Römerstrasse 52                                             */
+/*               D-70794 Filderstadt                                         */
 /* EMail:        uz@cc65.org                                                 */
 /*                                                                           */
 /*                                                                           */
 
 
 
-#include <stdio.h>
-
-
-
 /*****************************************************************************/
 /*                                  Code                                    */
 /*****************************************************************************/
@@ -54,9 +50,6 @@ void CreateMapFile (void);
 void CreateLabelFile (void);
 /* Create a label file */
 
-void CreateDbgFile (void);
-/* Create a debug info file */
-
 
 
 /* End of mapfile.h */
index c8c2c6a3750ad84c0dc9b6aa62128e9e1701f40d..2af9fa1619f506c36937bf41d72b21a5a0b8e6fd 100644 (file)
@@ -91,7 +91,6 @@ typedef enum {
     CFGTOK_RW,
     CFGTOK_BSS,
     CFGTOK_ZP,
-    CFGTOK_WPROT,
 
     CFGTOK_O65,
     CFGTOK_BIN,
index d834641d887e4b0f22efa8a5bbd83050b55b7ae1..4a518702de31e20154420338fbe53d63ba9b9232 100644 (file)
@@ -99,6 +99,7 @@ static Segment* NewSegment (unsigned Name, unsigned char Type)
     S->Align       = 0;
     S->FillVal    = 0;
     S->Type        = Type;
+    S->ReadOnly    = 0;
     S->Relocatable = 0;
     S->Dumped      = 0;
 
@@ -331,7 +332,7 @@ int IsBSSType (Segment* S)
                unsigned long Count = F->Size;
                while (Count--) {
                    if (*Data++ != 0) {
-                       return 0;
+                       return 0;
                    }
                }
            } else if (F->Type == FRAG_EXPR || F->Type == FRAG_SEXPR) {
@@ -602,15 +603,15 @@ void PrintSegmentMap (FILE* F)
        /* Get a pointer to the segment */
        S = SegPool [I];
 
-       /* Print empty segments only if explicitly requested */
-       if (VerboseMap || S->Size > 0) {
-           /* Print the segment data */
-           long End = S->PC + S->Size;
-           if (S->Size > 0) {
-               /* Point to last element addressed */
-               --End;
-           }
-           fprintf (F, "%-20s  %06lX  %06lX  %06lX\n",
+       /* Print empty segments only if explicitly requested */
+       if (VerboseMap || S->Size > 0) {
+           /* Print the segment data */
+           long End = S->PC + S->Size;
+           if (S->Size > 0) {
+               /* Point to last element addressed */
+               --End;
+           }
+           fprintf (F, "%-20s  %06lX  %06lX  %06lX\n",
                             GetString (S->Name), S->PC, End, S->Size);
        }
     }
@@ -621,6 +622,32 @@ void PrintSegmentMap (FILE* F)
 
 
 
+void PrintDbgSegments (FILE* F)
+/* Output the segments to the debug file */
+{
+    Segment* S;
+
+    /* Walk over all segments */
+    S = SegRoot;
+    while (S) {
+
+       /* Ignore empty segments */
+        if (S->Size > 0) {
+
+           /* Print the segment data */
+                   fprintf (F, "segment\t\"%s\", 0x%06lX, 0x%04lX, %s, %s\n",
+                            GetString (S->Name), S->PC, S->Size,
+                     SegTypeToStr (S->Type),
+                     S->ReadOnly? "ro" : "rw");
+       }
+
+       /* Follow the linked list */
+       S = S->List;
+    }
+}
+
+
+
 void CheckSegments (void)
 /* Walk through the segment list and check if there are segments that were
  * not written to the output file. Output an error if this is the case.
@@ -628,7 +655,7 @@ void CheckSegments (void)
 {
     Segment* S = SegRoot;
     while (S) {
-       if (S->Size > 0 && S->Dumped == 0) {
+       if (S->Size > 0 && S->Dumped == 0) {
                    Error ("Missing memory area assignment for segment `%s'",
                    GetString (S->Name));
        }
index 660ed78d11e6ad686e841ca178b9a42f5865e648..0df7e8fc366b8466356b3adf734e19ed9cc08e6b 100644 (file)
@@ -6,9 +6,9 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2001 Ullrich von Bassewitz                                       */
-/*               Wacholderweg 14                                             */
-/*               D-70597 Stuttgart                                           */
+/* (C) 1998-2003 Ullrich von Bassewitz                                       */
+/*               Römerstrasse 52                                             */
+/*               D-70794 Filderstadt                                         */
 /* EMail:        uz@cc65.org                                                 */
 /*                                                                           */
 /*                                                                           */
@@ -65,6 +65,7 @@ struct Segment {
     unsigned char      Align;          /* Alignment needed */
     unsigned char      FillVal;        /* Value to use for fill bytes */
     unsigned char      Type;           /* Type of segment */
+    unsigned char       ReadOnly;       /* True for readonly segments (config) */
     unsigned char       Relocatable;    /* True if the segment is relocatable */
     unsigned char              Dumped;         /* Did we dump this segment? */
 };
@@ -145,6 +146,9 @@ void SegWrite (FILE* Tgt, Segment* S, SegWriteFunc F, void* Data);
 void PrintSegmentMap (FILE* F);
 /* Print a segment map to the given file */
 
+void PrintDbgSegments (FILE* F);
+/* Output the segments to the debug file */
+
 void CheckSegments (void);
 /* Walk through the segment list and check if there are segments that were
  * not written to the output file. Output an error if this is the case.