]> git.sur5r.net Git - cc65/blobdiff - src/ld65/segments.h
Removed (pretty inconsistently used) tab chars from source code base.
[cc65] / src / ld65 / segments.h
index c61d7839e62b582056e7fbef9c2f46c2e06867fa..67006bcc10e71928327d9d19e624009c5af0e9bb 100644 (file)
@@ -1,12 +1,12 @@
 /*****************************************************************************/
 /*                                                                           */
-/*                               segments.h                                 */
+/*                                segments.h                                 */
 /*                                                                           */
-/*                  Segment handling for the ld65 linker                    */
+/*                   Segment handling for the ld65 linker                    */
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2010, Ullrich von Bassewitz                                      */
+/* (C) 1998-2012, Ullrich von Bassewitz                                      */
 /*                Roemerstrasse 52                                           */
 /*                D-70794 Filderstadt                                        */
 /* EMail:         uz@cc65.org                                                */
 #include <stdio.h>
 
 /* common */
+#include "coll.h"
 #include "exprdefs.h"
 
 
 
 /*****************************************************************************/
-/*                                          Data                                    */
+/*                                   Data                                    */
 /*****************************************************************************/
 
 
 
+/* Forwards */
+struct MemoryArea;
+
 /* Segment structure */
 typedef struct Segment Segment;
 struct Segment {
     unsigned            Name;           /* Name index of the segment */
     unsigned            Id;             /* Segment id for debug info */
-    Segment*           Next;           /* Hash list */
-    Segment*           List;           /* List of all segments */
-    struct Section*    SecRoot;        /* Section list */
-    struct Section*    SecLast;        /* Pointer to last section */
-    unsigned long      PC;             /* PC were this segment is located */
-    unsigned long      Size;           /* Size of data so far */
-    struct ObjData*    AlignObj;       /* Module that requested the alignment */
+    Segment*            Next;           /* Hash list */
+    unsigned            Flags;          /* Segment flags */
+    Collection          Sections;       /* Sections in this segment */
+    struct MemoryArea*  MemArea;        /* Run memory area once placed */
+    unsigned long       PC;             /* PC were this segment is located */
+    unsigned long       Size;           /* Size of data so far */
     const char*         OutputName;     /* Name of output file or NULL */
     unsigned long       OutputOffs;     /* Offset in output file */
-    unsigned char      Align;          /* Alignment needed */
-    unsigned char      FillVal;        /* Value to use for fill bytes */
-    unsigned char      AddrSize;       /* Address size of segment */
+    unsigned long       Alignment;      /* Alignment needed */
+    unsigned char       FillVal;        /* Value to use for fill bytes */
+    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              Dumped;         /* Did we dump this segment? */
+    unsigned char       Dumped;         /* Did we dump this segment? */
 };
 
 
@@ -78,15 +80,16 @@ struct Segment {
 /* Section structure (a section is a part of a segment) */
 typedef struct Section Section;
 struct Section {
-    Section*           Next;           /* List of sections in a segment */
-    Segment*           Seg;            /* Segment that contains the section */
-    struct Fragment*   FragRoot;       /* Fragment list */
-    struct Fragment*   FragLast;       /* Pointer to last fragment */
-    unsigned long      Offs;           /* Offset into the segment */
-    unsigned long      Size;           /* Size of the section */
-    unsigned char      Align;          /* Alignment */
-    unsigned char      Fill;           /* Fill bytes for alignment */
-    unsigned char      AddrSize;       /* Address size of segment */
+    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 */
+    unsigned long       Size;           /* Size of the section */
+    unsigned long       Fill;           /* Fill bytes for alignment */
+    unsigned long       Alignment;      /* Alignment */
+    unsigned char       AddrSize;       /* Address size of segment */
 };
 
 
@@ -94,21 +97,21 @@ struct Section {
 /* Prototype for a function that is used to write expressions to the target
  * file (used in SegWrite). It returns one of the following values:
  */
-#define SEG_EXPR_OK            0U      /* Ok */
-#define SEG_EXPR_RANGE_ERROR   1U      /* Range error */
-#define SEG_EXPR_TOO_COMPLEX   2U      /* Expression too complex */
+#define SEG_EXPR_OK             0U      /* Ok */
+#define SEG_EXPR_RANGE_ERROR    1U      /* Range error */
+#define SEG_EXPR_TOO_COMPLEX    2U      /* Expression too complex */
 #define SEG_EXPR_INVALID        3U      /* Expression is invalid (e.g. unmapped segment) */
 
-typedef unsigned (*SegWriteFunc) (ExprNode* E,               /* The expression to write */
-                                 int Signed,         /* Signed expression? */
-                                 unsigned Size,      /* Size (=range) */
-                                 unsigned long Offs, /* File offset */
-                                 void* Data);        /* Callers data */
+typedef unsigned (*SegWriteFunc) (ExprNode* E,        /* The expression to write */
+                                  int Signed,         /* Signed expression? */
+                                  unsigned Size,      /* Size (=range) */
+                                  unsigned long Offs, /* File offset */
+                                  void* Data);        /* Callers data */
 
 
 
 /*****************************************************************************/
-/*                                          Code                                    */
+/*                                   Code                                    */
 /*****************************************************************************/
 
 
@@ -119,7 +122,7 @@ Segment* GetSegment (unsigned Name, unsigned char AddrSize, const char* ObjName)
  * message and may be NULL if the segment is linker generated.
  */
 
-Section* NewSection (Segment* Seg, unsigned char Align, unsigned char AddrSize);
+Section* NewSection (Segment* Seg, unsigned long Alignment, unsigned char AddrSize);
 /* Create a new section for the given segment */
 
 Section* ReadSection (FILE* F, struct ObjData* O);
@@ -146,6 +149,9 @@ void SegWrite (const char* TgtName, FILE* Tgt, Segment* S, SegWriteFunc F, void*
  * called (see description of SegWriteFunc above).
  */
 
+unsigned SegmentCount (void);
+/* Return the total number of segments */
+
 void PrintSegmentMap (FILE* F);
 /* Print a segment map to the given file */