mirror of
https://github.com/cc65/cc65.git
synced 2025-01-10 19:29:45 +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:
commit
efe72c86fa
@ -870,8 +870,8 @@ static char GetAddrSizeCode (unsigned char AddrSize)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void PrintExportMap (FILE* F)
|
void PrintExportMapByName (FILE* F)
|
||||||
/* Print an export map to the given file */
|
/* Print an export map, sorted by symbol name, to the given file */
|
||||||
{
|
{
|
||||||
unsigned I;
|
unsigned I;
|
||||||
unsigned Count;
|
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)
|
void PrintImportMap (FILE* F)
|
||||||
/* Print an import map to the given file */
|
/* Print an import map to the given file */
|
||||||
{
|
{
|
||||||
|
@ -186,8 +186,11 @@ void CheckUnresolvedImports (ExpCheckFunc F, void* Data);
|
|||||||
* called (see the comments on ExpCheckFunc in the data section).
|
* called (see the comments on ExpCheckFunc in the data section).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void PrintExportMap (FILE* F);
|
void PrintExportMapByName (FILE* F);
|
||||||
/* Print an export map to the given file */
|
/* 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);
|
void PrintImportMap (FILE* F);
|
||||||
/* Print an import map to the given file */
|
/* Print an import map to the given file */
|
||||||
|
@ -111,11 +111,17 @@ void CreateMapFile (int ShortMap)
|
|||||||
/* The remainder is not written for short map files */
|
/* The remainder is not written for short map files */
|
||||||
if (!ShortMap) {
|
if (!ShortMap) {
|
||||||
|
|
||||||
/* Write the exports list */
|
/* Write the exports list by name */
|
||||||
fprintf (F, "\n\n"
|
fprintf (F, "\n\n"
|
||||||
"Exports list:\n"
|
"Exports list by name:\n"
|
||||||
"-------------\n");
|
"---------------------\n");
|
||||||
PrintExportMap (F);
|
PrintExportMapByName (F);
|
||||||
|
|
||||||
|
/* Write the exports list by value */
|
||||||
|
fprintf (F, "\n\n"
|
||||||
|
"Exports list by value:\n"
|
||||||
|
"----------------------\n");
|
||||||
|
PrintExportMapByValue (F);
|
||||||
|
|
||||||
/* Write the imports list */
|
/* Write the imports list */
|
||||||
fprintf (F, "\n\n"
|
fprintf (F, "\n\n"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user