1 /*****************************************************************************/
5 /* Exports handing for the ld65 linker */
9 /* (C) 1998 Ullrich von Bassewitz */
11 /* D-70597 Stuttgart */
12 /* EMail: uz@musoftware.de */
15 /* This software is provided 'as-is', without any expressed or implied */
16 /* warranty. In no event will the authors be held liable for any damages */
17 /* arising from the use of this software. */
19 /* Permission is granted to anyone to use this software for any purpose, */
20 /* including commercial applications, and to alter it and redistribute it */
21 /* freely, subject to the following restrictions: */
23 /* 1. The origin of this software must not be misrepresented; you must not */
24 /* claim that you wrote the original software. If you use this software */
25 /* in a product, an acknowledgment in the product documentation would be */
26 /* appreciated but is not required. */
27 /* 2. Altered source versions must be plainly marked as such, and must not */
28 /* be misrepresented as being the original software. */
29 /* 3. This notice may not be removed or altered from any source */
32 /*****************************************************************************/
43 #include "../common/exprdefs.h"
44 #include "../common/filepos.h"
51 /*****************************************************************************/
53 /*****************************************************************************/
57 /* Import symbol structure */
58 typedef struct Import_ Import;
60 Import* Next; /* Single linked list */
61 ObjData* Obj; /* Object file that imports the name */
62 FilePos Pos; /* File position of reference */
64 struct Export_* Exp; /* Matching export for this import */
65 const char* Name; /* Name if not in table */
67 unsigned char Type; /* Type of import */
72 /* Export symbol structure */
73 typedef struct Export_ Export;
75 Export* Next; /* Hash table link */
76 unsigned Flags; /* Generic flags */
77 ObjData* Obj; /* Object file that exports the name */
78 unsigned ImpCount; /* How many imports for this symbol? */
79 Import* ImpList; /* List of imports for this symbol */
80 FilePos Pos; /* File position of definition */
81 ExprNode* Expr; /* Expression (0 if not def'd) */
82 unsigned char Type; /* Type of export */
83 char Name [1]; /* Name - dynamically allocated */
88 /* Prototype of a function that is called if an undefined symbol is found. It
89 * may check if the symbol is an external symbol (for binary formats that
90 * support externals) and will return zero if the symbol could not be
91 * resolved, or a value != zero if the symbol could be resolved. The
92 * CheckExports routine will print out the missing symbol in the first case.
94 typedef int (*ExpCheckFunc) (const char* Name, void* Data);
98 /*****************************************************************************/
100 /*****************************************************************************/
104 Import* ReadImport (FILE* F, ObjData* Obj);
105 /* Read an import from a file and insert it into the table */
107 void InsertImport (Import* I);
108 /* Insert an import into the table */
110 Export* ReadExport (FILE* F, ObjData* Obj);
111 /* Read an export from a file */
113 void InsertExport (Export* E);
114 /* Insert an exported identifier and check if it's already in the list */
116 Export* CreateConstExport (const char* Name, long Value);
117 /* Create an export for a literal date */
119 Export* CreateMemExport (const char* Name, Memory* Mem, unsigned long Offs);
120 /* Create an relative export for a memory area offset */
122 int IsUnresolved (const char* Name);
123 /* Check if this symbol is an unresolved export */
125 int IsConstExport (const Export* E);
126 /* Return true if the expression associated with this export is const */
128 long GetExportVal (const Export* E);
129 /* Get the value of this export */
131 void CheckExports (ExpCheckFunc F, void* Data);
132 /* Check if there are any unresolved symbols. On unresolved symbols, F is
133 * called (see the comments on ExpCheckFunc in the data section).
136 void PrintExportMap (FILE* F);
137 /* Print an export map to the given file */
139 void PrintImportMap (FILE* F);
140 /* Print an import map to the given file */
142 void PrintExportLabels (FILE* F);
143 /* Print the exports in a VICE label file */
145 void MarkExport (Export* E);
146 /* Mark the export */
148 void UnmarkExport (Export* E);
149 /* Remove the mark from the export */
151 int ExportHasMark (Export* E);
152 /* Return true if the export has a mark */
154 void CircularRefError (const Export* E);
155 /* Print an error about a circular reference using to define the given export */
159 /* End of exports.h */