1 /*****************************************************************************/
5 /* Map file creation for the ld65 linker */
9 /* (C) 1998 Ullrich von Bassewitz */
11 /* D-70597 Stuttgart */
12 /* EMail: uz@musoftware.de */
15 /* This software is provided 'as-is', without any expressed or implied */
16 /* warranty. In no event will the authors be held liable for any damages */
17 /* arising from the use of this software. */
19 /* Permission is granted to anyone to use this software for any purpose, */
20 /* including commercial applications, and to alter it and redistribute it */
21 /* freely, subject to the following restrictions: */
23 /* 1. The origin of this software must not be misrepresented; you must not */
24 /* claim that you wrote the original software. If you use this software */
25 /* in a product, an acknowledgment in the product documentation would be */
26 /* appreciated but is not required. */
27 /* 2. Altered source versions must be plainly marked as such, and must not */
28 /* be misrepresented as being the original software. */
29 /* 3. This notice may not be removed or altered from any source */
32 /*****************************************************************************/
51 /*****************************************************************************/
53 /*****************************************************************************/
57 void CreateMapFile (void)
58 /* Create a map file */
63 /* Open the map file */
64 FILE* F = fopen (MapFileName, "w");
66 Error ("Cannot create map file `%s': %s", MapFileName, strerror (errno));
69 /* Write a modules list */
70 fprintf (F, "Modules list:\n"
74 if (O->Flags & OBJ_HAVEDATA) {
75 /* We've linked this module */
77 /* The file is from a library */
78 fprintf (F, "%s(%s):\n", O->LibName, O->Name);
80 fprintf (F, "%s:\n", O->Name);
82 for (I = 0; I < O->SectionCount; ++I) {
83 const Section* S = O->Sections [I];
84 /* Don't include zero sized sections if not explicitly
87 if (VerboseMap || S->Size > 0) {
88 fprintf (F, " %-15s Offs = %06lX Size = %06lX\n",
89 S->Seg->Name, S->Offs, S->Size);
96 /* Write the segment list */
102 /* Write the exports list */
108 /* Write the imports list */
115 if (fclose (F) != 0) {
116 Error ("Error closing map file `%s': %s", MapFileName, strerror (errno));
122 void CreateLabelFile (void)
123 /* Create a label file */
127 /* Open the map file */
128 FILE* F = fopen (LabelFileName, "w");
130 Error ("Cannot create label file `%s': %s", LabelFileName, strerror (errno));
133 /* Print the labels for the export symbols */
134 PrintExportLabels (F);
136 /* Print debug symbols from all modules we have linked into the output file */
139 if (O->Flags & OBJ_HAVEDATA) {
140 /* We've linked this module */
141 PrintDbgSymLabels (O, F);
147 /* If we should mark write protected areas as such, do it */
149 SegDesc* S = SegDescList;
151 /* Is this segment write protected and contains data? */
152 if (S->Flags & SF_WPROT && S->Seg->Size > 0) {
153 /* Write protect the memory area in VICE */
154 fprintf (F, "wp %04lX %04lX\n",
156 S->Seg->PC + S->Seg->Size - 1);
164 if (fclose (F) != 0) {
165 Error ("Error closing map file `%s': %s", LabelFileName, strerror (errno));