-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;
+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 */
{
* 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 */
/* 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"