]> git.sur5r.net Git - cc65/blobdiff - src/ld65/objdata.c
Added the NES target
[cc65] / src / ld65 / objdata.c
index 04028cd8ca65b9acbc7ae08a34470920ea66aa43..5183c7d817c2f51660e1f914d4a842727e589893 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998     Ullrich von Bassewitz                                        */
-/*              Wacholderweg 14                                              */
-/*              D-70597 Stuttgart                                            */
-/* EMail:       uz@musoftware.de                                             */
+/* (C) 1998-2001 Ullrich von Bassewitz                                       */
+/*               Wacholderweg 14                                             */
+/*               D-70597 Stuttgart                                           */
+/* EMail:        uz@cc65.org                                                 */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
 
 #include <string.h>
 
-#include "mem.h"
+/* common */
+#include "check.h"
+#include "xmalloc.h"
+
+/* ld65 */
 #include "error.h"
+#include "fileinfo.h"
 #include "objdata.h"
 
 
@@ -65,7 +70,7 @@ ObjData* NewObjData (void)
 /* Allocate a new structure on the heap, insert it into the list, return it */
 {
     /* Allocate memory */
-    ObjData* O = Xmalloc (sizeof (ObjData));
+    ObjData* O = xmalloc (sizeof (ObjData));
 
     /* Initialize the data */
     O->Next            = 0;
@@ -79,14 +84,16 @@ ObjData* NewObjData (void)
     O->Imports         = 0;
     O->DbgSymCount     = 0;
     O->DbgSyms         = 0;
+    O->LineInfoCount    = 0;
+    O->LineInfos        = 0;
 
     /* Link it into the list */
     if (ObjLast) {
-       ObjLast->Next = O;
-       ObjLast       = O;
+       ObjLast->Next = O;
+       ObjLast       = O;
     } else {
-       /* First entry */
-       ObjRoot = ObjLast = O;
+       /* First entry */
+       ObjRoot = ObjLast = O;
     }
 
     /* One object file more now */
@@ -101,12 +108,48 @@ ObjData* NewObjData (void)
 void FreeObjData (ObjData* O)
 /* Free a complete struct */
 {
-    Xfree (O->Name);
-    Xfree (O->Imports);
-    Xfree (O->Exports);
-    Xfree (O->DbgSyms);
-    Xfree (O);
+    xfree (O->Name);
+    xfree (O->Imports);
+    xfree (O->Exports);
+    xfree (O->DbgSyms);
+    xfree (O->LineInfos);
+    xfree (O);
+}
+
+
+
+const char* GetObjFileName (const ObjData* O)
+/* Get the name of the object file. Return "[linker generated]" if the object
+ * file is NULL.
+ */
+{
+    return O? O->Name : "[linker generated]";
 }
 
 
 
+const char* GetSourceFileName (const ObjData* O, unsigned Index)
+/* Get the name of the source file with the given index. If O is NULL, return
+ * "[linker generated]" as the file name.
+ */
+{
+    /* Check if we have an object file */
+    if (O == 0) {
+
+       /* No object file */
+       return "[linker generated]";
+
+    } else {
+
+       /* Check the parameter */
+       PRECONDITION (Index < O->FileCount);
+
+       /* Return the name */
+       return O->Files[Index]->Name;
+
+    }
+}
+
+
+
+