1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-23 04:30:10 +00:00

Merge pull request #94 from groessler/something_to_pull

Extend the map file to include a table of exports sorted by value.
This commit is contained in:
Oliver Schmidt 2014-03-20 11:12:55 +01:00
commit efe72c86fa
3 changed files with 72 additions and 8 deletions

View File

@ -870,8 +870,8 @@ static char GetAddrSizeCode (unsigned char AddrSize)
void PrintExportMap (FILE* F)
/* Print an export map to the given file */
void PrintExportMapByName (FILE* F)
/* Print an export map, sorted by symbol name, to the given file */
{
unsigned I;
unsigned Count;
@ -902,6 +902,61 @@ void PrintExportMap (FILE* F)
static int CmpExpValue (const void* I1, const void* I2)
/* Compare function for qsort */
{
long V1 = GetExportVal (ExpPool [*(unsigned *)I1]);
long V2 = GetExportVal (ExpPool [*(unsigned *)I2]);
return V1 < V2 ? -1 : V1 == V2 ? 0 : 1;
}
void PrintExportMapByValue (FILE* F)
/* Print an export map, sorted by symbol value, to the given file */
{
unsigned I;
unsigned Count;
unsigned *ExpValXlat;
/* Create a translation table where the symbols are sorted by value. */
ExpValXlat = xmalloc (ExpCount * sizeof (unsigned));
for (I = 0; I < ExpCount; ++I) {
/* Initialize table with current sort order. */
ExpValXlat [I] = I;
}
/* Sort them by value */
qsort (ExpValXlat, ExpCount, sizeof (unsigned), CmpExpValue);
/* Print all exports */
Count = 0;
for (I = 0; I < ExpCount; ++I) {
const Export* E = ExpPool [ExpValXlat [I]];
/* Print unreferenced symbols only if explictly requested */
if (VerboseMap || E->ImpCount > 0 || SYM_IS_CONDES (E->Type)) {
fprintf (F,
"%-25s %06lX %c%c%c%c ",
GetString (E->Name),
GetExportVal (E),
E->ImpCount? 'R' : ' ',
SYM_IS_LABEL (E->Type)? 'L' : 'E',
GetAddrSizeCode ((unsigned char) E->AddrSize),
SYM_IS_CONDES (E->Type)? 'I' : ' ');
if (++Count == 2) {
Count = 0;
fprintf (F, "\n");
}
}
}
fprintf (F, "\n");
xfree (ExpValXlat);
}
void PrintImportMap (FILE* F)
/* Print an import map to the given file */
{

View File

@ -186,8 +186,11 @@ void CheckUnresolvedImports (ExpCheckFunc F, void* Data);
* called (see the comments on ExpCheckFunc in the data section).
*/
void PrintExportMap (FILE* F);
/* Print an export map to the given file */
void PrintExportMapByName (FILE* F);
/* Print an export map to the given file (sorted by symbol name) */
void PrintExportMapByValue (FILE* F);
/* Print an export map to the given file (sorted by export value) */
void PrintImportMap (FILE* F);
/* Print an import map to the given file */

View File

@ -111,11 +111,17 @@ void CreateMapFile (int ShortMap)
/* The remainder is not written for short map files */
if (!ShortMap) {
/* Write the exports list */
/* Write the exports list by name */
fprintf (F, "\n\n"
"Exports list:\n"
"-------------\n");
PrintExportMap (F);
"Exports list by name:\n"
"---------------------\n");
PrintExportMapByName (F);
/* Write the exports list by value */
fprintf (F, "\n\n"
"Exports list by value:\n"
"----------------------\n");
PrintExportMapByValue (F);
/* Write the imports list */
fprintf (F, "\n\n"