]> git.sur5r.net Git - cc65/blobdiff - src/ld65/segments.c
Flag labels in the map file exports list
[cc65] / src / ld65 / segments.c
index 3e49facb755f05643b3d0725be8e9badf8347c17..0ae19b6d6398e8db36dd3ca5bf96f884cbf96656 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2000 Ullrich von Bassewitz                                       */
+/* (C) 1998-2001 Ullrich von Bassewitz                                       */
 /*               Wacholderweg 14                                             */
 /*               D-70597 Stuttgart                                           */
-/* EMail:        uz@musoftware.de                                            */
+/* EMail:        uz@cc65.org                                                 */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -51,6 +51,7 @@
 #include "fileio.h"
 #include "fragment.h"
 #include "global.h"
+#include "lineinfo.h"
 #include "segments.h"
 
 
@@ -230,7 +231,7 @@ Section* ReadSection (FILE* F, ObjData* O)
     Type = Read8 (F);
 
     /* Print some data */
-    Print (stdout, 1, "Module `%s': Found segment `%s', size = %lu, align = %u, type = %u\n",
+    Print (stdout, 2, "Module `%s': Found segment `%s', size = %lu, align = %u, type = %u\n",
           GetObjFileName (O), Name, Size, Align, Type);
 
     /* Get the segment for this section */
@@ -253,6 +254,7 @@ Section* ReadSection (FILE* F, ObjData* O)
     while (Size) {
 
        Fragment* Frag;
+       unsigned  LineInfoIndex;
 
        /* Read the fragment type */
        unsigned char Type = Read8 (F);
@@ -299,13 +301,30 @@ Section* ReadSection (FILE* F, ObjData* O)
            case FRAG_SEXPR:
                /* An expression */
                Frag->Expr = ReadExpr (F, O);
-               break;
+               break;
 
        }
 
        /* Read the file position of the fragment */
        ReadFilePos (F, &Frag->Pos);
 
+       /* Read the additional line info and resolve it */
+       LineInfoIndex = ReadVar (F);
+       if (LineInfoIndex) {
+           --LineInfoIndex;
+           if (LineInfoIndex >= O->LineInfoCount) {
+                       Internal ("In module `%s', file `%s', line %lu: Invalid line "
+                         "info with index %u (max count %u)",
+                         GetObjFileName (O),
+                         GetSourceFileName (O, Frag->Pos.Name),
+                                 Frag->Pos.Line, LineInfoIndex, O->LineInfoCount);
+           }
+           /* Point from the fragment to the line info... */
+           Frag->LI = O->LineInfos[LineInfoIndex];
+           /* ...and back from the line info to the fragment */
+           CollAppend (&Frag->LI->Fragments, Frag);
+       }
+
        /* Remember the module we had this fragment from */
        Frag->Obj = O;
 
@@ -482,6 +501,7 @@ void SegWrite (FILE* Tgt, Segment* S, SegWriteFunc F, void* Data)
 
        /* If we have fill bytes, write them now */
        WriteMult (Tgt, S->FillVal, Sec->Fill);
+       Offs += Sec->Fill;
 
        /* Loop over all fragments in this section */
        Frag = Sec->FragRoot;