]> git.sur5r.net Git - cc65/blobdiff - src/ld65/mapfile.c
Added classification macros for file types from struct dirent.
[cc65] / src / ld65 / mapfile.c
index 071b11318ff0f65cb976f957e28d18851f92958e..6dc4ffb60cb1663c015a9df7237d8248d899e1f8 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2003 Ullrich von Bassewitz                                       */
-/*               Römerstrasse 52                                             */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 1998-2010, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
 
 /* ld65 */
 #include "config.h"
-#include "dbginfo.h"
 #include "dbgsyms.h"
 #include "exports.h"
 #include "global.h"
 #include "error.h"
+#include "library.h"
 #include "mapfile.h"
 #include "objdata.h"
 #include "segments.h"
 
 
 
-void CreateMapFile (void)
-/* Create a map file */
+void CreateMapFile (int ShortMap)
+/* Create a map file. If ShortMap is true, only the segment lists are
+ * generated, not the import/export lists.
+ */
 {
     unsigned I;
 
@@ -79,20 +81,23 @@ void CreateMapFile (void)
         const ObjData* O = CollConstAt (&ObjDataList, I);
 
         /* Output the data */
-        if (O->LibName != INVALID_STRING_ID) {
+        if (O->Lib) {
             /* The file is from a library */
-            fprintf (F, "%s(%s):\n", GetString (O->LibName), GetObjFileName (O));
+            fprintf (F, "%s(%s):\n", GetLibFileName (O->Lib), GetObjFileName (O));
         } else {
             fprintf (F, "%s:\n", GetObjFileName (O));
         }
-        for (J = 0; J < O->SectionCount; ++J) {
-            const Section* S = O->Sections [J];
+        for (J = 0; J < CollCount (&O->Sections); ++J) {
+            const Section* S = CollConstAt (&O->Sections, J);
             /* Don't include zero sized sections if not explicitly
              * requested
              */
             if (VerboseMap || S->Size > 0) {
-                fprintf (F, "    %-15s   Offs = %06lX   Size = %06lX\n",
-                         GetString (S->Seg->Name), S->Offs, S->Size);
+                fprintf (F, 
+                         "    %-17s Offs=%06lX  Size=%06lX  "
+                         "Align=%05lX  Fill=%04lX\n",
+                         GetString (S->Seg->Name), S->Offs, S->Size,
+                         S->Alignment, S->Fill);
             }
         }
     }
@@ -103,17 +108,21 @@ void CreateMapFile (void)
                "-------------\n");
     PrintSegmentMap (F);
 
-    /* Write the exports list */
-    fprintf (F, "\n\n"
-               "Exports list:\n"
-               "-------------\n");
-    PrintExportMap (F);
+    /* The remainder is not written for short map files */
+    if (!ShortMap) {
 
-    /* Write the imports list */
-    fprintf (F, "\n\n"
-               "Imports list:\n"
-               "-------------\n");
-    PrintImportMap (F);
+        /* Write the exports list */
+        fprintf (F, "\n\n"
+                    "Exports list:\n"
+                    "-------------\n");
+        PrintExportMap (F);
+
+        /* Write the imports list */
+        fprintf (F, "\n\n"
+                    "Imports list:\n"
+                    "-------------\n");
+        PrintImportMap (F);
+    }
 
     /* Close the file */
     if (fclose (F) != 0) {
@@ -126,8 +135,6 @@ void CreateMapFile (void)
 void CreateLabelFile (void)
 /* Create a label file */
 {
-    unsigned I;
-
     /* Open the label file */
     FILE* F = fopen (LabelFileName, "w");
     if (F == 0) {
@@ -137,48 +144,12 @@ void CreateLabelFile (void)
     /* Print the labels for the export symbols */
     PrintExportLabels (F);
 
-    /* Create labels from all modules we have linked into the output file */
-    for (I = 0; I < CollCount (&ObjDataList); ++I) {
-
-        /* Get the object file */
-        ObjData* O = CollAtUnchecked (&ObjDataList, I);
-
-        /* Output the labels */
-       PrintDbgSymLabels (O, F);
-    }
-
-    /* Close the file */
-    if (fclose (F) != 0) {
-       Error ("Error closing map file `%s': %s", LabelFileName, strerror (errno));
-    }
-}
-
-
-
-void CreateDbgFile (void)
-/* Create a debug info file */
-{
-    unsigned I;
-
-    /* Open the debug info file */
-    FILE* F = fopen (DbgFileName, "w");
-    if (F == 0) {
-       Error ("Cannot create label file `%s': %s", DbgFileName, strerror (errno));
-    }
-
-    /* Print line infos from all modules we have linked into the output file */
-    for (I = 0; I < CollCount (&ObjDataList); ++I) {
-
-        /* Get the object file */
-        ObjData* O = CollAtUnchecked (&ObjDataList, I);
-
-        /* Output debug info */
-       PrintDbgInfo (O, F);
-    }
+    /* Output the labels */
+    PrintDbgSymLabels (F);
 
     /* Close the file */
     if (fclose (F) != 0) {
-       Error ("Error closing map file `%s': %s", DbgFileName, strerror (errno));
+               Error ("Error closing label file `%s': %s", LabelFileName, strerror (errno));
     }
 }