1 /*****************************************************************************/
5 /* Map file creation for the ld65 linker */
9 /* (C) 1998-2003 Ullrich von Bassewitz */
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 /*****************************************************************************/
53 /*****************************************************************************/
55 /*****************************************************************************/
59 void CreateMapFile (void)
60 /* Create a map file */
64 /* Open the map file */
65 FILE* F = fopen (MapFileName, "w");
67 Error ("Cannot create map file `%s': %s", MapFileName, strerror (errno));
70 /* Write a modules list */
71 fprintf (F, "Modules list:\n"
73 for (I = 0; I < CollCount (&ObjDataList); ++I) {
77 /* Get the object file */
78 const ObjData* O = CollConstAt (&ObjDataList, I);
81 if (O->LibName != INVALID_STRING_ID) {
82 /* The file is from a library */
83 fprintf (F, "%s(%s):\n", GetString (O->LibName), GetObjFileName (O));
85 fprintf (F, "%s:\n", GetObjFileName (O));
87 for (J = 0; J < O->SectionCount; ++J) {
88 const Section* S = O->Sections [J];
89 /* Don't include zero sized sections if not explicitly
92 if (VerboseMap || S->Size > 0) {
93 fprintf (F, " %-15s Offs = %06lX Size = %06lX\n",
94 GetString (S->Seg->Name), S->Offs, S->Size);
99 /* Write the segment list */
105 /* Write the exports list */
111 /* Write the imports list */
118 if (fclose (F) != 0) {
119 Error ("Error closing map file `%s': %s", MapFileName, strerror (errno));
125 void CreateLabelFile (void)
126 /* Create a label file */
130 /* Open the label file */
131 FILE* F = fopen (LabelFileName, "w");
133 Error ("Cannot create label file `%s': %s", LabelFileName, strerror (errno));
136 /* Clear the debug sym table (used to detect duplicates) */
139 /* Print the labels for the export symbols */
140 PrintExportLabels (F);
142 /* Create labels from all modules we have linked into the output file */
143 for (I = 0; I < CollCount (&ObjDataList); ++I) {
145 /* Get the object file */
146 ObjData* O = CollAtUnchecked (&ObjDataList, I);
148 /* Output the labels */
149 PrintDbgSymLabels (O, F);
153 if (fclose (F) != 0) {
154 Error ("Error closing label file `%s': %s", LabelFileName, strerror (errno));