]> git.sur5r.net Git - cc65/blobdiff - src/ld65/exports.h
Merge CfgProcess and CfgAssignSegments because both do some sort of
[cc65] / src / ld65 / exports.h
index cad0313c09f7671759d5581aa792a112a951e4d8..170f80978fa7b57cffdc9512f520f90d68733432 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2000 Ullrich von Bassewitz                                       */
-/*               Wacholderweg 14                                             */
-/*               D-70597 Stuttgart                                           */
-/* EMail:        uz@musoftware.de                                            */
+/* (C) 1998-2010, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -46,8 +46,9 @@
 #include "filepos.h"
 
 /* ld65 */
-#include "objdata.h"
 #include "config.h"
+#include "memarea.h"
+#include "objdata.h"
 
 
 
@@ -63,11 +64,10 @@ struct Import {
     Import*            Next;           /* Single linked list */
     ObjData*           Obj;            /* Object file that imports the name */
     FilePos            Pos;            /* File position of reference */
-    union {
-       struct Export*  Exp;            /* Matching export for this import */
-       const char*     Name;           /* Name if not in table */
-    } V;
-    unsigned char      Type;           /* Type of import */
+    struct Export*     Exp;            /* Matching export for this import */
+    unsigned            Name;          /* Name if not in table */
+    unsigned char       Flags;          /* Generic flags */
+    unsigned char      AddrSize;       /* Address size of import */
 };
 
 
@@ -75,6 +75,7 @@ struct Import {
 /* Export symbol structure */
 typedef struct Export Export;
 struct Export {
+    unsigned            Name;                  /* Name */
     Export*                    Next;           /* Hash table link */
     unsigned           Flags;          /* Generic flags */
     ObjData*           Obj;            /* Object file that exports the name */
@@ -83,8 +84,8 @@ struct Export {
     FilePos            Pos;            /* File position of definition */
     ExprNode*                  Expr;           /* Expression (0 if not def'd) */
     unsigned char      Type;           /* Type of export */
+    unsigned char       AddrSize;       /* Address size of export */
     unsigned char      ConDes[CD_TYPE_COUNT];  /* Constructor/destructor decls */
-    char*                      Name;           /* Name - dynamically allocated */
 };
 
 
@@ -95,7 +96,7 @@ struct Export {
  * resolved, or a value != zero if the symbol could be resolved. The
  * CheckExports routine will print out the missing symbol in the first case.
  */
-typedef int (*ExpCheckFunc) (const char* Name, void* Data);
+typedef int (*ExpCheckFunc) (unsigned Name, void* Data);
 
 
 
@@ -105,11 +106,26 @@ typedef int (*ExpCheckFunc) (const char* Name, void* Data);
 
 
 
+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).
+ */
+
 Import* ReadImport (FILE* F, ObjData* Obj);
 /* Read an import from a file and insert it into the table */
 
-void InsertImport (Import* I);
-/* Insert an import into the table */
+Import* GenImport (unsigned Name, unsigned char AddrSize);
+/* Generate a new import with the given name and address size and return it */
+
+Import* InsertImport (Import* I);
+/* Insert an import into the table, return I */
+
+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).
+ */
 
 Export* ReadExport (FILE* F, ObjData* Obj);
 /* Read an export from a file */
@@ -117,24 +133,24 @@ Export* ReadExport (FILE* F, ObjData* Obj);
 void InsertExport (Export* E);
 /* Insert an exported identifier and check if it's already in the list */
 
-Export* CreateConstExport (const char* Name, long Value);
+Export* CreateConstExport (unsigned Name, long Value);
 /* Create an export for a literal date */
 
-Export* CreateMemoryExport (const char* Name, Memory* Mem, unsigned long Offs);
+Export* CreateMemoryExport (unsigned Name, MemoryArea* Mem, unsigned long Offs);
 /* Create an relative export for a memory area offset */
 
-Export* CreateSegmentExport (const char* Name, Segment* Seg, unsigned long Offs);
+Export* CreateSegmentExport (unsigned Name, Segment* Seg, unsigned long Offs);
 /* Create a relative export to a segment */
 
-Export* CreateSectionExport (const char* Name, Section* S, unsigned long Offs);
+Export* CreateSectionExport (unsigned Name, Section* S, unsigned long Offs);
 /* Create a relative export to a section */
 
-Export* FindExport (const char* Name);
+Export* FindExport (unsigned Name);
 /* Check for an identifier in the list. Return 0 if not found, otherwise
  * return a pointer to the export.
  */
 
-int IsUnresolved (const char* Name);
+int IsUnresolved (unsigned Name);
 /* Check if this symbol is an unresolved export */
 
 int IsUnresolvedExport (const Export* E);
@@ -146,8 +162,13 @@ int IsConstExport (const Export* E);
 long GetExportVal (const Export* E);
 /* Get the value of this export */
 
-void CheckExports (ExpCheckFunc F, void* Data);
-/* Check if there are any unresolved symbols. On unresolved symbols, F is
+void CheckExports (void);
+/* Setup the list of all exports and check for export/import symbol type
+ * mismatches.
+ */
+
+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).
  */
 
@@ -180,3 +201,4 @@ void CircularRefError (const Export* E);
 
 
 
+