2000-05-28 13:40:48 +00:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/* */
|
|
|
|
|
/* exports.h */
|
|
|
|
|
/* */
|
|
|
|
|
/* Exports handing for the ld65 linker */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
2003-05-25 17:57:50 +00:00
|
|
|
|
/* (C) 1998-2003 Ullrich von Bassewitz */
|
|
|
|
|
/* R<>merstrasse 52 */
|
|
|
|
|
/* D-70794 Filderstadt */
|
|
|
|
|
/* EMail: uz@cc65.org */
|
2000-05-28 13:40:48 +00:00
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* This software is provided 'as-is', without any expressed or implied */
|
|
|
|
|
/* warranty. In no event will the authors be held liable for any damages */
|
|
|
|
|
/* arising from the use of this software. */
|
|
|
|
|
/* */
|
|
|
|
|
/* Permission is granted to anyone to use this software for any purpose, */
|
|
|
|
|
/* including commercial applications, and to alter it and redistribute it */
|
|
|
|
|
/* freely, subject to the following restrictions: */
|
|
|
|
|
/* */
|
|
|
|
|
/* 1. The origin of this software must not be misrepresented; you must not */
|
|
|
|
|
/* claim that you wrote the original software. If you use this software */
|
|
|
|
|
/* in a product, an acknowledgment in the product documentation would be */
|
|
|
|
|
/* appreciated but is not required. */
|
|
|
|
|
/* 2. Altered source versions must be plainly marked as such, and must not */
|
|
|
|
|
/* be misrepresented as being the original software. */
|
|
|
|
|
/* 3. This notice may not be removed or altered from any source */
|
|
|
|
|
/* distribution. */
|
|
|
|
|
/* */
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef EXPORTS_H
|
|
|
|
|
#define EXPORTS_H
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
2000-08-02 13:23:06 +00:00
|
|
|
|
/* common */
|
2000-11-20 15:22:57 +00:00
|
|
|
|
#include "cddefs.h"
|
2000-08-02 13:23:06 +00:00
|
|
|
|
#include "exprdefs.h"
|
|
|
|
|
#include "filepos.h"
|
2000-11-02 22:11:25 +00:00
|
|
|
|
|
2000-08-02 13:23:06 +00:00
|
|
|
|
/* ld65 */
|
2000-05-28 13:40:48 +00:00
|
|
|
|
#include "objdata.h"
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/* Data */
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Import symbol structure */
|
2000-11-02 22:11:25 +00:00
|
|
|
|
typedef struct Import Import;
|
|
|
|
|
struct Import {
|
|
|
|
|
Import* Next; /* Single linked list */
|
|
|
|
|
ObjData* Obj; /* Object file that imports the name */
|
|
|
|
|
FilePos Pos; /* File position of reference */
|
2003-06-04 12:40:14 +00:00
|
|
|
|
struct Export* Exp; /* Matching export for this import */
|
|
|
|
|
unsigned Name; /* Name if not in table */
|
2003-06-05 16:50:01 +00:00
|
|
|
|
unsigned char Flags; /* Generic flags */
|
2000-11-02 22:11:25 +00:00
|
|
|
|
unsigned char Type; /* Type of import */
|
2000-05-28 13:40:48 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Export symbol structure */
|
2000-11-02 22:11:25 +00:00
|
|
|
|
typedef struct Export Export;
|
|
|
|
|
struct Export {
|
2003-06-04 12:40:14 +00:00
|
|
|
|
unsigned Name; /* Name */
|
2000-05-28 13:40:48 +00:00
|
|
|
|
Export* Next; /* Hash table link */
|
2000-11-02 22:11:25 +00:00
|
|
|
|
unsigned Flags; /* Generic flags */
|
|
|
|
|
ObjData* Obj; /* Object file that exports the name */
|
|
|
|
|
unsigned ImpCount; /* How many imports for this symbol? */
|
|
|
|
|
Import* ImpList; /* List of imports for this symbol */
|
|
|
|
|
FilePos Pos; /* File position of definition */
|
2000-05-28 13:40:48 +00:00
|
|
|
|
ExprNode* Expr; /* Expression (0 if not def'd) */
|
2000-11-20 21:56:48 +00:00
|
|
|
|
unsigned char Type; /* Type of export */
|
2000-11-20 15:22:57 +00:00
|
|
|
|
unsigned char ConDes[CD_TYPE_COUNT]; /* Constructor/destructor decls */
|
2000-05-28 13:40:48 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Prototype of a function that is called if an undefined symbol is found. It
|
|
|
|
|
* may check if the symbol is an external symbol (for binary formats that
|
|
|
|
|
* support externals) and will return zero if the symbol could not be
|
|
|
|
|
* resolved, or a value != zero if the symbol could be resolved. The
|
|
|
|
|
* CheckExports routine will print out the missing symbol in the first case.
|
|
|
|
|
*/
|
2003-06-04 12:40:14 +00:00
|
|
|
|
typedef int (*ExpCheckFunc) (unsigned Name, void* Data);
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/* Code */
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-06-05 16:50:01 +00:00
|
|
|
|
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).
|
|
|
|
|
*/
|
|
|
|
|
|
2000-05-28 13:40:48 +00:00
|
|
|
|
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 */
|
|
|
|
|
|
2003-06-05 16:50:01 +00:00
|
|
|
|
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).
|
|
|
|
|
*/
|
|
|
|
|
|
2000-05-28 13:40:48 +00:00
|
|
|
|
Export* ReadExport (FILE* F, ObjData* Obj);
|
|
|
|
|
/* Read an export from a file */
|
|
|
|
|
|
|
|
|
|
void InsertExport (Export* E);
|
|
|
|
|
/* Insert an exported identifier and check if it's already in the list */
|
|
|
|
|
|
2003-06-04 12:40:14 +00:00
|
|
|
|
Export* CreateConstExport (unsigned Name, long Value);
|
2000-05-28 13:40:48 +00:00
|
|
|
|
/* Create an export for a literal date */
|
|
|
|
|
|
2003-06-04 12:40:14 +00:00
|
|
|
|
Export* CreateMemoryExport (unsigned Name, Memory* Mem, unsigned long Offs);
|
2000-05-28 13:40:48 +00:00
|
|
|
|
/* Create an relative export for a memory area offset */
|
|
|
|
|
|
2003-06-04 12:40:14 +00:00
|
|
|
|
Export* CreateSegmentExport (unsigned Name, Segment* Seg, unsigned long Offs);
|
2002-12-14 22:57:00 +00:00
|
|
|
|
/* Create a relative export to a segment */
|
|
|
|
|
|
2003-06-04 12:40:14 +00:00
|
|
|
|
Export* CreateSectionExport (unsigned Name, Section* S, unsigned long Offs);
|
2002-12-14 22:57:00 +00:00
|
|
|
|
/* Create a relative export to a section */
|
2000-11-20 21:56:48 +00:00
|
|
|
|
|
2003-06-04 12:40:14 +00:00
|
|
|
|
Export* FindExport (unsigned Name);
|
2001-12-01 17:14:12 +00:00
|
|
|
|
/* Check for an identifier in the list. Return 0 if not found, otherwise
|
|
|
|
|
* return a pointer to the export.
|
|
|
|
|
*/
|
|
|
|
|
|
2003-06-04 12:40:14 +00:00
|
|
|
|
int IsUnresolved (unsigned Name);
|
2000-05-28 13:40:48 +00:00
|
|
|
|
/* Check if this symbol is an unresolved export */
|
|
|
|
|
|
2001-12-01 17:14:12 +00:00
|
|
|
|
int IsUnresolvedExport (const Export* E);
|
|
|
|
|
/* Return true if the given export is unresolved */
|
|
|
|
|
|
2002-12-14 22:57:00 +00:00
|
|
|
|
int IsConstExport (const Export* E);
|
2000-05-28 13:40:48 +00:00
|
|
|
|
/* Return true if the expression associated with this export is const */
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
* called (see the comments on ExpCheckFunc in the data section).
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
void PrintExportMap (FILE* F);
|
|
|
|
|
/* Print an export map to the given file */
|
|
|
|
|
|
|
|
|
|
void PrintImportMap (FILE* F);
|
|
|
|
|
/* Print an import map to the given file */
|
|
|
|
|
|
|
|
|
|
void PrintExportLabels (FILE* F);
|
|
|
|
|
/* Print the exports in a VICE label file */
|
|
|
|
|
|
|
|
|
|
void MarkExport (Export* E);
|
|
|
|
|
/* Mark the export */
|
|
|
|
|
|
|
|
|
|
void UnmarkExport (Export* E);
|
|
|
|
|
/* Remove the mark from the export */
|
|
|
|
|
|
|
|
|
|
int ExportHasMark (Export* E);
|
|
|
|
|
/* Return true if the export has a mark */
|
|
|
|
|
|
|
|
|
|
void CircularRefError (const Export* E);
|
|
|
|
|
/* Print an error about a circular reference using to define the given export */
|
|
|
|
|
|
|
|
|
|
|
2000-11-20 15:22:57 +00:00
|
|
|
|
|
2000-05-28 13:40:48 +00:00
|
|
|
|
/* End of exports.h */
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-06-04 12:40:14 +00:00
|
|
|
|
|