]> git.sur5r.net Git - cc65/blobdiff - src/ld65/o65.c
Added support for arbitrary alignments.
[cc65] / src / ld65 / o65.c
index 7dbcd8f9bc1ddfc6f183f488e9efb0dd7e08f55b..1c8eb6cc1db510516198e8ef24c96c563a6ad77a 100644 (file)
@@ -6,7 +6,7 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1999-2009, Ullrich von Bassewitz                                      */
+/* (C) 1999-2011, Ullrich von Bassewitz                                      */
 /*                Roemerstrasse 52                                           */
 /*                D-70794 Filderstadt                                        */
 /* EMail:         uz@cc65.org                                                */
@@ -53,6 +53,7 @@
 #include "fileio.h"
 #include "global.h"
 #include "lineinfo.h"
+#include "memarea.h"
 #include "o65.h"
 #include "spool.h"
 
@@ -175,7 +176,7 @@ struct ExprDesc {
     O65Desc*               D;                  /* File format descriptor */
     long                   Val;                /* The offset value */
     int                    TooComplex;         /* Expression too complex */
-    Memory*         MemRef;             /* Memory reference if any */
+    MemoryArea*     MemRef;             /* Memory reference if any */
     Segment*        SegRef;             /* Segment reference if any */
     Section*               SecRef;             /* Section reference if any */
     ExtSym*                ExtRef;             /* External reference if any */
@@ -244,7 +245,7 @@ static void CvtMemoryToSegment (ExprDesc* ED)
  */
 {
     /* Get the memory area from the expression */
-    Memory* M = ED->MemRef;
+    MemoryArea* M = ED->MemRef;
 
     /* Remember the "nearest" segment and its offset */
     Segment* Nearest   = 0;
@@ -778,15 +779,12 @@ static void O65WriteSeg (O65Desc* D, SegDesc** Seg, unsigned Count, int DoWrite)
        /* Get the segment from the list node */
                S = Seg [I];
 
-        /* Relocate line info for this segment */
-        RelocLineInfo (S->Seg);
-
        /* Keep the user happy */
        Print (stdout, 1, "    Writing `%s'\n", GetString (S->Name));
 
        /* 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 */
@@ -1111,19 +1109,19 @@ void O65SetLargeModel (O65Desc* D)
 
 
 
-void O65SetAlignment (O65Desc* D, unsigned Align)
+void O65SetAlignment (O65Desc* D, unsigned Alignment)
 /* Set the executable alignment */
 {
     /* Remove all alignment bits from the mode word */
     D->Header.Mode &= ~MF_ALIGN_MASK;
 
     /* Set the alignment bits */
-    switch (Align) {
+    switch (Alignment) {
        case 1:   D->Header.Mode |= MF_ALIGN_1;   break;
        case 2:   D->Header.Mode |= MF_ALIGN_2;   break;
        case 4:   D->Header.Mode |= MF_ALIGN_4;   break;
         case 256: D->Header.Mode |= MF_ALIGN_256; break;
-        default:  Error ("Invalid alignment for O65 format: %u", Align);
+        default:  Error ("Invalid alignment for O65 format: %u", Alignment);
     }
 }
 
@@ -1227,9 +1225,9 @@ static void O65SetupSegments (O65Desc* D, File* F)
     D->ZPCount   = 0;
 
     /* Walk over the memory list */
-    for (I = 0; I < CollCount (&F->MemList); ++I) {
+    for (I = 0; I < CollCount (&F->MemoryAreas); ++I) {
         /* Get this entry */
-        Memory* M = CollAtUnchecked (&F->MemList, I);
+        MemoryArea* M = CollAtUnchecked (&F->MemoryAreas, I);
 
         /* Walk through the segment list and count the segment types */
         unsigned J;
@@ -1257,9 +1255,9 @@ static void O65SetupSegments (O65Desc* D, File* F)
 
     /* Walk again through the list and setup the segment arrays */
     TextIdx = DataIdx = BssIdx = ZPIdx = 0;
-    for (I = 0; I < CollCount (&F->MemList); ++I) {
+    for (I = 0; I < CollCount (&F->MemoryAreas); ++I) {
         /* Get this entry */
-        Memory* M = CollAtUnchecked (&F->MemList, I);
+        MemoryArea* M = CollAtUnchecked (&F->MemoryAreas, I);
 
         /* Walk over the segment list and check the segment types */
         unsigned J;