Added a new attribute IMPORT to the CONDES definition of the FEATURES section.

If this attribute is defined, an import for the given symbol is added to the
module that contains the condes declaraction. Using this feature, it is
possible to force linkage of a module that contains an export for the symbol.


git-svn-id: svn://svn.cc65.org/cc65/trunk@5900 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz
2012-11-03 21:37:19 +00:00
parent 77e6bb483f
commit 77bd3169f6
8 changed files with 265 additions and 86 deletions

View File

@@ -1,15 +1,15 @@
/*****************************************************************************/
/* */
/* condes.h */
/* condes.c */
/* */
/* Module constructor/destructor support */
/* */
/* */
/* */
/* (C) 2000-2008 Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* (C) 2000-2012, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
@@ -39,6 +39,7 @@
#include "addrsize.h"
#include "check.h"
#include "coll.h"
#include "filepos.h"
#include "fragdefs.h"
#include "xmalloc.h"
@@ -62,20 +63,64 @@ typedef struct ConDesDesc ConDesDesc;
struct ConDesDesc {
Collection ExpList; /* List of exported symbols */
unsigned SegName; /* Name of segment the table is in */
unsigned Label; /* Name of table label */
unsigned Label; /* Name of table label */
unsigned CountSym; /* Name of symbol for entry count */
unsigned char Order; /* Table order (increasing/decreasing) */
unsigned char Order; /* Table order (increasing/decreasing) */
ConDesImport Import; /* Forced import if any */
};
/* Array for all types */
static ConDesDesc ConDes[CD_TYPE_COUNT] = {
{ STATIC_COLLECTION_INITIALIZER, INVALID_STRING_ID, INVALID_STRING_ID, INVALID_STRING_ID, cdIncreasing },
{ STATIC_COLLECTION_INITIALIZER, INVALID_STRING_ID, INVALID_STRING_ID, INVALID_STRING_ID, cdIncreasing },
{ STATIC_COLLECTION_INITIALIZER, INVALID_STRING_ID, INVALID_STRING_ID, INVALID_STRING_ID, cdIncreasing },
{ STATIC_COLLECTION_INITIALIZER, INVALID_STRING_ID, INVALID_STRING_ID, INVALID_STRING_ID, cdIncreasing },
{ STATIC_COLLECTION_INITIALIZER, INVALID_STRING_ID, INVALID_STRING_ID, INVALID_STRING_ID, cdIncreasing },
{ STATIC_COLLECTION_INITIALIZER, INVALID_STRING_ID, INVALID_STRING_ID, INVALID_STRING_ID, cdIncreasing },
{ STATIC_COLLECTION_INITIALIZER, INVALID_STRING_ID, INVALID_STRING_ID, INVALID_STRING_ID, cdIncreasing },
{
STATIC_COLLECTION_INITIALIZER,
INVALID_STRING_ID,
INVALID_STRING_ID,
INVALID_STRING_ID,
cdIncreasing,
{ INVALID_STRING_ID, STATIC_FILEPOS_INITIALIZER, ADDR_SIZE_DEFAULT },
},{
STATIC_COLLECTION_INITIALIZER,
INVALID_STRING_ID,
INVALID_STRING_ID,
INVALID_STRING_ID,
cdIncreasing,
{ INVALID_STRING_ID, STATIC_FILEPOS_INITIALIZER, ADDR_SIZE_DEFAULT },
},{
STATIC_COLLECTION_INITIALIZER,
INVALID_STRING_ID,
INVALID_STRING_ID,
INVALID_STRING_ID,
cdIncreasing,
{ INVALID_STRING_ID, STATIC_FILEPOS_INITIALIZER, ADDR_SIZE_DEFAULT },
},{
STATIC_COLLECTION_INITIALIZER,
INVALID_STRING_ID,
INVALID_STRING_ID,
INVALID_STRING_ID,
cdIncreasing,
{ INVALID_STRING_ID, STATIC_FILEPOS_INITIALIZER, ADDR_SIZE_DEFAULT },
},{
STATIC_COLLECTION_INITIALIZER,
INVALID_STRING_ID,
INVALID_STRING_ID,
INVALID_STRING_ID,
cdIncreasing,
{ INVALID_STRING_ID, STATIC_FILEPOS_INITIALIZER, ADDR_SIZE_DEFAULT },
},{
STATIC_COLLECTION_INITIALIZER,
INVALID_STRING_ID,
INVALID_STRING_ID,
INVALID_STRING_ID,
cdIncreasing,
{ INVALID_STRING_ID, STATIC_FILEPOS_INITIALIZER, ADDR_SIZE_DEFAULT },
},{
STATIC_COLLECTION_INITIALIZER,
INVALID_STRING_ID,
INVALID_STRING_ID,
INVALID_STRING_ID,
cdIncreasing,
{ INVALID_STRING_ID, STATIC_FILEPOS_INITIALIZER, ADDR_SIZE_DEFAULT },
},
};
@@ -226,6 +271,38 @@ void ConDesSetSegName (unsigned Type, unsigned SegName)
const ConDesImport* ConDesGetImport (unsigned Type)
/* Get the forced import for the given ConDes type. Returns NULL if there is
* no forced import for this type.
*/
{
const ConDesImport* Import;
/* Check the parameters */
PRECONDITION (Type <= CD_TYPE_MAX);
/* Return the import */
Import = &ConDes[Type].Import;
return (Import->Name != INVALID_STRING_ID)? Import : 0;
}
void ConDesSetImport (unsigned Type, const ConDesImport* Import)
/* Set the forced import for the given ConDes type */
{
/* Check the parameters */
PRECONDITION (Type <= CD_TYPE_MAX && Import != 0);
/* Setting the import twice is bad */
CHECK (ConDes[Type].Import.Name == INVALID_STRING_ID);
/* Set the import and its position */
ConDes[Type].Import = *Import;
}
void ConDesSetLabel (unsigned Type, unsigned Name)
/* Set the label for the given ConDes type */
{