From c17816fafd2d2550d38526070bb02d2e963f0ab3 Mon Sep 17 00:00:00 2001 From: uz Date: Wed, 8 Jun 2011 18:28:21 +0000 Subject: [PATCH] Added more debug output. git-svn-id: svn://svn.cc65.org/cc65/trunk@5041 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/ld65/segments.c | 23 +++++++++++++++++------ src/ld65/segments.h | 3 ++- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/ld65/segments.c b/src/ld65/segments.c index e1153de82..f6add7a21 100644 --- a/src/ld65/segments.c +++ b/src/ld65/segments.c @@ -172,6 +172,7 @@ Section* NewSection (Segment* Seg, unsigned char Align, unsigned char AddrSize) /* Initialize the data */ S->Next = 0; S->Seg = Seg; + S->Obj = 0; S->FragRoot = 0; S->FragLast = 0; S->Size = 0; @@ -231,6 +232,9 @@ Section* ReadSection (FILE* F, ObjData* O) /* Allocate the section we will return later */ Sec = NewSection (S, Align, Type); + /* Remember the object file this section was from */ + Sec->Obj = O; + /* Set up the minimum segment alignment */ if (Sec->Align > S->Align) { /* Section needs larger alignment, use this one */ @@ -467,7 +471,12 @@ void SegWrite (const char* TgtName, FILE* Tgt, Segment* S, SegWriteFunc F, void* while (Sec) { Fragment* Frag; + /* Output were this section is from */ + Print (stdout, 2, " Section from \"%s\"\n", GetObjFileName (Sec->Obj)); + /* If we have fill bytes, write them now */ + Print (stdout, 2, " Filling 0x%x bytes with 0x%02x\n", + Sec->Fill, S->FillVal); WriteMult (Tgt, S->FillVal, Sec->Fill); Offs += Sec->Fill; @@ -480,14 +489,14 @@ void SegWrite (const char* TgtName, FILE* Tgt, Segment* S, SegWriteFunc F, void* /* Output fragment data */ - switch (Frag->Type) { + switch (Frag->Type) { - case FRAG_LITERAL: - WriteData (Tgt, Frag->LitBuf, Frag->Size); - break; + case FRAG_LITERAL: + WriteData (Tgt, Frag->LitBuf, Frag->Size); + break; - case FRAG_EXPR: - case FRAG_SEXPR: + case FRAG_EXPR: + case FRAG_SEXPR: Sign = (Frag->Type == FRAG_SEXPR); /* Call the users function and evaluate the result */ switch (F (Frag->Expr, Sign, Frag->Size, Offs, Data)) { @@ -527,6 +536,8 @@ void SegWrite (const char* TgtName, FILE* Tgt, Segment* S, SegWriteFunc F, void* } /* Update the offset */ + Print (stdout, 2, " Fragment with 0x%x bytes\n", + Frag->Size); Offs += Frag->Size; /* Next fragment */ diff --git a/src/ld65/segments.h b/src/ld65/segments.h index 3af9fa09e..45f5f512f 100644 --- a/src/ld65/segments.h +++ b/src/ld65/segments.h @@ -70,7 +70,7 @@ struct Segment { unsigned char AddrSize; /* Address size of segment */ unsigned char ReadOnly; /* True for readonly segments (config) */ unsigned char Relocatable; /* True if the segment is relocatable */ - unsigned char Placed; /* Did we place this segment already? */ + unsigned char Placed; /* Did we place this segment already? */ unsigned char Dumped; /* Did we dump this segment? */ }; @@ -81,6 +81,7 @@ typedef struct Section Section; struct Section { Section* Next; /* List of sections in a segment */ Segment* Seg; /* Segment that contains the section */ + struct ObjData* Obj; /* Object file this section comes from */ struct Fragment* FragRoot; /* Fragment list */ struct Fragment* FragLast; /* Pointer to last fragment */ unsigned long Offs; /* Offset into the segment */ -- 2.39.5