1 /*****************************************************************************/
5 /* Map file creation for the ld65 linker */
9 /* (C) 1998-2010, Ullrich von Bassewitz */
10 /* Roemerstrasse 52 */
11 /* D-70794 Filderstadt */
12 /* EMail: uz@cc65.org */
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 /*****************************************************************************/
54 /*****************************************************************************/
56 /*****************************************************************************/
60 void CreateMapFile (int ShortMap)
61 /* Create a map file. If ShortMap is true, only the segment lists are
62 * generated, not the import/export lists.
67 /* Open the map file */
68 FILE* F = fopen (MapFileName, "w");
70 Error ("Cannot create map file `%s': %s", MapFileName, strerror (errno));
73 /* Write a modules list */
74 fprintf (F, "Modules list:\n"
76 for (I = 0; I < CollCount (&ObjDataList); ++I) {
80 /* Get the object file */
81 const ObjData* O = CollConstAt (&ObjDataList, I);
85 /* The file is from a library */
86 fprintf (F, "%s(%s):\n", GetLibFileName (O->Lib), GetObjFileName (O));
88 fprintf (F, "%s:\n", GetObjFileName (O));
90 for (J = 0; J < CollCount (&O->Sections); ++J) {
91 const Section* S = CollConstAt (&O->Sections, J);
92 /* Don't include zero sized sections if not explicitly
95 if (VerboseMap || S->Size > 0) {
97 " %-17s Offs=%06lX Size=%06lX "
98 "Align=%05lX Fill=%04lX\n",
99 GetString (S->Seg->Name), S->Offs, S->Size,
100 S->Alignment, S->Fill);
105 /* Write the segment list */
111 /* The remainder is not written for short map files */
114 /* Write the exports list */
120 /* Write the imports list */
128 if (fclose (F) != 0) {
129 Error ("Error closing map file `%s': %s", MapFileName, strerror (errno));
135 void CreateLabelFile (void)
136 /* Create a label file */
138 /* Open the label file */
139 FILE* F = fopen (LabelFileName, "w");
141 Error ("Cannot create label file `%s': %s", LabelFileName, strerror (errno));
144 /* Print the labels for the export symbols */
145 PrintExportLabels (F);
147 /* Output the labels */
148 PrintDbgSymLabels (F);
151 if (fclose (F) != 0) {
152 Error ("Error closing label file `%s': %s", LabelFileName, strerror (errno));