mirror of
https://github.com/cc65/cc65.git
synced 2024-09-08 01:54:33 +00:00
Fixed a bug with different load/run areas, where a segment was marked as
dumped if the run area preceeded the load area, so it was not output into the file for the load area (and not for the run area either). git-svn-id: svn://svn.cc65.org/cc65/trunk@603 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
083f0aee44
commit
724262fb90
@ -109,6 +109,14 @@ static unsigned BinWriteExpr (ExprNode* E, int Signed, unsigned Size,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void PrintBoolVal (const char* Name, int B)
|
||||||
|
/* Print a boolean value for debugging */
|
||||||
|
{
|
||||||
|
printf (" %s = %s\n", Name, B? "true" : "false");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void BinWriteMem (BinDesc* D, Memory* M)
|
static void BinWriteMem (BinDesc* D, Memory* M)
|
||||||
/* Write the segments of one memory area to a file */
|
/* Write the segments of one memory area to a file */
|
||||||
{
|
{
|
||||||
@ -134,6 +142,14 @@ static void BinWriteMem (BinDesc* D, Memory* M)
|
|||||||
S->Load == M && /* LOAD segment */
|
S->Load == M && /* LOAD segment */
|
||||||
S->Seg->Dumped == 0; /* Not already written */
|
S->Seg->Dumped == 0; /* Not already written */
|
||||||
|
|
||||||
|
/* Output the DoWrite flag for debugging */
|
||||||
|
if (Verbose > 1) {
|
||||||
|
PrintBoolVal ("bss", S->Flags & SF_BSS);
|
||||||
|
PrintBoolVal ("LoadArea", S->Load == M);
|
||||||
|
PrintBoolVal ("Dumped", S->Seg->Dumped);
|
||||||
|
PrintBoolVal ("DoWrite", DoWrite);
|
||||||
|
}
|
||||||
|
|
||||||
/* Check if we would need an alignment */
|
/* Check if we would need an alignment */
|
||||||
if (S->Seg->Align > S->Align) {
|
if (S->Seg->Align > S->Align) {
|
||||||
/* Segment itself requires larger alignment than configured
|
/* Segment itself requires larger alignment than configured
|
||||||
@ -175,7 +191,11 @@ static void BinWriteMem (BinDesc* D, Memory* M)
|
|||||||
} else if (M->Flags & MF_FILL) {
|
} else if (M->Flags & MF_FILL) {
|
||||||
WriteMult (D->F, M->FillVal, S->Seg->Size);
|
WriteMult (D->F, M->FillVal, S->Seg->Size);
|
||||||
}
|
}
|
||||||
S->Seg->Dumped = 1;
|
|
||||||
|
/* If this was the load memory area, mark the segment as dumped */
|
||||||
|
if (S->Load == M) {
|
||||||
|
S->Seg->Dumped = 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Calculate the new address */
|
/* Calculate the new address */
|
||||||
Addr += S->Seg->Size;
|
Addr += S->Seg->Size;
|
||||||
|
@ -1367,48 +1367,58 @@ void CfgWriteTarget (void)
|
|||||||
/* Walk through the files list */
|
/* Walk through the files list */
|
||||||
File* F = FileList;
|
File* F = FileList;
|
||||||
while (F) {
|
while (F) {
|
||||||
/* We don't need to look at files with no memory areas */
|
/* We don't need to look at files with no memory areas */
|
||||||
if (F->MemList) {
|
if (F->MemList) {
|
||||||
|
|
||||||
/* Is there an output file? */
|
/* Is there an output file? */
|
||||||
if (strlen (F->Name) > 0) {
|
if (strlen (F->Name) > 0) {
|
||||||
|
|
||||||
/* Assign a proper binary format */
|
/* Assign a proper binary format */
|
||||||
if (F->Format == BINFMT_DEFAULT) {
|
if (F->Format == BINFMT_DEFAULT) {
|
||||||
F->Format = DefaultBinFmt;
|
F->Format = DefaultBinFmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Call the apropriate routine for the binary format */
|
/* Call the apropriate routine for the binary format */
|
||||||
switch (F->Format) {
|
switch (F->Format) {
|
||||||
|
|
||||||
case BINFMT_BINARY:
|
case BINFMT_BINARY:
|
||||||
BinWriteTarget (BinFmtDesc, F);
|
BinWriteTarget (BinFmtDesc, F);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BINFMT_O65:
|
case BINFMT_O65:
|
||||||
O65WriteTarget (O65FmtDesc, F);
|
O65WriteTarget (O65FmtDesc, F);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Internal ("Invalid binary format: %u", F->Format);
|
Internal ("Invalid binary format: %u", F->Format);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
/* No output file. Walk through the list and mark all segments
|
/* No output file. Walk through the list and mark all segments
|
||||||
* assigned to the memory areas in this file as dumped.
|
* loading into these memory areas in this file as dumped.
|
||||||
*/
|
*/
|
||||||
M = F->MemList;
|
M = F->MemList;
|
||||||
while (M) {
|
while (M) {
|
||||||
/* Walk throught the segments */
|
|
||||||
MemListNode* N = M->SegList;
|
|
||||||
while (N) {
|
|
||||||
/* Mark the segment as dumped */
|
|
||||||
N->Seg->Seg->Dumped = 1;
|
|
||||||
|
|
||||||
/* Next segment node */
|
MemListNode* N;
|
||||||
N = N->Next;
|
|
||||||
|
/* Debugging */
|
||||||
|
if (Verbose > 1) {
|
||||||
|
printf ("Skipping `%s'...\n", M->Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Walk throught the segments */
|
||||||
|
N = M->SegList;
|
||||||
|
while (N) {
|
||||||
|
if (N->Seg->Load == M) {
|
||||||
|
/* Load area - mark the segment as dumped */
|
||||||
|
N->Seg->Seg->Dumped = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Next segment node */
|
||||||
|
N = N->Next;
|
||||||
}
|
}
|
||||||
/* Next memory area */
|
/* Next memory area */
|
||||||
M = M->FNext;
|
M = M->FNext;
|
||||||
|
Loading…
Reference in New Issue
Block a user