/* */
/* */
/* */
-/* (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.
+ */
{
- ObjData* O;
unsigned I;
/* Open the map file */
/* Write a modules list */
fprintf (F, "Modules list:\n"
"-------------\n");
- O = ObjRoot;
- while (O) {
- if (O->Flags & OBJ_HAVEDATA) {
- /* We've linked this module */
- if (O->LibName) {
- /* The file is from a library */
- fprintf (F, "%s(%s):\n", O->LibName, GetObjFileName (O));
- } else {
- fprintf (F, "%s:\n", GetObjFileName (O));
- }
- for (I = 0; I < O->SectionCount; ++I) {
- const Section* S = O->Sections [I];
- /* 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);
- }
- }
- }
- O = O->Next;
+ for (I = 0; I < CollCount (&ObjDataList); ++I) {
+
+ unsigned J;
+
+ /* Get the object file */
+ const ObjData* O = CollConstAt (&ObjDataList, I);
+
+ /* Output the data */
+ if (O->Lib) {
+ /* The file is from a library */
+ fprintf (F, "%s(%s):\n", GetLibFileName (O->Lib), GetObjFileName (O));
+ } else {
+ fprintf (F, "%s:\n", GetObjFileName (O));
+ }
+ 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,
+ " %-17s Offs=%06lX Size=%06lX "
+ "Align=%05lX Fill=%04lX\n",
+ GetString (S->Seg->Name), S->Offs, S->Size,
+ S->Alignment, S->Fill);
+ }
+ }
}
/* Write the segment list */
"-------------\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) {
void CreateLabelFile (void)
/* Create a label file */
{
- ObjData* O;
-
/* Open the label file */
FILE* F = fopen (LabelFileName, "w");
if (F == 0) {
/* Print the labels for the export symbols */
PrintExportLabels (F);
- /* Print debug symbols from all modules we have linked into the output file */
- O = ObjRoot;
- while (O) {
- if (O->Flags & OBJ_HAVEDATA) {
- /* We've linked this module */
- PrintDbgSymLabels (O, F);
-
- }
- O = O->Next;
- }
-
- /* If we should mark write protected areas as such, do it */
- if (WProtSegs) {
- SegDesc* S = SegDescList;
- while (S) {
- /* Is this segment write protected and contains data? */
- if (S->Flags & SF_WPROT && S->Seg->Size > 0) {
- /* Write protect the memory area in VICE */
- fprintf (F, "wp %04lX %04lX\n",
- S->Seg->PC,
- S->Seg->PC + S->Seg->Size - 1);
- }
- /* Next segment */
- S = S->Next;
- }
- }
-
- /* 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 */
-{
- ObjData* O;
-
- /* 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 */
- O = ObjRoot;
- while (O) {
- if (O->Flags & OBJ_HAVEDATA) {
- /* We've linked this module */
- PrintDbgInfo (O, F);
-
- }
- O = O->Next;
- }
+ /* 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));
}
}