mirror of
https://github.com/cc65/cc65.git
synced 2024-12-26 08:32:00 +00:00
Another format change: Record the output file and offset for each segment
written to the output. Make this information available in the debug info file. git-svn-id: svn://svn.cc65.org/cc65/trunk@4797 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
6272c93556
commit
14e567aed2
@ -225,7 +225,7 @@ static void BinWriteMem (BinDesc* D, Memory* M)
|
|||||||
if (DoWrite) {
|
if (DoWrite) {
|
||||||
unsigned long P = ftell (D->F);
|
unsigned long P = ftell (D->F);
|
||||||
S->Seg->FillVal = M->FillVal;
|
S->Seg->FillVal = M->FillVal;
|
||||||
SegWrite (D->F, S->Seg, BinWriteExpr, D);
|
SegWrite (D->Filename, D->F, S->Seg, BinWriteExpr, D);
|
||||||
PrintNumVal ("Wrote", (unsigned long) (ftell (D->F) - P));
|
PrintNumVal ("Wrote", (unsigned long) (ftell (D->F) - P));
|
||||||
} 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);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1999-2009, Ullrich von Bassewitz */
|
/* (C) 1999-2010, Ullrich von Bassewitz */
|
||||||
/* Roemerstrasse 52 */
|
/* Roemerstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
@ -786,7 +786,7 @@ static void O65WriteSeg (O65Desc* D, SegDesc** Seg, unsigned Count, int DoWrite)
|
|||||||
|
|
||||||
/* Write this segment */
|
/* Write this segment */
|
||||||
if (DoWrite) {
|
if (DoWrite) {
|
||||||
SegWrite (D->F, S->Seg, O65WriteExpr, D);
|
SegWrite (D->Filename, D->F, S->Seg, O65WriteExpr, D);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mark the segment as dumped */
|
/* Mark the segment as dumped */
|
||||||
|
@ -96,6 +96,8 @@ static Segment* NewSegment (unsigned Name, unsigned char AddrSize)
|
|||||||
S->PC = 0;
|
S->PC = 0;
|
||||||
S->Size = 0;
|
S->Size = 0;
|
||||||
S->AlignObj = 0;
|
S->AlignObj = 0;
|
||||||
|
S->OutputName = 0;
|
||||||
|
S->OutputOffs = 0;
|
||||||
S->Align = 0;
|
S->Align = 0;
|
||||||
S->FillVal = 0;
|
S->FillVal = 0;
|
||||||
S->AddrSize = AddrSize;
|
S->AddrSize = AddrSize;
|
||||||
@ -481,7 +483,7 @@ unsigned SegWriteConstExpr (FILE* F, ExprNode* E, int Signed, unsigned Size)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void SegWrite (FILE* Tgt, Segment* S, SegWriteFunc F, void* Data)
|
void SegWrite (const char* TgtName, FILE* Tgt, Segment* S, SegWriteFunc F, void* Data)
|
||||||
/* Write the data from the given segment to a file. For expressions, F is
|
/* Write the data from the given segment to a file. For expressions, F is
|
||||||
* called (see description of SegWriteFunc above).
|
* called (see description of SegWriteFunc above).
|
||||||
*/
|
*/
|
||||||
@ -489,18 +491,22 @@ void SegWrite (FILE* Tgt, Segment* S, SegWriteFunc F, void* Data)
|
|||||||
int Sign;
|
int Sign;
|
||||||
unsigned long Offs = 0;
|
unsigned long Offs = 0;
|
||||||
|
|
||||||
|
/* Remember the output file and offset for the segment */
|
||||||
|
S->OutputName = TgtName;
|
||||||
|
S->OutputOffs = (unsigned long) ftell (Tgt);
|
||||||
|
|
||||||
/* Loop over all sections in this segment */
|
/* Loop over all sections in this segment */
|
||||||
Section* Sec = S->SecRoot;
|
Section* Sec = S->SecRoot;
|
||||||
while (Sec) {
|
while (Sec) {
|
||||||
Fragment* Frag;
|
Fragment* Frag;
|
||||||
|
|
||||||
/* If we have fill bytes, write them now */
|
/* If we have fill bytes, write them now */
|
||||||
WriteMult (Tgt, S->FillVal, Sec->Fill);
|
WriteMult (Tgt, S->FillVal, Sec->Fill);
|
||||||
Offs += Sec->Fill;
|
Offs += Sec->Fill;
|
||||||
|
|
||||||
/* Loop over all fragments in this section */
|
/* Loop over all fragments in this section */
|
||||||
Frag = Sec->FragRoot;
|
Frag = Sec->FragRoot;
|
||||||
while (Frag) {
|
while (Frag) {
|
||||||
|
|
||||||
/* Do fragment alignment checks */
|
/* Do fragment alignment checks */
|
||||||
|
|
||||||
@ -523,13 +529,13 @@ void SegWrite (FILE* Tgt, Segment* S, SegWriteFunc F, void* Data)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SEG_EXPR_RANGE_ERROR:
|
case SEG_EXPR_RANGE_ERROR:
|
||||||
Error ("Range error in module `%s', line %lu",
|
Error ("Range error in module `%s', line %lu",
|
||||||
GetFragmentSourceName (Frag),
|
GetFragmentSourceName (Frag),
|
||||||
GetFragmentSourceLine (Frag));
|
GetFragmentSourceLine (Frag));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SEG_EXPR_TOO_COMPLEX:
|
case SEG_EXPR_TOO_COMPLEX:
|
||||||
Error ("Expression too complex in module `%s', line %lu",
|
Error ("Expression too complex in module `%s', line %lu",
|
||||||
GetFragmentSourceName (Frag),
|
GetFragmentSourceName (Frag),
|
||||||
GetFragmentSourceLine (Frag));
|
GetFragmentSourceLine (Frag));
|
||||||
break;
|
break;
|
||||||
@ -553,7 +559,7 @@ void SegWrite (FILE* Tgt, Segment* S, SegWriteFunc F, void* Data)
|
|||||||
Internal ("Invalid fragment type: %02X", Frag->Type);
|
Internal ("Invalid fragment type: %02X", Frag->Type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update the offset */
|
/* Update the offset */
|
||||||
Offs += Frag->Size;
|
Offs += Frag->Size;
|
||||||
|
|
||||||
/* Next fragment */
|
/* Next fragment */
|
||||||
@ -651,22 +657,21 @@ void PrintSegmentMap (FILE* F)
|
|||||||
void PrintDbgSegments (FILE* F)
|
void PrintDbgSegments (FILE* F)
|
||||||
/* Output the segments to the debug file */
|
/* Output the segments to the debug file */
|
||||||
{
|
{
|
||||||
Segment* S;
|
|
||||||
|
|
||||||
/* Walk over all segments */
|
/* Walk over all segments */
|
||||||
S = SegRoot;
|
Segment* S = SegRoot;
|
||||||
while (S) {
|
while (S) {
|
||||||
|
|
||||||
/* Ignore empty segments */
|
/* Print the segment data */
|
||||||
if (S->Size > 0) {
|
fprintf (F,
|
||||||
|
"segment\tid=%u,name=\"%s\",start=0x%06lX,size=0x%04lX,addrsize=%s,type=%s",
|
||||||
/* Print the segment data */
|
S->Id, GetString (S->Name), S->PC, S->Size,
|
||||||
fprintf (F,
|
AddrSizeToStr (S->AddrSize),
|
||||||
"segment\tid=%u,name=\"%s\",start=0x%06lX,size=0x%04lX,addrsize=%s,type=%s\n",
|
S->ReadOnly? "ro" : "rw");
|
||||||
S->Id, GetString (S->Name), S->PC, S->Size,
|
if (S->OutputName) {
|
||||||
AddrSizeToStr (S->AddrSize),
|
fprintf (F, ",outputname=\"%s\",outputoffs=%lu",
|
||||||
S->ReadOnly? "ro" : "rw");
|
S->OutputName, S->OutputOffs);
|
||||||
}
|
}
|
||||||
|
fputc ('\n', F);
|
||||||
|
|
||||||
/* Follow the linked list */
|
/* Follow the linked list */
|
||||||
S = S->List;
|
S = S->List;
|
||||||
|
@ -63,6 +63,8 @@ struct Segment {
|
|||||||
unsigned long PC; /* PC were this segment is located */
|
unsigned long PC; /* PC were this segment is located */
|
||||||
unsigned long Size; /* Size of data so far */
|
unsigned long Size; /* Size of data so far */
|
||||||
struct ObjData* AlignObj; /* Module that requested the alignment */
|
struct ObjData* AlignObj; /* Module that requested the alignment */
|
||||||
|
const char* OutputName; /* Name of output file or NULL */
|
||||||
|
unsigned long OutputOffs; /* Offset in output file */
|
||||||
unsigned char Align; /* Alignment needed */
|
unsigned char Align; /* Alignment needed */
|
||||||
unsigned char FillVal; /* Value to use for fill bytes */
|
unsigned char FillVal; /* Value to use for fill bytes */
|
||||||
unsigned char AddrSize; /* Address size of segment */
|
unsigned char AddrSize; /* Address size of segment */
|
||||||
@ -139,7 +141,7 @@ unsigned SegWriteConstExpr (FILE* F, ExprNode* E, int Signed, unsigned Size);
|
|||||||
* check and return one of the SEG_EXPR_xxx codes.
|
* check and return one of the SEG_EXPR_xxx codes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void SegWrite (FILE* Tgt, Segment* S, SegWriteFunc F, void* Data);
|
void SegWrite (const char* TgtName, FILE* Tgt, Segment* S, SegWriteFunc F, void* Data);
|
||||||
/* Write the data from the given segment to a file. For expressions, F is
|
/* Write the data from the given segment to a file. For expressions, F is
|
||||||
* called (see description of SegWriteFunc above).
|
* called (see description of SegWriteFunc above).
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user