{ "RW", CFGTOK_RW },
{ "BSS", CFGTOK_BSS },
{ "ZP", CFGTOK_ZP },
- { "WP", CFGTOK_WPROT },
- { "WPROT", CFGTOK_WPROT },
+ { "WPROT", CFGTOK_RO }, /* ### OBSOLETE */
};
unsigned Count;
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;
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;
}
+/* ld65 */
#include "segments.h"
#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 */
--- /dev/null
+/*****************************************************************************/
+/* */
+/* 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));
+ }
+}
+
+
+
--- /dev/null
+/*****************************************************************************/
+/* */
+/* 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
+
+
+
#include "binfmt.h"
#include "condes.h"
#include "config.h"
+#include "dbgfile.h"
#include "error.h"
#include "exports.h"
#include "fileio.h"
binfmt.o \
condes.o \
config.o \
+ dbgfile.o \
dbginfo.o \
dbgsyms.o \
error.o \
binfmt.obj \
condes.obj \
config.obj \
+ dbgfile.obj \
dbginfo.obj \
dbgsyms.obj \
error.obj \
/* ld65 */
#include "config.h"
-#include "dbginfo.h"
#include "dbgsyms.h"
#include "exports.h"
#include "global.h"
-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));
- }
-}
-
-
-
/* */
/* */
/* */
-/* (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 */
/*****************************************************************************/
void CreateLabelFile (void);
/* Create a label file */
-void CreateDbgFile (void);
-/* Create a debug info file */
-
/* End of mapfile.h */
CFGTOK_RW,
CFGTOK_BSS,
CFGTOK_ZP,
- CFGTOK_WPROT,
CFGTOK_O65,
CFGTOK_BIN,
S->Align = 0;
S->FillVal = 0;
S->Type = Type;
+ S->ReadOnly = 0;
S->Relocatable = 0;
S->Dumped = 0;
unsigned long Count = F->Size;
while (Count--) {
if (*Data++ != 0) {
- return 0;
+ return 0;
}
}
} else if (F->Type == FRAG_EXPR || F->Type == FRAG_SEXPR) {
/* 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);
}
}
+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.
{
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));
}
/* */
/* */
/* */
-/* (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 */
/* */
/* */
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? */
};
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.