Added a "fillval" attribute to the segment definition. When given, it

overrides the value from the memory area for all space that lies within the
segment itself.


git-svn-id: svn://svn.cc65.org/cc65/trunk@5823 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz
2012-09-09 19:00:43 +00:00
parent 1c77d3a6f0
commit 574c8fa273
5 changed files with 55 additions and 19 deletions

View File

@@ -118,6 +118,7 @@ static Collection SegDescList = STATIC_COLLECTION_INITIALIZER;
#define SA_OFFSET 0x0040
#define SA_START 0x0080
#define SA_OPTIONAL 0x0100
#define SA_FILLVAL 0x0200
/* Symbol types used in the CfgSymbol structure */
typedef enum {
@@ -353,6 +354,7 @@ static SegDesc* NewSegDesc (unsigned Name)
S->Seg = 0;
S->Attr = 0;
S->Flags = 0;
S->FillVal = 0;
S->RunAlignment = 1;
S->LoadAlignment = 1;
@@ -637,6 +639,7 @@ static void ParseSegments (void)
{ "ALIGN", CFGTOK_ALIGN },
{ "ALIGN_LOAD", CFGTOK_ALIGN_LOAD },
{ "DEFINE", CFGTOK_DEFINE },
{ "FILLVAL", CFGTOK_FILLVAL },
{ "LOAD", CFGTOK_LOAD },
{ "OFFSET", CFGTOK_OFFSET },
{ "OPTIONAL", CFGTOK_OPTIONAL },
@@ -706,6 +709,12 @@ static void ParseSegments (void)
CfgNextTok ();
break;
case CFGTOK_FILLVAL:
FlagAttr (&S->Attr, SA_FILLVAL, "FILLVAL");
S->FillVal = (unsigned char) CfgCheckedConstExpr (0, 0xFF);
S->Flags |= SF_FILLVAL;
break;
case CFGTOK_LOAD:
FlagAttr (&S->Attr, SA_LOAD, "LOAD");
S->Load = CfgGetMemory (GetStrBufId (&CfgSVal));
@@ -1561,22 +1570,22 @@ static void ProcessSegments (void)
while (I < CollCount (&SegDescList)) {
/* Get the next segment descriptor */
SegDesc* S = CollAtUnchecked (&SegDescList, I);
SegDesc* S = CollAtUnchecked (&SegDescList, I);
/* Search for the actual segment in the input files. The function may
* return NULL (no such segment), this is checked later.
*/
S->Seg = SegFind (S->Name);
/* If the segment is marked as BSS style, and if the segment exists
/* If the segment is marked as BSS style, and if the segment exists
* in any of the object file, check that there's no initialized data
* in the segment.
*/
if ((S->Flags & SF_BSS) != 0 && S->Seg != 0 && !IsBSSType (S->Seg)) {
*/
if ((S->Flags & SF_BSS) != 0 && S->Seg != 0 && !IsBSSType (S->Seg)) {
CfgWarning (GetSourcePos (S->LI),
"Segment `%s' with type `bss' contains initialized data",
GetString (S->Name));
}
GetString (S->Name));
}
/* If this segment does exist in any of the object files, insert the
* segment into the load/run memory areas. Otherwise print a warning
@@ -1592,6 +1601,9 @@ static void ProcessSegments (void)
MemoryInsert (S->Load, S);
}
/* Use the fill value from the config */
S->Seg->FillVal = S->FillVal;
/* Process the next segment descriptor in the next run */
++I;
@@ -1894,6 +1906,13 @@ unsigned CfgProcess (void)
}
/* If this is the load memory area and the segment doesn't have a
* fill value defined, use the one from the memory area.
*/
if (S->Load == M && (S->Flags & SF_FILLVAL) == 0) {
S->Seg->FillVal = M->FillVal;
}
/* Increment the fill level of the memory area and check for an
* overflow.
*/