]> git.sur5r.net Git - cc65/blobdiff - src/ld65/exports.c
Since we have now builtin search paths, we need to be able to forget them,
[cc65] / src / ld65 / exports.c
index 515b8527d3c6e8ed5a8d8ae2c5ee364fb7ac6300..a5415bf8276950f95d348386b2138301384146c1 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998     Ullrich von Bassewitz                                        */
-/*              Wacholderweg 14                                              */
-/*              D-70597 Stuttgart                                            */
-/* EMail:       uz@musoftware.de                                             */
+/* (C) 1998-2009, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -38,6 +38,7 @@
 #include <string.h>
 
 /* common */
+#include "addrsize.h"
 #include "check.h"
 #include "coll.h"
 #include "hashstr.h"
 /* ld65 */
 #include "condes.h"
 #include "error.h"
+#include "exports.h"
+#include "expr.h"
 #include "fileio.h"
 #include "global.h"
 #include "objdata.h"
-#include "expr.h"
-#include "exports.h"
+#include "spool.h"
 
 
 
@@ -62,8 +64,9 @@
 
 
 /* Hash table */
-#define HASHTAB_SIZE           4081
-static Export*                 HashTab [HASHTAB_SIZE];
+#define HASHTAB_MASK    0x0FFFU
+#define HASHTAB_SIZE           (HASHTAB_MASK + 1)
+static Export*                 HashTab[HASHTAB_SIZE];
 
 /* Import management variables */
 static unsigned                ImpCount = 0;           /* Import count */
@@ -73,8 +76,12 @@ static unsigned              ImpOpen  = 0;           /* Count of open imports */
 static unsigned                ExpCount = 0;           /* Export count */
 static Export**                ExpPool  = 0;           /* Exports array */
 
+/* Defines for the flags in Import */
+#define IMP_INLIST      0x0001U                 /* Import is in exports list */
+
 /* Defines for the flags in Export */
-#define EXP_USERMARK           0x0001
+#define EXP_INLIST      0x0001U                 /* Export is in exports list */
+#define EXP_USERMARK           0x0002U                 /* User setable flag */
 
 
 
@@ -84,12 +91,13 @@ static Export**             ExpPool  = 0;           /* Exports array */
 
 
 
-static Export* NewExport (unsigned char Type, const char* Name, ObjData* Obj);
+static Export* NewExport (unsigned char Type, unsigned char AddrSize,
+                          unsigned Name, ObjData* Obj);
 /* Create a new export and initialize it */
 
 
 
