unsigned long Offs attribute ((unused)),
void* Data)
/* Called from SegWrite for an expression. Evaluate the expression, check the
- * range and write the expression value to the file.
- */
+** range and write the expression value to the file.
+*/
{
/* There's a predefined function to handle constant expressions */
return SegWriteConstExpr (((BinDesc*)Data)->F, E, Signed, Size);
SegDesc* S = CollAtUnchecked (&M->SegList, I);
/* Keep the user happy */
- Print (stdout, 1, " Writing `%s'\n", GetString (S->Name));
+ Print (stdout, 1, " Writing '%s'\n", GetString (S->Name));
/* Writes do only occur in the load area and not for BSS segments */
DoWrite = (S->Flags & SF_BSS) == 0 && /* No BSS segment */
PrintNumVal ("Address", Addr);
PrintNumVal ("FileOffs", (unsigned long) ftell (D->F));
- /* Check if the alignment for the segment from the linker config is
- * a multiple for that of the segment.
- */
- if ((S->RunAlignment % S->Seg->Alignment) != 0) {
- /* Segment requires another alignment than configured
- * in the linker.
- */
- Warning ("Segment `%s' is not aligned properly. Resulting "
- "executable may not be functional.",
- GetString (S->Name));
- }
-
/* If this is the run memory area, we must apply run alignment. If
- * this is not the run memory area but the load memory area (which
- * means that both are different), we must apply load alignment.
- * Beware: DoWrite may be true even if this is the run memory area,
- * because it may be also the load memory area.
- */
+ ** this is not the run memory area but the load memory area (which
+ ** means that both are different), we must apply load alignment.
+ ** Beware: DoWrite may be true even if this is the run memory area,
+ ** because it may be also the load memory area.
+ */
if (S->Run == M) {
/* Handle ALIGN and OFFSET/START */
NewAddr += M->Start;
}
if (DoWrite || (M->Flags & MF_FILL) != 0) {
- WriteMult (D->F, M->FillVal, NewAddr-Addr);
- PrintNumVal ("SF_OFFSET", NewAddr - Addr);
+ /* Seek in "overwrite" segments */
+ if (S->Flags & SF_OVERWRITE) {
+ fseek (D->F, NewAddr - M->Start, SEEK_SET);
+ } else {
+ WriteMult (D->F, M->FillVal, NewAddr-Addr);
+ PrintNumVal ("SF_OFFSET", NewAddr - Addr);
+ }
}
Addr = NewAddr;
}
}
/* Now write the segment to disk if it is not a BSS type segment and
- * if the memory area is the load area.
- */
+ ** if the memory area is the load area.
+ */
if (DoWrite) {
unsigned long P = ftell (D->F);
SegWrite (D->Filename, D->F, S->Seg, BinWriteExpr, D);
/* Called if an unresolved symbol is encountered */
{
/* Unresolved symbols are an error in binary format. Bump the counter
- * and return zero telling the caller that the symbol is indeed
- * unresolved.
- */
+ ** and return zero telling the caller that the symbol is indeed
+ ** unresolved.
+ */
((BinDesc*) D)->Undef++;
return 0;
}
D->Filename = GetString (F->Name);
/* Check for unresolved symbols. The function BinUnresolved is called
- * if we get an unresolved symbol.
- */
+ ** if we get an unresolved symbol.
+ */
D->Undef = 0; /* Reset the counter */
CheckUnresolvedImports (BinUnresolved, D);
if (D->Undef > 0) {
/* Open the file */
D->F = fopen (D->Filename, "wb");
if (D->F == 0) {
- Error ("Cannot open `%s': %s", D->Filename, strerror (errno));
+ Error ("Cannot open '%s': %s", D->Filename, strerror (errno));
}
/* Keep the user happy */
- Print (stdout, 1, "Opened `%s'...\n", D->Filename);
+ Print (stdout, 1, "Opened '%s'...\n", D->Filename);
/* Dump all memory areas */
for (I = 0; I < CollCount (&F->MemoryAreas); ++I) {
/* Get this entry */
MemoryArea* M = CollAtUnchecked (&F->MemoryAreas, I);
- Print (stdout, 1, " Dumping `%s'\n", GetString (M->Name));
+ Print (stdout, 1, " Dumping '%s'\n", GetString (M->Name));
BinWriteMem (D, M);
}
/* Close the file */
if (fclose (D->F) != 0) {
- Error ("Cannot write to `%s': %s", D->Filename, strerror (errno));
+ Error ("Cannot write to '%s': %s", D->Filename, strerror (errno));
}
/* Reset the file and filename */