Added an OPTIONAL segment attribute

git-svn-id: svn://svn.cc65.org/cc65/trunk@2162 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2003-05-22 22:20:32 +00:00
parent 741362f830
commit 40609f0a3c
3 changed files with 108 additions and 93 deletions

View File

@@ -6,10 +6,10 @@
/* */ /* */
/* */ /* */
/* */ /* */
/* (C) 1998-2002 Ullrich von Bassewitz */ /* (C) 1998-2003 Ullrich von Bassewitz */
/* Wacholderweg 14 */ /* R<EFBFBD>merstrasse 52 */
/* D-70597 Stuttgart */ /* D-70794 Filderstadt */
/* EMail: uz@musoftware.de */ /* EMail: uz@cc65.org */
/* */ /* */
/* */ /* */
/* This software is provided 'as-is', without any expressed or implied */ /* This software is provided 'as-is', without any expressed or implied */
@@ -98,6 +98,7 @@ unsigned SegDescCount; /* Number of entries in list */
#define SA_DEFINE 0x0010 #define SA_DEFINE 0x0010
#define SA_OFFSET 0x0020 #define SA_OFFSET 0x0020
#define SA_START 0x0040 #define SA_START 0x0040
#define SA_OPTIONAL 0x0080
@@ -336,11 +337,10 @@ static SegDesc* NewSegDesc (const char* Name)
CfgError ("Segment `%s' defined twice", Name); CfgError ("Segment `%s' defined twice", Name);
} }
/* Verify that the given segment does really exist */ /* Search for the actual segment in the input files. The function may
* return NULL (no such segment), this is checked later.
*/
Seg = SegFind (Name); Seg = SegFind (Name);
if (Seg == 0) {
CfgWarning ("Segment `%s' does not exist", Name);
}
/* Allocate memory */ /* Allocate memory */
S = xmalloc (sizeof (SegDesc) + Len); S = xmalloc (sizeof (SegDesc) + Len);
@@ -608,13 +608,14 @@ static void ParseSegments (void)
/* Parse a SEGMENTS section */ /* Parse a SEGMENTS section */
{ {
static const IdentTok Attributes [] = { static const IdentTok Attributes [] = {
{ "LOAD", CFGTOK_LOAD },
{ "RUN", CFGTOK_RUN },
{ "TYPE", CFGTOK_TYPE },
{ "ALIGN", CFGTOK_ALIGN }, { "ALIGN", CFGTOK_ALIGN },
{ "DEFINE", CFGTOK_DEFINE }, { "DEFINE", CFGTOK_DEFINE },
{ "LOAD", CFGTOK_LOAD },
{ "OFFSET", CFGTOK_OFFSET }, { "OFFSET", CFGTOK_OFFSET },
{ "OPTIONAL", CFGTOK_OPTIONAL },
{ "RUN", CFGTOK_RUN },
{ "START", CFGTOK_START }, { "START", CFGTOK_START },
{ "TYPE", CFGTOK_TYPE },
}; };
static const IdentTok Types [] = { static const IdentTok Types [] = {
{ "RO", CFGTOK_RO }, { "RO", CFGTOK_RO },
@@ -653,29 +654,6 @@ static void ParseSegments (void)
/* Check which attribute was given */ /* Check which attribute was given */
switch (AttrTok) { switch (AttrTok) {
case CFGTOK_LOAD:
FlagAttr (&S->Attr, SA_LOAD, "LOAD");
S->Load = CfgGetMemory (CfgSVal);
break;
case CFGTOK_RUN:
FlagAttr (&S->Attr, SA_RUN, "RUN");
S->Run = CfgGetMemory (CfgSVal);
break;
case CFGTOK_TYPE:
FlagAttr (&S->Attr, SA_TYPE, "TYPE");
CfgSpecialToken (Types, ENTRY_COUNT (Types), "Type");
switch (CfgTok) {
case CFGTOK_RO: S->Flags |= SF_RO; break;
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;
case CFGTOK_ALIGN: case CFGTOK_ALIGN:
CfgAssureInt (); CfgAssureInt ();
FlagAttr (&S->Attr, SA_ALIGN, "ALIGN"); FlagAttr (&S->Attr, SA_ALIGN, "ALIGN");
@@ -696,6 +674,11 @@ static void ParseSegments (void)
} }
break; break;
case CFGTOK_LOAD:
FlagAttr (&S->Attr, SA_LOAD, "LOAD");
S->Load = CfgGetMemory (CfgSVal);
break;
case CFGTOK_OFFSET: case CFGTOK_OFFSET:
CfgAssureInt (); CfgAssureInt ();
FlagAttr (&S->Attr, SA_OFFSET, "OFFSET"); FlagAttr (&S->Attr, SA_OFFSET, "OFFSET");
@@ -704,6 +687,19 @@ static void ParseSegments (void)
S->Flags |= SF_OFFSET; S->Flags |= SF_OFFSET;
break; break;
case CFGTOK_OPTIONAL:
FlagAttr (&S->Attr, SA_OPTIONAL, "OPTIONAL");
CfgBoolToken ();
if (CfgTok == CFGTOK_TRUE) {
S->Flags |= SF_OPTIONAL;
}
break;
case CFGTOK_RUN:
FlagAttr (&S->Attr, SA_RUN, "RUN");
S->Run = CfgGetMemory (CfgSVal);
break;
case CFGTOK_START: case CFGTOK_START:
CfgAssureInt (); CfgAssureInt ();
FlagAttr (&S->Attr, SA_START, "START"); FlagAttr (&S->Attr, SA_START, "START");
@@ -712,6 +708,19 @@ static void ParseSegments (void)
S->Flags |= SF_START; S->Flags |= SF_START;
break; break;
case CFGTOK_TYPE:
FlagAttr (&S->Attr, SA_TYPE, "TYPE");
CfgSpecialToken (Types, ENTRY_COUNT (Types), "Type");
switch (CfgTok) {
case CFGTOK_RO: S->Flags |= SF_RO; break;
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;
default: default:
FAIL ("Unexpected attribute token"); FAIL ("Unexpected attribute token");
@@ -772,9 +781,9 @@ static void ParseSegments (void)
} }
/* If this segment does exist in any of the object files, insert the /* If this segment does exist in any of the object files, insert the
* descriptor into the list of segment descriptors. Otherwise discard * descriptor into the list of segment descriptors. Otherwise print a
* it silently, because the segment pointer in the descriptor is * warning and discard it, because the segment pointer in the
* invalid. * descriptor is invalid.
*/ */
if (S->Seg != 0) { if (S->Seg != 0) {
/* Insert the descriptor into the list of all descriptors */ /* Insert the descriptor into the list of all descriptors */
@@ -786,7 +795,11 @@ static void ParseSegments (void)
MemoryInsert (S->Load, S); MemoryInsert (S->Load, S);
} }
} else { } else {
/* Segment does not exist, discard the descriptor */ /* Print a warning if the segment is not optional */
if ((S->Flags & SF_OPTIONAL) == 0) {
CfgWarning ("Segment `%s' does not exist", S->Name);
}
/* Discard the descriptor */
FreeSegDesc (S); FreeSegDesc (S);
} }

View File

@@ -6,10 +6,10 @@
/* */ /* */
/* */ /* */
/* */ /* */
/* (C) 1998-2000 Ullrich von Bassewitz */ /* (C) 1998-2003 Ullrich von Bassewitz */
/* Wacholderweg 14 */ /* R<EFBFBD>merstrasse 52 */
/* D-70597 Stuttgart */ /* D-70794 Filderstadt */
/* EMail: uz@musoftware.de */ /* EMail: uz@cc65.org */
/* */ /* */
/* */ /* */
/* This software is provided 'as-is', without any expressed or implied */ /* This software is provided 'as-is', without any expressed or implied */
@@ -115,6 +115,7 @@ extern unsigned SegDescCount; /* Number of entries in list */
#define SF_ALIGN 0x0020 /* Align the segment */ #define SF_ALIGN 0x0020 /* Align the segment */
#define SF_OFFSET 0x0040 /* Segment has offset in memory */ #define SF_OFFSET 0x0040 /* Segment has offset in memory */
#define SF_START 0x0080 /* Segment has fixed start address */ #define SF_START 0x0080 /* Segment has fixed start address */
#define SF_OPTIONAL 0x0100 /* Segment is optional (must not exist) */
#define SF_LOAD_AND_RUN 0x1000 /* LOAD and RUN given */ #define SF_LOAD_AND_RUN 0x1000 /* LOAD and RUN given */
#define SF_RUN_DEF 0x2000 /* RUN symbols already defined */ #define SF_RUN_DEF 0x2000 /* RUN symbols already defined */
#define SF_LOAD_DEF 0x4000 /* LOAD symbols already defined */ #define SF_LOAD_DEF 0x4000 /* LOAD symbols already defined */

View File

@@ -6,10 +6,10 @@
/* */ /* */
/* */ /* */
/* */ /* */
/* (C) 1998-2000 Ullrich von Bassewitz */ /* (C) 1998-2003 Ullrich von Bassewitz */
/* Wacholderweg 14 */ /* R<EFBFBD>merstrasse 52 */
/* D-70597 Stuttgart */ /* D-70794 Filderstadt */
/* EMail: uz@musoftware.de */ /* EMail: uz@cc65.org */
/* */ /* */
/* */ /* */
/* This software is provided 'as-is', without any expressed or implied */ /* This software is provided 'as-is', without any expressed or implied */
@@ -85,6 +85,7 @@ typedef enum {
CFGTOK_RUN, CFGTOK_RUN,
CFGTOK_ALIGN, CFGTOK_ALIGN,
CFGTOK_OFFSET, CFGTOK_OFFSET,
CFGTOK_OPTIONAL,
CFGTOK_RO, CFGTOK_RO,
CFGTOK_RW, CFGTOK_RW,