-static Import* NewImport (unsigned char Type, ObjData* Obj)
+static Import* NewImport (unsigned char AddrSize, ObjData* Obj)
 /* Create a new import and initialize it */
 {
     /* Allocate memory */
@@ -98,8 +106,11 @@ static Import* NewImport (unsigned char Type, ObjData* Obj)
     /* Initialize the fields */
     I->Next    = 0;
     I->Obj     = Obj;
-    I->V.Name  = 0;
-    I->Type    = Type;
+    InitFilePos (&I->Pos);
+    I->Exp      = 0;
+    I->Name     = INVALID_STRING_ID;
+    I->Flags    = 0;
+    I->AddrSize = AddrSize;
 
     /* Return the new structure */
     return I;
@@ -107,35 +118,127 @@ static Import* NewImport (unsigned char Type, ObjData* Obj)
 
 
 
+void FreeImport (Import* I)
+/* Free an import. NOTE: This won't remove the import from the exports table,
+ * so it may only be called for unused imports (imports from modules that
+ * aren't referenced).
+ */
+{
+    /* Safety */
+    PRECONDITION ((I->Flags & IMP_INLIST) == 0);
+
+    /* Free the struct */
+    xfree (I);
+}
+
+
+
+Import* ReadImport (FILE* F, ObjData* Obj)
+/* Read an import from a file and return it */
+{
+    Import* I;
+
+    /* Read the import address size */
+    unsigned char AddrSize = Read8 (F);
+
+    /* Create a new import */
+    I = NewImport (AddrSize, Obj);
+
+    /* Read the name */
+    I->Name = MakeGlobalStringId (Obj, ReadVar (F));
+
+    /* Read the file position */
+    ReadFilePos (F, &I->Pos);
+
+    /* Check the address size */
+    if (I->AddrSize == ADDR_SIZE_DEFAULT || I->AddrSize > ADDR_SIZE_LONG) {
+        /* Beware: This function may be called in cases where the object file
+         * is not read completely into memory. In this case, the file list is
+         * invalid. Be sure not to access it in this case.
+         */
+        if (ObjHasFiles (I->Obj)) {
+            Error ("Invalid import size in for `%s', imported from %s(%lu): 0x%02X",
+                   GetString (I->Name),
+                   GetSourceFileName (I->Obj, I->Pos.Name),
+                   I->Pos.Line,
+                   I->AddrSize);
+        } else {
+            Error ("Invalid import size in for `%s', imported from %s: 0x%02X",
+                   GetString (I->Name),
+                   GetObjFileName (I->Obj),
+                   I->AddrSize);
+        }
+    }
+
+    /* Return the new import */
+    return I;
+}
+
+
+
+Import* GenImport (const char* Name, unsigned char AddrSize)
+/* Generate a new import with the given name and address size and return it */
+{
+    /* Create a new import */
+    Import* I = NewImport (AddrSize, 0);
+
+    /* Read the name */
+    I->Name = GetStringId (Name);
+
+    /* Check the address size */
+    if (I->AddrSize == ADDR_SIZE_DEFAULT || I->AddrSize > ADDR_SIZE_LONG) {
+        /* Beware: This function may be called in cases where the object file
+         * is not read completely into memory. In this case, the file list is
+         * invalid. Be sure not to access it in this case.
+         */
+        if (ObjHasFiles (I->Obj)) {
+            Error ("Invalid import size in for `%s', imported from %s(%lu): 0x%02X",
+                   GetString (I->Name),
+                   GetSourceFileName (I->Obj, I->Pos.Name),
+                   I->Pos.Line,
+                   I->AddrSize);
+        } else {
+            Error ("Invalid import size in for `%s', imported from %s: 0x%02X",
+                   GetString (I->Name),
+                   GetObjFileName (I->Obj),
+                   I->AddrSize);
+        }
+    }
+
+    /* Return the new import */
+    return I;
+}
+
+
+
 void InsertImport (Import* I)
 /* Insert an import into the table */
 {
     Export* E;
-    unsigned HashVal;
 
     /* As long as the import is not inserted, V.Name is valid */
-    const char* Name = I->V.Name;
+    unsigned Name = I->Name;
 
     /* Create a hash value for the given name */
-    HashVal = HashStr (Name) % HASHTAB_SIZE;
+    unsigned Hash = (Name & HASHTAB_MASK);
 
     /* Search through the list in that slot and print matching duplicates */
-    if (HashTab [HashVal] == 0) {
+    if (HashTab[Hash] == 0) {
        /* The slot is empty, we need to insert a dummy export */
-       E = HashTab [HashVal] = NewExport (0, Name, 0);
+               E = HashTab[Hash] = NewExport (0, ADDR_SIZE_DEFAULT, Name, 0);
        ++ExpCount;
     } else {
-       E = HashTab [HashVal];
+       E = HashTab [Hash];
        while (1) {
-           if (strcmp (E->Name, Name) == 0) {
+           if (E->Name == Name) {
                /* We have an entry, L points to it */
-                       break;
+                       break;
            }
            if (E->Next == 0) {
                /* End of list an entry not found, insert a dummy */
-               E->Next = NewExport (0, Name, 0);
-               E = E->Next;            /* Point to dummy */
-               ++ExpCount;             /* One export more */
+               E->Next = NewExport (0, ADDR_SIZE_DEFAULT, Name, 0);
+               E = E->Next;            /* Point to dummy */
+               ++ExpCount;             /* One export more */
                        break;
            } else {
                E = E->Next;
@@ -146,44 +249,18 @@ void InsertImport (Import* I)
     /* Ok, E now points to a valid exports entry for the given import. Insert
      * the import into the imports list and update the counters.
      */
-    I->V.Exp   = E;
+    I->Exp     = E;
     I->Next    = E->ImpList;
     E->ImpList = I;
     E->ImpCount++;
-    ++ImpCount;                        /* Total import count */
+    ++ImpCount;                        /* Total import count */
     if (E->Expr == 0) {
                /* This is a dummy export */
        ++ImpOpen;
     }
 
-    /* Now free the name since it's no longer needed */
-    xfree (Name);
-}
-
-
-
-Import* ReadImport (FILE* F, ObjData* Obj)
-/* Read an import from a file and return it */
-{
-    Import* I;
-
-    /* Read the import type and check it */
-    unsigned char Type = Read8 (F);
-    if (Type != IMP_ZP && Type != IMP_ABS) {
-       Error ("Unknown import type in module `%s': %02X", Obj->Name, Type);
-    }
-
-    /* Create a new import */
-    I = NewImport (Type, Obj);
-
-    /* Read the name */
-    I->V.Name = ReadStr (F);
-
-    /* Read the file position */
-    ReadFilePos (F, &I->Pos);
-
-    /* Return the new import */
-    return I;
+    /* Mark the import so we know it's in the list */
+    I->Flags |= IMP_INLIST;
 }
 
 
@@ -194,13 +271,15 @@ Import* ReadImport (FILE* F, ObjData* Obj)
 
 
 
-static Export* NewExport (unsigned char Type, const char* Name, ObjData* Obj)
+static Export* NewExport (unsigned char Type, unsigned char AddrSize,
+                          unsigned Name, ObjData* Obj)
 /* Create a new export and initialize it */
 {
     /* Allocate memory */
     Export* E = xmalloc (sizeof (Export));
 
     /* Initialize the fields */
+    E->Name     = Name;
     E->Next     = 0;
     E->Flags           = 0;
     E->Obj      = Obj;
@@ -208,13 +287,8 @@ static Export* NewExport (unsigned char Type, const char* Name, ObjData* Obj)
     E->ImpList  = 0;
     E->Expr            = 0;
     E->Type            = Type;
+    E->AddrSize = AddrSize;
     memset (E->ConDes, 0, sizeof (E->ConDes));
-    if (Name) {
-        E->Name = xstrdup (Name);
-    } else {
-               /* Name will get added later */
-               E->Name = 0;
-    }
 
     /* Return the new entry */
     return E;
@@ -222,13 +296,34 @@ static Export* NewExport (unsigned char Type, const char* Name, ObjData* Obj)
 
 
 
+void FreeExport (Export* E)
+/* Free an export. NOTE: This won't remove the export from the exports table,
+ * so it may only be called for unused exports (exports from modules that
+ * aren't referenced).
+ */
+{
+    /* Safety */
+    PRECONDITION ((E->Flags & EXP_INLIST) == 0);
+
+    /* Free the export expression */
+    FreeExpr (E->Expr);
+
+    /* Free the struct */
+    xfree (E);
+}
+
+
+
 void InsertExport (Export* E)
 /* Insert an exported identifier and check if it's already in the list */
 {
     Export* L;
     Export* Last;
     Import* Imp;
-    unsigned HashVal;
+    unsigned Hash;
+
+    /* Mark the export as inserted */
+    E->Flags |= EXP_INLIST;
 
     /* Insert the export into any condes tables if needed */
     if (IS_EXP_CONDES (E->Type)) {
@@ -236,46 +331,49 @@ void InsertExport (Export* E)
     }
 
     /* Create a hash value for the given name */
-    HashVal = HashStr (E->Name) % HASHTAB_SIZE;
+    Hash = (E->Name & HASHTAB_MASK);
 
     /* Search through the list in that slot */
-    if (HashTab [HashVal] == 0) {
+    if (HashTab[Hash] == 0) {
        /* The slot is empty */
-       HashTab [HashVal] = E;
+       HashTab[Hash] = E;
        ++ExpCount;
     } else {
 
        Last = 0;
-       L = HashTab [HashVal];
+       L = HashTab[Hash];
        do {
-           if (strcmp (L->Name, E->Name) == 0) {
-               /* This may be an unresolved external */
-               if (L->Expr == 0) {
-
-                   /* This *is* an unresolved external */
-                   E->Next     = L->Next;
-                   E->ImpCount = L->ImpCount;
-                   E->ImpList  = L->ImpList;
-                   if (Last) {
-                       Last->Next = E;
-                   } else {
-                       HashTab [HashVal] = E;
-                   }
+                   if (L->Name == E->Name) {
+               /* This may be an unresolved external */
+               if (L->Expr == 0) {
+
+                   /* This *is* an unresolved external. Use the actual export
+                     * in E instead of the dummy one in L.
+                     */
+                   E->Next     = L->Next;
+                   E->ImpCount = L->ImpCount;
+                   E->ImpList  = L->ImpList;
+                   if (Last) {
+                       Last->Next = E;
+                   } else {
+                       HashTab[Hash] = E;
+                   }
                            ImpOpen -= E->ImpCount;     /* Decrease open imports now */
-                   xfree (L);
-                   /* We must run through the import list and change the
+                   xfree (L);
+                   /* We must run through the import list and change the
                     * export pointer now.
-                    */
-                   Imp = E->ImpList;
-                   while (Imp) {
-                       Imp->V.Exp = E;
-                       Imp = Imp->Next;
-                   }
-               } else {
-                   /* Duplicate entry, ignore it */
-                           Warning ("Duplicate external identifier: `%s'", L->Name);
-               }
-               return;
+                    */
+                   Imp = E->ImpList;
+                   while (Imp) {
+                       Imp->Exp = E;
+                       Imp = Imp->Next;
+                   }
+               } else {
+                   /* Duplicate entry, ignore it */
+                           Warning ("Duplicate external identifier: `%s'",
+                             GetString (L->Name));
+               }
+               return;
            }
            Last = L;
            L = L->Next;
@@ -293,15 +391,17 @@ void InsertExport (Export* E)
 Export* ReadExport (FILE* F, ObjData* O)
 /* Read an export from a file */
 {
-    unsigned char Type;
     unsigned      ConDesCount;
     Export* E;
 
     /* Read the type */
-    Type = Read8 (F);
+    unsigned char Type = Read8 (F);
+
+    /* Read the address size */
+    unsigned char AddrSize = Read8 (F);
 
     /* Create a new export without a name */
-    E = NewExport (Type, 0, O);
+    E = NewExport (Type, AddrSize, INVALID_STRING_ID, O);
 
     /* Read the constructor/destructor decls if we have any */
     ConDesCount = GET_EXP_CONDES_COUNT (Type);
@@ -327,7 +427,7 @@ Export* ReadExport (FILE* F, ObjData* O)
     }
 
     /* Read the name */
-    E->Name = ReadStr (F);
+    E->Name = MakeGlobalStringId (O, ReadVar (F));
 
     /* Read the value */
     if (IS_EXP_EXPR (Type)) {
@@ -345,11 +445,11 @@ Export* ReadExport (FILE* F, ObjData* O)
 
 
 
-Export* CreateConstExport (const char* Name, long Value)
+Export* CreateConstExport (unsigned Name, long Value)
 /* Create an export for a literal date */
 {
     /* Create a new export */
-    Export* E = NewExport (EXP_ABS, Name, 0);
+    Export* E = NewExport (EXP_CONST | EXP_EQUATE, ADDR_SIZE_ABS, Name, 0);
 
     /* Assign the value */
     E->Expr = LiteralExpr (Value, 0);
@@ -363,14 +463,14 @@ Export* CreateConstExport (const char* Name, long Value)
 
 
 
-Export* CreateMemExport (const char* Name, Memory* Mem, unsigned long Offs)
+Export* CreateMemoryExport (unsigned Name, Memory* Mem, unsigned long Offs)
 /* Create an relative export for a memory area offset */
 {
     /* Create a new export */
-    Export* E = NewExport (EXP_ABS, Name, 0);
+    Export* E = NewExport (EXP_EXPR | EXP_LABEL, ADDR_SIZE_ABS, Name, 0);
 
     /* Assign the value */
-    E->Expr = MemExpr (Mem, Offs, 0);
+    E->Expr = MemoryExpr (Mem, Offs, 0);
 
     /* Insert the export */
     InsertExport (E);
@@ -381,16 +481,52 @@ Export* CreateMemExport (const char* Name, Memory* Mem, unsigned long Offs)
 
 
 
-static Export* FindExport (const char* Name)
+Export* CreateSegmentExport (unsigned Name, Segment* Seg, unsigned long Offs)
+/* Create a relative export to a segment */
+{
+    /* Create a new export */
+    Export* E = NewExport (EXP_EXPR | EXP_LABEL, Seg->AddrSize, Name, 0);
+
+    /* Assign the value */
+    E->Expr = SegmentExpr (Seg, Offs, 0);
+
+    /* Insert the export */
+    InsertExport (E);
+
+    /* Return the new export */
+    return E;
+}
+
+
+
+Export* CreateSectionExport (unsigned Name, Section* Sec, unsigned long Offs)
+/* Create a relative export to a section */
+{
+    /* Create a new export */
+    Export* E = NewExport (EXP_EXPR | EXP_LABEL, Sec->AddrSize, Name, 0);
+
+    /* Assign the value */
+    E->Expr = SectionExpr (Sec, Offs, 0);
+
+    /* Insert the export */
+    InsertExport (E);
+
+    /* Return the new export */
+    return E;
+}
+
+
+
+Export* FindExport (unsigned Name)
 /* Check for an identifier in the list. Return 0 if not found, otherwise
  * return a pointer to the export.
  */
 {
     /* Get a pointer to the list with the symbols hash value */
-    Export* L = HashTab [HashStr (Name) % HASHTAB_SIZE];
+    Export* L = HashTab[Name & HASHTAB_MASK];
     while (L) {
         /* Search through the list in that slot */
-       if (strcmp (L->Name, Name) == 0) {
+               if (L->Name == Name) {
            /* Entry found */
            return L;
        }
@@ -403,12 +539,18 @@ static Export* FindExport (const char* Name)
 
 
 
-int IsUnresolved (const char* Name)
+int IsUnresolved (unsigned Name)
 /* Check if this symbol is an unresolved export */
 {
     /* Find the export */
-    Export* E = FindExport (Name);
+    return IsUnresolvedExport (FindExport (Name));
+}
+
 
+
+int IsUnresolvedExport (const Export* E)
+/* Return true if the given export is unresolved */
+{
     /* Check if it's unresolved */
     return E != 0 && E->Expr == 0;
 }
@@ -433,7 +575,7 @@ long GetExportVal (const Export* E)
 {
     if (E->Expr == 0) {
        /* OOPS */
-               Internal ("`%s' is an undefined external", E->Name);
+               Internal ("`%s' is an undefined external", GetString (E->Name));
     }
     return GetExprVal (E->Expr);
 }
@@ -445,22 +587,36 @@ static void CheckSymType (const Export* E)
 {
     /* External with matching imports */
     Import* Imp = E->ImpList;
-    int ZP = IS_EXP_ZP (E->Type);
     while (Imp) {
-       if (ZP != IS_IMP_ZP (Imp->Type)) {
+               if (E->AddrSize != Imp->AddrSize) {
            /* Export is ZP, import is abs or the other way round */
+            const char* ExpAddrSize = AddrSizeToStr (E->AddrSize);
+            const char* ImpAddrSize = AddrSizeToStr (Imp->AddrSize);
+            const char* ExpObjName  = GetObjFileName (E->Obj);
+            const char* ImpObjName  = GetObjFileName (Imp->Obj);
            if (E->Obj) {
                /* User defined export */
-               Warning ("Type mismatch for `%s', export in "
-                        "%s(%lu), import in %s(%lu)",
-                        E->Name, E->Obj->Files [Imp->Pos.Name],
-                        E->Pos.Line, Imp->Obj->Files [Imp->Pos.Name],
-                        Imp->Pos.Line);
+                       Warning ("Address size mismatch for `%s': Exported from %s, "
+                        "%s(%lu) as `%s', import in %s, %s(%lu) as `%s'",
+                        GetString (E->Name),
+                         ExpObjName,
+                         GetSourceFileName (E->Obj, E->Pos.Name),
+                        E->Pos.Line,
+                         ExpAddrSize,
+                         ImpObjName,
+                         GetSourceFileName (Imp->Obj, Imp->Pos.Name),
+                        Imp->Pos.Line,
+                         ImpAddrSize);
            } else {
                /* Export created by the linker */
-               Warning ("Type mismatch for `%s', imported from %s(%lu)",
-                        E->Name, Imp->Obj->Files [Imp->Pos.Name],
-                        Imp->Pos.Line);
+               Warning ("Address size mismatch for `%s': Symbol is `%s'"
+                         ", but imported from %s, %s(%lu) as `%s'",
+                        GetString (E->Name),
+                         ExpAddrSize,
+                         ImpObjName,
+                         GetSourceFileName (Imp->Obj, Imp->Pos.Name),
+                        Imp->Pos.Line,
+                         ImpAddrSize);
            }
        }
        Imp = Imp->Next;
@@ -500,10 +656,10 @@ static void PrintUnresolved (ExpCheckFunc F, void* Data)
            /* Unresolved external */
            Import* Imp = E->ImpList;
            fprintf (stderr,
-                    "Unresolved external `%s' referenced in:\n",
-                    E->Name);
+                    "Unresolved external `%s' referenced in:\n",
+                    GetString (E->Name));
            while (Imp) {
-               const char* Name = Imp->Obj->Files [Imp->Pos.Name];
+               const char* Name = GetSourceFileName (Imp->Obj, Imp->Pos.Name);
                fprintf (stderr, "  %s(%lu)\n", Name, Imp->Pos.Line);
                Imp = Imp->Next;
            }
@@ -516,7 +672,8 @@ static void PrintUnresolved (ExpCheckFunc F, void* Data)
 static int CmpExpName (const void* K1, const void* K2)
 /* Compare function for qsort */
 {
-    return strcmp ((*(Export**)K1)->Name, (*(Export**)K2)->Name);
+    return SB_Compare (GetStrBuf ((*(Export**)K1)->Name),
+                       GetStrBuf ((*(Export**)K2)->Name));
 }
 
 
@@ -534,10 +691,10 @@ static void CreateExportPool (void)
 
     /* Walk through the list and insert the exports */
     for (I = 0, J = 0; I < sizeof (HashTab) / sizeof (HashTab [0]); ++I) {
-       Export* E = HashTab [I];
+       Export* E = HashTab[I];
        while (E) {
            CHECK (J < ExpCount);
-           ExpPool [J++] = E;
+                   ExpPool[J++] = E;
            E = E->Next;
        }
     }
@@ -548,9 +705,9 @@ static void CreateExportPool (void)
 
 
 
-void CheckExports (ExpCheckFunc F, void* Data)
-/* Check if there are any unresolved symbols. On unresolved symbols, F is
- * called (see the comments on ExpCheckFunc in the data section).
+void CheckExports (void)
+/* Setup the list of all exports and check for export/import symbol type
+ * mismatches.
  */
 {
     /* Create an export pool */
@@ -558,8 +715,16 @@ void CheckExports (ExpCheckFunc F, void* Data)
 
     /* Check for symbol type mismatches */
     CheckSymTypes ();
+}
+
+
 
-    /* Check for unresolved externals (check here for special bin formats) */
+void CheckUnresolvedImports (ExpCheckFunc F, void* Data)
+/* Check if there are any unresolved imports. On unresolved imports, F is
+ * called (see the comments on ExpCheckFunc in the data section).
+ */
+{
+    /* Check for unresolved externals */
     if (ImpOpen != 0) {
                /* Print all open imports */
        PrintUnresolved (F, Data);
@@ -568,6 +733,23 @@ void CheckExports (ExpCheckFunc F, void* Data)
 
 
 
+static char GetAddrSizeCode (unsigned char AddrSize)
+/* Get a one char code for the address size */
+{
+    switch (AddrSize) {
+        case ADDR_SIZE_ZP:      return 'Z';
+        case ADDR_SIZE_ABS:     return 'A';
+        case ADDR_SIZE_FAR:     return 'F';
+        case ADDR_SIZE_LONG:    return 'L';
+        default:
+            Internal ("Invalid address size: %u", AddrSize);
+           /* NOTREACHED */
+           return '-';
+    }
+}
+
+
+
 void PrintExportMap (FILE* F)
 /* Print an export map to the given file */
 {
@@ -580,13 +762,14 @@ void PrintExportMap (FILE* F)
        const Export* E = ExpPool [I];
 
        /* Print unreferenced symbols only if explictly requested */
-       if (VerboseMap || E->ImpCount > 0) {
+       if (VerboseMap || E->ImpCount > 0 || IS_EXP_CONDES (E->Type)) {
            fprintf (F,
-                    "%-25s %06lX %c%c%c   ",
-                    E->Name,
+                    "%-25s %06lX %c%c%c%c   ",
+                    GetString (E->Name),
                     GetExportVal (E),
                     E->ImpCount? 'R' : ' ',
-                    IS_EXP_ZP (E->Type)? 'Z' : ' ',
+                    IS_EXP_LABEL (E->Type)? 'L' : 'E',
+                            GetAddrSizeCode (E->AddrSize),
                     IS_EXP_CONDES (E->Type)? 'I' : ' ');
            if (++Count == 2) {
                Count = 0;
@@ -616,17 +799,11 @@ void PrintImportMap (FILE* F)
         */
        if (VerboseMap || Exp->ImpCount > 0) {
 
-           /* Get the name of the object file that exports the symbol.
-            * Beware: There may be no object file if the symbol is a linker
-            * generated symbol.
-            */
-           const char* ObjName = (Exp->Obj != 0)? Exp->Obj->Name : "linker generated";
-
            /* Print the export */
            fprintf (F,
                     "%s (%s):\n",
-                    Exp->Name,
-                    ObjName);
+                    GetString (Exp->Name),
+                    GetObjFileName (Exp->Obj));
 
            /* Print all imports for this symbol */
            Imp = Exp->ImpList;
@@ -635,8 +812,8 @@ void PrintImportMap (FILE* F)
                /* Print the import */
                fprintf (F,
                         "    %-25s %s(%lu)\n",
-                        Imp->Obj->Name,
-                        Imp->Obj->Files [Imp->Pos.Name],
+                        GetObjFileName (Imp->Obj),
+                        GetSourceFileName (Imp->Obj, Imp->Pos.Name),
                         Imp->Pos.Line);
 
                /* Next import */
@@ -657,7 +834,7 @@ void PrintExportLabels (FILE* F)
     /* Print all exports */
     for (I = 0; I < ExpCount; ++I) {
        const Export* E = ExpPool [I];
-               fprintf (F, "al %06lX .%s\n", GetExportVal (E), E->Name);
+               fprintf (F, "al %06lX .%s\n", GetExportVal (E), GetString (E->Name));
     }
 }
 
@@ -691,8 +868,11 @@ void CircularRefError (const Export* E)
 /* Print an error about a circular reference using to define the given export */
 {
     Error ("Circular reference for symbol `%s', %s(%lu)",
-          E->Name, E->Obj->Files [E->Pos.Name], E->Pos.Line);
+          GetString (E->Name),
+           GetSourceFileName (E->Obj, E->Pos.Name),
+           E->Pos.Line);
 }
 
 
 
+