1
0
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:
uz 2010-08-08 20:32:13 +00:00
parent 6272c93556
commit 14e567aed2
4 changed files with 35 additions and 28 deletions

View File

@ -225,7 +225,7 @@ static void BinWriteMem (BinDesc* D, Memory* M)
if (DoWrite) {
unsigned long P = ftell (D->F);
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));
} else if (M->Flags & MF_FILL) {
WriteMult (D->F, M->FillVal, S->Seg->Size);

View File

@ -6,7 +6,7 @@
/* */
/* */
/* */
/* (C) 1999-2009, Ullrich von Bassewitz */
/* (C) 1999-2010, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
@ -786,7 +786,7 @@ static void O65WriteSeg (O65Desc* D, SegDesc** Seg, unsigned Count, int DoWrite)
/* Write this segment */
if (DoWrite) {
SegWrite (D->F, S->Seg, O65WriteExpr, D);
SegWrite (D->Filename, D->F, S->Seg, O65WriteExpr, D);
}
/* Mark the segment as dumped */

View File

@ -96,6 +96,8 @@ static Segment* NewSegment (unsigned Name, unsigned char AddrSize)
S->PC = 0;
S->Size = 0;
S->AlignObj = 0;
S->OutputName = 0;
S->OutputOffs = 0;
S->Align = 0;
S->FillVal = 0;
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
* called (see description of SegWriteFunc above).
*/
@ -489,6 +491,10 @@ void SegWrite (FILE* Tgt, Segment* S, SegWriteFunc F, void* Data)
int Sign;
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 */
Section* Sec = S->SecRoot;
while (Sec) {
@ -651,22 +657,21 @@ void PrintSegmentMap (FILE* F)
void PrintDbgSegments (FILE* F)
/* Output the segments to the debug file */
{
Segment* S;
/* Walk over all segments */
S = SegRoot;
Segment* S = SegRoot;
while (S) {
/* Ignore empty segments */
if (S->Size > 0) {
/* Print the segment data */
fprintf (F,
"segment\tid=%u,name=\"%s\",start=0x%06lX,size=0x%04lX,addrsize=%s,type=%s\n",
"segment\tid=%u,name=\"%s\",start=0x%06lX,size=0x%04lX,addrsize=%s,type=%s",
S->Id, GetString (S->Name), S->PC, S->Size,
AddrSizeToStr (S->AddrSize),
S->ReadOnly? "ro" : "rw");
if (S->OutputName) {
fprintf (F, ",outputname=\"%s\",outputoffs=%lu",
S->OutputName, S->OutputOffs);
}
fputc ('\n', F);
/* Follow the linked list */
S = S->List;

View File

@ -63,6 +63,8 @@ struct Segment {
unsigned long PC; /* PC were this segment is located */
unsigned long Size; /* Size of data so far */
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 FillVal; /* Value to use for fill bytes */
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.
*/
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
* called (see description of SegWriteFunc above).
*/