]> git.sur5r.net Git - cc65/blobdiff - src/ca65/segment.c
Fixed an error in calculation of the fill bytes necessary for alignment.
[cc65] / src / ca65 / segment.c
index 0411f4d6e93d9aaca317d0faca86f7a0cede791f..c6a08b56d1e5f52f72f0c9c3aec27fcbf2d833f7 100644 (file)
@@ -41,6 +41,7 @@
 #include "alignment.h"
 #include "coll.h"
 #include "mmodel.h"
+#include "segdefs.h"
 #include "segnames.h"
 #include "xmalloc.h"
 
@@ -107,6 +108,7 @@ static Segment* NewSegFromDef (SegDef* Def)
     S->Last      = 0;
     S->FragCount = 0;
     S->Num       = CollCount (&SegmentList);
+    S->Flags     = SEG_FLAG_NONE;
     S->Align     = 1;
     S->RelocMode = 1;
     S->PC        = 0;
@@ -310,7 +312,7 @@ void SegAlign (unsigned long Alignment, int FillVal)
         }
 
         /* Calculate the number of fill bytes */
-        Count = AlignCount (ActiveSeg->PC, Alignment) - ActiveSeg->PC;
+        Count = AlignCount (ActiveSeg->PC, Alignment);
 
     }
 
@@ -408,7 +410,7 @@ void SegDone (void)
                } else {
 
                     /* Finalize the expression */
-                    F->V.Expr = FinalizeExpr (F->V.Expr, &F->LI);        
+                    F->V.Expr = FinalizeExpr (F->V.Expr, &F->LI);
 
                     /* Simplify the expression */
                     /* ### F->V.Expr = SimplifyExpr (F->V.Expr, &ED); */
@@ -540,6 +542,7 @@ static void WriteOneSeg (Segment* Seg)
 
     /* Write the segment data */
     ObjWriteVar (GetStringId (Seg->Def->Name)); /* Name of the segment */
+    ObjWriteVar (Seg->Flags);                   /* Segment flags */
     ObjWriteVar (Seg->PC);                      /* Size */
     ObjWriteVar (Seg->Align);                   /* Segment alignment */
     ObjWrite8 (Seg->Def->AddrSize);             /* Address size of the segment */