]> git.sur5r.net Git - cc65/blob - src/ld65/exports.h
Use gcc attribs, fixed a wrong arg
[cc65] / src / ld65 / exports.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                 exports.h                                 */
4 /*                                                                           */
5 /*                    Exports handing for the ld65 linker                    */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 1998     Ullrich von Bassewitz                                        */
10 /*              Wacholderweg 14                                              */
11 /*              D-70597 Stuttgart                                            */
12 /* EMail:       uz@musoftware.de                                             */
13 /*                                                                           */
14 /*                                                                           */
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.                                    */
18 /*                                                                           */
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:                            */
22 /*                                                                           */
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              */
30 /*    distribution.                                                          */
31 /*                                                                           */
32 /*****************************************************************************/
33
34
35
36 #ifndef EXPORTS_H
37 #define EXPORTS_H
38
39
40
41 #include <stdio.h>
42
43 #include "../common/exprdefs.h"
44 #include "../common/filepos.h"
45
46 #include "objdata.h"
47 #include "config.h"
48
49
50
51 /*****************************************************************************/
52 /*                                   Data                                    */
53 /*****************************************************************************/
54
55
56
57 /* Import symbol structure */
58 typedef struct Import_ Import;
59 struct Import_ {
60     Import*             Next;           /* Single linked list */
61     ObjData*            Obj;            /* Object file that imports the name */
62     FilePos             Pos;            /* File position of reference */
63     union {
64         struct Export_* Exp;            /* Matching export for this import */
65         const char*     Name;           /* Name if not in table */
66     } V;
67     unsigned char       Type;           /* Type of import */
68 };
69
70
71
72 /* Export symbol structure */
73 typedef struct Export_ Export;
74 struct 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 */
84 };
85
86
87
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.
93  */
94 typedef int (*ExpCheckFunc) (const char* Name, void* Data);
95
96
97
98 /*****************************************************************************/
99 /*                                   Code                                    */
100 /*****************************************************************************/
101
102
103
104 Import* ReadImport (FILE* F, ObjData* Obj);
105 /* Read an import from a file and insert it into the table */
106
107 void InsertImport (Import* I);
108 /* Insert an import into the table */
109
110 Export* ReadExport (FILE* F, ObjData* Obj);
111 /* Read an export from a file */
112
113 void InsertExport (Export* E);
114 /* Insert an exported identifier and check if it's already in the list */
115
116 Export* CreateConstExport (const char* Name, long Value);
117 /* Create an export for a literal date */
118
119 Export* CreateMemExport (const char* Name, Memory* Mem, unsigned long Offs);
120 /* Create an relative export for a memory area offset */
121
122 int IsUnresolved (const char* Name);
123 /* Check if this symbol is an unresolved export */
124
125 int IsConstExport (const Export* E);
126 /* Return true if the expression associated with this export is const */
127
128 long GetExportVal (const Export* E);
129 /* Get the value of this export */
130
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).
134  */
135
136 void PrintExportMap (FILE* F);
137 /* Print an export map to the given file */
138
139 void PrintImportMap (FILE* F);
140 /* Print an import map to the given file */
141
142 void PrintExportLabels (FILE* F);
143 /* Print the exports in a VICE label file */
144
145 void MarkExport (Export* E);
146 /* Mark the export */
147
148 void UnmarkExport (Export* E);
149 /* Remove the mark from the export */
150
151 int ExportHasMark (Export* E);
152 /* Return true if the export has a mark */
153
154 void CircularRefError (const Export* E);
155 /* Print an error about a circular reference using to define the given export */
156
157
158
159 /* End of exports.h */
160
161 #endif
162
163
164