static void PrintBoolVal (const char* Name, int B)
/* Print a boolean value for debugging */
{
- printf (" %s = %s\n", Name, B? "true" : "false");
+ Print (stdout, 2, " %s = %s\n", Name, B? "true" : "false");
+}
+
+
+
+static void PrintNumVal (const char* Name, unsigned long V)
+/* Print a numerical value for debugging */
+{
+ Print (stdout, 2, " %s = 0x%lx\n", Name, V);
}
S->Load == M && /* LOAD segment */
S->Seg->Dumped == 0; /* Not already written */
- /* Output the DoWrite flag for debugging */
- if (Verbosity > 1) {
- PrintBoolVal ("bss", S->Flags & SF_BSS);
- PrintBoolVal ("LoadArea", S->Load == M);
- PrintBoolVal ("Dumped", S->Seg->Dumped);
- PrintBoolVal ("DoWrite", DoWrite);
- }
+ /* Output debugging stuff */
+ PrintBoolVal ("bss", S->Flags & SF_BSS);
+ PrintBoolVal ("LoadArea", S->Load == M);
+ PrintBoolVal ("Dumped", S->Seg->Dumped);
+ PrintBoolVal ("DoWrite", DoWrite);
+ PrintNumVal ("Address", Addr);
+ PrintNumVal ("FileOffs", (unsigned long) ftell (D->F));
/* Check if we would need an alignment */
if (S->Seg->Align > S->Align) {
/* Align the address */
unsigned long Val = (0x01UL << S->Align) - 1;
unsigned long NewAddr = (Addr + Val) & ~Val;
- if (DoWrite) {
- WriteMult (D->F, M->FillVal, NewAddr-Addr);
+ if (DoWrite || (M->Flags & MF_FILL) != 0) {
+ WriteMult (D->F, M->FillVal, NewAddr - Addr);
+ PrintNumVal ("SF_ALIGN", NewAddr - Addr);
}
Addr = NewAddr;
} else if (S->Flags & (SF_OFFSET | SF_START)) {
/* It's an offset, not a fixed address, make an address */
NewAddr += M->Start;
}
- if (DoWrite) {
+ if (DoWrite || (M->Flags & MF_FILL) != 0) {
WriteMult (D->F, M->FillVal, NewAddr-Addr);
+ PrintNumVal ("SF_OFFSET", NewAddr - Addr);
}
Addr = NewAddr;
}
/* Align the address */
unsigned long Val = (0x01UL << S->AlignLoad) - 1;
unsigned long NewAddr = (Addr + Val) & ~Val;
- if (DoWrite) {
+ if (DoWrite || (M->Flags & MF_FILL) != 0) {
WriteMult (D->F, M->FillVal, NewAddr-Addr);
+ PrintNumVal ("SF_ALIGN_LOAD", NewAddr - Addr);
}
Addr = NewAddr;
}
* if the memory area is the load area.
*/
if (DoWrite) {
+ unsigned long P = ftell (D->F);
RelocLineInfo (S->Seg);
S->Seg->FillVal = M->FillVal;
SegWrite (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);
+ PrintNumVal ("Filled", (unsigned long) S->Seg->Size);
}
/* If this was the load memory area, mark the segment as dumped */
/* If a fill was requested, fill the remaining space */
if ((M->Flags & MF_FILL) != 0 && M->FillLevel < M->Size) {
- WriteMult (D->F, M->FillVal, M->Size - M->FillLevel);
+ unsigned long ToFill = M->Size - M->FillLevel;
+ Print (stdout, 2, " Filling 0x%lx bytes with 0x%02x\n",
+ ToFill, M->FillVal);
+ WriteMult (D->F, M->FillVal, ToFill);
M->FillLevel = M->Size;
}
}