1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-25 02:29:52 +00:00
This commit is contained in:
laubzega 2020-05-25 23:43:28 -07:00 committed by Oliver Schmidt
parent 68eb0f2cdc
commit 083f3ae26b
2 changed files with 11 additions and 3 deletions

View File

@ -195,7 +195,7 @@ static void BinWriteMem (BinDesc* D, MemoryArea* M)
if (DoWrite || (M->Flags & MF_FILL) != 0) {
/* Seek in "overwrite" segments */
if (S->Flags & SF_OVERWRITE) {
fseek (D->F, NewAddr - M->Start, SEEK_SET);
fseek (D->F, NewAddr - M->Start + M->FileOffs, SEEK_SET);
} else {
WriteMult (D->F, M->FillVal, NewAddr-Addr);
PrintNumVal ("SF_OFFSET", NewAddr - Addr);
@ -226,6 +226,12 @@ static void BinWriteMem (BinDesc* D, MemoryArea* M)
unsigned long P = ftell (D->F);
SegWrite (D->Filename, D->F, S->Seg, BinWriteExpr, D);
PrintNumVal ("Wrote", (unsigned long) (ftell (D->F) - P));
/* If we have just written an OVERWRITE segement, move position to the
* end of file, so that subsequent segments are written in the correct
* place. */
if (S->Flags & SF_OVERWRITE) {
fseek (D->F, 0, SEEK_END);
}
} else if (M->Flags & MF_FILL) {
WriteMult (D->F, S->Seg->FillVal, S->Seg->Size);
PrintNumVal ("Filled", (unsigned long) S->Seg->Size);

View File

@ -2107,10 +2107,12 @@ unsigned CfgProcess (void)
Addr += S->Seg->Size;
/* If this segment will go out to the file, or its place
** in the file will be filled, then increase the file size.
** in the file will be filled, then increase the file size,
** unless it's an OVERWRITE segment.
*/
if (S->Load == M &&
((S->Flags & SF_BSS) == 0 || (M->Flags & MF_FILL) != 0)) {
((S->Flags & SF_BSS) == 0 || (M->Flags & MF_FILL) != 0)
&& (S->Flags & SF_OVERWRITE) == 0) {
M->F->Size += Addr - StartAddr;
}
}