]> git.sur5r.net Git - cc65/blobdiff - src/ld65/objfile.c
Removed unneeded include files.
[cc65] / src / ld65 / objfile.c
index 8f7fbe9d67f868e0c7432883cc4fe803afa65e1a..24a9afda81bb3f64c67623acacb23f9493b49f19 100644 (file)
@@ -6,7 +6,7 @@
 /*                                                                          */
 /*                                                                          */
 /*                                                                          */
-/* (C) 1998-2011, Ullrich von Bassewitz                                      */
+/* (C) 1998-2012, Ullrich von Bassewitz                                      */
 /*                Roemerstrasse 52                                           */
 /*                D-70794 Filderstadt                                        */
 /* EMail:         uz@cc65.org                                                */
 
 
 #include <string.h>
-#include <errno.h>
-#include <time.h>
-#include <sys/types.h>         /* EMX needs this */
-#include <sys/stat.h>
 
 /* common */
 #include "fname.h"
@@ -107,6 +103,8 @@ static void ObjReadHeader (FILE* Obj, ObjHeader* H, const char* Name)
     H->AssertSize   = Read32 (Obj);
     H->ScopeOffs    = Read32 (Obj);
     H->ScopeSize    = Read32 (Obj);
+    H->SpanOffs     = Read32 (Obj);
+    H->SpanSize     = Read32 (Obj);
 }
 
 
@@ -196,11 +194,18 @@ void ObjReadDbgSyms (FILE* F, unsigned long Pos, ObjData* O)
     /* Seek to the correct position */
     FileSetPos (F, Pos);
 
-    /* Read the data */
+    /* Read the asm debug symbols */
     DbgSymCount = ReadVar (F);
     CollGrow (&O->DbgSyms, DbgSymCount);
     for (I = 0; I < DbgSymCount; ++I) {
-       CollAppend (&O->DbgSyms, ReadDbgSym (F, O));
+       CollAppend (&O->DbgSyms, ReadDbgSym (F, O, I));
+    }
+
+    /* Read the hll debug symbols */
+    DbgSymCount = ReadVar (F);
+    CollGrow (&O->HLLDbgSyms, DbgSymCount);
+    for (I = 0; I < DbgSymCount; ++I) {
+               CollAppend (&O->HLLDbgSyms, ReadHLLDbgSym (F, O, I));
     }
 }
 
@@ -281,6 +286,25 @@ void ObjReadScopes (FILE* F, unsigned long Pos, ObjData* O)
 
 
 
+void ObjReadSpans (FILE* F, unsigned long Pos, ObjData* O)
+/* Read the span table from a file at the given offset */
+{
+    unsigned I;
+    unsigned SpanCount;
+
+    /* Seek to the correct position */
+    FileSetPos (F, Pos);
+
+    /* Read the data */
+    SpanCount = ReadVar (F);
+    CollGrow (&O->Spans, SpanCount);
+    for (I = 0; I < SpanCount; ++I) {
+        CollAppend (&O->Spans,  ReadSpan (F, O, I));
+    }
+}
+
+
+
 void ObjAdd (FILE* Obj, const char* Name)
 /* Add an object file to the module list */
 {
@@ -317,15 +341,20 @@ void ObjAdd (FILE* Obj, const char* Name)
     /* Read the assertions from the object file */
     ObjReadAssertions (Obj, O->Header.AssertOffs, O);
 
-    /* Read the scope table from the object file */
-    ObjReadScopes (Obj, O->Header.ScopeOffs, O);
-
-    /* Read the segment list from the object file. This must be last, since
+    /* Read the segment list from the object file. This must be late, since
      * the expressions stored in the code may reference segments or imported
      * symbols.
      */
     ObjReadSections (Obj, O->Header.SegOffs, O);
 
+    /* Read the scope table from the object file. Scopes reference segments, so
+     * we must read them after the sections.
+     */
+    ObjReadScopes (Obj, O->Header.ScopeOffs, O);
+
+    /* Read the spans from the object file */
+    ObjReadSpans (Obj, O->Header.SpanOffs, O);
+
     /* Mark this object file as needed */
     O->Flags |= OBJ_REF;